/* Dashboard Shell Layout */

/* Phase 27.6-01 DBT-04: kill 300ms double-tap zoom delay on mobile for all
   interactive elements. Applies to buttons, anchor links, role=button/tab,
   nav items, toggles, and keyboard-activated rows. */
button, a, [role="button"], [role="tab"], [role="tabpanel"] > *,
.nav-item, .ap-toggle-btn, .ov-toggle-btn, .filter-btn,
tr[tabindex], .hm-comp-row, .hm-kw-row {
  touch-action: manipulation;
}

.dashboard {
  display: flex;
  min-height: 100vh;
}

/* ─── Header ─── */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: var(--z-header);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  height: 32px;
  width: auto;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
}

.header-client {
  display: flex;
  flex-direction: column;
}

.header-client-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-client-domain {
  font-size: 12px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(106, 171, 181, 0.1);
  color: var(--tc-primary);
  border: 1px solid rgba(106, 171, 181, 0.2);
}

.header-badge.demo {
  background: rgba(245, 158, 11, 0.1);
  color: var(--severity-warning);
  border-color: rgba(245, 158, 11, 0.2);
}

/* Demo-only CTA to the public get-started page (#demo-getstarted-cta). Dark teal
   fill keeps it on-brand and AA-contrast with white text (~5.3:1). */
.header-getstarted-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  background: #0F766E;
  color: #fff;
  border: 1px solid #0F766E;
  transition: filter 0.15s ease;
}
/* Keep white text on hover/focus — the global `a:hover { color: var(--tc-primary-light) }`
   (variables.css) otherwise wins on specificity and renders pale teal-on-green. */
.header-getstarted-cta:hover { filter: brightness(1.08); color: #fff; }
.header-getstarted-cta:focus-visible { outline: 2px solid #0F766E; outline-offset: 2px; color: #fff; }
.header-getstarted-cta svg { flex-shrink: 0; }

.header-updated {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── Phase 64-05: Data accuracy trust pill ───
   Always-visible header pill that signals "is the data trustworthy right now?"
   Reads data/_qa-status.json (written weekly by the Sunday QA gate, Phase 64-04).
   Three states via [data-status]: pass (green), fail (red), unknown (muted).
   Per-tenant framing — pill count reflects the currently-viewed tenant. */
.qa-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--severity-pass-bg);
  color: var(--severity-pass);
  border: 1px solid rgba(34, 197, 94, 0.25);
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
  cursor: default;
}

.qa-pill[data-status="fail"] {
  background: var(--severity-critical-bg);
  color: var(--severity-critical);
  border-color: rgba(239, 68, 68, 0.25);
}

.qa-pill[data-status="unknown"] {
  background: rgba(128, 139, 148, 0.10);
  color: var(--text-muted);
  border-color: rgba(128, 139, 148, 0.25);
}

.qa-pill-icon {
  font-size: 13px;
  line-height: 1;
}

.qa-pill-label {
  /* Inherits color from .qa-pill */
}

.qa-pill-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.client-selector {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-xs);
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
}

.client-selector:hover {
  border-color: var(--border-color-hover);
}

/* Hamburger */

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-primary);
}

.hamburger svg {
  width: 24px;
  height: 24px;
}

/* ─── Sidebar ─── */

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-normal);
  overflow-y: auto;
}

.sidebar-nav {
  /* padding-top drops the whole nav so the first row's active indicator lines up
     with the content area's blue product-tab underline (.v2-product.is-active).
     Tuned against getBoundingClientRect at 1440×900 — see the sidebar UX-polish plan. */
  padding: 16px 0 14px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  min-height: 34px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
  border-left: 3px solid transparent;
  /* Phase 27.6-01 DBT-01: explicit properties (was transition:all) */
  transition: background-color var(--transition-fast), color var(--transition-fast), padding-left var(--transition-fast), border-left-color var(--transition-fast);
  user-select: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  padding-left: 18px;
}

.nav-item.active {
  background: var(--tc-primary-glow);
  color: var(--tc-primary);
  border-left-color: var(--tc-primary);
}

/* Keyboard focus — visible ring on every interactive row (roving tabindex). */
.nav-item:focus-visible,
.nav-group-header:focus-visible {
  outline: 2px solid var(--tc-primary-light);
  outline-offset: -2px;
}

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

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

.nav-item-label {
  flex: 1;
  min-width: 0;
}

.nav-item-score {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
}

/* An un-populated score pill (a tenant with no audit/AI/progress value, or the demo)
   would otherwise render as a tiny empty rounded rect AND steal width from the label —
   which is what wrapped "Site Health & Competitors" to two lines. Hide when empty; the
   badge JS fills textContent, so a real value re-shows it automatically. */
