/**
 * live-ops.css
 *
 * Public Live Flights page. Light/dark theming follows the dashboard
 * `data-bs-theme` attribute and reuses the schedules-map blue/orange palette.
 */

.lo-page {
  --lo-bg: #f3f5f7;
  --lo-card: #ffffff;
  --lo-border: #e6eaef;
  --lo-text: #141250;
  --lo-muted: #69729b;
  --lo-accent: #f58932;
  --lo-accent-strong: #003875;
  --lo-track: #eef1f5;
  --lo-row-hover: #f6f8fb;
  --lo-shadow: 0 10px 30px rgba(20, 40, 70, 0.06);

  padding: 32px 0 56px;
  color: var(--lo-text);
}

[data-bs-theme="dark"] .lo-page {
  --lo-bg: #00182e;
  --lo-card: #061d35;
  --lo-border: rgba(126, 192, 255, 0.16);
  --lo-text: #f4f8ff;
  --lo-muted: #b8c9e4;
  --lo-accent: #ff7a42;
  --lo-track: rgba(126, 192, 255, 0.12);
  --lo-row-hover: rgba(126, 192, 255, 0.06);
  --lo-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ---------------------------------------------------------------- header */
.lo-header { text-align: center; margin-bottom: 0; }
.lo-eyebrow {
  font-size: 0.78rem; font-weight: 800; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--lo-muted); margin-bottom: 6px;
}
.lo-title {
  font-size: clamp(2rem, 4vw, 3rem); font-weight: 900; margin: 0 0 8px;
  position: relative; display: inline-block;
}
.lo-title::after {
  content: ""; display: block; width: 64px; height: 3px; border-radius: 2px;
  background: var(--lo-accent); margin: 8px auto 0;
}
/* ------------------------------------------------------------------ stats */
.lo-stats {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px;
  background: var(--lo-card); border: 1px solid var(--lo-border);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--lo-shadow);
  margin: 8px 0 18px;
}
.lo-stat { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 4px 6px; }
.lo-stat + .lo-stat { border-left: 1px solid var(--lo-border); }
.lo-stat-icon { font-size: 1.3rem; color: var(--lo-accent); }
.lo-stat > div { display: flex; flex-direction: column; line-height: 1.15; }
.lo-stat-num { font-size: 1.3rem; font-weight: 800; }
.lo-stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--lo-muted); }
.lo-stat-label small { text-transform: none; letter-spacing: 0; }

/* -------------------------------------------------------------------- map */
.lo-map-wrap { position: relative; margin-bottom: 22px; }
.lo-map {
  width: 100%; height: clamp(420px, 58vh, 620px);
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--lo-border); box-shadow: var(--lo-shadow);
}
.lo-map .maplibregl-ctrl-group { border-radius: 10px; overflow: hidden; }
.lo-map-wrap .maplibregl-ctrl-top-right { top: 18px; right: 18px; }
.lo-map-wrap .maplibregl-ctrl-bottom-left { left: 18px; bottom: 18px; }

/* --------------------------------------------------------- map markers */
.lo-marker { position: relative; cursor: pointer; width: 0; height: 0; }
.lo-marker-icon {
  width: 30px; height: 30px; position: absolute;
  left: -15px; top: -15px; transform-origin: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}
.lo-marker-label {
  position: absolute; white-space: nowrap;
  background: rgba(8, 24, 40, 0.92); color: #f4f8ff;
  border-radius: 5px; padding: 1px 5px; font-size: 0.58rem; font-weight: 700; line-height: 1.35;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.3); pointer-events: none;
}
/* The tag sits at the aircraft's right wing, snapped to four positions. */
.lo-marker-label--right  { left: 16px;  top: 0;     transform: translateY(-50%); }
.lo-marker-label--left   { right: 16px; top: 0;     transform: translateY(-50%); }
.lo-marker-label--top    { left: 0;     top: -16px; transform: translate(-50%, -100%); }
.lo-marker-label--bottom { left: 0;     top: 16px;  transform: translate(-50%, 0); }
.lo-marker.is-selected .lo-marker-label { outline: 2px solid var(--lo-accent); }
.lo-marker.is-selected .lo-marker-icon { filter: drop-shadow(0 0 4px var(--lo-accent)); }

