/* assets/css/style_index.css - Refactored */
:root {
  /* Color System */
  --bg-gradient-start: #7366ea;
  --bg-gradient-end: #764ba2;
  --card-bg: #ffffff;
  --card-shadow: rgba(0, 0, 0, 0.1);
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --header-bg: #f8fafc;
  --hover-bg: #f8fafc;
  --input-bg: #ffffff;
  --input-border: #e2e8f0;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --accent-primary: #667eea;
  --accent-secondary: #764ba2;
}

[data-theme="dark"] {
  --bg-gradient-start: #1e293b;
  --bg-gradient-end: #0f172a;
  --card-bg: #1e293b;
  --card-shadow: rgba(0, 0, 0, 0.3);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #3b3355;
  --header-bg: #06326e;
  --hover-bg: #334155;
  --input-bg: #0f172a;
  --input-border: #334155;
  --code-bg: #1e4ab3;
  --code-text: #e2e8f0;
  --accent-primary: #818cf8;
  --accent-secondary: #a78bfa;
}

/* ============================================= */
/* BASE STYLES & RESET */
/* ============================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  min-height: 100vh;
  padding: 50px;
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

/* ============================================= */
/* LAYOUT COMPONENTS */
/* ============================================= */
.container {
  max-width: 100%;
  margin: 20 auto;
}

/* Theme Controls */
.theme-controls {
  position: fixed;
  top: 15px;
  right: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1000;
}

.theme-toggle-btn,
.config-btn {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: none;
  color: white;
  font-size: 18px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  box-shadow: 0 3px 6px var(--card-shadow);
  transition: transform 0.2s ease, opacity 0.3s ease;
}

.theme-toggle-btn:hover,
.config-btn:hover {
  transform: scale(1.1);
}

/* Config Panel */
.config-panel {
  position: absolute;
  top: 50px;
  right: 0;
  background: var(--card-bg);
  color: var(--text-primary);
  border-radius: 12px;
  box-shadow: 0 4px 12px var(--card-shadow);
  padding: 15px 20px;
  display: none;
  flex-direction: column;
  gap: 10px;
  min-width: 180px;
  animation: fadeIn 0.2s ease forwards;
}

.config-panel.active {
  display: flex;
}

.config-panel label {
  font-size: 13px;
  color: var(--text-secondary);
}