.nav-item-score:empty { display: none; }

/* Nav section hierarchy */
.nav-section-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 8px 16px;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 20px 4px;
}

/* ─── Sidebar submenu (always-expanded) ───
   Supersedes the B-4 single-open accordion. All 7 parent destinations + Help show
   their children at ALL times, so navigating never collapses a section → no menu
   "jump". _syncNavGroups only HIGHLIGHTS (it no longer toggles .expanded); the
   hierarchy is carried by a connecting rail + indent + smaller child type. Children
   render via plain display (no height animation) so the capture settle is never
   mid-transition, and the cold-load tree is deterministic for the visual gate. */

/* Parent destination header — the .nav-item visual language, a touch heavier. */
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  min-height: 34px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  border-left: 3px solid transparent;
  transition: background-color var(--transition-fast), color var(--transition-fast), padding-left var(--transition-fast), border-left-color var(--transition-fast);
  user-select: none;
}
.nav-group-header:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  padding-left: 18px;
}
/* A hair of breathing room between the 7 destination blocks keeps them scannable. */
.nav-group + .nav-group { margin-top: 1px; }

/* Two-tier active state. The active SECTION's parent header is SUBTLE (teal text =
   "you're in here"). When the parent is ITSELF the active destination (Results, Leads,
   AI Visibility — no child page active) it gets .parent-current and carries the STRONG
   highlight (glow + accent bar). When a child PAGE is active the strong highlight lives
   on that child (.nav-child.active) and the parent stays subtle — a breadcrumb read. */
.nav-group.active > .nav-group-header {
  color: var(--tc-primary);
}
.nav-group.active.parent-current > .nav-group-header {
  background: var(--tc-primary-glow);
  border-left-color: var(--tc-primary);
}

/* Children submenu — ALWAYS shown. A hairline rail (the contiguous child left-borders)
   + indent ties them to the parent above. */
.nav-group-children { display: block; padding: 2px 0 3px; }

/* Child rows: indented off the rail, smaller + lighter than the parent. The active
   child's rail segment turns teal (the .nav-item.active highlight, on a 2px border). */
.nav-child {
  margin-left: 24px;
  padding: 5px 16px 5px 18px;
  min-height: 30px;
  /* Theme-aware rail: --border-color resolves to the light-shell grey (#E6EBF2) or the
     dark-theme border — so the rail is visible on whichever sidebar palette is active
     (the hard-coded white-alpha it replaced vanished on the live v2-shell white bg). */
  border-left: 2px solid var(--border-color);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}
.nav-child:hover {
  /* Hover bg + text + (no) padding-shift come from the .nav-item:hover base and the
     v2-shell light override (.nav-child IS a .nav-item); just deepen the rail segment. */
  border-left-color: var(--border-color-hover);
}
.nav-child.active {
  border-left-color: var(--tc-primary);
  background: var(--tc-primary-glow);
  color: var(--tc-primary);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .nav-item, .nav-group-header { transition: none; }
}

/* Sidebar tenant-scoped quick-links row (e.g. BS social profiles).
   Hidden by default via [hidden]; shown by App._applyTenantNavItems
   when data-tenant matches the active client.
   Note: explicit [hidden] rules below — .nav-item's display:flex would
   otherwise win against the user-agent [hidden] rule on specificity. */
.nav-item[hidden] { display: none; }
.sidebar-tenant-links[hidden] { display: none; }

.sidebar-tenant-links {
  padding: 12px 20px 4px;
  border-top: 1px solid var(--border-color);
}

.sidebar-tenant-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sidebar-tenant-icons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.sidebar-tenant-icons a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.sidebar-tenant-icons a:hover {
  background: rgba(78, 205, 196, 0.15);
  color: var(--tc-primary);
  transform: translateY(-1px);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Main Content ─── */

.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  flex: 1;
  /* min-width:0 lets this flex item stay within its track instead of growing to
     its content's min-content. Without it, a wide non-shrinking child (e.g. the
     Local KPI strip's repeat(5,1fr) row, or a wide table) pushes the whole
     content area past the viewport — horizontal overflow on the Local tab. */
  min-width: 0;
  min-height: calc(100vh - var(--header-height));
}

.tab-content {
  display: none;
  padding: 32px;
  max-width: var(--content-max-width);
  margin: 0 auto;
  animation: fadeIn var(--transition-normal);
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Backdrop (mobile) ─── */

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-sidebar) - 1);
}

.sidebar-backdrop.visible {
  display: block;
}

/* ─── Tab Header ─── */

.tab-header {
  margin-bottom: 28px;
}

.tab-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.tab-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}
