/* -----------------------------
   Base
----------------------------- */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0b1220;
  color: #e8eef7;
}

/* -----------------------------
   App Layout (header + main + footer)
----------------------------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* -----------------------------
   Header (3-zone: left / center / right)
----------------------------- */
#header {
  height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-sizing: border-box;
  background: linear-gradient(90deg, #0a1a2b, #103a63);
  border-bottom: 1px solid rgba(120, 170, 220, 0.25);
  column-gap: 16px;
}

/* Left title */
#header .header-left {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Center stats */
/* Center stats: same “tone” as title */
#global-stats.header-center {
  justify-self: center;
  display: flex;
  align-items: baseline;
  gap: 10px;

  font-size: 16px;             /* closer to title */
  font-weight: 700;            /* title-like weight */
  letter-spacing: 0.2px;       /* same as title */
  color: rgba(232, 238, 247, 0.92);
  white-space: nowrap;
}

#global-stats .stat b {
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(120, 170, 220, 0.18); /* subtle “header glow” */
}

#global-stats .sep {
  opacity: 0.35;
  transform: translateY(-0.5px);
}

#global-stats.header-center b {
  color: #ffffff;
  font-weight: 800;
}

#global-stats.header-center .divider {
  opacity: 0.45;
}

/* Right controls */
#header .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  opacity: 0.95;
}

/* Mobile menu button */
.icon-btn {
  display: none; /* shown on mobile */
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e8eef7;
  border-radius: 10px;
  height: 36px;
  width: 44px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* -----------------------------
   Header pill button (paths toggle)
----------------------------- */
.pill-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.10);
  color: #e8eef7;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.pill-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(120, 170, 220, 0.35);
  transform: translateY(-1px);
}

.pill-btn:active {
  transform: translateY(0);
}

.pill-btn.active {
  background: rgba(24, 255, 139, 0.12);
  border-color: rgba(24, 255, 139, 0.35);
}

/* -----------------------------
   LIVE indicator
----------------------------- */
#live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}

.live-dot {
  width: 10px;
  height: 10px;
  background: #18ff8b;
  border-radius: 50%;
  box-shadow: 0 0 8px #18ff8b;
  animation: pulse 1.6s infinite;
}

.live-text {
  letter-spacing: 0.5px;
}

@keyframes pulse {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.4); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

/* -----------------------------
   Main (map + sidebar)
----------------------------- */
#main {
  flex: 1;
  display: flex;
  min-height: 0; /* critical for scroll areas in flex children */
}

#map {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
}

/* Sidebar */
#sidebar {
  flex: 0 0 400px;
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 14px;

  background: rgba(10, 16, 26, 0.92);
  color: #e8eef7;
  border-left: 1px solid rgba(120, 170, 220, 0.25);
  backdrop-filter: blur(6px);
  -webkit-overflow-scrolling: touch;
}

#sidebar h3 {
  margin: 0 0 10px 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  opacity: 0.9;
}

/* Sidebar heading with right-aligned counter */
.sidebar-heading {
  display: flex;
  align-items: center;
  width: 100%;              /* ensure full width */
}

#sidebar-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  opacity: 0.9;
}

/* Push counter fully to the right */
.sidebar-count {
  margin-left: auto;        /* THIS makes it snap right */
  font-size: 12px;
  font-weight: 700;
  opacity: 0.7;
  letter-spacing: 0.3px;
}

#aircraft-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Aircraft items */
.aircraft-item {
  padding: 10px 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.aircraft-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(120, 170, 220, 0.25);
  transform: translateY(-1px);
}

.no-pos {
  color: rgba(232, 238, 247, 0.65);
  font-style: italic;
}


