/* ==========================================================================
   Vision-Based Adaptive Traffic Control Simulator
   Pure Neumorphism Design Engine + Floating Dynamic Island Header
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Neumorphic Palette */
  --bg-dark: #121722;
  --bg-canvas: #0c1018;
  --neu-bg: #141b28;
  --neu-card: #161e2e;

  /* Extruded & Inset Shadows */
  --neu-drop-shadow: 7px 7px 18px #0b0f19, -5px -5px 14px #212d43;
  --neu-drop-shadow-hover: 9px 9px 22px #090d16, -6px -6px 16px #233149;
  --neu-inset-shadow: inset 4px 4px 10px #0a0e16, inset -3px -3px 8px #1a2336;
  --neu-button-shadow: 5px 5px 12px #0c101b, -4px -4px 10px #202c41;
  --neu-button-pressed: inset 3px 3px 8px #0a0d16, inset -2px -2px 6px #222e46;

  /* Accent Colors */
  --accent-cyan: #00f3ff;
  --accent-blue: #38bdf8;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #ef4444;

  /* Text Colors */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Dimensions & Spacing */
  --sidebar-width: 440px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  /* Transitions */
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Floating Dynamic Island Header
   ========================================================================== */

.dynamic-island-header {
  position: absolute;
  top: 18px;
  left: calc(50% - (var(--sidebar-width) / 2));
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: auto;
}

.island-content {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: #141b28;
  border-radius: 40px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 8px 8px 25px #0a0e16, -6px -6px 20px #1f2a3f;
  backdrop-filter: blur(12px);
  transition: var(--transition-normal);
}

.island-content:hover {
  box-shadow: 10px 10px 30px #080b12, -7px -7px 24px #222e46;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, #1d4ed8 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 243, 255, 0.35);
}

.brand-logo svg {
  width: 20px;
  height: 20px;
  color: #ffffff;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.1px;
  color: #ffffff;
}

.brand-subtitle {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.island-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.12);
}

.header-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #111724;
  border-radius: 30px;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--accent-emerald);
  box-shadow: var(--neu-inset-shadow);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 1.8s infinite alternate;
}

@keyframes pulse-dot {
  0% { opacity: 0.4; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.25); }
}

/* ==========================================================================
   Main Application Layout
   ========================================================================== */

.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* Simulation Canvas Area (Main Working Area - Kept 100% Intact) */
.canvas-container {
  flex: 1;
  height: 100%;
  position: relative;
  background-color: var(--bg-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas#simCanvas {
  display: block;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.85);
  border-radius: var(--radius-sm);
}

/* Floating Overlay HUD chips on canvas */
.canvas-hud-top {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  gap: 12px;
  z-index: 10;
}

.hud-chip {
  padding: 8px 16px;
  background: #141b28;
  border-radius: var(--radius-md);
  font-size: 0.76rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  box-shadow: var(--neu-drop-shadow);
}

.hud-chip .label {
  color: var(--text-muted);
  font-weight: 500;
}
.hud-chip .value {
  color: var(--accent-cyan);
  font-weight: 700;
}

/* Dashboard Sidebar (Pure Neumorphism) */
.dashboard-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--neu-bg);
  border-left: 1px solid #192233;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
  box-shadow: -10px 0 35px #090c13;
}

/* Panel Sections */
.panel-section {
  padding: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   Metrics & Analytics Cards (Neumorphic Insets & Extrusions)
   ========================================================================== */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.metric-card {
  background: var(--neu-card);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
  box-shadow: var(--neu-drop-shadow);
}

.metric-card:hover {
  box-shadow: var(--neu-drop-shadow-hover);
  transform: translateY(-2px);
}

.metric-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: #111724;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: inline-block;
  box-shadow: var(--neu-inset-shadow);
}

.metric-unit {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 3px;
}

