/* ========================================
   FLIGHT TELEMETRY DASHBOARD
   Aesthetic: Military avionics / dark ops
   ======================================== */

:root {
  --bg-primary: #05080e;
  --bg-secondary: #0a0f1a;
  --bg-panel: #0d1320;
  --bg-elevated: #111827;
  --border: rgba(0, 229, 160, 0.12);
  --border-strong: rgba(0, 229, 160, 0.25);
  --text-primary: #e0e7ef;
  --text-secondary: #7a8ba8;
  --text-muted: #4a5568;
  --accent: #00e5a0;
  --accent-dim: rgba(0, 229, 160, 0.15);
  --accent-glow: rgba(0, 229, 160, 0.4);
  --warning: #ff6b35;
  --danger: #ff3b5c;
  --info: #3b82f6;
  --chart-alt: #00e5a0;
  --chart-spd: #3b82f6;
  --chart-fuel: #f59e0b;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 8px;
  --radius-lg: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font-display);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scanline overlay */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

/* ======== HEADER ======== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.header h1 {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.header h1 .accent {
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}

.sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-badge.active .status-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.status-badge.active { color: var(--accent); border-color: var(--border-strong); }

.status-badge.warning .status-dot {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(255, 107, 53, 0.5);
  animation: pulse-dot 0.8s ease-in-out infinite;
}
.status-badge.warning { color: var(--warning); border-color: rgba(255, 107, 53, 0.3); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.clock {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

/* ======== DASHBOARD LAYOUT ======== */
.dashboard {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 100px);
}

/* ======== SIDEBAR ======== */
.sidebar {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-y: auto;
  max-height: calc(100vh - 100px);
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 229, 160, 0.03);
}

.panel-icon {
  color: var(--accent);
  font-size: 8px;
}

.warning-icon {
  color: var(--warning);
  font-size: 12px;
}

.panel-header h2 {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-secondary);
  flex: 1;
}

.panel-body {
  padding: 12px 14px;
}

/* ======== BUTTONS ======== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-elevated);
  color: var(--text-primary);
  width: 100%;
  text-transform: uppercase;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-dim);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--border-strong);
  color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: rgba(0, 229, 160, 0.25);
  box-shadow: 0 0 20px var(--accent-dim);
}

.btn-secondary {
  color: var(--text-secondary);
}

.btn-icon { font-size: 10px; }

.file-upload {
  display: block;
  margin-top: 8px;
  cursor: pointer;
}

.file-upload input { display: none; }

.btn-export {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-secondary);
}

/* ======== GAUGES ======== */
.gauge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.gauge {
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.gauge-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.gauge-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.gauge-unit {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.gauge-bar {
  height: 3px;
  background: var(--bg-secondary);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

#altGauge .gauge-fill { background: var(--chart-alt); }
#spdGauge .gauge-fill { background: var(--chart-spd); }
#fuelGauge .gauge-fill { background: var(--chart-fuel); }

.gauge.alert-active {
  border-color: var(--danger);
  box-shadow: 0 0 12px rgba(255, 59, 92, 0.2);
}

.gauge.alert-active .gauge-value {
  color: var(--danger);
}

.timestamp-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ======== REPLAY ======== */
.replay-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.btn-play {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.replay-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-primary);
  outline: none;
  border: 1px solid var(--border);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.slider:disabled::-webkit-slider-thumb { background: var(--text-muted); box-shadow: none; }

.speed-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
}

.speed-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-right: 4px;
}

.btn-speed {
  width: auto;
  padding: 3px 10px;
  font-size: 10px;
  border-radius: 4px;
}

.btn-speed.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ======== ALERTS ======== */
.alert-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--bg-primary);
  background: var(--warning);
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.alerts-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
}

.alerts-list li {
  padding: 8px 10px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.alerts-list li:hover:not(.alert-empty) {
  border-color: var(--border-strong);
  background: var(--accent-dim);
}

.alert-empty {
  color: var(--text-muted);
  cursor: default !important;
  font-style: italic;
}

.alert-item {
  background: rgba(255, 107, 53, 0.06);
  border-color: rgba(255, 107, 53, 0.15) !important;
}

.alert-type {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-right: 6px;
}

.alert-type.overspeed { background: rgba(255, 59, 92, 0.2); color: var(--danger); }
.alert-type.rapid-descent { background: rgba(255, 107, 53, 0.2); color: var(--warning); }
.alert-type.fuel-spike { background: rgba(245, 158, 11, 0.2); color: var(--chart-fuel); }

.alert-timestamp {
  color: var(--text-muted);
  margin-left: 4px;
}

.alert-details {
  display: block;
  margin-top: 3px;
  color: var(--text-secondary);
  font-size: 10px;
}

/* ======== CHART AREA ======== */
.chart-area {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: calc(100vh - 100px);
}

.chart-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  flex: 1;
  min-height: 180px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 229, 160, 0.02);
}

.chart-header h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-secondary);
}

.chart-unit {
  font-weight: 400;
  color: var(--text-muted);
}

.chart-indicator {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}

.alt-indicator { color: var(--chart-alt); }
.spd-indicator { color: var(--chart-spd); }
.fuel-indicator { color: var(--chart-fuel); }

.chart-container {
  padding: 8px 10px;
  height: calc(100% - 40px);
  position: relative;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ======== SUMMARY BAR ======== */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
}

.summary-item {
  text-align: center;
}

.summary-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.summary-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.anomaly-count { color: var(--warning); }

/* ======== FOOTER ======== */
.footer {
  padding: 10px 20px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.footer-sep {
  margin: 0 8px;
  color: var(--border-strong);
}

/* ======== ANIMATIONS ======== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel { animation: fadeIn 0.4s ease both; }
.panel:nth-child(2) { animation-delay: 0.05s; }
.panel:nth-child(3) { animation-delay: 0.1s; }
.panel:nth-child(4) { animation-delay: 0.15s; }
.panel:nth-child(5) { animation-delay: 0.2s; }

.chart-panel { animation: fadeIn 0.4s ease both; }
.chart-panel:nth-child(1) { animation-delay: 0.1s; }
.chart-panel:nth-child(2) { animation-delay: 0.15s; }
.chart-panel:nth-child(3) { animation-delay: 0.2s; }

/* ======== SCROLLBAR ======== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ======== RESPONSIVE ======== */
@media (max-width: 900px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  .sidebar {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .chart-area {
    max-height: none;
  }
  .header-right { display: none; }
  .summary-bar { grid-template-columns: repeat(3, 1fr); }
}