.lo-airport-pin {
  --lo-airport-pin-scale: 1;
  align-items: center;
  display: flex;
  flex-direction: column;
  height: 64px;
  justify-content: flex-start;
  pointer-events: auto;
  transform: translateY(-6px);
  width: 56px;
}
.lo-airport-pin-svg {
  display: block;
  filter: drop-shadow(0 6px 9px rgba(2, 6, 23, 0.36));
  height: 48px;
  transform: scale(var(--lo-airport-pin-scale));
  transform-origin: 50% 100%;
  transition: transform 0.12s ease;
  width: 48px;
}
.lo-airport-pin-label {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 10px rgba(2, 6, 23, 0.18);
  color: #0f172a;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  margin-top: -5px;
  padding: 3px 6px;
  letter-spacing: 0.02em;
  transition: font-size 0.12s ease, margin-top 0.12s ease, padding 0.12s ease;
}
.lo-airport-pin-compact .lo-airport-pin-label {
  font-size: 8px;
  margin-top: -7px;
  padding: 2px 5px;
}
[data-bs-theme="dark"] .lo-airport-pin-label,
body.dark .lo-airport-pin-label,
.dark .lo-airport-pin-label {
  background: rgba(15, 23, 42, 0.9);
  color: #f8fafc;
}
.lo-airport-popup-title {
  font-weight: 800;
  color: #0f172a;
}
.lo-airport-popup-body {
  margin-top: 2px;
  color: #334155;
}

/* ------------------------------------------------------------- flight panel */
.flight-panel {
  position: absolute;
  inset: 18px auto 18px 18px;
  width: min(360px, calc(100% - 92px));
  max-height: calc(100% - 36px);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(20, 33, 60, 0.16);
  overflow: hidden;
  z-index: 4;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.flight-panel.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}
.panel-body {
  overflow-y: auto;
  padding: 16px;
}
.panel-top,
.panel-actions,
.pilot-strip,
.section-title,
.progress-head,
.distance-line,
.airport-row,
.detail-row {
  display: flex;
  align-items: center;
}
.panel-top,
.section-title,
.progress-head,
.distance-line,
.airport-row,
.detail-row {
  justify-content: space-between;
}
.panel-top { gap: 12px; margin-bottom: 14px; }
.panel-actions { gap: 10px; align-items: center; }
.flight-code {
  font-size: 1.25rem;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #003875;
}
.route-code {
  font-size: 0.86rem;
  color: var(--lo-text);
}
.close-panel {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 18, 80, 0.08);
  color: var(--lo-text);
  font-size: 1.15rem;
  line-height: 1;
}
.close-panel:hover,
.close-panel:focus-visible {
  background: rgba(20, 18, 80, 0.14);
  outline: none;
}
.pilot-strip {
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(0, 56, 117, 0.04);
}
.flight-panel .avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  background: #003875;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-image.is-hidden {
  display: none;
}
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.pilot-name {
  font-size: 0.92rem;
  font-weight: 800;
}
.pilot-meta,
.airport-city,
.update-pill,
.metric-label,
.time-item span,
.detail-row span {
  color: var(--lo-muted);
}
.pilot-meta,
.airport-city,
.airport-time,
.update-pill,
.metric-label,
.time-item span,
.detail-row span {
  font-size: 0.76rem;
}
.section {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid rgba(20, 18, 80, 0.08);
}
.section:first-of-type {
  margin-top: 0;
}
.section-title {
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.update-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(20, 18, 80, 0.06);
}
.airport-stack {
  display: grid;
  gap: 10px;
}
.airport-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}
.airport-copy { min-width: 0; }
.icao-box {
  min-width: 52px;
  padding: 8px 9px;
  border-radius: 11px;
  background: rgba(0, 56, 117, 0.08);
  color: #003875;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.airport-name {
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
}
.airport-time {
  white-space: nowrap;
  color: var(--lo-text);
  text-align: right;
}
.progress-head {
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 700;
}
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(20, 18, 80, 0.08);
  overflow: hidden;
}
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f58932 0%, #003875 100%);
}
.distance-line {
  margin-top: 8px;
  gap: 10px;
  font-size: 0.76rem;
}
.metric-grid,
.time-grid {
  display: grid;
  gap: 10px;
}
.metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.time-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.metric,
.time-item {
  border-radius: 12px;
  background: rgba(20, 18, 80, 0.04);
  padding: 10px 11px;
}
.metric-value {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--lo-text);
}
.time-item strong,
.detail-row strong {
  font-size: 0.84rem;
  color: var(--lo-text);
}
.detail-list {
  display: grid;
  gap: 8px;
}
.detail-row {
  gap: 12px;
}
.detail-row--stacked {
  display: grid;
  justify-content: stretch;
}
.detail-row--stacked strong {
  line-height: 1.4;
  text-align: left;
  word-break: break-word;
}

