/**
 * Savage Dashboard Layout - Sidebar + Top Bar
 * Supabase-inspired icon rail with expandable sidebar
 */

/* ── Layout Variables ────────────────────────────────────────────── */
:root {
  --sidebar-width-collapsed: 48px;
  --sidebar-width-expanded: 240px;
  --topbar-height: 48px;
  --sidebar-transition: 200ms ease;
  --sidebar-bg: #0a0a0a;
  --sidebar-border: #1f1f1f;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: rgba(255, 255, 255, 0.1);
  --topbar-bg: #0a0a0a;
  --topbar-border: #1f1f1f;
  --dropdown-bg: #1a1a1a;
  --dropdown-border: #2a2a2a;
  --dropdown-hover: rgba(255, 255, 255, 0.06);
}

/* ── App Shell ───────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-body {
  display: flex;
  flex: 1;
  padding-top: var(--topbar-height);
}

/* ── Top Bar ─────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
  overflow: visible;
}
/* When any dropdown is open, topbar must sit above the overlay so dropdown items are clickable */
.topbar.dropdown-open,
.topbar:has(.project-selector.open),
.topbar:has(.workspace-selector.open),
.topbar:has(.location-selector.open),
.topbar:has(.account-selector.open),
.topbar:has(.profile-wrapper.open) {
  z-index: 260;
}

.topbar-left {
  display: flex;
  align-items: center;
  align-self: stretch;
  gap: 0;
}

.topbar-logo {
  display: flex;
  align-items: center;
  align-self: center;
  text-decoration: none;
  margin-right: 6px;
  flex-shrink: 0;
}

.topbar-logo img {
  height: 28px;
  width: auto;
  object-fit: contain;
  display: block;
  vertical-align: middle;
}

/* ── Project / Client Selector ───────────────────────────────────── */
.project-selector {
  position: relative;
  z-index: 200;
}
.project-selector.open {
  z-index: 260;
}

.project-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.project-selector-btn:hover {
  background: var(--sidebar-hover-bg);
  border-color: var(--border-secondary);
}

.project-selector-btn .chevron {
  width: 12px;
  height: 12px;
  color: var(--text-dim);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.project-selector.open .chevron {
  transform: rotate(180deg);
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #22c55e, #06b6d4);
  color: #000;
  line-height: 1.4;
}

/* Project Dropdown */
.project-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 300;
  display: none;
}

.project-selector.open .project-dropdown {
  display: block;
}

.project-dropdown-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--dropdown-border);
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}

.project-dropdown-search input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.8rem;
}

.project-dropdown-search input::placeholder {
  color: var(--text-dim);
}

.project-dropdown-search input:focus {
  outline: none;
  border-color: var(--border-hover);
}

.project-dropdown-list {
  padding: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.project-dropdown-list:last-child {
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.project-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.project-dropdown-item:hover {
  background: var(--dropdown-hover);
}

.project-dropdown-item.active {
  color: var(--text-primary);
}

.project-dropdown-item .check-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-success);
  opacity: 0;
}

.project-dropdown-item.active .check-icon {
  opacity: 1;
}

