/* Tokens de color. Escala de altitud = secuencial de UN tono (azul), de la paleta de referencia
   de la guía de visualización; el color del avión lo calcula app.js con esos mismos pasos. */
:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --good: #006300;
  --warn-bg: #fff3d6;
  --warn-ink: #5c3d00;
  --ext-bg: #eef3fb;
  --own-bg: #e8f3ea;
  --shadow: 0 2px 10px rgba(11, 11, 11, 0.18);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface: #1a1a19;
    --page: #0d0d0d;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --line: #2c2c2a;
    --axis: #383835;
    --accent: #3987e5;
    --good: #0ca30c;
    --warn-bg: #3a2c08;
    --warn-ink: #f3d58a;
    --ext-bg: #1c2433;
    --own-bg: #1b2a1e;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #1a1a19; --page: #0d0d0d; --ink: #f0efec; --ink-2: #c3c2b7;
  --line: #2c2c2a; --axis: #383835; --accent: #3987e5; --good: #0ca30c;
  --warn-bg: #3a2c08; --warn-ink: #f3d58a; --ext-bg: #1c2433; --own-bg: #1b2a1e;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex; flex-direction: column;
}
.muted { color: var(--muted); }

.bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 17px; margin: 0; letter-spacing: 0.2px; }
.bar h1 span { color: var(--accent); }
.meta { color: var(--ink-2); font-size: 13px; }
.bar .btn { margin-left: auto; }
.bar .btn + .btn { margin-left: 0; }
.btn {
  background: var(--surface); color: var(--ink); border: 1px solid var(--axis);
  border-radius: 6px; padding: 6px 12px; font: inherit; cursor: pointer;
}
.btn:hover { background: var(--line); }
.btn:focus-visible, .close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.pill.live { color: var(--good); }
.pill.live .dot { background: #0ca30c; }
.pill.wait { color: var(--warn-ink); }
.pill.wait .dot { background: #fab219; }
.pill.down { color: #d03b3b; }
.pill.down .dot { background: #d03b3b; }

main { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; background: #e8eef2; }

/* Íconos de avión */
.ac { position: relative; width: 28px; height: 28px; }
.ac svg {
  width: 26px; height: 26px; position: absolute; left: 1px; top: 1px;
  transition: transform 0.4s linear;
  stroke: rgba(11, 11, 11, 0.7); stroke-width: 0.9; stroke-linejoin: round;
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.9));
}
.ac.sel svg { stroke: #000; stroke-width: 1.8; filter: drop-shadow(0 0 4px #fff); }
.ac .lbl {
  position: absolute; left: 30px; top: 5px; white-space: nowrap;
  font-size: 11px; font-weight: 600; color: #0b0b0b;
  background: rgba(252, 252, 251, 0.82); padding: 0 4px; border-radius: 3px;
  pointer-events: none;
}
.leaflet-marker-icon.acwrap { background: none; border: none; }

.ringlbl {
  font-size: 10px; color: #52514e; background: rgba(252, 252, 251, 0.8);
  padding: 0 3px; border-radius: 2px; white-space: nowrap;
}

/* Modo radar scope (estético): fondo oscuro sin teselas, anillos y blips verdes */
#sweep {
  display: none; position: absolute; z-index: 300; pointer-events: none; border-radius: 50%;
  /* cola que se apaga detrás del borde delantero, que queda nítido a las 360° */
  background: conic-gradient(from 0deg, rgba(60, 255, 120, 0) 0deg, rgba(60, 255, 120, 0) 250deg,
                             rgba(60, 255, 120, 0.28) 359deg, rgba(60, 255, 120, 0.55) 360deg);
  animation: sweep-spin 6s linear infinite;
}
@keyframes sweep-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #sweep { display: none !important; } }

.legend-row.radar-only { display: none; margin-top: 4px; }
body.radar .legend-row.radar-only { display: block; }
body.radar #map { background: #04110a; }
body.radar .ringlbl { color: #58e07a; background: rgba(4, 17, 10, 0.8); }
body.radar .ac svg { stroke: rgba(0, 20, 8, 0.8); filter: drop-shadow(0 0 3px #39ff7a); }
body.radar .ac.sel svg { stroke: #eaffef; stroke-width: 1.6; filter: drop-shadow(0 0 5px #93f5ad); }
body.radar .ac .lbl {
  color: #7dff9f; background: rgba(4, 17, 10, 0.8); border: 1px solid rgba(80, 255, 140, 0.25);
}
body.radar .swatch.unknown { background: #4a6b54; }
body.radar .leaflet-control-zoom a { background: #0b1f14; color: #7dff9f; border-color: #1f5a37; }

/* Leyenda */
.legend {
  position: absolute; left: 12px; bottom: 28px; z-index: 900; width: 250px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); font-size: 12px;
}
.legend-title { font-weight: 600; margin-bottom: 4px; }
.ramp { height: 10px; border-radius: 3px; }
.ticks { display: flex; justify-content: space-between; color: var(--ink-2); margin: 2px 0 6px; font-size: 11px; }
.legend-row { color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,0.3); }
.swatch.unknown { background: #898781; }
.sep { width: 4px; }

/* Panel lateral */
.panel {
  position: absolute; top: 12px; right: 12px; bottom: 28px; width: 340px; max-width: calc(100% - 24px);
  z-index: 1000; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  overflow-y: auto; padding: 14px 16px;
}
.panel[hidden], .tablewrap[hidden] { display: none; }
.close {
  position: absolute; top: 6px; right: 8px; border: none; background: none;
  color: var(--ink-2); font-size: 24px; line-height: 1; cursor: pointer; padding: 4px 8px;
}
.ph { margin-bottom: 8px; }
.callsign { font-size: 22px; font-weight: 700; }
.icao { font-size: 12px; font-variant-numeric: tabular-nums; }
.stale { margin-top: 8px; background: var(--warn-bg); color: var(--warn-ink); padding: 6px 8px; border-radius: 6px; font-size: 12px; }
.panel section { margin-top: 14px; }
.panel h2 { font-size: 13px; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.tag { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 10px; color: var(--ink-2); }
.tag.ext { background: var(--ext-bg); }
.tag.own { background: var(--own-bg); }
.tag.est { background: var(--warn-bg); color: var(--warn-ink); }
.co2chip { border-left: 1px solid var(--line); padding-left: 12px; }
dl { display: grid; grid-template-columns: 118px 1fr; gap: 3px 10px; margin: 0; }
dt { color: var(--ink-2); }
dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
dd.na { color: var(--muted); font-style: italic; }
.note { color: var(--muted); font-size: 11.5px; margin: 6px 0 0; }

/* Tabla (vista alternativa accesible) */
.tablewrap {
  position: absolute; left: 12px; right: 12px; bottom: 12px; max-height: 45%; overflow: auto;
  z-index: 1100; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); color: var(--ink-2); font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--line); }

@media (max-width: 640px) {
  .panel { top: auto; left: 8px; right: 8px; width: auto; max-width: none; bottom: 8px; max-height: 55%; }
  .legend { bottom: auto; top: 8px; left: 56px; width: calc(100% - 72px); }   /* deja libres los botones de zoom */
  .bar { gap: 8px; padding: 8px 12px; }
}
