/*
 * dashboard/assets/theme.css — "Precision Architect" design system (ADR-013).
 *
 * Ported from the sibling powerup-bermuda repo's production frontend
 * (packages/frontend/src/theme/globals.css + tailwind.config.ts). Dash
 * auto-serves any CSS placed under <app_dir>/assets/, so this file loads
 * with no code changes to the Dash() constructor.
 *
 * Python-side mirror of these tokens: dashboard/theme.py::PALETTE. Keep the
 * two in sync by hand — see ADR-013's "Consequences" section.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@300;500;600;700&display=swap');

:root {
  /* Primary — near-black green (headings, high-contrast text) */
  --primary: #001a02;
  --primary-light: #a3f69c;
  --primary-hover: #003207;

  /* Accent — functional green (icons, progress, hero data series) */
  --accent: #53a252;
  --accent-light: #DCFCE7;

  /* Secondary — indigo (data differentiation, secondary series) */
  --secondary: #4c56af;
  --secondary-light: #e0e0ff;

  /* Surfaces (tonal layering) */
  --bg-page: #f8fafb;
  --bg-surface: #FFFFFF;
  --border: #DDE2E6;
  --grid-line: #DDE2E6;
  --tab-bg: #F1F5F9;
  --surface-container-low: #F2F4F5;
  --surface-container: #ECEEEF;

  /* Text */
  --heading: #001a02;
  --muted: #44474c;

  /* Semantic */
  --success: #53a252;
  --warning: #D4862C;
  --danger: #ba1a1a;

  /* Info-icon (v5, Track G) — the ONE new token: blue used only for the
     glossary ℹ affordance, kept distinct from the accent green so tooltips
     read as "help", not data. */
  --info-blue: #2563eb;

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

  /* Shape / elevation */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-pill: 9999px;
  --shadow-card: 0 16px 32px rgba(0, 0, 0, 0.02);
  --ease-apple: cubic-bezier(0.2, 0, 0, 1);

  /*
   * Dash 4.x ships its own design-token system for native components
   * (RadioItems, Slider, Tabs, DataTable) driven by --Dash-* CSS custom
   * properties — internal class names (e.g. dash-options-list-option,
   * dash-slider-thumb) are more likely to change between Dash versions than
   * these public tokens, so recolor via the tokens rather than fighting
   * component internals with selector specificity. This is the primary
   * mechanism by which the RadioItems "selected" pill and the Slider
   * track/thumb/focus-ring pick up the accent green instead of Dash's
   * default purple (--Dash-Fill-Interactive-Strong: #7f4bc4).
   */
  --Dash-Fill-Interactive-Strong: var(--accent);
  --Dash-Fill-Interactive-Weak: var(--accent-light);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: #191c1d;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────── Page shell ─────────────────────────── */

.ppd-page {
  min-height: 100vh;
  padding: 40px 48px 64px;
  max-width: 1280px;
  margin: 0 auto;
}

.ppd-header {
  margin-bottom: 40px;
}

.ppd-eyebrow {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 10px;
}

.ppd-title {
  font-family: var(--font-headline);
  font-weight: 300;
  font-size: 2.75rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--heading);
  margin: 0;
}

.ppd-subtitle {
  color: #64748b;
  font-size: 1rem;
  margin: 10px 0 0;
  max-width: 640px;
  line-height: 1.5;
}

.ppd-content {
  margin-top: 32px;
}

/* ─────────────────────────── Cards ─────────────────────────── */

.ppd-card {
  background: var(--bg-surface);
  border: 1px solid rgba(196, 198, 205, 0.35);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 28px 32px;
  margin-bottom: 24px;
}

.ppd-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-heading {
  font-family: var(--font-headline);
  font-weight: 300;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--heading);
  margin: 0;
}

/* ─────────────────────────── Controls bar ─────────────────────────── */

.ppd-controls-bar {
  display: flex;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
}

.ppd-control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ppd-control-group--grow {
  flex: 1;
  min-width: 260px;
}

.ppd-control-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
}

/*
 * Stream toggle (dcc.RadioItems), styled as a segmented pill control.
 *
 * Dash 4.1's RadioItems DOM (verified via CDP inspection, not guessed):
 *   <div class="dash-options-list dash-radioitems ppd-radio-group">
 *     <label class="dash-options-list-option [selected]">
 *       <span class="dash-options-list-option-wrapper"><input .../></span>
 *       <span class="dash-options-list-option-text ppd-radio-label">...</span>
 *     </label>
 *     ...
 *   </div>
 * i.e. `labelClassName`/`inputClassName` land on inner spans, not the
 * clickable `<label>` — so the segmented-pill chrome below targets Dash's
 * own `.dash-options-list-option[.selected]` classes directly rather than
 * `ppd-radio-label`.
 */
.ppd-radio-group {
  display: inline-flex;
  gap: 2px;
  background: var(--tab-bg);
  border-radius: var(--radius-md);
  padding: 3px;
  width: fit-content;
}

.ppd-radio-group .dash-options-list-option {
  display: inline-flex;
  align-items: center;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: background var(--ease-apple) 150ms, color var(--ease-apple) 150ms;
}

.ppd-radio-group .dash-options-list-option.selected {
  background: var(--bg-surface);
  color: var(--heading);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Radio bullet isn't part of the reference "segmented control" look — the
   whole pill is clickable via the wrapping <label>, so hiding the bullet
   loses no functionality. */
.ppd-radio-group .dash-options-list-option-wrapper {
  display: none;
}

/*
 * Slider — Dash 4.1 ships a Radix-based slider (verified via CDP), not the
 * `rc-slider` markup older Dash versions used:
 *   .dash-slider-track / .dash-slider-range / .dash-slider-thumb / .dash-slider-mark
 * Color is primarily driven by the --Dash-Fill-Interactive-Strong token
 * override in :root above; these rules are the small remainder Dash doesn't
 * expose a token for (unfilled track color, mark text color).
 */
.ppd-slider .dash-slider-track {
  background-color: var(--border);
}
.ppd-slider .dash-slider-mark {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* ─────────────────────────── Tabs container ─────────────────────────── */

.ppd-tabs-parent {
  border-bottom: none !important;
  margin-bottom: 8px;
}

.ppd-tabs {
  background: var(--tab-bg);
  border-radius: var(--radius-md);
  padding: 4px;
  width: fit-content;
  border: none !important;
}

/* ─────────────────────────── Stat cards ─────────────────────────── */

.stat-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid rgba(196, 198, 205, 0.35);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-container-low);
  margin-bottom: 20px;
  font-size: 1.1rem;
}

.stat-card-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 4px;
}

.stat-card-value {
  font-family: var(--font-headline);
  font-weight: 300;
  font-size: 2rem;
  line-height: 1;
  color: var(--heading);
}

.stat-card-value .unit {
  font-size: 0.875rem;
  font-weight: 400;
  color: #94a3b8;
  margin-left: 4px;
}

.stat-card-progress-track {
  width: 100%;
  height: 4px;
  margin-top: 18px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--surface-container-low);
}

.stat-card-progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
}

/* ─────────────────────────── Badges / pills ─────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}

.badge-success { background: #DCFCE7; color: #1B4332; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-info    { background: #e0e0ff; color: var(--secondary); }
.badge-neutral { background: var(--surface-container-low); color: var(--muted); }

.badge-pill {
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

/* ─────────────────────────── Error banner ─────────────────────────── */

.api-error-banner {
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #ffb4ab;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 24px;
}

/* ─────────────────────────── Empty state ─────────────────────────── */

.empty-state {
  color: #94a3b8;
  font-size: 0.875rem;
  padding: 32px 0;
  text-align: center;
}

/* ─────────────────────────── DataTable (dash_table) niceties ─────────────────────────── */

.dash-table-container {
  margin-top: 8px;
  font-family: var(--font-sans);
}

