/* ==========================================================================
   FLIGHTPATH 2D — MODERN AEROSPACE TELEMETRY & FLIGHT SIMULATION STYLES
   ========================================================================== */

:root {
  --bg-dark: #0a0e14;
  --bg-panel: #111822;
  --bg-panel-light: #182230;
  --bg-card: #151d28;
  --border-dim: #1e2c3d;
  --border-bright: #2f455c;
  
  --accent-cyan: #00e5ff;
  --accent-cyan-dim: rgba(0, 229, 255, 0.15);
  --accent-green: #00ff88;
  --accent-amber: #ffb800;
  --accent-orange: #ff7700;
  --accent-blue: #0088ff;
  
  --text-main: #e6edf3;
  --text-dim: #8b9bb0;
  --text-muted: #536477;
  
  --sky-blue: #2389da;
  --ground-brown: #795548;

  --font-mono: 'Share Tech Mono', monospace;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Orbitron', monospace;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
  height: 58px;
  background: linear-gradient(180deg, #131b26 0%, #0d131c 100%);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  flex-shrink: 0;
  z-index: 100;
}

.header-left .flight-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.flight-icon {
  font-size: 20px;
  color: var(--accent-cyan);
  background: var(--accent-cyan-dim);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(0, 229, 255, 0.3);
  transform: rotate(45deg);
}

.flight-callsign {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
  font-weight: 700;
}

.flight-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  padding: 5px 12px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-green);
  font-weight: 600;
}

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

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.time-display-box, .speed-display-box {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.time-label, .speed-label {
  color: var(--text-muted);
}

.time-val {
  color: var(--text-main);
  font-weight: 700;
  font-size: 13px;
}

.speed-val {
  color: var(--accent-amber);
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-tool {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-tool:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-panel-light);
  color: var(--accent-cyan);
}

/* ==========================================================================
   MAIN LAYOUT (SPLIT VIEW)
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* LEFT: 2D SIMULATION SECTION */
.simulation-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: radial-gradient(circle at 50% 30%, #0e1724 0%, #070a0f 100%);
  border-right: 1px solid var(--border-dim);
  overflow: hidden;
}

.canvas-header-bar {
  height: 38px;
  background: rgba(17, 24, 34, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
}

.canvas-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--accent-cyan);
  font-weight: 700;
}

.radar-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-cyan);
}

.canvas-stats-quick {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.canvas-stats-quick strong {
  color: var(--text-main);
}

.canvas-tools {
  display: flex;
  gap: 4px;
}

.btn-canvas-preset {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-dim);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-canvas-preset:hover {
  background: var(--border-dim);
  color: var(--text-main);
  border-color: var(--border-bright);
}

.btn-canvas-preset.active {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
}

.btn-canvas-ctrl {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-dim);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-canvas-ctrl:hover {
  background: var(--border-dim);
  color: var(--text-main);
  border-color: var(--border-bright);
}

.canvas-viewport {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#flight-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#flight-canvas:active {
  cursor: grabbing;
}

.canvas-overlay-legend {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(13, 19, 28, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  pointer-events: none;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.legend-swatch.path {
  background: var(--accent-cyan);
  box-shadow: 0 0 4px var(--accent-cyan);
}

.legend-swatch.gravity {
  background: #ff5252;
}

.legend-swatch.inertial {
  background: #e040fb;
  border: 1px dashed #fff;
}

/* RIGHT: AVIONICS & INSTRUMENTS SECTION */
.avionics-section {
  width: 360px;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
  border-left: 1px solid var(--border-dim);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 8px;
}

.panel-title-text {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--accent-cyan);
}

.system-ok-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

/* INSTRUMENT CARDS */
.instrument-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.instrument-card-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.instrument-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inst-icon {
  font-size: 16px;
}

.instrument-name strong {
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--text-main);
  display: block;
}

.inst-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  display: block;
}

.instrument-readout-badge {
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}

.alt-badge {
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.3);
  color: var(--accent-green);
}

.instrument-canvas-box {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.instrument-canvas-box canvas {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: #05080c;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(0, 0, 0, 0.8);
  border: 3px solid #222e3d;
}

/* GYRO MODE TOGGLE */
.gyro-mode-card {
  width: 100%;
  margin-top: 10px;
  background: #0d131c;
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 8px;
}

.mode-card-title {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.mode-switch-group {
  display: flex;
  gap: 6px;
}

.mode-btn {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  transition: all 0.2s ease;
  text-align: left;
}

.mode-btn .radio-indicator {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 14px;
}

.mode-btn .mode-text strong {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
}

.mode-btn .mode-text small {
  display: block;
  font-size: 8px;
  color: var(--text-muted);
  margin-top: 2px;
}

.mode-btn.active {
  background: rgba(0, 229, 255, 0.12);
  border-color: var(--accent-cyan);
}

.mode-btn.active .radio-indicator {
  color: var(--accent-cyan);
}

.mode-btn.active .mode-text strong {
  color: var(--accent-cyan);
}

.mode-btn.active .mode-text small {
  color: var(--text-dim);
}

.mode-explanation-blurb {
  margin-top: 6px;
  font-size: 9.5px;
  color: var(--text-dim);
  line-height: 1.35;
  font-family: var(--font-sans);
  background: rgba(0, 0, 0, 0.25);
  padding: 5px 8px;
  border-radius: 4px;
  border-left: 2px solid var(--accent-cyan);
}

/* ALTIMETER SUB-STATS */
.alt-telemetry-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-top: 10px;
}

.alt-mini-stat {
  background: #0d131c;
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 5px 6px;
  text-align: center;
}

.alt-mini-stat .label {
  display: block;
  font-size: 8px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.alt-mini-stat .val {
  display: block;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-main);
  font-weight: 700;
  margin-top: 2px;
}

/* COMPACT TELEMETRY CARD */
.telemetry-compact-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 10px 12px;
}