/* Dropdown Section Labels */
.project-dropdown-section-label {
  padding: 10px 12px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Audit plan badge variant */
.plan-badge.audit {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.project-dropdown-footer {
  padding: 8px;
  border-top: 1px solid var(--dropdown-border);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

/* Quick-Add Trigger Button */
.quick-add-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quick-add-trigger:hover {
  background: var(--dropdown-hover);
  color: var(--text-secondary);
}

.quick-add-trigger .quick-add-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-add-trigger .quick-add-icon svg {
  width: 16px;
  height: 16px;
}

/* Quick-Add Form */
.quick-add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-add-form input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.8rem;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.quick-add-form input::placeholder {
  color: var(--text-dim);
}

.quick-add-form input:focus {
  outline: none;
  border-color: var(--accent-success);
}

.quick-add-form-row {
  display: flex;
  gap: 6px;
}

.quick-add-form-row select {
  flex: 1;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.8rem;
  cursor: pointer;
}

.quick-add-form-row select:focus {
  outline: none;
  border-color: var(--border-hover);
}

.quick-add-btn {
  padding: 6px 16px;
  background: var(--accent-success);
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.quick-add-btn:hover {
  opacity: 0.9;
}

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

.project-dropdown-footer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.project-dropdown-footer-item:hover {
  background: var(--dropdown-hover);
  color: var(--text-secondary);
}

.project-dropdown-footer-item svg {
  width: 14px;
  height: 14px;
}

/* ── Preview Portal Button (in client dropdown) ──────────────── */

.project-dropdown-preview {
  padding: 8px 12px;
  border-bottom: 1px solid var(--dropdown-border);
}

.preview-portal-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 6px;
  background: rgba(124, 58, 237, 0.12);
  color: #a78bfa;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  width: 100%;
  cursor: pointer;
}

.preview-portal-btn:hover {
  background: rgba(124, 58, 237, 0.22);
  color: #c4b5fd;
}

.preview-portal-icon svg {
  width: 14px;
  height: 14px;
}

/* ── Workspace Switcher (in project dropdown) ────────────────── */

.project-dropdown-workspace {
  padding: 4px;
  border-bottom: 1px solid var(--dropdown-border);
}

.project-workspace-options {
  display: flex;
  flex-direction: column;
}

.project-workspace-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.project-workspace-option:hover {
  background: var(--dropdown-hover);
}

.project-workspace-option.active {
  color: var(--text-primary);
}

.project-workspace-option .check-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-success);
  opacity: 0;
}

.project-workspace-option.active .check-icon {
  opacity: 1;
}

/* Uppercase client names in project dropdown */
.project-dropdown-item span:first-child {
  text-transform: uppercase;
}

/* ── Client Brand Selector (client role) ──────────────────────── */
.client-brand-selector {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 12px;
  padding: 0 8px;
}

.client-brand-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* ── Workspace Selector ───────────────────────────────────────── */
/* ── Topbar selector divider (between client switcher and workspace switcher) ── */
.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-secondary);
  flex-shrink: 0;
  margin: 0 2px;
}

.workspace-selector {
  position: relative;
  z-index: 200;
}
.workspace-selector.open {
  z-index: 260;
}

.workspace-selector-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.workspace-selector-btn:hover {
  background: var(--sidebar-hover-bg);
  border-color: var(--border-secondary);
}

.workspace-selector-btn .chevron {
  width: 12px;
  height: 12px;
  color: var(--text-dim);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.workspace-selector.open .chevron {
  transform: rotate(180deg);
}

/* Make the active-workspace badge readable as a label */
.workspace-active-badge {
  font-size: 0.7rem !important;
  letter-spacing: 0.04em !important;
  text-transform: none !important;
}

.workspace-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 300;
  display: none;
  padding-bottom: 6px;
}

.workspace-selector.open .workspace-dropdown {
  display: block;
}

.workspace-dropdown-list {
  padding: 2px 4px 4px;
}

.workspace-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.workspace-dropdown-item:hover {
  background: var(--dropdown-hover);
}

.workspace-dropdown-item.active {
  color: var(--text-primary);
}

.workspace-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.workspace-item-check {
  width: 16px;
  height: 16px;
  color: var(--accent-success);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  flex-shrink: 0;
}

.workspace-item-check svg {
  width: 16px;
  height: 16px;
}

.workspace-dropdown-item.active .workspace-item-check {
  opacity: 1;
}

.workspace-dropdown-header-label {
  padding: 10px 12px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--dropdown-border);
  margin-bottom: 2px;
}

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

/* Group label inside the dropdown (replaces old single section-label use) */
.workspace-dropdown-section-label {
  padding: 8px 12px 2px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Profile dropdown workspace group labels */
.profile-dropdown-workspace-group-label {
  padding: 6px 12px 2px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.profile-dropdown-workspace-divider {
  height: 1px;
  background: var(--dropdown-border);
  margin: 4px 8px;
}

/* ── Location Selector ────────────────────────────────────────── */
.location-selector {
  position: relative;
  z-index: 200;
}
.location-selector.open {
  z-index: 260;
}

.location-selector-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-secondary, #2a2a2a);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.location-selector-btn:hover {
  background: var(--sidebar-hover-bg);
  border-color: var(--border-hover, #3a3a3a);
}

.location-selector-icon {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  color: var(--text-dim);
}

.location-selector-icon svg {
  width: 14px;
  height: 14px;
}

.location-selector-btn .chevron {
  width: 12px;
  height: 12px;
  color: var(--text-dim);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.location-selector.open .chevron {
  transform: rotate(180deg);
}

/* Location Dropdown */
.location-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 300;
  display: none;
}

.location-selector.open .location-dropdown {
  display: block;
}

.location-dropdown-list {
  padding: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.location-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.location-dropdown-item:hover {
  background: var(--dropdown-hover);
}

.location-dropdown-item.active {
  color: var(--text-primary);
}

.location-dropdown-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-dim);
}

.location-dropdown-item.active svg {
  color: var(--accent-success);
}

.location-dropdown-item .check-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-success);
  opacity: 0;
  margin-left: auto;
  flex-shrink: 0;
}