.config-panel input[type="color"] {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* ============================================= */
/* TYPOGRAPHY & HEADINGS */
/* ============================================= */
h1 {
  color: white;
  text-align: center;
  margin-bottom: 30px;
  font-size: 2.5em;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* ============================================= */
/* CARD COMPONENTS */
/* ============================================= */
.config-section,
.stats_all,
.endpoint,
.results {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 6px var(--card-shadow);
  transition: background 0.3s ease;
  margin-bottom: 20px;
}

.endpoint:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px var(--card-shadow);
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.stat-card {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: white;
  padding: 10px;
  border-radius: 10px;
  text-align: center;
}

.stat-card.color {
  background: linear-gradient(135deg, #a70574 0%, #a70574 100%);
}

.stat-card h3 {
  font-size: 1.5em;
  margin-bottom: 5px;
}

.stat-card p {
  font-size: 0.9em;
  opacity: 0.9;
}

/* Endpoint Grid */
.endpoints {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 15px;
  margin-bottom: 0x;
}

.endpoint h3 {
  color: var(--accent-primary);
  margin-bottom: 8px;
  font-size: 1.1em;
}

.endpoint p {
  color: var(--text-secondary);
  font-size: 0.9em;
  margin-bottom: 10px;
}

.endpoint button {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
  transition: opacity 0.2s;
}

.endpoint button:hover {
  opacity: 0.9;
}

/* ============================================= */
/* FORM ELEMENTS */
/* ============================================= */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin: 15px 0;
  padding: 10px;
  background: var(--hover-bg);
  border-radius: 5px;
  transition: background 0.3s ease;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-primary);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.refresh-status {
  color: var(--text-secondary);
  font-size: 14px;
}

.refresh-status.active {
  color: var(--accent-primary);
  font-weight: 600;
}

.input-group {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.input-group label {
  min-width: 100px;
  font-weight: 500;
  color: var(--text-primary);
}

.input-group input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--input-border);
  border-radius: 5px;
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

/* ============================================= */
/* TABLE STYLES */
/* ============================================= */
.table-container {
  overflow-x: auto;
  margin-top: 20px;
  max-height: 800px;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent; /* Hidden by default */
  transition: scrollbar-color 0.3s ease;
}

.table-container::-webkit-scrollbar {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

th, td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  transition: border-color 0.3s ease;
}

th {
  background: var(--header-bg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 1.1em;
}

tr:hover {
  background: var(--hover-bg);
}

/* Fixed column widths for flights table */
table th:nth-child(1), table td:nth-child(1) { width: auto; }
table th:nth-child(2), table td:nth-child(2) { width: auto; }
table th:nth-child(3), table td:nth-child(3) { width: auto; }
table th:nth-child(4), table td:nth-child(4) { width: auto; }
table th:nth-child(5), table td:nth-child(5) { width: auto; }
table th:nth-child(6), table td:nth-child(6) { width: auto; }
table th:nth-child(7), table td:nth-child(7) { width: auto; }
table th:nth-child(8), table td:nth-child(8) { width: auto; }
table th:nth-child(9), table td:nth-child(9) { width: auto; }


/* Sticky headers */
#flightsTable thead th,
#airlineTable thead th,
#routeTable thead th,
#milTable thead th,
#civTable thead th,
#govTable thead th,
#polTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--header-bg) !important;
  background-clip: padding-box;
  opacity: 1;
  /* Add a pseudo-element to create a solid backing */
  isolation: isolate;
}

/* Create solid background layer for sticky headers */
#flightsTable thead th::before,
#airlineTable thead th::before,
#routeTable thead th::before,
#milTable thead th::before,
#civTable thead th::before,
#govTable thead th::before,
#polTable thead th::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--header-bg);
  z-index: -1;
}

/* Table shadows */
#milTable thead,
#civTable thead,
#govTable thead,
#polTable thead {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* mode-s flights */
.mode-s-flight {
    font-style: italic !important;
    color: var(--text-secondary) !important;
    background-color: rgba(255, 193, 7, 0.05) !important;
}

.mode-s-flight:hover {
    background-color: rgba(255, 193, 7, 0.1) !important;
}

.mode-s-separator {
    background-color: rgba(255, 193, 7, 0.1) !important;
    border-top: 2px solid #ffc107 !important;
    border-bottom: 2px solid #ffc107 !important;
}

/* ============================================= */
/* SCROLL BAR VISIBILITY */
/* ============================================= */
/* Show scrollbars on hover */
.table-container:hover,
.table-container:focus-within {
  scrollbar-color: var(--accent-primary) var(--border-color);
}

/* Webkit browsers (Chrome, Safari, Edge) */
.table-container::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-container::-webkit-scrollbar-thumb {
  background: transparent; /* Hidden by default */
  border-radius: 4px;
  transition: background 0.3s ease;
}

/* Show scrollbar thumb on hover */
.table-container:hover::-webkit-scrollbar-thumb,
.table-container:focus-within::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
}

.table-container::-webkit-scrollbar-track {
  background: transparent; /* Hidden by default */
  transition: background 0.3s ease;
}

/* Show scrollbar track on hover */
.table-container:hover::-webkit-scrollbar-track,
.table-container:focus-within::-webkit-scrollbar-track {
  background: var(--border-color);
}
/* ============================================= */
/* SPECIAL COMPONENTS */
/* ============================================= */
/* ============================================= */
/* FLIGHTS MAP CONTAINER - UPDATED */
/* ============================================= */
.flights-map-container {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0px;
}

.flights-section {
  flex: 3; /* Increased from 1.5 to give table more space */
  min-width: 0;
}

.map-section {
  flex: 0.5; /* Reduced map width */
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  margin-top: 48px; /* This aligns with table header */
}

.map-section iframe {
  width: 100%;
  height: 100%;
  min-height: 800px;
  border: none;
  border-radius: 8px;
}

/* Map maximize/minimize styles */
.map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  gap: 5px;
}

.map-control-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  color: #333;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

.map-control-btn:hover {
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.map-section.maximized {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999;
  background: white;
  margin: 0 !important;
  padding: 0 !important;
}

.map-section.maximized iframe {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
}

/* When map is maximized, hide other content */
.map-section.maximized ~ .flights-section {
  display: none;
} 

/* ============================================= */
/* AIRCRAFT POPUP STYLES */
/* ============================================= */


.highlight-orange {
    background: linear-gradient(135deg, #ff8c00 , #ff8c00 ) !important;
}

.aircraft-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  backdrop-filter: blur(5px);
}

.aircraft-popup {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  animation: popupSlideIn 0.3s ease-out;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--accent-primary);
  color: white; /* This makes ALL text in header white */
  position: sticky;
  top: 0;
  z-index: 10;
}

.popup-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: white !important; /* Force white text */
}

/* FIXED CLOSE BUTTON - Make it visible on blue background */
.popup-close {
  position: relative !important;
  background: rgba(255, 255, 255, 0.2) !important; /* Semi-transparent white */
  border: none !important;
  font-size: 28px !important;
  color: white !important; /* MUST be white for contrast */
  cursor: pointer !important;
  width: 40px !important;
  height: 40px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  transition: all 0.2s ease !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1 !important;
  z-index: 10001 !important;
  top: auto !important;
  right: auto !important;
  font-weight: bold !important;
}

