/* =======================================================================
   Base / Page
   ======================================================================= */

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050816;
  color: #f7fafc;

  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden; /* lock page scroll */
}

main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

main > .container-fluid {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* =======================================================================
   Header / Footer
   ======================================================================= */

.header-bar,
.footer-bar {
  --bs-border-color: rgba(15, 23, 42, 0.9);
}

.bg-header {
  background: radial-gradient(circle at top left, #1a365d, #020617);
}

.bg-footer {
  background: #020617;
}

/* Footer layout */
.footer-content {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.footer-content > :first-child {
  justify-self: start;
}

.footer-content > :last-child {
  justify-self: end;
}

/* Footer center links */
.footer-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

.footer-links a {
  color: #cbd5f5;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.75;
  transition: opacity 120ms ease, color 120ms ease;
}

.footer-links a:hover {
  opacity: 1;
  color: #f8fafc;
}

/* Footer updated text hover swap */
.footer-updated {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}

.db-updated-text {
  display: none;
}

.footer-updated .db-updated-text:first-of-type {
  display: inline;
}

.footer-updated:hover .db-updated-text:first-of-type {
  display: none;
}

.footer-updated:hover .db-updated-text:last-of-type {
  display: inline;
}

/* Header subheading fade (JS toggles .is-fading) */
#header-subheading {
  opacity: 1;
  transition: opacity 220ms ease;
}

#header-subheading.is-fading {
  opacity: 0;
}

/* =======================================================================
   Main Layout
   ======================================================================= */

.main-layout {
  display: flex;
  flex-direction: row;
  flex: 1 1 auto;
  min-height: 0;
}

/* =======================================================================
   Sidebar
   ======================================================================= */

#sidebar {
  flex: 0 0 280px;
  max-width: 280px;
  min-width: 280px;
  min-height: 0;

  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #e5e7eb;
}

/* Sidebar section separators */
.sidebar-block {
  padding-bottom: 0.8rem;
  margin-bottom: 0.8rem;

  border-bottom: 1px solid transparent;
  border-image: linear-gradient(
      to right,
      transparent,
      rgba(148, 163, 184, 0.30),
      transparent
    )
    1;
}

.sidebar-block-last {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}

/* Sidebar headings */
.sidebar h2,
.sidebar label,
.sidebar .small {
  color: #e5e7eb;
}

.sidebar h2 {
  position: relative;
  padding-left: 0.5rem;
}

.sidebar h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.15rem;
  bottom: 0.15rem;
  width: 3px;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.6);
}

.sidebar h2.filters::before {
  background: #60a5fa;
}

.sidebar h2.legend::before {
  background: #f6ad55;
}

.sidebar h2.airports::before {
  background: #48bb78;
}

/* Sidebar inputs */
.sidebar .form-check-input {
  cursor: pointer;
}

.sidebar .form-control {
  background: #020617;
  border-color: rgba(148, 163, 184, 0.8);
  color: #e5e7eb;
}

.sidebar .form-control::placeholder {
  color: #64748b;
}

/* =======================================================================
   Airports header row (title + sort controls)
   ======================================================================= */

.airports-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

/* =======================================================================
   Filters (critical to keep Bootstrap from overriding)
   ======================================================================= */

.filter-panel {
  padding: 0.6rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.35);
}

.filter-row {
  margin-top: 0.55rem;
}

/* Filter chips are buttons; these styles define the look */
.filter-chip {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.45rem;

  padding: 0.42rem 0.55rem;
  border-radius: 0.65rem;

  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.25);
  color: #e5e7eb;

  cursor: pointer;
  text-align: left;

  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.filter-chip + .filter-chip {
  margin-top: 0.35rem;
}

.filter-chip:hover {
  background: rgba(148, 163, 184, 0.10);
  border-color: rgba(148, 163, 184, 0.22);
}

/* Hide the checkbox but keep it accessible */
.filter-chip .form-check-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Active state (JS toggles .is-active) */
.filter-chip.is-active {
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.35);
}

/* Dark selects inside filter panel */
.filter-panel .form-select {
  background-color: rgba(15, 23, 42, 0.85);
  border-color: rgba(148, 163, 184, 0.55);
  color: #f8fafc;
}

.filter-panel .form-select option {
  background-color: #020617;
  color: #f8fafc;
}

.filter-panel .form-select:focus {
  background-color: rgba(15, 23, 42, 0.95);
  border-color: #60a5fa;
  box-shadow: 0 0 0 0.15rem rgba(96, 165, 250, 0.25);
}

.filter-panel .filter-row:last-child {
  opacity: 0.9;
}

/* =======================================================================
   Sort controls
   ======================================================================= */