.location-dropdown-item.active .check-icon {
  opacity: 1;
}

.location-primary-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
  margin-left: auto;
}

/* ── Account Selector (Attribution Portal) ───────────────────── */
.account-selector {
  position: relative;
  z-index: 200;
}
.account-selector.open {
  z-index: 260;
}

.account-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.account-selector-btn:hover {
  background: var(--sidebar-hover-bg);
  border-color: var(--border-secondary);
}

.account-selector-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.account-selector-btn .chevron {
  width: 12px;
  height: 12px;
  color: var(--text-dim);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.account-selector.open .chevron {
  transform: rotate(180deg);
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 300px;
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 300;
  display: none;
}

.account-selector.open .account-dropdown {
  display: block;
}

.account-dropdown-header {
  padding: 10px 14px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.account-dropdown-list {
  padding: 4px;
  max-height: 360px;
  overflow-y: auto;
}

.account-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s, opacity 0.15s;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.account-dropdown-item:hover {
  background: var(--dropdown-hover);
}

.account-dropdown-item.active {
  color: var(--text-primary);
}

.account-dropdown-item.disabled {
  opacity: 0.45;
}

.account-dropdown-item.disabled .account-item-name {
  text-decoration: line-through;
}

.account-dropdown-item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-dim);
}

.account-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-item-count {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-weight: 600;
  flex-shrink: 0;
}

.account-dropdown-item .check-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-success);
  opacity: 0;
  flex-shrink: 0;
}

.account-dropdown-item.active .check-icon {
  opacity: 1;
}

/* Toggle switch */
.account-toggle {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
  flex-shrink: 0;
}

.account-toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.account-toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.account-toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  left: 2px;
  bottom: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.account-toggle-input:checked + .account-toggle-slider {
  background: rgba(34, 197, 94, 0.3);
}

.account-toggle-input:checked + .account-toggle-slider::before {
  transform: translateX(12px);
  background: #22c55e;
}

/* ── Sidebar Location Indicator ───────────────────────────────── */
.sidebar-location-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-location-icon {
  width: 12px;
  height: 12px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.6;
}

.sidebar-location-icon svg {
  width: 12px;
  height: 12px;
}

.sidebar-location-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Top Bar Right ───────────────────────────────────────────────── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.topbar-icon-btn:hover {
  background: var(--sidebar-hover-bg);
  color: var(--text-secondary);
}

.topbar-icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Profile Button & Dropdown ───────────────────────────────────── */
.profile-wrapper {
  position: relative;
  margin-left: 4px;
}

.profile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-success), var(--accent-cyan));
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
  overflow: hidden;
  padding: 0;
}

.profile-btn:hover {
  opacity: 0.9;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.profile-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-btn .profile-initials {
  font-size: 0.75rem;
  font-weight: 700;
  color: #000;
  font-family: var(--font-family);
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 300;
  display: none;
  overflow: hidden;
}

.profile-wrapper.open .profile-dropdown {
  display: block;
}

.profile-dropdown-header {
  padding: 16px;
  border-bottom: 1px solid var(--dropdown-border);
}

.profile-dropdown-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.profile-dropdown-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-dropdown-section {
  padding: 4px;
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.profile-dropdown-item:hover {
  background: var(--dropdown-hover);
  color: var(--text-primary);
}

.profile-dropdown-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.profile-dropdown-divider {
  height: 1px;
  background: var(--dropdown-border);
  margin: 0;
}

/* Theme Selector */
.profile-dropdown-theme-section {
  padding: 12px 16px;
  border-top: 1px solid var(--dropdown-border);
}

.profile-dropdown-theme-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.theme-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.theme-option:hover {
  background: var(--dropdown-hover);
  color: var(--text-secondary);
}

.theme-option.active {
  color: var(--text-primary);
}

.theme-option .theme-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.theme-option.active .theme-dot {
  background: var(--text-primary);
}

/* Workspace Selector */
.profile-dropdown-workspace-section {
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--dropdown-border);
  border-bottom: 1px solid var(--dropdown-border);
  margin: 0 !important;
  padding: 12px 16px;
}

.profile-dropdown-workspace-section .profile-dropdown-theme-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  font-weight: 600;
}

