/* ============================================================================
   AI Infographic — design system
   Apple/Vercel mindset: restraint, depth via subtle layering, system type,
   one accent, motion that explains. Light + dark via tokens.
   ========================================================================== */

:root {
  /* Light theme tokens */
  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --bg-subtle: #fafafa;
  --bg-inset: #f4f4f5;
  --fg: #0a0a0a;
  --fg-secondary: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;
  --border: #ededed;
  --border-strong: #e0e0e0;
  --accent: #0070f3;
  --accent-hover: #0761d1;
  --accent-soft: #e6f0ff;
  --accent-fg: #ffffff;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --warning: #f5a623;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.05);
  --shadow-glow: 0 0 0 1px var(--border), 0 8px 24px rgba(0,0,0,.08);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  --maxw: 1120px;
  --nav-h: 64px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

:root[data-theme="dark"],
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --bg-elevated: #111111;
    --bg-subtle: #0f0f0f;
    --bg-inset: #1a1a1a;
    --fg: #fafafa;
    --fg-secondary: #d4d4d8;
    --muted: #a1a1aa;
    --faint: #71717a;
    --border: #1f1f1f;
    --border-strong: #2a2a2a;
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-soft: #112844;
    --accent-fg: #ffffff;
    --success-soft: #0f2417;
    --danger-soft: #2a1416;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,.5);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.6);
    --shadow-glow: 0 0 0 1px var(--border), 0 8px 24px rgba(0,0,0,.5);
  }
}
/* Explicit dark when toggled */
:root[data-theme="dark"] {
  --bg: #0a0a0a; --bg-elevated: #111111; --bg-subtle: #0f0f0f; --bg-inset: #1a1a1a;
  --fg: #fafafa; --fg-secondary: #d4d4d8; --muted: #a1a1aa; --faint: #71717a;
  --border: #1f1f1f; --border-strong: #2a2a2a;
  --accent: #0a84ff; --accent-hover: #409cff; --accent-soft: #112844;
  --success-soft: #0f2417; --danger-soft: #2a1416;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 4px 12px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.6); --shadow-glow: 0 0 0 1px var(--border), 0 8px 24px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); line-height: 1.55;
  font-feature-settings: "cv02","cv03","cv04","cv11";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: #fff; }

a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0; letter-spacing: -0.025em; font-weight: 650; line-height: 1.12; }
p { margin: 0; }
img { max-width: 100%; display: block; }
[data-lucide] { width: 1em; height: 1em; vertical-align: -0.125em; stroke-width: 2; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }

/* brand lockup — shared across landing, dashboard, admin */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; letter-spacing: -0.02em; color: var(--fg); }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff; font-size: 16px; flex-shrink: 0;
}
.brand .logo [data-lucide] { font-size: 16px; }
.center { text-align: center; }
.hidden { display: none !important; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.stack > * + * { margin-top: var(--gap, 16px); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font: inherit; font-weight: 550; font-size: 14px; line-height: 1;
  padding: 11px 18px; border-radius: var(--radius-full); cursor: pointer;
  border: 1px solid transparent; background: var(--bg-inset); color: var(--fg);
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .btn-i { font-size: 16px; }
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover { background: var(--fg); opacity: .85; }
.btn-accent { background: var(--accent); color: var(--accent-fg); box-shadow: 0 1px 2px rgba(0,112,243,.3); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-subtle); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 14px 26px; font-size: 15px; }
.btn-icon { padding: 9px; border-radius: var(--radius); background: transparent; }
.btn-icon:hover { background: var(--bg-inset); }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--accent); padding: 0; cursor: pointer; font: inherit; }
.btn-link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- forms */
label.field { display: block; }
.field-label { font-size: 13px; font-weight: 550; color: var(--fg-secondary); margin-bottom: 6px; display: block; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--fg);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 12px; transition: border .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------------------------------------------------------------- card */
.card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm);
}
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title [data-lucide] { font-size: 17px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 550;
  padding: 3px 9px; border-radius: var(--radius-full);
  background: var(--bg-inset); color: var(--fg-secondary); border: 1px solid var(--border);
}
.pill[data-tone="ok"], .pill[data-tone="done"] { background: var(--success-soft); color: var(--success); border-color: transparent; }
.pill[data-tone="active"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill[data-tone="error"], .pill[data-tone="failed"], .pill[data-tone="suspended"] { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---------------------------------------------------------------- table */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 550; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--bg-subtle); }

/* ---------------------------------------------------------------- toast */
#toasts { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; min-width: 240px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 14px; animation: toastIn .25s cubic-bezier(.2,.8,.2,1);
}
.toast [data-lucide] { font-size: 18px; }
.toast.ok [data-lucide] { color: var(--success); }
.toast.error [data-lucide] { color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------------------------------------------------------------- misc */
.empty {
  text-align: center; padding: 48px 24px; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
}
.empty [data-lucide] { font-size: 28px; color: var(--faint); margin-bottom: 8px; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-strong); display: inline-block; }
.skeleton { background: linear-gradient(90deg, var(--bg-inset) 25%, var(--bg-subtle) 50%, var(--bg-inset) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