.card-sub-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.8px;
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.telem-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.telem-cell {
  background: #0d131c;
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 6px 8px;
}

.telem-cell .t-name {
  display: block;
  font-size: 8.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 2px;
}

.telem-cell .t-val {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-main);
  font-weight: 700;
}

.telem-cell .t-val.highlight {
  color: var(--accent-cyan);
}

.telem-cell .t-val.accent {
  color: var(--accent-amber);
}

/* ==========================================================================
   FOOTER (TIMELINE SCRUBBER & PLAYBACK CONTROLS)
   ========================================================================== */
.app-footer {
  background: linear-gradient(0deg, #131b26 0%, #0d131c 100%);
  border-top: 1px solid var(--border-dim);
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  z-index: 100;
}

.scrubber-bar-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scrubber-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-muted);
  padding: 0 4px;
}

.scrubber-labels .marker.pole {
  color: var(--accent-cyan);
  font-weight: 700;
}

.scrubber-labels .marker.equator {
  color: var(--accent-green);
  font-weight: 700;
}

.slider-wrapper {
  position: relative;
  width: 100%;
  height: 20px;
  display: flex;
  align-items: center;
}

#flight-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #182433;
  outline: none;
  cursor: pointer;
  z-index: 2;
  position: relative;
}

#flight-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
  border: 2px solid #ffffff;
  cursor: pointer;
  transition: transform 0.1s ease;
}

#flight-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

#flight-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
  border: 2px solid #ffffff;
  cursor: pointer;
}

.slider-fill {
  position: absolute;
  left: 0;
  top: 6px;
  height: 8px;
  background: linear-gradient(90deg, var(--accent-cyan) 0%, var(--accent-green) 100%);
  border-radius: 4px;
  pointer-events: none;
  width: 0%;
  z-index: 1;
}

.scrubber-footer-info {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.scrubber-footer-info strong {
  color: var(--accent-cyan);
}

/* CONTROLS BAR */
.controls-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.playback-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-ctrl {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-ctrl:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-panel-light);
  color: var(--accent-cyan);
}

.btn-primary-action {
  background: linear-gradient(135deg, #0088ff 0%, #00e5ff 100%);
  border: none;
  color: #070d14;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
}

.btn-primary-action:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.6);
  color: #000;
}

.speed-controls-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.speed-group-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.speed-buttons {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #090e14;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--border-dim);
}

.speed-pill {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.speed-pill:hover {
  color: var(--text-main);
}

.speed-pill.active {
  background: var(--bg-card);
  color: var(--accent-amber);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 184, 0, 0.3);
}

.altitude-adjust-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alt-selector {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  outline: none;
  cursor: pointer;
}

.alt-selector:focus {
  border-color: var(--accent-cyan);
}

/* ==========================================================================
   MODAL DIALOG & TOAST
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-dialog {
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 229, 255, 0.15);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--accent-cyan);
}

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
}

.btn-modal-close:hover {
  color: var(--text-main);
}

.modal-content {
  padding: 20px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
}

.modal-content h4 {
  color: var(--accent-cyan);
  font-size: 13px;
  margin: 16px 0 8px 0;
  letter-spacing: 0.5px;
}

.modal-content h4:first-child {
  margin-top: 0;
}

.modal-content p, .modal-content ul {
  color: var(--text-dim);
  margin-bottom: 10px;
}

.modal-content ul {
  padding-left: 20px;
}

.modal-content li {
  margin-bottom: 6px;
}

.modal-mode-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}

.modal-mode-box > div {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 12px;
}

.modal-mode-box strong {
  color: var(--accent-amber);
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}

.modal-mode-box p {
  font-size: 11.5px;
  margin-bottom: 0;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-dim);
  display: flex;
  justify-content: flex-end;
}

/* ARRIVAL TOAST */
.toast-card {
  position: fixed;
  bottom: 110px;
  right: 24px;
  background: #0f1926;
  border: 1px solid var(--accent-green);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 255, 136, 0.2);
  z-index: 500;
  animation: slideIn 0.3s ease;
}

.toast-card.hidden {
  display: none;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast-body {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast-emoji {
  font-size: 24px;
}

.toast-body strong {
  color: var(--accent-green);
  font-size: 13px;
  display: block;
}

.toast-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.btn-toast-dismiss {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

/* RESPONSIVE DESIGN */
@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
  }
  .avionics-section {
    width: 100%;
    height: 320px;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .instrument-card {
    min-width: 250px;
  }
  .controls-panel {
    justify-content: center;
  }
}