.workspace-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.workspace-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.workspace-option:hover {
  background: var(--dropdown-hover);
  color: var(--text-secondary);
}

.workspace-option.active {
  background: rgba(59, 130, 246, 0.12);
  color: var(--text-primary);
  font-weight: 600;
}

.workspace-option .theme-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.1s;
}

.workspace-option:hover .theme-dot {
  background: var(--text-muted);
}

.workspace-option.active .theme-dot {
  background: var(--accent-info);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.4);
}

/* Log Out */
.profile-dropdown-logout {
  padding: 4px;
  border-top: 1px solid var(--dropdown-border);
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width-collapsed);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transition: width var(--sidebar-transition), box-shadow var(--sidebar-transition);
  overflow: hidden;
  box-shadow: none;
}

.sidebar:hover {
  width: var(--sidebar-width-expanded);
  box-shadow: 6px 0 20px rgba(0, 0, 0, 0.35);
}

.sidebar-nav {
  flex: 1;
  padding: 6px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 2px;
}

/* ── Sidebar Section Headers ─────────────────────────────────────── */
.sidebar-section-label {
  padding: 0 14px;
  max-height: 0;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--sidebar-transition), max-height var(--sidebar-transition), padding var(--sidebar-transition);
}

.sidebar:hover .sidebar-section-label {
  opacity: 1;
  max-height: 32px;
  padding: 16px 14px 6px;
}

/* ── Sidebar Nav Items ───────────────────────────────────────────── */
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 9px;
  height: 36px;
  margin: 1px 6px;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.825rem;
  font-weight: 450;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.sidebar-nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--text-secondary);
}

.sidebar-nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--text-primary);
}

.sidebar-nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-nav-item .nav-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-nav-item .nav-label {
  opacity: 0;
  transition: opacity var(--sidebar-transition);
  overflow: hidden;
}

.sidebar:hover .sidebar-nav-item .nav-label {
  opacity: 1;
}

/* Sidebar divider */
.sidebar-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 8px 12px;
  flex-shrink: 0;
}

/* ── Sidebar Footer ──────────────────────────────────────────────── */
.sidebar-footer {
  padding: 8px 0;
  border-top: 1px solid var(--sidebar-border);
}

/* ── Main Content ────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width-collapsed);
  min-height: calc(100vh - var(--topbar-height));
  padding: 24px;
  transition: margin-left var(--sidebar-transition);
  min-width: 0;
}

.main-content .container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* Client context → wider container */
body.has-client .main-content .container {
  max-width: 1600px;
}

/* ── Overlay for dropdowns ───────────────────────────────────────── */
/* Overlay starts below topbar so the project/client dropdown is never covered and stays clickable */
.dropdown-overlay {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 250;
  display: none;
}

.dropdown-overlay.active {
  display: block;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 0;
    border-right: none;
  }

  .sidebar:hover {
    width: var(--sidebar-width-expanded);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
  }

  .sidebar:hover ~ .main-content,
  .sidebar.expanded ~ .main-content {
    /* Don't shift content on mobile, sidebar overlays */
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
  }

  .topbar-logo img {
    height: 24px;
  }

  /* Show hamburger on mobile */
  .sidebar-toggle {
    display: flex;
  }
}

/* ── Sidebar toggle (mobile only) ────────────────────────────────── */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-right: 8px;
}

.sidebar-toggle:hover {
  background: var(--sidebar-hover-bg);
  color: var(--text-secondary);
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
}

/* ── Account Page Specific Styles ────────────────────────────────── */
.account-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - var(--topbar-height));
}

.account-sidebar {
  width: 200px;
  padding: 24px 16px;
  border-right: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.account-sidebar-section {
  margin-bottom: 24px;
}

.account-sidebar-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding: 0 8px;
}

.account-sidebar-link {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.account-sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--text-secondary);
}

.account-sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--text-primary);
}

.account-main {
  flex: 1;
  padding: 32px 48px;
  max-width: 800px;
}

.account-heading {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.account-subheading {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.account-section {
  margin-bottom: 32px;
}

.account-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.account-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-secondary);
  border-radius: 8px;
  overflow: hidden;
}

.account-form-row {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-primary);
}

.account-form-row:last-child {
  border-bottom: none;
}

.account-form-label {
  width: 180px;
  flex-shrink: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.account-form-label small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.account-form-value {
  flex: 1;
}

.account-form-value input,
.account-form-value select {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: var(--font-family);
}

.account-form-value input:focus,
.account-form-value select:focus {
  outline: none;
  border-color: var(--border-hover);
}

.account-form-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border-primary);
  background: var(--bg-secondary);
}

