/* ═══════════════════════════════════════════════════════════════
   APEXCHARTS - CLEAN & READABLE STYLES
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────
   TOOLTIP STYLING (Large & Readable)
   ───────────────────────────────────────────────────────────────── */

.apexcharts-tooltip {
  background: #ffffff !important;
  border: none !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(45, 90, 90, 0.18) !important;
  padding: 0 !important;
  overflow: visible !important;
  font-size: 15px !important;
}

.apexcharts-tooltip-title {
  background: #449997 !important;
  border-bottom: none !important;
  padding: 12px 18px !important;
  font-weight: 600 !important;
  font-size: 15px !important;
  color: #fff !important;
  border-radius: 12px 12px 0 0 !important;
}

.apexcharts-tooltip-series-group {
  padding: 14px 18px !important;
  background: #fff !important;
}

.apexcharts-tooltip-text {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  font-size: 15px !important;
  line-height: 1.5 !important;
}

.apexcharts-tooltip-text-y-label {
  color: #5A7A7A !important;
  font-weight: 500 !important;
  font-size: 14px !important;
}

.apexcharts-tooltip-text-y-value {
  color: #2D5A5A !important;
  font-weight: 700 !important;
  font-size: 16px !important;
}

.apexcharts-tooltip-marker {
  width: 12px !important;
  height: 12px !important;
  border-radius: 4px !important;
  margin-right: 10px !important;
}

/* ─────────────────────────────────────────────────────────────────
   TREEMAP - CLEAN BOXES (No text labels)
   ───────────────────────────────────────────────────────────────── */

.apexcharts-treemap-rect {
  transition: all 0.2s ease !important;
  cursor: pointer;
}

.apexcharts-treemap-rect:hover {
  filter: brightness(1.15) !important;
}

/* ─────────────────────────────────────────────────────────────────
   CUSTOM TREEMAP LEGEND
   ───────────────────────────────────────────────────────────────── */

.treemap-legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 12px 8px;
  margin-top: 12px;
  background: #f8fafa;
  border-radius: 10px;
  scrollbar-width: thin;
  scrollbar-color: #449997 #e0e8e8;
}

.treemap-legend::-webkit-scrollbar {
  width: 8px;
}

.treemap-legend::-webkit-scrollbar-track {
  background: #e0e8e8;
  border-radius: 4px;
}

.treemap-legend::-webkit-scrollbar-thumb {
  background: #449997;
  border-radius: 4px;
}

.treemap-legend::-webkit-scrollbar-thumb:hover {
  background: #357A78;
}

.treemap-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #fff;
  font-size: 13px;
}

.treemap-legend-item:hover {
  background: #e8f4f4;
  transform: translateX(2px);
}

.treemap-legend-item.legend-active {
  background: #d0eded;
  box-shadow: 0 2px 8px rgba(68, 153, 151, 0.25);
}

