/* LLM Visibility Monitor — design tokens.

   The HTML root carries [data-theme] (light|dark|auto) and
   [data-surface] (warm|cool|mono). JS sets both on first paint based
   on [[config]] values fetched from /api/bootstrap; users can also
   toggle theme via the header (persists in localStorage).

   The accent color is injected as an inline style on <html> by
   public/app.js after bootstrap — the default below covers the
   pre-bootstrap flash. */

:root {
  --accent: #e85d2e;
  --accent-strong: color-mix(in srgb, var(--accent) 80%, black 20%);
  --accent-fade:   color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-faint:  color-mix(in srgb, var(--accent)  8%, transparent);

  /* Default palette (light + warm) — surface variants override below */
  --bg:          #faf7f2;
  --surface:     #ffffff;
  --surface-2:   #f3efe7;
  --border:      #ece7df;
  --border-soft: #f5f1ea;
  --text:        #1a1714;
  --text-dim:    #6b6359;
  --text-faint:  #a39a8d;

  /* Type */
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Radii + shadows */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 2px rgba(0,0,0,.04);
  --shadow-pop:  0 12px 32px rgba(0,0,0,.10);
  --shadow-inset: inset 0 0 0 1px var(--border);

  /* Semantic */
  --good:    #16a34a;
  --bad:     #dc2626;
  --warn:    #d97706;
  --neutral: #78716c;
  --good-soft: color-mix(in srgb, var(--good) 12%, transparent);
  --bad-soft:  color-mix(in srgb, var(--bad)  12%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 12%, transparent);
}

/* === Light surface variants === */
[data-surface="warm"] {
  --bg:          #faf7f2;
  --surface:     #ffffff;
  --surface-2:   #f3efe7;
  --border:      #ece7df;
  --border-soft: #f5f1ea;
  --text:        #1a1714;
  --text-dim:    #6b6359;
  --text-faint:  #a39a8d;
}
[data-surface="cool"] {
  --bg:          #f4f7fa;
  --surface:     #ffffff;
  --surface-2:   #eaf0f6;
  --border:      #dde4ec;
  --border-soft: #ecf1f6;
  --text:        #0f172a;
  --text-dim:    #475569;
  --text-faint:  #94a3b8;
}
[data-surface="mono"] {
  --bg:          #fafafa;
  --surface:     #ffffff;
  --surface-2:   #f5f5f4;
  --border:      #e7e5e4;
  --border-soft: #f0efee;
  --text:        #0a0a0a;
  --text-dim:    #57534e;
  --text-faint:  #a8a29e;
}

/* === Dark mode (explicit or via prefers-color-scheme when auto) === */
[data-theme="dark"],
[data-theme="auto"] {
  --shadow-card: 0 1px 2px rgba(0,0,0,.4);
  --shadow-pop:  0 12px 32px rgba(0,0,0,.5);
}
[data-theme="dark"] {
  --bg:          #0a0a0a;
  --surface:     #141413;
  --surface-2:   #1c1b1a;
  --border:      #2a2a28;
  --border-soft: #1f1f1d;
  --text:        #f5f5f4;
  --text-dim:    #a8a29e;
  --text-faint:  #57534e;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg:          #0a0a0a;
    --surface:     #141413;
    --surface-2:   #1c1b1a;
    --border:      #2a2a28;
    --border-soft: #1f1f1d;
    --text:        #f5f5f4;
    --text-dim:    #a8a29e;
    --text-faint:  #57534e;
  }
}

/* === Base === */
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Soft radial backdrop accent — gives the page a modern-SaaS hero feel
   without dominating. Only shows in wizard mode where the body has
   data-mode="wizard" set by the SPA after boot. */
body[data-mode="wizard"]::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(60% 50% at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    radial-gradient(40% 30% at 90% 90%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 80%);
  pointer-events: none;
  z-index: -1;
}

/* Subtle grain texture overlay for warmth — barely visible, adds depth */
body[data-mode="wizard"]::after {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='1' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.025 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  pointer-events: none;
  z-index: -1;
  opacity: 0.55;
  mix-blend-mode: multiply;
}
[data-theme="dark"] body[data-mode="wizard"]::after { mix-blend-mode: screen; opacity: 0.3; }

.tabular { font-variant-numeric: tabular-nums; }
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
}
.tracking-display { letter-spacing: -0.022em; }