/* "Show details (lineage)" toggle above the forecast table (B1). */
.ppd-detail-toggle {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.ppd-detail-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Freshness banner spacing (B1) — reuses .badge .badge-neutral chrome. */
.forecast-freshness {
  margin-bottom: 12px;
}

/* Track Record (v4) — verdict banner + honesty scope note. The verdict banner
   reuses .stat-card chrome; the win/loss/neutral tint comes from the added
   .badge-success/.badge-warning class or the inline neutral colour. */
.verdict-banner {
  margin-bottom: 20px;
}
.track-record-scope-note {
  margin: 0 0 16px;
  max-width: 62ch;
}

/* Fleet Estimate (ADR-021) — honesty scope note + spread summary reuse the
   muted small-print treatment; the MODELED badge in the per-method table reuses
   .badge .badge-warning chrome and just needs a small left offset from the
   anchor label so it reads as an inline tag. */
.fleet-estimate-scope-note,
.fleet-estimate-spread-summary {
  margin: 0 0 16px;
  max-width: 68ch;
}
.fleet-modeled-badge {
  margin-left: 8px;
}

/* Analog (PR / Canaries) PROXY tab (ADR-022) — a prominent PROXY badge (reuses
   .badge .badge-warning chrome, just larger/spaced so it can never be missed),
   an honesty scope note in the muted small-print treatment, and an in-context
   island indicator (reuses .badge .badge-info). */
.analog-proxy-badge {
  display: inline-block;
  margin: 4px 0 12px;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  padding: 4px 12px;
}
.analog-scope-note {
  margin: 0 0 16px;
  max-width: 68ch;
}
.analog-island-selector {
  margin: 0 0 16px;
}
.analog-island-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8125rem;
}
.analog-island-value {
  margin: 0 4px;
}

/* ─────────────────── Info-icon glossary (v5, Track G) ───────────────────
 *
 * A small blue ℹ affordance (dashboard/glossary.py::info_icon) placed beside
 * labels, table headers, stat-card labels and chart titles. On hover OR
 * keyboard focus it reveals a CSS-only popover (.ppd-info-tip) — no JS, no
 * dash-bootstrap-components. The native `title` attribute is the fallback for
 * assistive tech / reduced-motion. Appended section — nothing above is
 * modified.
 */
.ppd-info-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  vertical-align: middle;
  color: var(--info-blue, #2563eb);
  font-size: 0.85em;
  line-height: 1;
  cursor: help;
  /* Focus ring is handled by the browser default outline; keep the glyph
     from inheriting bold/label letter-spacing. */
  font-weight: 400;
  letter-spacing: normal;
}

.ppd-info-icon:focus {
  outline: 2px solid var(--info-blue, #2563eb);
  outline-offset: 2px;
  border-radius: var(--radius-pill);
}

.ppd-info-glyph {
  display: inline-block;
}

/* Popover: hidden until hover/focus, then floated above the icon. Uses the
   existing surface/radius/shadow tokens so it matches card chrome. */
.ppd-info-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40; /* above .ppd-card / .stat-card */
  min-width: 180px;
  max-width: 260px;
  width: max-content;
  padding: 10px 12px;
  background: var(--bg-surface);
  color: #191c1d;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card), 0 4px 12px rgba(0, 0, 0, 0.08);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  white-space: normal;
  /* Hidden by default; toggled visible on hover/focus below. */
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ease-apple) 120ms, visibility var(--ease-apple) 120ms;
  pointer-events: none;
}

.ppd-info-icon:hover .ppd-info-tip,
.ppd-info-icon:focus .ppd-info-tip {
  opacity: 1;
  visibility: visible;
}

/* Wide, scrollable variant (v6) for long multi-section definitions (e.g. the
   ramp-rate help). Positioned BELOW and left-aligned to the icon so a tall tip
   can't overflow off the top of the viewport, and scrolls if it exceeds height.
   `pre-line` preserves the paragraph breaks in the definition text. */
.ppd-info-tip--wide {
  bottom: auto;
  top: calc(100% + 8px);
  left: 0;
  transform: none;
  min-width: 300px;
  max-width: 420px;
  max-height: 60vh;
  overflow-y: auto;
  white-space: pre-line;
  line-height: 1.5;
  pointer-events: auto; /* allow hovering into the tip to scroll */
}