.metric-trend {
  font-size: 0.70rem;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.trend-positive { color: var(--accent-emerald); }
.trend-negative { color: var(--accent-rose); }

/* Analytics Chart Box */
.chart-container {
  height: 140px;
  width: 100%;
  margin-top: 14px;
  background: #111724;
  border-radius: var(--radius-md);
  box-shadow: var(--neu-inset-shadow);
  padding: 10px;
  position: relative;
}

/* ==========================================================================
   Control Modules (Tactile Neumorphic Controls)
   ========================================================================== */

/* Mode Toggle Card */
.mode-toggle-card {
  background: var(--neu-card);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--neu-drop-shadow);
}

.mode-info .mode-title {
  font-weight: 700;
  font-size: 0.90rem;
  color: #ffffff;
}

.mode-info .mode-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Switch Toggle */
.switch-container {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 30px;
}

.switch-container input { opacity: 0; width: 0; height: 0; }

.slider-round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #111724;
  transition: .35s ease;
  border-radius: 34px;
  box-shadow: var(--neu-inset-shadow);
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background: linear-gradient(135deg, #e2e8f0 0%, #94a3b8 100%);
  transition: .35s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 50%;
  box-shadow: 3px 3px 6px #080b11, -2px -2px 4px #1c2639;
}

input:checked + .slider-round {
  background-color: #111724;
}

input:checked + .slider-round:before {
  transform: translateX(28px);
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-emerald) 100%);
  box-shadow: 0 0 10px var(--accent-emerald);
}

/* Custom Sliders for Traffic Density */
.lane-sliders {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
}

.slider-header .lane-name { color: var(--text-secondary); font-weight: 600; }
.slider-header .lane-val { font-family: 'JetBrains Mono', monospace; color: var(--accent-cyan); font-weight: 700; }

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

input[type=range]:focus { outline: none; }

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 8px;
  cursor: pointer;
  background: #111724;
  border-radius: 10px;
  box-shadow: var(--neu-inset-shadow);
}

input[type=range]::-webkit-slider-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -5px;
  box-shadow: 3px 3px 8px #080c14, -2px -2px 6px #1d273a;
  transition: transform 0.15s ease;
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Control Action Buttons (Tactile Extruded Neumorphism) */
.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.btn {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: var(--neu-card);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-bounce);
  box-shadow: var(--neu-button-shadow);
}

.btn:hover {
  box-shadow: var(--neu-drop-shadow-hover);
  color: #ffffff;
  transform: translateY(-2px);
}

.btn:active {
  box-shadow: var(--neu-button-pressed);
  transform: translateY(1px);
}

.btn-primary {
  color: var(--accent-blue);
}

.btn-danger {
  color: var(--accent-rose);
}

.btn-warning {
  color: var(--accent-amber);
}

.btn-full { grid-column: span 2; }

/* Scenario Preset Cards */
.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scenario-card {
  padding: 12px 16px;
  background: var(--neu-card);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  box-shadow: var(--neu-drop-shadow);
}

.scenario-card:hover {
  box-shadow: var(--neu-drop-shadow-hover);
  transform: translateX(4px);
}

.scenario-title { font-size: 0.80rem; font-weight: 700; }
.scenario-desc { font-size: 0.70rem; color: var(--text-muted); margin-top: 3px; }

/* Camera Matrix Badges */
.lane-status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.lane-badge {
  padding: 10px 8px;
  background: #111724;
  border-radius: var(--radius-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  box-shadow: var(--neu-inset-shadow);
}

.lane-badge .dir { font-size: 0.65rem; color: var(--text-muted); font-weight: 700; }
.lane-badge .count { font-family: 'JetBrains Mono', monospace; font-size: 1.15rem; font-weight: 700; color: var(--accent-cyan); }

.signal-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1f2a3e;
}

.signal-indicator.green {
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
}

.signal-indicator.yellow {
  background: var(--accent-amber);
  box-shadow: 0 0 10px var(--accent-amber);
}

.signal-indicator.red {
  background: var(--accent-rose);
  box-shadow: 0 0 10px var(--accent-rose);
}

/* Notification Toast */
.toast-notification {
  position: absolute;
  bottom: 24px;
  left: 24px;
  padding: 14px 22px;
  background: #141b28;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 8px 8px 25px #0a0e16, -6px -6px 20px #1f2a3f;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-notification.active {
  transform: translateY(0);
  opacity: 1;
}
