/* === Seller OS Design Tokens v2 — SaaS Management System === */

/* ========== Shared tokens (:root) ==========
   These tokens are theme-agnostic and always available.
   Only color/shadow tokens change between light and dark themes. */

:root {
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 20px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 24px;
  --font-size-3xl: 32px;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --topbar-height: 56px;

  /* Motion */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Charts (shared across themes) */
  --chart-1: #465fff;
  --chart-2: #039855;
  --chart-3: #f59e0b;
  --chart-4: #d92d20;
  --chart-5: #7c3aed;
  --chart-6: #06b6d4;
  --chart-7: #f97316;
  --chart-8: #84cc16;
}

/* ========== Light Theme (colors + shadows only) ========== */
[data-theme="light"] {
  /* Brand */
  --color-primary: #465fff;
  --color-primary-hover: #3641d9;
  --color-primary-light: #eef2ff;
  --color-primary-subtle: #f5f6ff;

  /* Semantic */
  --color-success: #039855;
  --color-success-light: #ecfdf3;
  --color-warning: #dc6803;
  --color-warning-light: #fffaeb;
  --color-danger: #d92d20;
  --color-danger-light: #fef3f2;
  --color-info: #1570ef;
  --color-info-light: #eff8ff;

  /* Backgrounds */
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-surface-hover: #f8fafc;
  --color-surface-secondary: #f8fafc;

  /* Sidebar */
  --color-sidebar: #101828;
  --color-sidebar-text: #98a2b3;
  --color-sidebar-active: #465fff;

  /* Text */
  --color-text-primary: #101828;
  --color-text-secondary: #344054;
  --color-text-tertiary: #667085;
  --color-text-inverse: #ffffff;
  --color-text-link: #465fff;

  /* Borders */
  --color-border: #eaecf0;
  --color-border-light: #f0f1f3;
  --color-border-focus: #465fff;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 8px rgba(16, 24, 40, 0.06), 0 0 1px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 8px 16px rgba(16, 24, 40, 0.06), 0 0 1px rgba(16, 24, 40, 0.06);
  --shadow-xl: 0 20px 32px rgba(16, 24, 40, 0.08), 0 0 1px rgba(16, 24, 40, 0.06);
}

/* ========== Dark Theme (colors + shadows only) ==========
   Depth uses reverse luminance ladder: lighter surfaces on darker background.
   Page bg (darkest) → surface-secondary → surface → surface-hover (lightest).
*/
[data-theme="dark"] {
  /* Brand */
  --color-primary: #8098ff;
  --color-primary-hover: #9db5ff;
  --color-primary-light: #1a1f40;
  --color-primary-subtle: #121530;

  /* Semantic */
  --color-success: #34d399;
  --color-success-light: #0a2e22;
  --color-warning: #fbbf24;
  --color-warning-light: #2e2008;
  --color-danger: #fb7185;
  --color-danger-light: #2e1018;
  --color-info: #38bdf8;
  --color-info-light: #0a1e2e;

  /* Backgrounds — luminance ladder (darkest→lightest) */
  --color-bg: #070a13;
  --color-surface: #151a2b;
  --color-surface-hover: #1d2438;
  --color-surface-secondary: #111624;

  /* Sidebar */
  --color-sidebar: #090d18;
  --color-sidebar-text: #99a3b8;
  --color-sidebar-active: #465fff;

  /* Text */
  --color-text-primary: #eff2f8;
  --color-text-secondary: #a8b1c4;
  --color-text-tertiary: #737b90;
  --color-text-inverse: #070a13;
  --color-text-link: #8ea3ff;

  /* Borders — must be visibly lighter than surface */
  --color-border: #252e46;
  --color-border-light: #1c2336;
  --color-border-focus: #8098ff;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.65);
}

/* ========== Dark mode component overrides ========== */

[data-theme="dark"] .card,
[data-theme="dark"] .metric-card {
  background: var(--color-surface);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .card--hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-focus);
}

[data-theme="dark"] .panel {
  background: var(--color-surface);
  border-color: var(--color-border);
}
[data-theme="dark"] .panel__header {
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .chart-container {
  background: var(--color-surface);
  border-color: var(--color-border);
}

[data-theme="dark"] .table th {
  background: var(--color-surface-secondary);
  color: var(--color-text-secondary);
  border-bottom-color: var(--color-border);
}
[data-theme="dark"] .table td {
  border-bottom-color: var(--color-border-light);
}
[data-theme="dark"] .table tr:hover td {
  background: var(--color-surface-hover);
}

[data-theme="dark"] .topbar {
  background: var(--color-surface);
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .sidebar__brand {
  border-bottom-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .sidebar__user {
  border-top-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: #d0d5e0;
}
[data-theme="dark"] .nav-item--active {
  background: var(--color-sidebar-active);
  color: white;
}

[data-theme="dark"] .tabs {
  border-bottom-color: var(--color-border);
}
[data-theme="dark"] .tab:hover {
  color: var(--color-text-primary);
}
[data-theme="dark"] .tab--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

[data-theme="dark"] .empty-state {
  color: var(--color-text-tertiary);
}
[data-theme="dark"] .empty-state__title {
  color: var(--color-text-secondary);
}

[data-theme="dark"] .alert-banner--red  { color: #fca5a5; }
[data-theme="dark"] .alert-banner--yellow { color: #fcd34d; }
[data-theme="dark"] .alert-banner--green { color: #6ee7b7; }

[data-theme="dark"] .filter-bar { background: transparent; }

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}
[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

[data-theme="dark"] ::placeholder { color: var(--color-text-tertiary); }

[data-theme="dark"] code {
  background: var(--color-surface-secondary);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-light);
}

[data-theme="dark"] .section-header__title { color: var(--color-text-primary); }

[data-theme="dark"] .badge--neutral {
  background: var(--color-surface-secondary);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-light);
}

[data-theme="dark"] .tag {
  background: var(--color-surface-hover);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-light);
}

[data-theme="dark"] .form-toggle { background: var(--color-border); }
[data-theme="dark"] .form-toggle--on { background: var(--color-primary); }

/* ========== Global Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== Focus ring ========== */
:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
}