.sort-select {
  width: 170px;
  background-color: rgba(15, 23, 42, 0.85) !important;
  border: 1px solid rgba(148, 163, 184, 0.55) !important;
  color: #f8fafc !important;

  height: 30px;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.sort-select option {
  background-color: #020617;
  color: #f8fafc;
}

.sort-select:focus {
  background-color: rgba(15, 23, 42, 0.95) !important;
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 0.15rem rgba(96, 165, 250, 0.25) !important;
}

.sort-dir-btn {
  width: 34px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sort-group .sort-select {
  border-right: 0;
}

/* =======================================================================
   Legend (status toggles)
   ======================================================================= */

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;

  display: inline-block;
  flex: 0 0 10px;
  min-width: 10px;
  min-height: 10px;
  align-self: center;
}

.legend-base {
  background: #a0aec0;
}

.legend-in_dev {
  background: #f6ad55;
}

.legend-released {
  background: #48bb78;
}

/* Clickable legend toggles (JS toggles .is-active) */
.legend-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.4rem;

  padding: 0.35rem 0.45rem;
  margin-bottom: 0.25rem;

  border-radius: 0.55rem;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(2, 6, 23, 0.35);
  color: #e5e7eb;

  cursor: pointer;
  text-align: left;

  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.legend-toggle:hover {
  background: rgba(148, 163, 184, 0.10);
  border-color: rgba(148, 163, 184, 0.22);
}

.legend-toggle.is-active {
  opacity: 1;
}

.legend-toggle:not(.is-active) {
  opacity: 0.45;
}

/* =======================================================================
   Airport Search + List
   ======================================================================= */

.airport-search .form-control {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: #f8fafc;
}

.airport-search .form-control::placeholder {
  color: #cbd5f5;
}

.airport-search .input-group-text {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.6);
  color: #e5e7eb;
}

.airport-search .form-control:focus {
  background: rgba(15, 23, 42, 0.95);
  border-color: #60a5fa;
  box-shadow: 0 0 0 0.15rem rgba(96, 165, 250, 0.25);
}

.airport-search .form-control,
.airport-search .input-group-text {
  transition: background 120ms ease, border-color 120ms ease;
}

.airport-list {
  min-height: 0;
}

/* List container + scrollbar */
#airport-list {
  padding-right: 0.25rem;

  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) rgba(2, 6, 23, 0.35);
  scrollbar-gutter: stable;
}

#airport-list .airport-item {
  margin-bottom: 0.35rem;
}

#airport-list .airport-item:last-child {
  margin-bottom: 0;
}

#airport-list::-webkit-scrollbar {
  width: 8px;
}

#airport-list::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
  margin: 6px 0;
}

#airport-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  border: 2px solid rgba(2, 6, 23, 0.55);
  background-clip: padding-box;
}

#airport-list::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.55);
}

#airport-list::-webkit-scrollbar-thumb:active {
  background: rgba(148, 163, 184, 0.7);
}

/* Airport row card (JS creates airport-title/airport-name/airport-meta) */
.airport-item {
  padding: 0.45rem 0.5rem;
  border-radius: 0.55rem;
  cursor: pointer;
  font-size: 0.85rem;

  display: flex;
  justify-content: space-between;
  align-items: center;

  color: #e5e7eb;

  border: 1px solid rgba(148, 163, 184, 0.08);
  background: rgba(2, 6, 23, 0.4);

  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.airport-item:hover {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 6px 14px rgba(0, 0, 0, 0.35);
}

.airport-item.is-selected {
  background: rgba(96, 165, 250, 0.14);
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 18px rgba(0, 0, 0, 0.35);
}

.airport-item.is-selected .airport-title {
  color: #f8fafc;
}

.airport-item.is-selected .airport-name {
  color: rgba(226, 232, 240, 0.9);
}

.airport-title {
  font-weight: 600;
}

.airport-name {
  font-size: 0.85rem;
  color: #94a3b8;
}

.airport-meta {
  opacity: 0.9;
  font-size: 0.7rem;
  color: #cbd5f5;
}

/* =======================================================================
   Globe Area
   ======================================================================= */

.globe-column {
  flex: 1 1 auto;
  display: flex;
  background: #020617;
  min-width: 0;
}

.globe-inner {
  flex: 1;
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  padding-left: 8px;
  padding-right: 8px;
  min-width: 0;
}

.globe-wrapper {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;

  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow: hidden;
  position: relative;

  display: flex;
  align-items: center;
  justify-content: center;
}

#globe {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

#globe canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Buy Me a Coffee widget placement */
#bmc-widget-container {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 6;
}

#bmc-widget-container #bmc-wbtn,
#bmc-widget-container .bmc-btn-container {
  position: static !important;
}

/* =======================================================================
   Airport Details Overlay
   ======================================================================= */

.airport-details-card {
  position: absolute;
  left: 12px;
  right: auto;
  bottom: 12px;
  max-width: 360px;

  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: #e5e7eb;
  backdrop-filter: blur(10px);
  z-index: 5;
  font-size: 0.85rem;
}

.airport-details-card .text-secondary {
  color: #9ca3af !important;
}

.airport-details-card .badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.airport-details-card a.disabled {
  pointer-events: none;
  opacity: 0.5;
  text-decoration: none;
}

/* =======================================================================
   Responsive
   ======================================================================= */

@media (max-width: 767.98px) {
  .main-layout {
    flex-direction: column;
    height: auto;
  }

  #sidebar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-bottom: 0.5rem;
  }

  .globe-wrapper {
    min-height: 280px;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .globe-wrapper {
    min-height: 320px;
  }
}