/* -----------------------------
   Leaflet controls polish
----------------------------- */
.leaflet-control-scale {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

/* -----------------------------
   Measure Distance Button
----------------------------- */
.leaflet-control-custom {
  background-color: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

.leaflet-control-custom:hover {
  background-color: #ffffff;
  transform: scale(1.08);
}

.leaflet-control-custom:active {
  background-color: #f0f0f0;
  transform: scale(1.06);
}

.leaflet-control-custom.active {
  background-color: #111;
  border-color: #111;
  color: #fff;
  transform: scale(1.08);
}

/* -----------------------------
   Responsive: widths + header center stats
----------------------------- */
@media (max-width: 900px) {
  #sidebar { flex-basis: 320px; }
  #global-stats.header-center { font-size: 14px; }
}

/* -----------------------------
   Mobile-friendly: bottom-sheet sidebar (toggle with body.sidebar-open)
----------------------------- */
@media (max-width: 700px) {
  .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #header {
    padding: 0 12px;
  }

  #header .header-left {
    font-size: 16px;
  }

  /* hide stats on small screens */
  #global-stats.header-center {
    display: none;
  }

  #footer {
    font-size: 11px;
    padding: 0 12px;
  }

  /* main stays one region; sidebar overlays as a sheet */
  #main {
    position: relative;
  }

  /* Sidebar becomes a bottom sheet, hidden by default */
  #sidebar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;

    width: 100%;
    height: 55vh;

    border-left: none;
    border-top: 1px solid rgba(120, 170, 220, 0.25);

    transform: translateY(100%);
    transition: transform 0.22s ease;
    z-index: 1200;
  }

  body.sidebar-open #sidebar {
    transform: translateY(0);
  }

  /* Map always occupies the main area behind */
  #map {
    height: 100%;
  }
}

/* Smaller LIVE on very small screens */
@media (max-width: 600px) {
  #live-status { font-size: 12px; }
  .live-dot { width: 8px; height: 8px; }

  .pill-btn {
    height: 34px;
    font-size: 12px;
    padding: 0 10px;
  }
}


/* -----------------------------
   Aircraft Detail Panel
----------------------------- */
.detail-panel {
  position: fixed;
  top: 58px; /* below header */
  left: -380px;
  width: 340px;
  bottom: 34px; /* above footer */
  z-index: 1500;
  transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.detail-panel.open {
  left: 0;
  pointer-events: all;
}

.detail-panel-inner {
  height: 100%;
  margin: 12px 0 12px 12px;
  background: rgba(8, 18, 32, 0.97);
  border: 1px solid rgba(120, 170, 220, 0.3);
  border-radius: 14px;
  backdrop-filter: blur(12px);
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-close {
  position: absolute;
  top: 20px;
  right: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e8eef7;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  z-index: 1;
}

.detail-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.detail-content {
  padding: 20px 18px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.detail-loading {
  color: rgba(232, 238, 247, 0.5);
  font-size: 13px;
  text-align: center;
  padding-top: 40px;
}

/* Detail header (flight + registration) */
.detail-header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(120, 170, 220, 0.15);
}

.detail-flight {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #ffffff;
  margin-bottom: 4px;
}

.detail-registration {
  font-size: 14px;
  font-weight: 700;
  color: rgba(120, 170, 220, 0.9);
  letter-spacing: 0.5px;
}

/* Section title */
.detail-section-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(120, 170, 220, 0.6);
  margin: 16px 0 8px 0;
}

/* Row */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
  gap: 8px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: rgba(232, 238, 247, 0.5);
  white-space: nowrap;
  flex-shrink: 0;
}

.detail-value {
  color: #e8eef7;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.detail-value.highlight {
  color: #18ff8b;
}

/* Backdrop */
.detail-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: rgba(0, 0, 0, 0.3);
}

.detail-backdrop.open {
  display: block;
}

/* Mobile adjustments */
@media (max-width: 700px) {
  .detail-panel {
    top: 0;
    bottom: 0;
    width: 85vw;
    left: -90vw;
  }

  .detail-panel-inner {
    margin: 0;
    border-radius: 0 14px 14px 0;
  }
}
/* -----------------------------
   Footer (clean status bar)
----------------------------- */
/* -----------------------------
   Footer layout (proper spacing)
----------------------------- */
/* -----------------------------
   Footer with header-style color
----------------------------- */
#footer {
  height: 32px;

  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;

  padding: 0 16px;
  box-sizing: border-box;

  /* match header gradient */
  background: linear-gradient(90deg, #0a1a2b, #103a63);
  border-top: 1px solid rgba(120, 170, 220, 0.25);

  font-size: 11px;
  color: rgba(232, 238, 247, 0.92);

}

/* Left and right spacing */
.footer-left {
  justify-self: start;
  min-width: 0;
}

.footer-right {
  justify-self: end;
  text-align: right;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(232, 238, 247, 0.85);
}

.footer-center {
  justify-self: center;
}

/* GitHub link stays minimal */
.github-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  font-size: 11px;
  font-weight: 600;

  color: rgba(255, 255, 255, 0.75); /* slightly brighter on gradient */
  text-decoration: none;

  opacity: 0.75;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.github-link:hover {
  opacity: 1;
  color: #ffffff;
}