/* ============================================================
   BOS Dashboard — Design System
   Brand tokens locked to BOS_Brand_Guide.pdf (May 2026)
   Per-client accent color injected at runtime via --client-accent
   ============================================================ */

:root {
  /* BOS brand palette */
  --bos-navy:        #0C304C;
  --bos-navy-deep:   #081f33;
  --bos-navy-rise:   #16466b;
  --bos-red:         #DC2626;
  --bos-red-hover:   #b91c1c;
  --bos-white:       #FFFFFF;
  --bos-dark:        #0F0D1D;
  --bos-steel:       #B0C4D8;
  --bos-steel-mute:  rgba(176, 196, 216, 0.65);
  --bos-rule:        rgba(176, 196, 216, 0.18);

  /* Per-client accent color — overridden by JS from config */
  /* Default to BOS red until client config loads */
  --client-accent:        #DC2626;
  --client-accent-soft:   rgba(220, 38, 38, 0.12);

  /* Typography */
  --font:            'Manrope', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout */
  --shell-max:       1180px;
  --content-max:     560px;
  --dash-shell-max:  1320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bos-navy);
  color: var(--bos-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  line-height: 1.55;
}

/* Atmospheric gradient — depth without noise */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 70% 20%, rgba(22, 70, 107, 0.55) 0%, transparent 60%),
    radial-gradient(ellipse 90% 70% at 20% 90%, rgba(8, 31, 51, 0.7) 0%, transparent 60%);
  z-index: 0;
}

/* Red top rule — brand-guide treatment */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--bos-red);
  z-index: 100;
}

/* ============================================================
   State screens — only one visible at a time
   ============================================================ */
.state-screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.state-screen.is-visible {
  display: block;
}

/* ============================================================
   Loading state
   ============================================================ */
.loading-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.loading-mark {
  width: 56px;
  height: 56px;
}

.loading-mark circle {
  fill: none;
  stroke: var(--bos-white);
  stroke-width: 2.2;
}

.loading-mark text {
  font-family: var(--font);
  font-weight: 700;
  font-size: 13px;
  fill: var(--bos-white);
  letter-spacing: 0.5px;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(176, 196, 216, 0.2);
  border-top-color: var(--bos-red);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 0.88rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bos-steel-mute);
  font-weight: 500;
  margin: 0;
}

/* ============================================================
   Logo lockup (shared across screens)
   ============================================================ */
.logo-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--bos-white);
}

.logo-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.logo-mark circle {
  fill: none;
  stroke: var(--bos-white);
  stroke-width: 2.2;
}

.logo-mark text {
  font-family: var(--font);
  font-weight: 700;
  font-size: 13px;
  fill: var(--bos-white);
  letter-spacing: 0.5px;
}

.logo-wordmark {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bos-white);
}

/* ============================================================
   Auth shell (sign-in / unauthorized / error)
   ============================================================ */
.auth-shell {
  min-height: 100vh;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 36px 40px 32px;
  display: flex;
  flex-direction: column;
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 0;
}

.auth-hero {
  max-width: var(--content-max);
}

.auth-mount {
  margin-top: 36px;
  max-width: 440px;
}

.auth-footnote {
  margin-top: 28px;
  font-size: 0.85rem;
  color: var(--bos-steel-mute);
  max-width: 440px;
}

.auth-footnote a {
  color: var(--bos-steel);
  text-decoration: underline;
  text-decoration-color: var(--bos-red);
  text-underline-offset: 3px;
}

.auth-actions {
  margin-top: 36px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-footer {
  border-top: 1px solid var(--bos-rule);
  padding-top: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--bos-steel-mute);
}

.footer-divider {
  color: rgba(176, 196, 216, 0.35);
}

/* ============================================================
   Eyebrow + headlines (shared pattern across all states)
   ============================================================ */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bos-steel);
  font-weight: 600;
  margin: 0 0 28px;
}

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

h1 {
  font-family: var(--font);
  font-weight: 800;
  font-size: clamp(2.4rem, 5.2vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.022em;
  margin: 0 0 24px;
  color: var(--bos-white);
}

h1 .accent {
  color: var(--bos-steel);
  font-weight: 300;
}

h2 {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.015em;
  margin: 0 0 8px;
  color: var(--bos-white);
}

.lede {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--bos-steel);
  font-weight: 400;
  margin: 0 0 16px;
  max-width: 540px;
}

