/* ==========================================================================
   MASTER.KE UNIVERSAL DESIGN SYSTEM
   Precision Architectural Monochrome (Linear / Vercel / Teenage Engineering)
   Typography: Jost with tabular-nums discipline
   Color System: Multi-step tonal zinc/slate hierarchy + engineered accents
   Motion Policy: Snappy high-damping spring physics (160ms–220ms), 0ms on drag
   Specificity Policy: Clean selector architecture without forced overrides
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Jost:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
  color-scheme: light dark;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }
}

/* --- 1. CORE TOKENS (LIGHT THEME DEFAULT) --- */
:root,
:root[data-theme="light"],
[data-theme="light"] {
  /* Core Surfaces - Pure White Blueprint */
  --bg-canvas: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-raised: #f8fafc;
  --bg-surface-hover: #f1f5f9;
  --bg-surface-active: #e2e8f0;
  --bg-backdrop: rgba(9, 9, 11, 0.45);

  /* Hairline Architectural Borders */
  --border-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #94a3b8;

  /* Typography Colors */
  --text-primary: #09090b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --text-inverse: #ffffff;

  /* Brand & Engineered Functional Accents */
  --brand-accent: #09090b;
  --accent-sync: #10b981;
  --accent-warning: #d97706;
  --accent-warning-bg: rgba(217, 119, 6, 0.12);
  --accent-danger: #e11d48;
  --accent-danger-bg: rgba(225, 29, 72, 0.12);

  /* Floorplan & Digital Twin Tonal Layers - Subdued so Bays Stand Out */
  --yard-outdoor: #ffffff;
  --cabro-gray: #f8fafc;
  --cabro-walkway: #f4f5f7;
  --cabro-terracotta: #f1f3f6;
  --facility-slab: #f8fafc;
  --facility-container: #f1f5f9;
  --facility-tank: #f1f5f9;
  --facility-washroom: #f1f5f9;
  --facility-gray: #f8fafc;
  --arch-line: rgba(100, 116, 139, 0.16);
  --zone-watermark: transparent;

  /* High-Contrast Interactive Work Bays */
  --bay-fill: #e2e8f0;
  --bay-hover: #cbd5e1;
  --bay-border: #64748b;
  --snap-target: #cbd5e1;
  --snap-border: #09090b;

  /* Default Vehicle Token Neutral */
  --bus-gray-body: #52525b;
  --bus-gray-border: #3f3f46;

  /* Elevation & Diffused Ambient Shadows */
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(9, 9, 11, 0.08), 0 1px 3px rgba(9, 9, 11, 0.04);
  --shadow-card: 0 12px 32px -4px rgba(9, 9, 11, 0.12), 0 2px 6px -1px rgba(9, 9, 11, 0.05);

  /* 3-Tier Corner Radius Scale */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Layout & Motion Constants */
  --cmd-bar-height: 48px;
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-med: 200ms;
}

/* --- 2. DARK THEME TOKENS --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(:has(> head > meta[name="color-scheme"][content="light"])) {
    --bg-canvas: #000000;
    --bg-surface: #121212;
    --bg-surface-raised: #1c1c1c;
    --bg-surface-hover: #262626;
    --bg-surface-active: #333333;
    --bg-backdrop: rgba(0, 0, 0, 0.72);

    --border-subtle: #1c1c1c;
    --border: #262626;
    --border-strong: #404040;

    --text-primary: #ffffff;
    --text-secondary: #d4d4d8;
    --text-muted: #a1a1aa;
    --text-faint: #71717a;
    --text-inverse: #000000;

    --brand-accent: #ffffff;
    --accent-sync: #10b981;
    --accent-warning: #f59e0b;
    --accent-warning-bg: rgba(245, 158, 11, 0.15);
    --accent-danger: #f43f5e;
    --accent-danger-bg: rgba(244, 63, 94, 0.15);

    --yard-outdoor: #08080a;
    --cabro-gray: #0f0f12;
    --cabro-walkway: #121215;
    --cabro-terracotta: #121215;
    --facility-slab: #0e0e11;
    --facility-container: #141417;
    --facility-tank: #141417;
    --facility-washroom: #111114;
    --facility-gray: #111114;
    --arch-line: rgba(255, 255, 255, 0.07);
    --zone-watermark: transparent;

    --bay-fill: #26262b;
    --bay-hover: #33333a;
    --bay-border: #52525b;
    --snap-target: #3f3f46;
    --snap-border: #ffffff;

    --bus-gray-body: #52525b;
    --bus-gray-border: #71717a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 24px 50px -8px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
}

:root[data-theme="dark"],
[data-theme="dark"],
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  /* Core Surfaces - Pure Black Blueprint */
  --bg-canvas: #000000;
  --bg-surface: #121212;
  --bg-surface-raised: #1c1c1c;
  --bg-surface-hover: #262626;
  --bg-surface-active: #333333;
  --bg-backdrop: rgba(0, 0, 0, 0.72);

  /* Hairline Architectural Borders */
  --border-subtle: #1c1c1c;
  --border: #262626;
  --border-strong: #404040;

  /* Typography Colors */
  --text-primary: #ffffff;
  --text-secondary: #d4d4d8;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --text-inverse: #000000;

  /* Brand & Engineered Functional Accents */
  --brand-accent: #ffffff;
  --accent-sync: #10b981;
  --accent-warning: #f59e0b;
  --accent-warning-bg: rgba(245, 158, 11, 0.15);
  --accent-danger: #f43f5e;
  --accent-danger-bg: rgba(244, 63, 94, 0.15);

  /* Floorplan & Digital Twin Tonal Layers */
  --yard-outdoor: #08080a;
  --cabro-gray: #0f0f12;
  --cabro-walkway: #121215;
  --cabro-terracotta: #121215;
  --facility-slab: #0e0e11;
  --facility-container: #141417;
  --facility-tank: #141417;
  --facility-washroom: #111114;
  --facility-gray: #111114;
  --arch-line: rgba(255, 255, 255, 0.07);
  --zone-watermark: transparent;

  /* High-Contrast Interactive Work Bays */
  --bay-fill: #26262b;
  --bay-hover: #33333a;
  --bay-border: #52525b;
  --snap-target: #3f3f46;
  --snap-border: #ffffff;

  /* Default Vehicle Token Neutral */
  --bus-gray-body: #52525b;
  --bus-gray-border: #71717a;

  /* Elevation & Diffused Ambient Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 24px 50px -8px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* --- 3. BASE RESET & TYPOGRAPHY DISCIPLINE --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
input,
button,
select,
textarea {
  font-family: 'Jost', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "ss01" 0;
  -webkit-font-feature-settings: "ss01" 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle 4px Precision Scrollbars for Panels & Timelines */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

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

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

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

/* Tabular Numerals Utility */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* --- 4. SHARED UI PRIMITIVES --- */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-spring),
              border-color var(--dur-fast) var(--ease-spring),
              color var(--dur-fast) var(--ease-spring),
              transform 100ms ease;
}

.ui-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.ui-btn:active {
  transform: scale(0.97);
}

.ui-btn-primary {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
  font-weight: 600;
}

.ui-btn-primary:hover {
  background: var(--text-secondary);
  border-color: var(--text-secondary);
  color: var(--text-inverse);
}

.ui-btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
}
