
/* ── shared.css — FactorLab base token system ── */
/* Loaded before page CSS so page-level :root vars override these defaults */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Dark theme (default) */
  --bg-primary: #1a1a1a;
  --bg-card: #222222;
  --bg-header: #1e1e1e;
  --bg-sidebar: #161616;
  --bg-elevated: #12121a;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --text-primary: #e4e6ec;
  --text-secondary: #8a8a96;
  --text-tertiary: #5a5a66;
  --accent: #FF8C00;
  --accent-hover: #e07d00;
  --accent-dim: rgba(255, 140, 0, 0.10);
  --accent-mid: rgba(255, 140, 0, 0.22);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(255, 140, 0, 0.18);
  --positive: #27ae60;
  --positive-dim: rgba(39, 174, 96, 0.10);
  --negative: #e74c3c;
  --negative-dim: rgba(231, 76, 60, 0.10);
  --warning: #f39c12;
  --warning-dim: rgba(243, 156, 18, 0.10);
  --blue: #3b82f6;
  --purple: #a855f7;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.6);
}

[data-theme="light"] {
  --bg-primary: #f0f2f5;
  --bg-card: #ffffff;
  --bg-header: #e8eaf0;
  --bg-sidebar: #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --text-primary: #1a1d2e;
  --text-secondary: #5a6275;
  --text-tertiary: #8a8a96;
  --accent: #e07d00;
  --accent-hover: #cc7000;
  --accent-dim: rgba(224, 125, 0, 0.10);
  --accent-mid: rgba(224, 125, 0, 0.20);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-accent: rgba(224, 125, 0, 0.25);
  --positive: #1e8449;
  --positive-dim: rgba(30, 132, 73, 0.10);
  --negative: #c0392b;
  --negative-dim: rgba(192, 57, 43, 0.10);
  --warning: #d68910;
  --warning-dim: rgba(214, 137, 16, 0.10);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.16);
}

html { background: var(--bg-primary); color: var(--text-primary); scroll-behavior: smooth; overflow-y: scroll; }
body { font-family: var(--font-body); font-size: 15px; line-height: 1.6; background: var(--bg-primary); -webkit-font-smoothing: antialiased; display: flex; min-height: 100vh; }
a { color: inherit; text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Focus (WCAG AA) ── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Screen reader only ── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ── Cards / surfaces ── */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 20px; }
.surface { background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius-sm); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; font-family: var(--font-body); cursor: pointer; transition: all 0.15s; border: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Form elements ── */
input, select, textarea { background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-body); font-size: 14px; padding: 8px 12px; transition: border-color 0.15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }

/* ── Loading / empty ── */
.loading-spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border-color); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); font-size: 14px; }
.empty-state svg { width: 36px; height: 36px; stroke: var(--text-tertiary); margin-bottom: 12px; display: block; margin-inline: auto; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; font-family: var(--font-mono); }
.badge-positive { background: var(--positive-dim); color: var(--positive); }
.badge-negative { background: var(--negative-dim); color: var(--negative); }
.badge-warn { background: var(--warning-dim); color: var(--warning); }
.badge-accent { background: var(--accent-dim); color: var(--accent); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; }
th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-secondary); font-weight: 600; padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 13px; }
[data-theme="light"] td { border-bottom-color: rgba(0,0,0,0.06); }
tr:hover td { background: var(--bg-hover); }

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.animate-in { animation: fadeIn 0.25s ease; }