.lede a {
  color: var(--bos-white);
  text-decoration: underline;
  text-decoration-color: var(--bos-red);
  text-underline-offset: 3px;
}

.error-detail {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--bos-steel-mute);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--bos-red);
  border-radius: 2px;
  max-width: 540px;
  display: none;
}

.error-detail.is-visible { display: block; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
  text-decoration: none;
  border: none;
  white-space: nowrap;
}

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

.btn-primary:hover { background: var(--bos-red-hover); }
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  background: transparent;
  color: var(--bos-white);
  border: 1px solid rgba(176, 196, 216, 0.3);
}

.btn-secondary:hover {
  border-color: var(--bos-steel);
  background: rgba(255, 255, 255, 0.04);
}

/* ============================================================
   Dashboard shell (authenticated state)
   ============================================================ */
.dash-header {
  max-width: var(--dash-shell-max);
  margin: 0 auto;
  padding: 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--bos-rule);
}

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

.dash-user-greeting {
  font-size: 0.86rem;
  color: var(--bos-steel-mute);
  font-weight: 500;
}

.user-button-mount {
  /* Clerk's UserButton mounts here. */
  display: inline-flex;
  align-items: center;
}

.dash-main {
  max-width: var(--dash-shell-max);
  margin: 0 auto;
  padding: 56px 40px 80px;
}

.dash-intro {
  max-width: 720px;
  margin-bottom: 48px;
}

.dash-intro h1 {
  font-size: clamp(2rem, 4.4vw, 3rem);
  margin-bottom: 16px;
}

.dash-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 56px;
}

.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--bos-rule);
  border-radius: 8px;
  padding: 26px 28px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.card:hover {
  border-color: rgba(176, 196, 216, 0.32);
  background: rgba(255, 255, 255, 0.05);
}

.card-kpi[data-state="placeholder"] {
  opacity: 0.7;
}

.card-eyebrow {
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bos-steel-mute);
  font-weight: 600;
  margin: 0 0 14px;
}

.card-value {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--bos-white);
  margin: 0 0 10px;
  line-height: 1;
}

.card-trend {
  font-size: 0.85rem;
  color: var(--bos-steel-mute);
  margin: 0;
}

.dash-section {
  margin-top: 56px;
}

.dash-section-header {
  margin-bottom: 24px;
  max-width: 640px;
}

.dash-section-header p {
  font-size: 0.95rem;
  color: var(--bos-steel);
  margin: 0;
  line-height: 1.6;
}

.dash-status-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--bos-rule);
  border-radius: 8px;
  overflow: hidden;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--bos-rule);
}

.status-item:last-child {
  border-bottom: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bos-steel-mute);
}

.status-item[data-status="in-progress"] .status-dot {
  background: var(--client-accent);
  box-shadow: 0 0 0 4px var(--client-accent-soft);
}

.status-item[data-status="complete"] .status-dot {
  background: #10b981;
}

.status-content {
  flex: 1;
}

.status-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bos-white);
  margin: 0 0 4px;
}

.status-detail {
  font-size: 0.85rem;
  color: var(--bos-steel-mute);
  margin: 0;
}

.status-label {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--bos-steel-mute);
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.status-item[data-status="in-progress"] .status-label {
  color: var(--client-accent);
  background: var(--client-accent-soft);
}

.dash-footer {
  max-width: var(--dash-shell-max);
  margin: 0 auto;
  padding: 24px 40px 32px;
  border-top: 1px solid var(--bos-rule);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--bos-steel-mute);
}

/* ============================================================
   Clerk component theming overrides
   Clerk components render into mounts; their internal classes
   can be styled or appearance-prop'd. Most styling is handled
   via Clerk's appearance config in auth.js. These are fallback
   styles in case Clerk's CSS doesn't fully apply.
   ============================================================ */
.cl-rootBox,
.cl-card {
  background: transparent !important;
  box-shadow: none !important;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .auth-shell, .dash-header, .dash-main, .dash-footer {
    padding-left: 22px;
    padding-right: 22px;
  }
  .dash-cards-grid {
    grid-template-columns: 1fr;
  }
  .dash-user-greeting {
    display: none;
  }
  .status-item {
    flex-wrap: wrap;
  }
  .status-label {
    margin-left: 24px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 2.1rem;
  }
  .lede {
    font-size: 1rem;
  }
  .card-value {
    font-size: 2rem;
  }
}
