/* Regional Indicators Viewer - Complete Fix */

/* Main container */
.indicators-container {
  width: 100%;
  max-width: 100%;
  height: 800px; /* Fixed total height */
  max-height: 800px !important; /* Force maximum height */
  position: relative;
  overflow: hidden !important; /* Prevent any overflow */
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Reset all existing layout constraints that might interfere */
.indicators-container * {
  box-sizing: border-box;
}

/* Force table to fixed dimensions */
.indicators-container table {
  width: 100% !important;
  height: 100% !important;
  max-height: 800px !important;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
  padding: 0;
  overflow: hidden !important;
}

/* Set fixed heights for each row */
.indicators-container tr:first-child {
  height: 380px !important; /* Fixed height for first row */
  max-height: 380px !important;
  overflow: hidden !important;
}

.indicators-container tr:last-child {
  height: 380px !important; /* Fixed height for second row */
  max-height: 380px !important;
  overflow: hidden !important;
}

/* Cells */
.indicators-container td {
  vertical-align: top;
  overflow: hidden !important;
  padding-bottom: 20px;
}

/* Column widths */
.indicators-container td:first-child {
  width: 60%;
  padding-right: 10px;
}

.indicators-container td:last-child {
  width: 40%;
}

/* Chart boxes - fixed height */
.indicator-box {
  width: 100%;
  height: 360px !important; /* Fixed height - no growth */
  max-height: 360px !important;
  min-height: 0 !important;
  background-color: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  overflow: hidden !important; /* Critically important */
}

/* Chart titles */
.chart-title {
  color: #58a6ff;
  margin: 0 0 5px 0;
  padding: 0;
  font-size: 14px;
  text-align: center;
  flex-shrink: 0;
  height: 20px; /* Fixed height */
  overflow: hidden;
}

.chart-subtitle {
  color: #8b949e;
  font-size: 12px;
  text-align: center;
  margin: 0 0 5px 0;
  flex-shrink: 0;
  height: 15px; /* Fixed height */
  overflow: hidden;
}

/* Plot containers - fixed height */
.plot-container {
  width: 100% !important;
  height: 310px !important; /* Fixed height based on container minus headers */
  max-height: 310px !important;
  min-height: 0 !important;
  flex: 0 0 auto !important; /* Prevent flex growth */
  position: relative;
  overflow: hidden !important;
}

/* Special container for stacked charts */
.stacked-charts {
  display: block !important; /* Use simple block instead of flex */
  padding: 0;
  height: 310px !important;
  max-height: 310px !important;
  overflow: hidden !important;
}

/* Individual chart elements */
#health-chart, #economic-chart {
  width: 100% !important;
  height: 145px !important; /* Exactly half of parent */
  max-height: 145px !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  position: relative !important;
  display: block !important;
  overflow: hidden !important;
}

/* Force Plotly elements to respect fixed bounds */
.js-plotly-plot,
.js-plotly-plot .plotly,
.js-plotly-plot .plotly .svg-container,
.js-plotly-plot .main-svg {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* Sunburst specific styling */
#sunburst {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 90% !important;
  height: 90% !important;
  max-width: 90% !important;
  max-height: 90% !important;
  margin: auto !important;
  overflow: hidden !important;
}

/* Reset any conflicting rules */
#bubble, #heatmap {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
}

/* Mobile layout - simplified to fixed heights */
@media (max-width: 768px) {
  .indicators-container {
    height: auto;
    max-height: none;
  }
  
  .indicators-container table,
  .indicators-container tr,
  .indicators-container td {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    padding-right: 0 !important;
  }
  
  .indicator-box {
    height: 300px !important;
    max-height: 300px !important;
    margin-bottom: 15px !important;
  }
  
  .plot-container {
    height: 250px !important;
    max-height: 250px !important;
  }
  
  #health-chart, #economic-chart {
    height: 115px !important;
    max-height: 115px !important;
  }
}