/* === Components === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 36px; padding: 0; justify-content: center; }

.input {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faint);
}
.input::placeholder { color: var(--text-faint); opacity: 1; }
.input:disabled { opacity: 0.55; cursor: not-allowed; }
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a8a29e' stroke-width='2' stroke-linecap='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; line-height: 1.5; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  font-size: 11px; font-weight: 500;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border-soft);
}
.chip-active {
  background: var(--accent-fade);
  color: var(--accent-strong);
  border-color: transparent;
}
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  height: 20px; padding: 0 7px;
  font-size: 11px; font-weight: 500;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.pill-success { background: var(--good-soft); color: var(--good); }
.pill-running { background: var(--accent-fade); color: var(--accent-strong); }
.pill-pending { background: var(--surface-2); color: var(--text-dim); }
.pill-failed  { background: var(--bad-soft); color: var(--bad); }

.row-hover { transition: background 0.12s; }
.row-hover:hover { background: var(--surface-2); }

/* sidebar nav item */
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item-active {
  background: var(--accent-fade);
  color: var(--accent-strong);
}
.nav-item-active:hover { background: var(--accent-fade); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Marketing-tier hero card — used on the wizard's main screen. The
   gradient border + subtle inner shadow gives it weight without
   feeling heavy; mimics how Linear/Vercel/Stripe present product
   surfaces. */
.hero-card {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  padding: 1px;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 50%, transparent), color-mix(in srgb, var(--accent) 8%, var(--border))) border-box;
  border: 1px solid transparent;
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.18), 0 4px 12px -4px rgba(0,0,0,.06);
}
[data-theme="dark"] .hero-card {
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.65), 0 4px 12px -4px rgba(0,0,0,.3);
}

/* Display headline used on hero cards */
.h-display {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.026em;
  line-height: 1.15;
  color: var(--text);
}
@media (min-width: 768px) {
  .h-display { font-size: 36px; }
}

/* Tag-row above the hero headline ("New", "v1.0", etc.) */
.tag-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-faint);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
}

/* Stat tile — used in the wizard preview pane to show "what you'll
   get" with realistic mini KPIs */
.stat-tile {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.stat-tile-value { font-size: 22px; font-weight: 600; letter-spacing: -0.022em; }
.stat-tile-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }

/* Stepper — modern pill style. Used in the wizard top bar. */
.stepper { display: inline-flex; align-items: center; gap: 0; }
.stepper-item {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 14px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  transition: all 0.2s;
}
.stepper-item.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faint);
}
.stepper-item.done {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.stepper-item .stepper-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,.06);
  font-size: 10px;
  font-weight: 600;
}
.stepper-item.done .stepper-num { background: rgba(255,255,255,.25); }
.stepper-item.active .stepper-num { background: var(--accent-fade); color: var(--accent-strong); }
.stepper-divider {
  width: 24px;
  height: 1px;
  background: var(--border);
  margin: 0 6px;
}

/* boot overlay — hides content while bootstrap fetches */
.boot-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  transition: opacity 0.3s;
}
.boot-overlay.boot-hidden { opacity: 0; pointer-events: none; }
.boot-spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: boot-spin 0.8s linear infinite;
}
@keyframes boot-spin { to { transform: rotate(360deg); } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

[x-cloak] { display: none !important; }

/* Brand mark */
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.02em;
}

/* Inline-icon size overrides — inline SVGs from icons.js are 20px by
   default; these classes force a smaller render so we can use them
   inside small footer/meta UIs. */
.icon-xs { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 12px; height: 12px; }
.icon-xs svg { width: 12px; height: 12px; display: block; }
.icon-sm { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 16px; height: 16px; }
.icon-sm svg { width: 16px; height: 16px; display: block; }

/* SVG chart helpers */
.chart-grid line { stroke: var(--border-soft); stroke-width: 1; }
.chart-axis    { fill: var(--text-faint); font-size: 10px; }
.chart-label   { fill: var(--text-dim);  font-size: 11px; }

/* Tooltip used in lineChart */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: var(--shadow-pop);
  white-space: nowrap;
  z-index: 20;
}

/* Side panel — run detail */
.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 600px; max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease-out;
  box-shadow: var(--shadow-pop);
}
.side-panel.open { transform: translateX(0); }
.side-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.18);
  z-index: 49; opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.side-backdrop.open { opacity: 1; pointer-events: auto; }

/* Scrollbar polish */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }