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

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --accent: #238636;
  --accent-bright: #2ea043;
  --red: #da3633;
  --text: #e6edf3;
  --muted: #8b949e;
  --airborne: #39d353;
  --sidebar-w: 320px;
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 13px; }

#app { display: flex; height: 100vh; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar-header {
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#header-title { display: flex; align-items: center; gap: 10px; }
.header-flag { font-size: 1.6rem; }
h1 { font-size: 0.95rem; font-weight: 700; color: var(--text); }
#last-update { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

.section { padding: 14px 12px; border-bottom: 1px solid var(--border); }
.section-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

/* Aircraft cards */
.ac-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 6px;
}
.ac-card:hover { background: var(--surface2); border-color: var(--border); }
.ac-card.airborne  { border-left: 3px solid var(--airborne); }
.ac-card.grounded  { border-left: 3px solid var(--border); }
.ac-card.highlighted {
  background: rgba(88, 166, 255, 0.13);
  border-color: #58a6ff !important;
  border-left: 3px solid #58a6ff !important;
  box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.4), 0 0 12px rgba(88, 166, 255, 0.15);
}

.ac-photo {
  width: 54px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}
.ac-photo-placeholder {
  width: 54px;
  height: 36px;
  border-radius: 4px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.ac-info { flex: 1; min-width: 0; }
.ac-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.82rem; }
.ac-reg  { font-size: 0.75rem; color: var(--muted); font-family: monospace; margin-top: 1px; font-weight: 600; }

.ac-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-air    { background: rgba(57,211,83,.15);  color: var(--airborne); }
.badge-gnd    { background: rgba(139,148,158,.1); color: var(--muted); }
.badge-off    { background: rgba(218,54,51,.1);   color: #f85149; }

/* ── Aircraft filter dropdown ── */
#acf-wrapper { position: relative; margin-bottom: 10px; }

#acf-toggle {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 10px; cursor: pointer;
  transition: border-color 0.15s;
}
#acf-toggle:hover { border-color: var(--muted); }
#acf-toggle.acf-open { border-color: #58a6ff; border-radius: 6px 6px 0 0; }

#acf-current { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.acf-toggle-photo {
  width: 38px; height: 26px; border-radius: 3px;
  object-fit: cover; flex-shrink: 0;
}
.acf-toggle-placeholder {
  width: 38px; height: 26px; border-radius: 3px;
  background: var(--surface); display: flex;
  align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.acf-toggle-label {
  font-size: 0.8rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acf-chevron {
  color: var(--muted); font-size: 0.72rem; flex-shrink: 0;
  transition: transform 0.15s; margin-left: 4px;
}
#acf-toggle.acf-open .acf-chevron { transform: rotate(180deg); }

#acf-list {
  display: none; position: absolute; top: 100%;
  left: 0; right: 0; z-index: 600;
  background: var(--surface); border: 1px solid #58a6ff;
  border-top: none; border-radius: 0 0 6px 6px;
  max-height: 260px; overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
#acf-list.acf-open { display: block; }

.acf-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.acf-item:last-child { border-bottom: none; }
.acf-item:hover { background: var(--surface2); }
.acf-item.selected { background: rgba(88,166,255,.1); }

.acf-photo {
  width: 46px; height: 30px; border-radius: 4px;
  object-fit: cover; flex-shrink: 0; background: var(--surface2);
}
.acf-placeholder {
  width: 46px; height: 30px; border-radius: 4px;
  background: var(--surface2); display: flex;
  align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.acf-info { min-width: 0; }
.acf-reg { font-size: 0.78rem; font-family: monospace; font-weight: 600; color: var(--text); }
.acf-name { font-size: 0.7rem; color: var(--muted); margin-top: 1px; }

.fl-item {
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  margin-bottom: 5px;
  transition: background 0.15s, border-color 0.15s;
}
.fl-item:hover { background: var(--surface2); border-color: var(--border); }
.fl-item.selected { border-color: #58a6ff; background: rgba(88,166,255,.07); }
.fl-item.active-flight { border-color: var(--airborne); }

.fl-top { display: flex; justify-content: space-between; align-items: center; }
.fl-reg { font-weight: 600; font-family: monospace; font-size: 0.82rem; }
.fl-num { font-size: 0.72rem; color: var(--muted); font-family: monospace; }
.fl-time { font-size: 0.7rem; color: var(--muted); margin-top: 3px; }
.fl-dur  { font-size: 0.68rem; color: var(--muted); margin-top: 1px; }
.fl-type  { font-size: 0.7rem; color: var(--muted); margin-top: 1px; }
.fl-route { font-size: 0.72rem; color: #58a6ff; font-family: monospace; font-weight: 600; }

.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--airborne);
  margin-right: 5px;
  animation: blink 1.4s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }

#load-more {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background 0.15s;
}
#load-more:hover { background: var(--border); }

/* ── Map area ── */
#map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

/* Support bar */
#support-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 52px;
  background: rgba(13,17,23,.93);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  backdrop-filter: blur(6px);
}

.support-btn {
  display: flex; align-items: center; gap: 12px;
  height: 100%; padding: 0 22px;
  text-decoration: none;
  transition: background 0.15s;
}
.support-btn:hover { background: rgba(255,255,255,.05); }
.support-btn:hover .bmc-logo-wrap,
.support-btn:hover .pp-logo-wrap { transform: scale(1.08); }

.support-sep {
  width: 1px; height: 28px;
  background: var(--border); flex-shrink: 0;
}

.bmc-logo-wrap {
  width: 36px; height: 36px;
  background: #FFDD00;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform 0.15s;
}
.bmc-icon { height: 22px; display: block; }

.pp-logo-wrap {
  width: 36px; height: 36px;
  background: #0070ba;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform 0.15s;
}
.pp-icon { height: 22px; display: block; }

.bmc-text { display: flex; flex-direction: column; }
.bmc-main { font-size: 0.83rem; font-weight: 700; color: var(--text); }
.bmc-sub   { font-size: 0.68rem; color: #58a6ff; margin-top: 1px; }

/* Flight detail panel */
#flight-panel {
  position: absolute;
  bottom: 60px;
  right: 16px;
  width: 260px;
  background: rgba(13,17,23,.93);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  backdrop-filter: blur(12px);
  z-index: 1000;
}
#flight-panel.hidden { display: none; }
#close-panel {
  position: absolute;
  top: 8px; right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
#close-panel:hover { color: var(--text); }
.fp-title { font-weight: 700; font-size: 0.88rem; margin-bottom: 8px; color: var(--text); }
.fp-route-row {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-bottom: 10px;
  background: var(--surface2); border-radius: 6px; padding: 7px 10px;
}
.fp-airport {
  font-family: monospace; font-weight: 700; font-size: 1rem;
  color: var(--text); letter-spacing: 0.04em;
}
.fp-route-arrow { color: var(--muted); font-size: 0.9rem; }
.fp-row { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 0.78rem; }
.fp-label { color: var(--muted); }
.fp-val   { color: var(--text); font-family: monospace; font-weight: 500; }
.fp-live  { font-size: 0.7rem; color: var(--airborne); margin-top: 8px; }

/* Stats bar */
#stats-bar {
  position: absolute;
  top: 10px; right: 10px;
  display: flex;
  gap: 8px;
  z-index: 900;
}
#stats-bar span {
  background: rgba(13,17,23,.82);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  color: var(--muted);
  backdrop-filter: blur(6px);
}

/* ── Mobile ── */
#mobile-nav { display: none; }

@media (max-width: 768px) {
  #app { flex-direction: column; }

  #sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    bottom: 56px;
    width: 100%;
    z-index: 1500;
    border-right: none;
    overflow-y: auto;
    flex-direction: column;
  }
  #sidebar.mobile-show { display: flex; }

  #map-container {
    width: 100%;
    height: calc(100vh - 56px);
  }

  #mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 2000;
  }
  .mob-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
  }
  .mob-tab .tab-icon { font-size: 1.2rem; line-height: 1; }
  .mob-tab.active { color: var(--text); }

  /* BMC tab icon — size matches emoji height so text aligns */
  .bmc-tab-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.2rem; height: 1.2rem;
    background: #FFDD00; border-radius: 50%;
    flex-shrink: 0; vertical-align: middle;
  }
  .bmc-tab-img { height: 0.75rem; display: block; }

  #flight-panel {
    position: fixed;
    bottom: 72px;
    width: calc(100vw - 32px);
    left: 16px;
    right: 16px;
    max-height: 44vh;
    overflow-y: auto;
    z-index: 1500;
  }

  #support-bar { display: none; }
  #stats-bar { top: 8px; right: 8px; left: auto; }
}

/* ── Support modal (mobile) ── */
#support-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(0,0,0,.88);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
#support-modal.hidden { display: none; }

#support-modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 28px 32px;
  position: relative;
  min-width: 280px;
}
#close-support-modal {
  position: absolute;
  top: 12px; right: 16px;
  background: none; border: none;
  color: var(--muted); font-size: 1.4rem;
  cursor: pointer; line-height: 1;
}
#close-support-modal:hover { color: var(--text); }

#support-modal-title {
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); text-align: center;
  margin-bottom: 20px;
}
#support-modal-btns {
  display: flex; gap: 12px;
}
.modal-support-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  text-decoration: none;
  padding: 18px 16px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  flex: 1;
  transition: border-color 0.15s, background 0.15s;
}
.modal-support-btn:hover {
  border-color: #58a6ff;
  background: rgba(88,166,255,.07);
}
.modal-support-btn:hover .bmc-logo-lg,
.modal-support-btn:hover .pp-logo-lg { transform: scale(1.06); }

.bmc-logo-lg { width: 56px; height: 56px; transition: transform 0.15s; }
.bmc-icon-lg { height: 34px; display: block; }
.pp-logo-lg  { width: 56px; height: 56px; transition: transform 0.15s; }
.pp-icon-lg  { height: 34px; display: block; }
.modal-btn-label {
  font-size: 0.82rem; font-weight: 700; color: var(--text);
}

/* Leaflet overrides */
.leaflet-container { background: #e8e4d8; }
.aircraft-tooltip {
  background: rgba(13,17,23,.92) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  color: var(--text) !important;
  font-size: 0.78rem !important;
  box-shadow: 0 4px 12px rgba(0,0,0,.5) !important;
  padding: 6px 10px !important;
}
.leaflet-tooltip-top .aircraft-tooltip::before { border-top-color: var(--border) !important; }