.treemap-legend-item .legend-color {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.treemap-legend-item .legend-name {
  flex: 1;
  font-weight: 500;
  color: #2D5A5A;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.treemap-legend-item .legend-value {
  font-weight: 700;
  color: #449997;
  min-width: 50px;
  text-align: right;
}

.treemap-legend-item .legend-pct {
  font-weight: 600;
  color: #888;
  min-width: 45px;
  text-align: right;
  font-size: 12px;
}

/* ─────────────────────────────────────────────────────────────────
   GENERAL LEGEND STYLING
   ───────────────────────────────────────────────────────────────── */

/* For other charts (donut, etc) */
.apexcharts-pie .apexcharts-legend-series,
.apexcharts-donut .apexcharts-legend-series {
  margin: 5px 10px !important;
}

/* ─────────────────────────────────────────────────────────────────
   DATA LABELS
   ───────────────────────────────────────────────────────────────── */

.apexcharts-data-labels text,
.apexcharts-datalabel {
  font-weight: 700 !important;
}

/* Bar chart data labels */
.apexcharts-bar-series .apexcharts-datalabel {
  font-size: 14px !important;
  fill: #2D5A5A !important;
}

/* ─────────────────────────────────────────────────────────────────
   AXIS LABELS
   ───────────────────────────────────────────────────────────────── */

.apexcharts-xaxis-label,
.apexcharts-yaxis-label {
  font-weight: 500 !important;
  fill: #5A7A7A !important;
  font-size: 13px !important;
}

/* Y-axis labels for horizontal bars (names) */
.apexcharts-yaxis-label tspan {
  font-size: 14px !important;
  font-weight: 600 !important;
}

/* ─────────────────────────────────────────────────────────────────
   DONUT CENTER LABELS
   ───────────────────────────────────────────────────────────────── */

.apexcharts-datalabel-label {
  fill: #5A7A7A !important;
  font-size: 15px !important;
  font-weight: 600 !important;
}

.apexcharts-datalabel-value {
  fill: #449997 !important;
  font-size: 26px !important;
  font-weight: 700 !important;
}

/* ─────────────────────────────────────────────────────────────────
   GRID
   ───────────────────────────────────────────────────────────────── */

.apexcharts-gridlines-horizontal line,
.apexcharts-gridlines-vertical line {
  stroke: #e8f0f0 !important;
}

/* ─────────────────────────────────────────────────────────────────
   HOVER EFFECTS
   ───────────────────────────────────────────────────────────────── */

.apexcharts-bar-area {
  transition: opacity 0.15s ease !important;
}

.apexcharts-bar-area:hover {
  opacity: 0.85 !important;
}

.apexcharts-pie-area {
  transition: transform 0.2s ease !important;
}

.apexcharts-pie-area:hover {
  transform: scale(1.02) !important;
}

/* ─────────────────────────────────────────────────────────────────
   ACTIVE/INACTIVE STATES
   ───────────────────────────────────────────────────────────────── */

.apexcharts-series-collapsed {
  opacity: 0.25 !important;
}

/* ─────────────────────────────────────────────────────────────────
   DONUT CHART WITH SIDE LEGEND (Chart 5)
   ───────────────────────────────────────────────────────────────── */

#topSchoolBuildingsWrapper {
  position: relative;
  overflow: hidden;
}

.donut-overlay-legend {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(45, 90, 90, 0.12);
  border: 1px solid rgba(107, 158, 156, 0.15);
  max-height: 360px;
  max-width: 320px;
  overflow-y: auto;
  z-index: 10;
}

#topSchoolBuildings {
  display: flex;
  justify-content: flex-end;
}

#topSchoolBuildings .apexcharts-canvas {
  margin-right: 0 !important;
}

.donut-overlay-legend::-webkit-scrollbar {
  width: 4px;
}

.donut-overlay-legend::-webkit-scrollbar-track {
  background: #f0f5f5;
  border-radius: 4px;
}

.donut-overlay-legend::-webkit-scrollbar-thumb {
  background: #6B9E9C;
  border-radius: 4px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.donut-legend-item:hover,
.donut-legend-item.active {
  background: rgba(107, 158, 156, 0.12);
}

.donut-legend-marker {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.donut-legend-text {
  font-size: 13px;
  font-weight: 500;
  color: #2D5A5A;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.donut-legend-value {
  font-size: 13px;
  font-weight: 700;
  color: #6B9E9C;
  margin-left: auto;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────
   RESPONSIVE: Mobile layout for donut chart
   ───────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .donut-overlay-legend {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    max-height: none;
    max-width: none;
    width: 100%;
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
  }

  .donut-legend-item {
    flex: 0 0 auto;
    padding: 5px 10px;
  }

  .donut-legend-text {
    font-size: 12px;
    max-width: 150px;
  }

  .donut-legend-value {
    font-size: 12px;
  }

  #topSchoolBuildings .apexcharts-canvas {
    float: none;
    margin: 0 auto;
  }
}