.account-save-btn {
  padding: 6px 16px;
  background: var(--accent-success);
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: opacity 0.15s;
}

.account-save-btn:hover {
  opacity: 0.9;
}

.account-section-page {
  /* Section visibility is toggled via JS; this just ensures block display when visible */
}

/* ── Coming Soon Banner ─────────────────────────────────────────── */
.coming-soon-banner {
  margin-bottom: 20px;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.25);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(234, 179, 8, 0.04));
  overflow: hidden;
}

.coming-soon-banner-content {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
}

.coming-soon-banner-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: #f59e0b;
  margin-top: 1px;
}

.coming-soon-banner-icon svg {
  width: 24px;
  height: 24px;
}

.coming-soon-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coming-soon-banner-text strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f59e0b;
}

.coming-soon-banner-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.coming-soon-banner-dismiss {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.coming-soon-banner-dismiss:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
}

/* Sidebar Coming Soon badge */
.nav-badge-coming-soon {
  display: inline-block;
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.2);
  padding: 1px 5px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.4;
  opacity: 0;
  transition: opacity var(--sidebar-transition);
}

.sidebar:hover .nav-badge-coming-soon {
  opacity: 1;
}

/* Sidebar Dynamic badge (purple) */
.nav-badge-dynamic {
  display: inline-block;
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.25);
  padding: 1px 5px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.4;
  opacity: 0;
  transition: opacity var(--sidebar-transition);
}

.sidebar:hover .nav-badge-dynamic {
  opacity: 1;
}

/* ── Remove old header spacing ───────────────────────────────────── */
/* Override for pages that still use .main class */
.app-shell .main {
  padding-top: 0;
  min-height: auto;
}

/* ── Sidebar Submenu ────────────────────────────────────────── */
.sidebar-submenu {
  display: none;
  padding: 2px 0 4px 0;
}
.sidebar-submenu.open {
  display: block;
}
.sidebar-submenu-item {
  display: block;
  padding: 6px 16px 6px 44px;
  font-size: 0.75rem;
  color: var(--text-muted, rgba(255,255,255,0.45));
  text-decoration: none;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.sidebar-submenu-item:hover {
  color: var(--text-primary, #fff);
  background: rgba(255,255,255,0.04);
}
.sidebar-submenu-item.active {
  color: #a855f7;
  background: rgba(168,85,247,0.08);
}
.sidebar-tool-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.55rem;
  color: var(--text-dim, rgba(255,255,255,0.25));
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-left: auto;
}
.sidebar-tool-toggle:hover {
  color: var(--text-secondary, rgba(255,255,255,0.6));
  background: rgba(255,255,255,0.06);
}
.sidebar-tool-toggle.open {
  transform: rotate(90deg);
}

/* ── Onboarding Sidebar (portal shell) ──────────────────────────── */
.sidebar-ob-progress {
  padding: 10px 14px 8px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity var(--sidebar-transition), max-height var(--sidebar-transition);
}
.sidebar:hover .sidebar-ob-progress {
  opacity: 1;
  max-height: 60px;
}
.sidebar-ob-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.sidebar-ob-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
}
.sidebar-ob-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  background: linear-gradient(90deg, #a855f7, #3b82f6);
}
.sidebar-ob-progress-fill.done {
  background: var(--accent-success, #22c55e);
}
.sidebar-ob-step .nav-icon {
  color: var(--text-dim);
}
.sidebar-ob-step .nav-icon.complete {
  color: var(--accent-success, #22c55e);
}
.sidebar-ob-step .nav-icon.in_progress {
  color: #a855f7;
}
.sidebar-ob-badge-complete,
.sidebar-ob-badge-progress,
.sidebar-ob-badge-pending {
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
  white-space: nowrap;
}
.sidebar-ob-badge-complete {
  color: var(--accent-success, #22c55e);
  background: rgba(34,197,94,0.1);
}
.sidebar-ob-badge-progress {
  color: #a855f7;
  background: rgba(168,85,247,0.1);
}
.sidebar-ob-badge-pending {
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
}
.sidebar-ob-submit {
  padding: 8px 0;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-ob-submit-btn .nav-icon {
  color: var(--accent-success, #22c55e) !important;
}
.sidebar-ob-submit-btn .nav-label {
  font-weight: 600;
}
