/* ---------------- HEADER ---------------- */

.top-bar {
  position: fixed; /* pin entire bar */
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000; /* keep above charts */
  background-color: #222; /* unify background */
  color: #fff;
}

/* Stack header, KPI card, and controls vertically */
.top-bar > * {
  display: block;
  width: 100%;
}

/* Push dashboard content down so it clears the fixed bar */
.dashboard-content {
  position: relative;
  top: 200px;
  overflow-y: auto;
}

.Header {
  position: relative;
  width: 100%;
  height: 100px;
  overflow: hidden;
}

.HeaderImg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.HeaderContent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: white;
  z-index: 2;
}

.HeaderLogo {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 300px;
  height: auto;
  z-index: 3;
}

.HeaderText {
  color: white;
  font-family: "Corbel Light", "Corbel", Arial, sans-serif;
  font-size: 50px;
  font-weight: normal;
  margin: 0 0 10px 0;
  text-align: center;
  text-shadow: 6px 6px 6px rgba(0, 0, 0, 0.6);
}

/* ---------------- BODY ---------------- */

body {
  font-family: Arial, sans-serif;
  margin: 20px;
  background: black;
  background-image: url("../images/DashBG1.jpg"); /* path to your image */
  background-repeat: no-repeat; /* don’t tile the image */
  background-size: cover; /* scale to cover the whole page */
  background-position: center center; /* center the image */
  background-attachment: fixed;
}

.controls {
  display: flex;
  gap: 1rem;
  align-items: flex-start; /* align top */
  height: 130px;
}

.dashboard-header,
.kpi-container,
.controls {
  position: sticky; /* stick to top while scrolling */
  top: 0; /* position relative to viewport */
  z-index: 1000; /* keep above charts */
  background-color: #222; /* dark background to match theme */
  color: #fff;
}

/* Adjust stacking order so they appear in sequence */
.dashboard-header {
  top: 0;
}
.kpi-container {
  top: 3rem;
} /* adjust based on header height */
.controls {
  top: 6rem;
} /* adjust based on header+KPI height */

/* Main content scrolls behind */
.dashboard-content {
  margin-top: 9rem; /* leave space so charts don’t overlap pinned bar */
  overflow-y: auto;
}

.filter-group {
  display: flex;
  flex-direction: column; /* stack label, dropdown, button vertically */
  margin-bottom: 1rem; /* spacing between groups */
}

.filter-group select {
  background-color: #2a2a2a; /* dark grey background */
  color: #fff; /* white text */
  border: 1px solid #555; /* subtle border */
  padding: 0.4rem; /* comfortable spacing */
  border-radius: 4px; /* rounded corners */
}

/* Date Selectors*/
.filter-group input[type="date"] {
  background-color: #2a2a2a; /* dark grey background */
  color: #fff; /* white text */
  border: 1px solid #555; /* subtle border */
  padding: 0.4rem;
  border-radius: 4px;
  box-sizing: border-box;
}

/* Force the calendar dropdown itself to inherit colors (varies by browser) */
.filter-group input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1); /* makes the calendar icon white on dark background */
}

/* ---------------- KPI CARDS ---------------- */
.kpi-title {
  color: white;
  font-family: "Corbel Light", "Corbel", Arial, sans-serif;
  font-size: 25px;
  font-weight: normal;
  margin: 0;
  text-align: center;
  text-shadow: 6px 6px 6px rgba(0, 0, 0, 0.6);
  margin-bottom: 5px;
}

.kpi-labels {
  color: "White";
  font-family: "Corbel Light", "Corbel", Arial, sans-serif;
  font-size: 30px;
  font-weight: normal;
  margin: 0 0 5px 0;
  text-align: center;
  text-shadow: 6px 6px 6px rgba(0, 0, 0, 0.6);
}

.kpi-container {
  position: sticky;
  display: flex;
  gap: 20px;
  margin-bottom: 10px; /* reduced to avoid collision */
}

.kpi-card {
  background-color: #2a2a2a;
  color: white;
  padding: 6px 10px; /* reduce vertical padding */
  border-radius: 6px;
  margin: 10px;
  min-height: 60px; /* smaller height */
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* 🔽 aligns content at the top */
}

.kpi-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3); /* underline effect */
  text-align: center;
}

.kpi-card .params {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  gap: 4px;
}

.kpi-card .params p {
  margin: 0;
  font-size: 16px;
}

/* ---------------- BAR CHARTS + GAUGES ---------------- */

#top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#middle-row {
  display: grid;
  grid-template-columns: 1fr 4fr 1fr; /* empty, chart, empty */
  gap: 10px;
  margin-top: 20px;
}

#bottom-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}

