/* =====================================================
   BASE
===================================================== */
html, body {
  height: 100%;
}

body {
  background: #0f0f0f;
  margin: 0;
  overflow: hidden; /* scrolling handled inside panels */
}


/* =====================================================
   STICKY HEADER
===================================================== */
#statsHeader {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(
    to bottom,
    rgba(15, 15, 15, 0.95),
    rgba(15, 15, 15, 0.85)
  );
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #222;
}

.back-link {
  color: #ccc;
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover {
  color: #fff;
}


/* =====================================================
   PAGE + GRID LAYOUT
===================================================== */
#statsPage {
  max-width: 1800px;
  margin: 0 auto;
  padding: 24px;
  height: calc(100vh - 56px); /* viewport minus header */
  box-sizing: border-box;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr; /* equal-height left charts */
  gap: 20px;
  height: 100%;
}


/* =====================================================
   PANEL BASE
===================================================== */
.stats-panel {
  display: flex;
  flex-direction: column;
  min-height: 0; /* 🔑 REQUIRED for Chart.js */
}

.stats-panel h2,
.stats-panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}


/* =====================================================
   GRID PLACEMENT (EXPLICIT — FIXES SWAP ISSUE)
===================================================== */
/* LEFT TOP */
.stats-panel--top-left {
  grid-column: 1;
  grid-row: 1;
}

/* LEFT BOTTOM */
.stats-panel--bottom-left {
  grid-column: 1;
  grid-row: 2;
}

/* RIGHT (SPANS BOTH ROWS) */
.stats-panel--right {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
}


/* =====================================================
   CONTROLS
===================================================== */
.stats-select {
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
}


/* =====================================================
   CHART CONTAINERS
===================================================== */
/* Ensures axis labels never get clipped */
.chart-fill {
  flex: 1;
  position: relative;
  min-height: 0;
}

.chart-fill canvas {
  width: 100% !important;
  height: 100% !important;
}


/* =====================================================
   RIGHT-HAND SCROLLING AIRLINE CHART
===================================================== */
.airline-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;   /* permanent scrollbar */
  overflow-x: hidden;
}

/* Scrollbar styling */
.airline-scroll::-webkit-scrollbar {
  width: 8px;
}

.airline-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}

.airline-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

.airline-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}


/* Canvas must be allowed to be taller than viewport */
#flightsPerAirlineYearChart {
  display: block;
  width: 100% !important;
}


/* =====================================================
   OPTIONAL PLACEHOLDER (SAFE TO KEEP)
===================================================== */
.stats-placeholder {
  color: #777;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #333;
  border-radius: 12px;
  height: 100%;
}
