/* ============================================================
   Portal Design System — Design Tokens
   ============================================================ */

:root {
  /* Brand */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-muted: #bfdbfe;

  /* Surfaces */
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-hover: #f1f5f9;
  --surface-active: #e2e8f0;

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-inverse: #f8fafc;
  --text-on-primary: #ffffff;

  /* Borders */
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #2563eb;

  /* Status */
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0284c7;
  --info-soft: #e0f2fe;

  /* Sidebar */
  --sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(37, 99, 235, 0.18);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;

  /* Layout */
  --topbar-height: 60px;
  --mobile-nav-height: 64px;
  --content-max: 1280px;
  /* Stable mobile frame (updated by JS from visualViewport on iOS) */
  --app-height: 100dvh;
  --vv-top: 0px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.25);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 250ms;

  /* Z-index */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-sidebar: 300;
  --z-overlay: 400;
  --z-modal: 500;
  --z-toast: 600;
  --z-tooltip: 700;
}

/* Dark mode */
[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, 0.15);
  --primary-muted: rgba(59, 130, 246, 0.35);

  --background: #0b1220;
  --surface: #111827;
  --surface-elevated: #1a2332;
  --surface-hover: #1e293b;
  --surface-active: #243044;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-inverse: #0f172a;

  --border: #1e293b;
  --border-strong: #334155;
  --border-focus: #3b82f6;

  --success-soft: rgba(22, 163, 74, 0.18);
  --warning-soft: rgba(217, 119, 6, 0.18);
  --danger-soft: rgba(220, 38, 38, 0.18);
  --info-soft: rgba(2, 132, 199, 0.18);

  --sidebar: #020617;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f8fafc;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(59, 130, 246, 0.2);
  --sidebar-border: rgba(255, 255, 255, 0.06);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-soft: rgba(59, 130, 246, 0.15);
    --primary-muted: rgba(59, 130, 246, 0.35);

    --background: #0b1220;
    --surface: #111827;
    --surface-elevated: #1a2332;
    --surface-hover: #1e293b;
    --surface-active: #243044;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-inverse: #0f172a;

    --border: #1e293b;
    --border-strong: #334155;
    --border-focus: #3b82f6;

    --success-soft: rgba(22, 163, 74, 0.18);
    --warning-soft: rgba(217, 119, 6, 0.18);
    --danger-soft: rgba(220, 38, 38, 0.18);
    --info-soft: rgba(2, 132, 199, 0.18);

    --sidebar: #020617;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f8fafc;
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-active: rgba(59, 130, 246, 0.2);
    --sidebar-border: rgba(255, 255, 255, 0.06);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.35);
  }
}