#middle-row .chart-block:first-child {
  background: none; /* no background */
  border: none; /* no border */
  box-shadow: none; /* no shadow */
}
#middle-row .chart-block:third-child {
  background: none; /* no background */
  border: none; /* no border */
  box-shadow: none; /* no shadow */
}

#middle-row.dashboard-container {
  padding: 10px;
  border: 1px solid #444;
  border-radius: 8px;
}

#bottom-row > div {
  flex: 1 1 300px;
  min-height: 300px;
  width: 100%;
}
/* Dark container */
/* Outer wrapper for all charts */

#dashboard-wrapper {
  background-color: transparent; /* dark grey background */
  border: 2px solid #3a3a3a;
  border-radius: 5%; /* rounded corners */
  padding: 20px; /* inner spacing */
  margin: 20px; /* space around container */
  box-sizing: border-box;
}

/* Inner dashboard flex container */
.dashboard-container {
  display: flex;
  flex-direction: row;
  gap: 20px;
  justify-content: space-evenly;
  align-items: stretch;
}

/* Individual chart panels */
/* Let charts flex naturally */

#mainChart,
#choroplethMap,
#choroplethMapPercent {
  flex: 1; /* allow proportional growth */
  min-width: 200px; /* prevent collapsing too small */
  min-height: 200px;
  width: 100%; /* fill parent */
  height: auto; /* let height adapt */
}

/* Proportional sizing */
/* Proportional sizing by viewport width */
#mainGauge {
  width: 80px;
  height: 80px;
}
#mainChart {
  width: 100% !important;
  height: 100% !important;
}

#choroplethMap {
  width: 15vw;
  height: 50vh;
}
#choroplethMapPercent {
  width: 15vw;
  height: 50vh;
}

/* Inner dashboard flex container */
.dashboard-container {
  display: flex;
  flex-wrap: wrap; /* allow wrapping if needed */
  gap: 10px; /* spacing between blocks */
}

.charts-bars {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  width: 100%;
  align-items: stretch;
  margin-bottom: 40px;
}

/* FIX: chart-block must NOT use height:100% */
.chart-block {
  height: 400px;
  border: 2px solid black;
  border-radius: 15px;
  background-color: rgba(0, 0, 0, 0.6);
  box-shadow: 0 4px 8px rgb(0, 0, 0, 0.9);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

#top-row .chart-block {
  flex: 1 1 300px;
  height: 400px; /* 👈 same height for all blocks */
  border: 2px solid black;
  box-sizing: border-box;
  overflow: hidden; /* prevent overflow */
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

/* Ensure all charts inside blocks share the same height */
.chart {
  width: 100%;
  flex: 1; /* fill available space */
  min-height: 400px; /* 👈 consistent height baseline */
  margin-top: 20px;
  background-color: black; /* keeps theme consistent */
  border: 2px solid black; /* 👈 border around chart itself */
  border-radius: 6px;
}

.chart-title {
  margin: 0;
  padding: 6px;
  font-family: Corbel, sans-serif;
  font-size: 16px;
  color: white;
  text-align: center;
  background-color: rgb (0, 0, 0, 0.6);
  border-bottom: 1px solid black;
}

.chart-block.invisible {
  background: none;
  border: none;
  box-shadow: none;
}

.chart-block > div {
  flex: 1;
  width: 100%;
  height: 100%;
}

/* FIX: gauges must have enough room */
.gauge {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 500px; /* increased to avoid cropping */
  padding: 20px;
  box-sizing: border-box;
  overflow: hidden;
}

.gauge-wrapper {
  height: 220px; /* controls total gauge space */
  overflow: hidden; /* prevents spillover */
  display: flex;
  justify-content: center;
  align-items: center;
}

#mainGauge {
  width: 100% !important; /* 👈 force full width */
  height: 100% !important; /* 👈 match block height */
}

#choroplethDiv {
  width: 100%;
  height: 500px; /* or whatever fits your dashboard */
}

#choroplethMap,
#choroplethMapPercent {
  width: 100%; /* fill the chart block horizontally */
  height: 400px; /* or match your other chart blocks */
}

.chart-title {
  color: white;
  font-family: "Corbel Light", "Corbel", Arial, sans-serif;
  font-weight: normal;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  margin-top: 10px;
  margin-bottom: -5px; /* pulls title closer to the gauge/chart */
}
.spinner {
  border: 6px solid #f3f3f3; /* Light grey */
  border-top: 6px solid #3498db; /* Blue */
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ---------------- MOBILE ---------------- */

@media (max-width: 600px) {
  .chart-block {
    flex: 1 1 100%;
  }

  .charts-donuts {
    flex-wrap: wrap;
  }

  .donut-column {
    flex: 1 1 100%;
  }

  .gauge {
    height: 160px;
  }
}
