/**
 * Workspace Switcher Styles
 */

.workspace-switcher {
  position: relative;
  display: inline-block;
}

.workspace-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(var(--primary-rgb), 0.1);
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
}

.workspace-button:hover {
  background: rgba(var(--primary-rgb), 0.15);
  border-color: rgba(var(--primary-rgb), 0.3);
}

.workspace-icon {
  font-size: 18px;
  line-height: 1;
}

.workspace-name {
  font-weight: 500;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-chevron {
  opacity: 0.6;
  transition: transform 0.2s;
}

.workspace-button:hover .workspace-chevron {
  opacity: 1;
}

/* Disabled state for when platform admin has no team */
.workspace-switcher-disabled .workspace-button {
  opacity: 0.6;
  cursor: not-allowed;
  background: rgba(128, 128, 128, 0.05);
  border-color: rgba(128, 128, 128, 0.2);
}

.workspace-switcher-disabled .workspace-button:hover {
  background: rgba(128, 128, 128, 0.05);
  border-color: rgba(128, 128, 128, 0.2);
}

.workspace-switcher-disabled .workspace-name {
  color: var(--text-muted);
}

.workspace-dropdown {
  position: fixed;
  max-width: 320px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: var(--z-dropdown, 1000);
  overflow-y: auto;
  overflow-x: hidden;
  /* Ensure no horizontal scroll */
  box-sizing: border-box;
  /* Prevent any content from extending beyond bounds */
  contain: layout;
}

.workspace-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}

.workspace-dropdown-item:hover {
  background: rgba(var(--primary-rgb), 0.05);
}

.workspace-dropdown-item.active {
  background: rgba(var(--primary-rgb), 0.1);
}

.workspace-dropdown-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
}

.workspace-item-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.workspace-item-content {
  flex: 1;
  min-width: 0;
  /* Ensure flex item can shrink below content size */
  overflow: hidden;
}

.workspace-item-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Use 100% of parent width instead of fixed pixels */
  width: 100%;
}

.workspace-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Use 100% of parent width instead of fixed pixels */
  width: 100%;
}

.workspace-item-check {
  flex-shrink: 0;
  stroke: var(--primary);
}

.workspace-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 0;
}

.workspace-section-label {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.workspace-empty {
  padding: 24px 16px;
  text-align: center;
}

.workspace-empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.workspace-empty-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.workspace-empty-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

.workspace-action {
  color: var(--primary);
}

.workspace-action:hover {
  background: rgba(var(--primary-rgb), 0.08);
}

.workspace-action .workspace-item-name {
  color: var(--primary);
  font-weight: 500;
}

/* Header integration */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  gap: 12px;
}

.sidebar-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.sidebar-header-right {
  flex-shrink: 0;
}

#workspace-switcher-container {
  flex-shrink: 0;
}

/* Modal styles for project creation/settings */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(27, 28, 32, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop, 2000);
  pointer-events: auto;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: auto;
  position: relative;
  z-index: var(--z-modal, 2001);
  opacity: 1;
  pointer-events: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5, 20px) var(--space-6, 24px);
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: var(--text-lg, 18px);
  font-weight: 600;
  color: var(--text-header);
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
}

.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-control::placeholder {
  color: var(--text-muted);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.text-muted {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-secondary);
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

/* Responsive */
@media (max-width: 768px) {
  .workspace-name {
    max-width: 100px;
  }

  .workspace-dropdown {
    min-width: 260px;
  }

  .modal-content {
    width: 95%;
    max-height: 95vh;
  }
}