/* ------------------------------------------------------------------ table */
.lo-table-card {
  background: var(--lo-card); border: 1px solid var(--lo-border);
  border-radius: 14px; box-shadow: var(--lo-shadow); overflow: hidden; margin-bottom: 18px;
}
.lo-table-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--lo-border);
}
.lo-table-title { font-size: 0.8rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; margin: 0; }
.lo-search { position: relative; }
.lo-search i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--lo-muted); }
.lo-search input {
  width: 320px; max-width: 60vw; padding: 9px 34px 9px 14px;
  border: 1px solid var(--lo-border); border-radius: 9px;
  background: var(--lo-bg); color: var(--lo-text); font-size: 0.86rem;
}
.lo-search input:focus { outline: none; border-color: var(--lo-accent); }

.lo-table-scroll { overflow-x: auto; }
.lo-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.lo-table thead th {
  text-align: left; padding: 12px 16px; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--lo-muted);
  border-bottom: 1px solid var(--lo-border); white-space: nowrap;
}
.lo-table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--lo-border); vertical-align: middle; }
.lo-table tbody tr { cursor: pointer; transition: background 0.12s ease; }
.lo-table tbody tr:hover { background: var(--lo-row-hover); }
.lo-table tbody tr.is-selected { background: var(--lo-row-hover); box-shadow: inset 3px 0 0 var(--lo-accent); }

.lo-flight-id, .lo-ac-reg { display: block; font-weight: 800; }
.lo-flight-call, .lo-ac-type { display: block; font-size: 0.75rem; color: var(--lo-muted); }
.lo-arrow { color: var(--lo-muted); margin: 0 2px; }
.lo-col-route { white-space: nowrap; }

.lo-pilot { display: flex; align-items: center; gap: 9px; }
.lo-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.lo-avatar--blank { background: var(--lo-track); display: inline-block; }

.lo-progress { width: 90px; height: 6px; border-radius: 4px; background: var(--lo-track); overflow: hidden; display: inline-block; vertical-align: middle; }
.lo-progress-bar { height: 100%; background: var(--lo-accent); border-radius: 4px; }
.lo-progress-val { font-size: 0.75rem; color: var(--lo-muted); margin-left: 8px; }

.lo-col-chevron a { color: var(--lo-muted); }
.lo-col-chevron a:hover { color: var(--lo-accent); }

.lo-table-foot { padding: 12px 20px; }
.lo-count { font-size: 0.78rem; color: var(--lo-muted); }
.lo-empty { padding: 32px; text-align: center; color: var(--lo-muted); }

/* ------------------------------------------------------------------ badges */
.lo-badge {
  display: inline-block; padding: 4px 10px; border-radius: 6px;
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em; color: #fff; white-space: nowrap;
}

/* --------------------------------------------------------- phase legend */
.lo-phase-legend {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 16px;
  padding: 4px 0 18px; font-size: 0.76rem; color: var(--lo-muted);
}
.lo-phase { display: inline-flex; align-items: center; gap: 6px; }
.lo-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* phase colours shared by badges (.lo-badge.phase-x) and legend dots (.lo-dot.phase-x) */
.phase-boarding { background-color: #7c5cff; }
.phase-taxiing { background-color: #f5832f; }
.phase-takeoff { background-color: #18b9d4; }
.phase-climb { background-color: #2f7fe0; }
.phase-cruise { background-color: #16407a; }
.phase-descent { background-color: #1f9e8f; }
.phase-approach { background-color: #46a72b; }
.phase-landing { background-color: #8bc34a; }
.phase-landed { background-color: #2e7d32; }
.phase-disconnected { background-color: #9aa6b2; }

/* ---------------------------------------------------------------- footnote */
.lo-footnote { text-align: center; color: var(--lo-muted); font-size: 0.82rem; }
.lo-footnote i { margin-right: 6px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 992px) {
  .lo-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lo-stat:nth-child(3n+1) { border-left: 0; }
  .flight-panel {
    inset: auto 16px 16px 16px;
    width: auto;
    max-height: min(54%, 430px);
  }
}
@media (max-width: 576px) {
  .lo-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lo-stat { border-left: 0 !important; }
  .lo-search input { width: min(100%, 280px); max-width: 100%; }
  .lo-table-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .flight-panel {
    inset: auto 12px 12px 12px;
    max-height: min(58%, 460px);
    border-radius: 16px;
  }
  .panel-body { padding: 14px; }
  .metric-grid,
  .time-grid { grid-template-columns: 1fr 1fr; }
}
