/* ==========================================================================
   Vision-Based Adaptive Traffic Control Simulator - Cyberpunk Glassmorphic Theme
   ========================================================================== */

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

:root {
  /* Dark Mode Palette */
  --bg-dark: #07090e;
  --bg-canvas: #0f121a;
  --panel-bg: rgba(18, 24, 38, 0.65);
  --panel-bg-hover: rgba(28, 36, 56, 0.75);
  --panel-border: rgba(255, 255, 255, 0.12);
  --panel-border-glow: rgba(0, 243, 255, 0.4);

  /* Cyberpunk Accents */
  --neon-cyan: #00f3ff;
  --neon-blue: #3b82f6;
  --neon-green: #00ff66;
  --neon-red: #ff0055;
  --neon-amber: #ffb700;
  --neon-purple: #a855f7;

  /* Status Colors */
  --status-green: #10b981;
  --status-amber: #f59e0b;
  --status-red: #ef4444;

  /* Text Colors */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-glow: 0 0 10px rgba(0, 243, 255, 0.5);

  /* Dimensions & Spacing */
  --sidebar-width: 440px;
  --header-height: 64px;
  --border-radius: 16px;
  --border-radius-sm: 8px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(0, 243, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(168, 85, 247, 0.04) 0%, transparent 40%);
}

/* ==========================================================================
   Header Architecture
   ========================================================================== */

.app-header {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
  z-index: 100;
  position: relative;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

.brand-logo svg {
  width: 22px;
  height: 22px;
  color: #000;
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ffffff, var(--neon-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.header-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(0, 243, 255, 0.08);
  border: 1px solid rgba(0, 243, 255, 0.25);
  border-radius: 20px;
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--neon-cyan);
}

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

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

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

.app-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
  width: 100vw;
  position: relative;
}

/* Simulation Canvas Area */
.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 0 40px rgba(0, 0, 0, 0.8);
  border-radius: 4px;
}

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

.hud-chip {
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
}

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

/* Sidebar Dashboard Overlay */
.dashboard-sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 20;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.dashboard-sidebar::-webkit-scrollbar {
  width: 6px;
}
.dashboard-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Panel Sections */
.panel-section {
  padding: 20px;
  border-bottom: 1px solid var(--panel-border);
}

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

/* ==========================================================================
   Metrics & Analytics Cards
   ========================================================================== */

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

.metric-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  padding: 14px;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--neon-blue);
  opacity: 0.6;
}

.metric-card.highlight::before {
  background: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan);
}

.metric-card.warning::before {
  background: var(--neon-amber);
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 500;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-unit {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 2px;
}

.metric-trend {
  font-size: 0.7rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.trend-positive { color: var(--neon-green); }
.trend-negative { color: var(--neon-red); }

/* Chart Container */
.chart-container {
  height: 140px;
  width: 100%;
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 8px;
  position: relative;
}

/* ==========================================================================
   Control Matrix Modules
   ========================================================================== */

/* Mode Toggle Switch */
.mode-toggle-card {
  background: rgba(0, 243, 255, 0.05);
  border: 1px solid rgba(0, 243, 255, 0.2);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

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

.switch-container {
  position: relative;
  display: inline-block;
  width: 60px;
  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: #1e293b;
  transition: .4s;
  border-radius: 34px;
  border: 1px solid var(--panel-border);
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider-round {
  background-color: rgba(0, 243, 255, 0.2);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.3);
}

input:checked + .slider-round:before {
  transform: translateX(30px);
  background-color: var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan);
}

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

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

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

.slider-header .lane-name {
  color: var(--text-secondary);
  font-weight: 500;
}

.slider-header .lane-val {
  font-family: 'JetBrains Mono', monospace;
  color: var(--neon-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: 6px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

input[type=range]::-webkit-slider-thumb {
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--neon-cyan);
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -5px;
  box-shadow: 0 0 8px var(--neon-cyan);
}

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

.btn {
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-fast);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.2), rgba(59, 130, 246, 0.2));
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(0, 243, 255, 0.35), rgba(59, 130, 246, 0.35));
  box-shadow: 0 0 12px rgba(0, 243, 255, 0.3);
}

.btn-danger {
  background: rgba(255, 0, 85, 0.15);
  border-color: var(--neon-red);
  color: var(--neon-red);
}

.btn-danger:hover {
  background: rgba(255, 0, 85, 0.3);
  box-shadow: 0 0 12px rgba(255, 0, 85, 0.3);
}

.btn-warning {
  background: rgba(255, 183, 0, 0.15);
  border-color: var(--neon-amber);
  color: var(--neon-amber);
}

.btn-warning:hover {
  background: rgba(255, 183, 0, 0.3);
  box-shadow: 0 0 12px rgba(255, 183, 0, 0.3);
}

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

/* Test Scenarios Container */
.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-card {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.scenario-card:hover {
  background: rgba(0, 243, 255, 0.05);
  border-color: rgba(0, 243, 255, 0.3);
}

.scenario-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.scenario-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   Camera Matrix & Signal Status Overlay
   ========================================================================== */

.lane-status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.lane-badge {
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.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.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

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

.signal-indicator.green {
  background: var(--neon-green);
  box-shadow: 0 0 8px var(--neon-green);
}

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

.signal-indicator.red {
  background: var(--neon-red);
  box-shadow: 0 0 8px var(--neon-red);
}

/* Notification Toast */
.toast-notification {
  position: absolute;
  bottom: 24px;
  left: 24px;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid var(--neon-cyan);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 243, 255, 0.2);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.toast-notification.warning {
  border-color: var(--neon-amber);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 183, 0, 0.2);
}

.toast-notification.danger {
  border-color: var(--neon-red);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 0, 85, 0.2);
}
