/* ═══════════════════════════════════════════════════════════
   SD Modeler — Design System
   Design Tokens, CSS Custom Properties, Base Reset
   ═══════════════════════════════════════════════════════════ */

/* ── Google Fonts ────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Reset ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ── Design Tokens: Light Mode (default) ─────────────────── */
:root {
  /* Backgrounds */
  --bg-primary: #fafbfc;
  --bg-secondary: #f0f2f5;
  --bg-canvas: #ffffff;
  --bg-canvas-dot: #e2e5ea;

  /* Surfaces */
  --surface: #ffffff;
  --surface-hover: #f5f6f8;
  --surface-active: #eef0f4;

  /* Borders */
  --border: #e2e5ea;
  --border-strong: #d1d5db;

  /* Text */
  --text-primary: #1a1d2e;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --text-inverse: #ffffff;

  /* Accent Colors — SD Elements */
  --accent-stock: #3b82f6;
  --accent-stock-bg: #eff6ff;
  --accent-flow: #10b981;
  --accent-flow-bg: #ecfdf5;
  --accent-converter: #f59e0b;
  --accent-converter-bg: #fffbeb;
  --accent-connector: #8b5cf6;
  --accent-connector-bg: #f5f3ff;
  --accent-cloud: #6b7280;
  --accent-cloud-bg: #f3f4f6;
  --accent-delay: #ec4899;
  --accent-delay-bg: #fdf2f8;

  /* Semantic */
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --success: #22c55e;
  --success-bg: #f0fdf4;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-tooltip: 0 4px 12px rgba(0,0,0,0.15);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Z-index layers */
  --z-canvas: 1;
  --z-toolbar: 10;
  --z-panel: 20;
  --z-header: 30;
  --z-tooltip: 100;
  --z-modal: 200;
  --z-notification: 300;

  /* Transitions */
  --transition-fast: 100ms ease-out;
  --transition-base: 150ms ease-out;
  --transition-slow: 300ms ease-in-out;
  --transition-theme: 300ms ease-in-out;

  /* Toolbar dimensions */
  --toolbar-width: 48px;
  --header-height: 44px;
  --inspector-width: 280px;
  --chart-panel-height: 240px;
  --status-bar-height: 28px;
}

/* ── Design Tokens: Dark Mode ────────────────────────────── */
[data-theme="dark"] {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-canvas: #12141c;
  --bg-canvas-dot: #2a2d3a;

  --surface: #1e2130;
  --surface-hover: #252839;
  --surface-active: #2d3045;

  --border: #2a2d3a;
  --border-strong: #3a3d4a;

  --text-primary: #e8eaf0;
  --text-secondary: #8b92a8;
  --text-tertiary: #5a6178;
  --text-inverse: #0f1117;

  --accent-stock: #60a5fa;
  --accent-stock-bg: #1e3a5f;
  --accent-flow: #34d399;
  --accent-flow-bg: #1a3d2e;
  --accent-converter: #fbbf24;
  --accent-converter-bg: #3d3520;
  --accent-connector: #a78bfa;
  --accent-connector-bg: #2d2550;
  --accent-cloud: #9ca3af;
  --accent-cloud-bg: #252839;
  --accent-delay: #f472b6;
  --accent-delay-bg: #3d2035;

  --danger: #f87171;
  --danger-bg: #3d2020;
  --success: #4ade80;
  --success-bg: #1a3d20;
  --warning: #fbbf24;
  --warning-bg: #3d3520;
  --info: #60a5fa;
  --info-bg: #1e3a5f;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-tooltip: 0 4px 12px rgba(0,0,0,0.5);
}

/* ── Typography ──────────────────────────────────────────── */
.font-mono {
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
}

/* ── Theme Transition ────────────────────────────────────── */
body,
body * {
  transition: background-color var(--transition-theme),
              color var(--transition-theme),
              border-color var(--transition-theme),
              box-shadow var(--transition-theme);
}

/* Disable transitions on canvas for performance */
canvas,
.canvas-container * {
  transition: none !important;
}

/* ── Scrollbar Styling ───────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ── Selection ───────────────────────────────────────────── */
::selection {
  background: var(--accent-stock);
  color: var(--text-inverse);
}
