/* ============================================================
   BOS Dashboard Platform - styles.css
   Brand-locked styles for all client dashboards.
   
   Per-client accent color is injected at runtime as --client-accent
   via auth.js from BRAND_ACCENT_COLOR env var.
   ============================================================ */

/* --- CSS variables --- */
:root {
  /* BOS brand palette */
  --bos-navy:        #0C304C;
  --bos-navy-deep:   #081F31;
  --bos-navy-soft:   #16466A;
  --bos-red:         #DC2626;
  --bos-white:       #FFFFFF;
  --bos-mist:        #E5ECF2;
  --bos-slate:       #1F3A52;
  
  /* Per-client accent (overridden by auth.js at runtime) */
  --client-accent:   #DC2626;
  
  /* Surfaces */
  --surface-bg:      var(--bos-navy);
  --surface-elev:    rgba(255, 255, 255, 0.04);
  --surface-elev-2:  rgba(255, 255, 255, 0.08);
  --surface-border:  rgba(255, 255, 255, 0.12);
  
  /* Text */
  --text-primary:    rgba(255, 255, 255, 0.96);
  --text-secondary:  rgba(255, 255, 255, 0.72);
  --text-muted:      rgba(255, 255, 255, 0.50);
  --text-faint:      rgba(255, 255, 255, 0.32);
  
  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  
  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* Typography */
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --- Reset / base --- */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bos-navy);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

button {
  font-family: inherit;
}

[hidden] { display: none !important; }

/* Thin red top rule (BOS brand) */
body::before {
  content: '';
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bos-red);
  z-index: 1000;
  pointer-events: none;
}

/* ============================================================
   STATE SCREENS (loading / signin / unauthorized / error)
   ============================================================ */

.state-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: 3px; /* clear the brand rule */
}

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

.state-inner {
  flex: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.state-inner-signin {
  max-width: 480px;
}

.state-eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 var(--space-4) 0;
}

.state-eyebrow-warn {
  color: var(--bos-red);
}

.eyebrow-rule {
  display: inline-block;
  width: 32px;
  height: 2px;
  background: var(--client-accent);
}

.state-eyebrow-warn .eyebrow-rule {
  background: var(--bos-red);
}

.state-headline {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.15;
  margin: 0 0 var(--space-4) 0;
  letter-spacing: -0.01em;
}

.state-lede {
  font-size: 17px;
  color: var(--text-secondary);
  margin: 0 0 var(--space-6) 0;
  max-width: 56ch;
}

.state-message {
  font-size: 18px;
  color: var(--text-secondary);
  margin: 0;
}

/* ============================================================
   BRAND (logo + name in header)
   ============================================================ */

.dash-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--text-primary);
}

.dash-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--text-primary);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-primary);
}

.dash-brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* ============================================================
   CLERK MOUNTS
   ============================================================ */

.clerk-mount {
  margin-top: var(--space-5);
}

.dash-user {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.dash-user-greeting {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn-secondary {
  display: inline-block;
  padding: 10px 18px;
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
}

.btn-secondary:hover {
  border-color: var(--text-primary);
  background: var(--surface-elev);
}

/* ============================================================
   DASHBOARD STATE - shell (header, nav, footer)
   ============================================================ */

#state-dashboard {
  display: none;
}

#state-dashboard[hidden] {
  display: none !important;
}

#state-dashboard:not([hidden]) {
  display: flex;
}

.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--surface-border);
  background: var(--bos-navy-deep);
}

.dash-nav {
  display: flex;
  gap: 0;
  padding: 0 var(--space-6);
  background: var(--bos-navy-deep);
  border-bottom: 1px solid var(--surface-border);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.dash-nav::-webkit-scrollbar {
  height: 4px;
}

.dash-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.nav-tab {
  display: inline-block;
  padding: var(--space-4) var(--space-5);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 150ms, border-color 150ms;
  cursor: pointer;
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab.is-active {
  color: var(--text-primary);
  border-bottom-color: var(--client-accent);
}

.nav-tab:focus-visible {
  outline: 2px solid var(--client-accent);
  outline-offset: -2px;
}

/* ============================================================
   VIEW CONTAINER (where router injects view HTML)
   ============================================================ */

.view-content {
  flex: 1;
  padding: var(--space-7) var(--space-6) var(--space-8);
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.view-loading {
  padding: var(--space-7) 0;
  color: var(--text-muted);
  font-size: 15px;
  text-align: center;
}

.view-error {
  padding: var(--space-7) 0;
  max-width: 600px;
}

.view-error-eyebrow {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bos-red);
  margin: 0 0 var(--space-3) 0;
}

.view-error-headline {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 var(--space-3) 0;
}

.view-error-message,
.view-error-hint {
  color: var(--text-secondary);
  margin: 0 0 var(--space-3) 0;
}

.view-error-hint {
  font-size: 14px;
  color: var(--text-muted);
}

/* ============================================================
   FOOTER
   ============================================================ */

.dash-footer {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--surface-border);
  background: var(--bos-navy-deep);
}

.dash-footer-meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.dash-footer-meta a {
  color: var(--text-secondary);
  text-decoration: none;
}

.dash-footer-meta a:hover {
  color: var(--text-primary);
}

/* ============================================================
   REUSABLE VIEW COMPONENTS
   Available to any view HTML fragment.
   ============================================================ */

/* --- view-header (eyebrow + title + lede) --- */

.view {
  display: block;
}

.view-header {
  margin-bottom: var(--space-7);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 0 0 var(--space-3) 0;
}

.view-title {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3) 0;
  color: var(--text-primary);
}

.view-lede {
  font-size: 17px;
  color: var(--text-secondary);
  margin: 0;
  max-width: 64ch;
}

/* --- KPI grid + cards --- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-7);
}

.card {
  background: var(--surface-elev);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.card-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}

.card-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.card-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* --- Status section (used in home view's "Coming soon") --- */

.status-section {
  margin-top: var(--space-6);
}

.status-headline {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 var(--space-3) 0;
}

.status-lede {
  color: var(--text-secondary);
  margin: 0 0 var(--space-5) 0;
  max-width: 64ch;
}

.status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.status-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-elev);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.status-dot-active {
  background: var(--client-accent);
}

.status-content {
  flex: 1;
  min-width: 0;
}

.status-title {
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.status-detail {
  font-size: 14px;
  color: var(--text-secondary);
  margin: var(--space-1) 0 0 0;
}

.status-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1px solid var(--surface-border);
  border-radius: 100px;
  color: var(--text-muted);
  white-space: nowrap;
}

.status-badge-active {
  color: var(--client-accent);
  border-color: var(--client-accent);
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 640px) {
  .state-inner,
  .view-content {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  
  .state-headline,
  .view-title {
    font-size: 28px;
  }
  
  .dash-header,
  .dash-nav,
  .dash-footer {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  
  .nav-tab {
    padding: var(--space-3) var(--space-4);
  }
  
  .dash-user-greeting {
    display: none;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .card-value {
    font-size: 28px;
  }
}
