/* Single source of truth for the two provenance colors. Used by aircraft
   markers, trails, sidebar badges, popups, and the legend — changing one
   variable retints every surface at once. */
:root {
  --color-api:   #60a5fa; /* community-fed provider (OpenSky, adsb.lol) */
  --color-local: #f59e0b; /* own dump1090 receiver */
}

/* Shared provenance classes — JS puts these on aircraft icons, trail
   polylines, and legend SVGs so the color only lives in one place. */
.ac-api        { color: var(--color-api); }
.ac-local      { color: var(--color-local); }
.trail-api     { stroke: var(--color-api); }
.trail-local   { stroke: var(--color-local); }
.legend-api    { fill: var(--color-api); }
.legend-local  { fill: var(--color-local); }

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: system-ui, sans-serif; background: #0f1117; }

#layout { display: flex; height: 100vh; }
#map { flex: 1; }

/* ── Sidebar ── */
#sidebar {
  width: 340px;
  flex-shrink: 0;
  background: rgba(15, 17, 23, 0.95);
  border-left: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  z-index: 1000;
}
#sidebar-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#sidebar-header span { color: rgba(255,255,255,0.5); }
#sidebar-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  overscroll-behavior: contain;
}
.sb-row {
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.1s;
  touch-action: manipulation;
}
.sb-row:hover,
.sb-row:active { background: rgba(255,255,255,0.08); }
.sb-main {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.sb-badge { font-size: 8px; line-height: 1; }
.sb-badge--local { color: var(--color-local); }
.sb-badge--api   { color: var(--color-api); }
.sb-callsign {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.02em;
  flex: 1;
}
.sb-dist {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  font-variant-numeric: tabular-nums;
}
.sb-detail {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  padding-left: 14px;
}

/* ── Low-level row highlighting ── */
.sb-row--lowlevel {
  border-left: 2px solid rgba(239,68,68,0.6);
  background: rgba(239,68,68,0.04);
}
.sb-row--lowlevel:hover,
.sb-row--lowlevel:active { background: rgba(239,68,68,0.12); }
.sb-lowlevel-tag {
  font-size: 11px;
  color: #f87171;
  line-height: 1;
}

/* ── Emergency squawk (7700/7600/7500) — pinned section at top ── */
.sb-emergency-section {
  border-bottom: 1px solid rgba(239, 68, 68, 0.25);
}
.sb-emergency-section-header {
  padding: 6px 14px 4px;
  font-size: 10px;
  color: #ef4444;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.08);
}
.sb-row--emergency {
  border-left: 3px solid #ef4444;
  background: rgba(239, 68, 68, 0.12);
}
.sb-row--emergency:hover,
.sb-row--emergency:active { background: rgba(239, 68, 68, 0.22); }
.sb-row--emergency .sb-callsign { color: #ef4444; font-weight: 600; }
.sb-emergency-tag {
  font-size: 10px;
  color: #ef4444;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1;
}

.sb-more-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: rgba(96,165,250,0.08);
  border: none;
  border-top: 1px solid rgba(96,165,250,0.2);
  border-bottom: 1px solid rgba(96,165,250,0.2);
  color: var(--color-api);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  touch-action: manipulation;
}
.sb-more-btn:hover,
.sb-more-btn:active { background: rgba(96,165,250,0.18); color: #93c5fd; }

.sb-poi-section {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 4px;
}
.sb-poi-header {
  padding: 8px 14px 4px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}
.sb-poi-name {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.sb-poi-meta {
  font-size: 10px;
  color: rgba(255,255,255,0.2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sb-poi-empty {
  padding: 4px 14px 8px 28px;
  font-size: 11px;
  color: rgba(255,255,255,0.2);
  font-style: italic;
}

/* ── Status bar ── */
/* Desktop: anchored to the left of the 340px sidebar, centred in the remaining viewport.
   Mobile override in mobile.css. */
#status-bar {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 352px; /* sidebar (340) + gutter (12) */
  margin: 0 auto;
  max-width: max-content;
  z-index: 1001;
  background: rgba(15, 17, 23, 0.85);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #e2e8f0;
  font-size: 13px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ef4444;
  transition: background 0.3s;
}
.status-dot.connected { background: #22c55e; }
#aircraft-count { color: #94a3b8; }
.legend { display: flex; align-items: center; gap: 6px; }
.legend-icon { width: 16px; height: 16px; }

/* ── Status-bar buttons & selects ── */
.status-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.45);
  border-radius: 5px;
  padding: 2px 10px;
  font-size: 12px;
  font-family: system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
}
.status-btn.active {
  background: rgba(96,165,250,0.15);
  border-color: rgba(96,165,250,0.35);
  color: var(--color-api);
}
.status-btn:hover,
.status-btn:active { background: rgba(255,255,255,0.18); }

.status-select {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.75);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 12px;
  font-family: system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}
.status-select:hover,
.status-select:active { background: rgba(255,255,255,0.18); }
.status-select option { background: #1a1a1a; color: #fff; }