.popup-close:hover {
  background: rgba(255, 255, 255, 0.3) !important;
  color: white !important;
  transform: scale(1.1) !important;
}

.popup-close:active {
  transform: scale(0.95) !important;
}

/* Ensure the close button has pointer cursor */
.popup-close {
  cursor: pointer !important;
}

.popup-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.popup-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  max-height: calc(85vh - 60px);
}

.popup-details {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  min-width: 300px;
}

.popup-map {
  flex: 1;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.flight-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.detail-value {
  font-weight: 500;
  color: var(--text-primary);
}

.map-container {
  flex: 1;
  min-height: 300px;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

#aircraftMap {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 350px;
  border-radius: 0 0 8px 0;
}

.map-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--input-bg);
  color: var(--text-secondary);
  min-height: 250px;
}

/* Popup Header Bubbles */
.popup-header-bubbles {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.popup-bubble {
  background: linear-gradient(135deg, #a70574 0%, #a70574 100%);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.popup-bubble .bubble-label {
  font-weight: 600;
  opacity: 0.9;
}

.popup-bubble .bubble-value {
  font-weight: 400;
}

/* Aircraft Photo Section */
.aircraft-photo-section {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

.photo-container {
  position: relative;
  display: inline-block;
  width: 100%;
}

.aircraft-photo {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  box-shadow: 0 4px 8px var(--card-shadow);
  display: none;
}

.photo-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-style: italic;
}

.photo-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

.photo-credits-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
  padding: 8px 12px;
  font-size: 0.8em;
  text-align: center;
}

.photo-credits-overlay a {
  color: white;
  text-decoration: none;
}

.no-photo-message {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
  font-style: italic;
  background: var(--hover-bg);
  border-radius: 8px;
}

.photo-error {
  text-align: center;
  padding: 20px;
  color: #e53e3e;
  background: #fed7d7;
  border-radius: 8px;
  margin-top: 10px;
}

/* ============================================= */
/* ANIMATIONS */
/* ============================================= */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popupSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================= */
/* COMBINED STATS LAYOUT OVERRIDES */
/* ============================================= */

/* Desktop: side-by-side grid */
@media (min-width: 769px) {
  .results > div[style*="grid-template-columns"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px;
  }
}

/* Mobile: force vertical stacking */
@media (max-width: 768px) {
  /* Force results container to be full width */
  .results {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: visible !important;
    box-sizing: border-box !important;
  }
  
  /* Override ALL inline grid styles */
  .results > div[style*="grid"],
  .results > div[style*="display: grid"],
  .results > div {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Ensure children don't overflow */
  .results > div > div {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    display: block !important;
  }
  
  /* Prevent table containers from overflowing */
  .results .table-container {
    width: 100% !important;
    overflow-x: auto !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  
  /* Make sure tables themselves don't force container width */
  .results table {
    min-width: 100% !important;
    width: 100% !important;
  }
}



/* ============================================= */
/* RESPONSIVE DESIGN - MOBILE FIRST APPROACH */
/* ============================================= */

/* Tablet and Desktop (768px and up) */
@media (min-width: 769px) {
  .interesting-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(400px, 1fr));
    gap: 5px;
  }
}

/* Mobile (768px and down) */
@media (max-width: 768px) {
  .container {
    max-width: 95%;
    padding: 10px;
  }

  h1 {
    font-size: 2em;
    margin-bottom: 20px;
  }

  /* Stack all grid layouts */
  .interesting-stats-grid,
  .results > div[style*="grid-template-columns"],
  .results > div:first-child {
    grid-template-columns: 1fr !important;
    gap: 15px !important;
  }

  /* Force flex column layout */
  .results > div {
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
  }

  .results > div > div {
    width: 100% !important;
  }

  /* Stack flights and map */
  .flights-map-container {
    flex-direction: column;
    gap: 15px;
  }




  .map-section iframe {
    height: 50vh;
  }

  /* Stack endpoints */
  .endpoints {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Adjust table containers */
  .table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 12px;
  }

  .table-container table {
    min-width: 100%;
    width: auto;
    table-layout: auto;
  }

  .table-container th,
  .table-container td {
    min-width: 80px;
    max-width: none;
    white-space: nowrap;
    padding: 8px 6px;
  }

  /* Specific table minimum widths */
  #flightsTable { min-width: auto; }
  #airlineTable,
  #routeTable { min-width: auto; }
  #milTable,
  #civTable,
  #govTable,
  #polTable { min-width: 500px; }

  /* Show scrollbars on mobile */
  .table-container::-webkit-scrollbar {
    height: 6px;
    display: block;
  }

  .table-container::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 3px;
  }

  .table-container::-webkit-scrollbar-track {
    background: var(--border-color);
  }

  /* Reduce padding */
  .endpoint,
  .results,
  .stats_all,
  .config-section {
    padding: 15px;
  }

  /* Stack filter controls */
  .filter-box {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px !important;
  }

  .filter-box label {
    min-width: auto;
  }

  .filter-box button {
    width: 100%;
  }

  /* Adjust theme controls */
  .theme-controls {
    top: 10px;
    right: 10px;
  }

  /* Aircraft popup adjustments */
  .aircraft-popup {
    max-height: 90vh;
    margin: 20px;
  }

  .popup-content {
    flex-direction: column;
    max-height: calc(90vh - 60px);
  }

  .popup-map {
    border-left: none;
    border-top: 1px solid var(--border-color);
    min-height: 300px;
  }

  .flight-details-grid {
    grid-template-columns: 1fr;
  }

  .popup-header-bubbles {
    gap: 8px;
  }

  .popup-bubble {
    padding: 5px 10px;
    font-size: 0.8rem;
  }
}

/* Small Mobile (430px and down) */
@media (max-width: 430px) {
  .container {
    max-width: 98%;
  }

  #flightsTable { min-width: 600px; }
  #airlineTable,
  #routeTable { min-width: 350px; }
  #milTable,
  #civTable,
  #govTable,
  #polTable { min-width: 450px; }

  .table-container th,
  .table-container td {
    padding: 6px 4px;
    font-size: 11px;
  }

  .popup-header-bubbles {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .popup-bubble {
    width: fit-content;
  }

  .aircraft-popup {
    margin: 10px;
    max-height: 95vh;
  }
}

/* Extra Small Mobile (375px and down) */
@media (max-width: 375px) {
  .container {
    max-width: 98%;
    padding: 5px;
  }

  .endpoint,
  .results,
  .stats_all,
  .config-section {
    padding: 12px;
  }

  h1 {
    font-size: 1.8em;
  }

  #flightsTable { min-width: 550px; }
  #airlineTable,
  #routeTable { min-width: 320px; }
  #milTable,
  #civTable,
  #govTable,
  #polTable { min-width: 400px; }

  .results > div {
    display: block !important;
  }

  .results > div > div {
    margin-bottom: 15px;
  }

  .results > div > div:last-child {
    margin-bottom: 0;
  }
}

/* Tablet Specific (431px to 768px) */
@media (min-width: 431px) and (max-width: 768px) {
  .interesting-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  .endpoints {
    grid-template-columns: repeat(2, 1fr);
  }

  .flights-map-container {
    gap: 15px;
  }
}

/* combined stats */
.combined-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.stats-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px var(--card-shadow);
}


/* Responsive design for mobile */
@media (max-width: 768px) {
  .flights-map-container {
    grid-template-columns: 1fr;
  }
  
}



/* Map maximize/minimize styles */
.map-section {
  flex: 1;
  min-width: 0;
  position: relative;  /* ✅ This allows absolute positioned controls to show */
  display: flex;
  flex-direction: column;
}

.map-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  gap: 5px;
}

.map-control-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  color: #333;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}
.map-control-btn:hover {
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.map-section.maximized {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999;
  background: white;
  margin: 0 !important;
  padding: 0 !important;
}

.map-section.maximized iframe {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
}

/* When map is maximized, hide other content */
.map-section.maximized ~ .flights-section {
  display: none;
}

/* Ensure the flights-map-container adjusts when map is minimized */
.flights-map-container {
  display: grid;
  grid-template-columns: 2fr 1.5fr;
  gap: 20px;
  transition: all 0.3s ease;
}

.map-section.minimized {
  grid-column: span 1;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
  .flights-map-container {
    grid-template-columns: 1fr;
  }
  
.map-controls {
  position: absolute;  /* Positioned relative to .map-section */
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  gap: 5px;
}
  
  .map-control-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
}


/* ============================================= */
/* ENHANCED DIGIT FLIP ANIMATIONS */
/* ============================================= */

/* Realistic flip animation with depth */
@keyframes realistic-digit-flip {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(-90deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

/* Container for stable number layout */
.stat-number {
  display: inline-flex;
  perspective: 300px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  /* REMOVED gap: 1px; */
}

/* Individual digit styling */
.stat-digit {
  display: inline-block;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  min-width: 0.6em; /* Ensure consistent digit width */
  text-align: center;
}

/* Flip animation */
.stat-digit.flipping {
  animation: realistic-digit-flip 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure stat cards maintain consistent height during animations */
.stat-card h3 {
  min-height: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
}