/* MS Ozone Forecast Web Dashboard */
:root {
  --primary: #3c8dbc;
  --success: #00a65a;
  --warning: #f39c12;
  --danger: #dd4b39;
  --info: #00c0ef;
  --sidebar-bg: #222d32;
  --sidebar-text: #b8c7ce;
  --body-bg: #f4f6f9;
  --card-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--body-bg);
  color: #333;
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  background: var(--primary);
  color: #fff;
  padding: 16px 20px;
  font-size: 1.2em;
  font-weight: bold;
  text-align: center;
}

.sidebar-nav {
  list-style: none;
  padding: 10px 0;
}

.sidebar-nav li {
  padding: 12px 20px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav li:hover,
.sidebar-nav li.active {
  background: rgba(255,255,255,0.08);
  border-left-color: var(--primary);
  color: #fff;
}

.sidebar-controls {
  padding: 15px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-controls label {
  display: block;
  font-size: 0.85em;
  margin-bottom: 4px;
  color: #b8c7ce;
}

.sidebar-controls select {
  width: 100%;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #4a6274;
  background: #2c3b41;
  color: #fff;
  margin-bottom: 12px;
  font-size: 0.95em;
}

.sidebar-map {
  margin: 10px 0;
  border-radius: 6px;
  overflow: hidden;
  height: 180px;
}

.sidebar-status {
  margin-top: 8px;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: bold;
}

.status-badge.success { background: var(--success); color: #fff; }
.status-badge.warning { background: var(--warning); color: #fff; }
.status-badge.danger { background: var(--danger); color: #fff; }

/* --- Main Content --- */
.main-content {
  margin-left: 280px;
  flex: 1;
  padding: 20px 25px;
  min-height: 100vh;
  /* Flex items default to min-width:auto, which lets wide content (Plotly)
     push this past the viewport. See the min-width:0 note below. */
  min-width: 0;
}

/* Grid and flex children default to min-width:auto, meaning they refuse to
   shrink below their content's intrinsic width. A Plotly chart reports a wide
   intrinsic width, so without this the chart widens its grid column, which
   widens the row, which gives the chart even more room on the next resize --
   the page ends up scrolling sideways and charts never settle at the right
   size. min-width:0 lets the column win and the chart fit into it instead. */
.row > *,
.value-boxes > *,
.info-boxes > * {
  min-width: 0;
}

/* Plotly injects inline widths; never let one exceed its container. */
.card-body .js-plotly-plot,
.sub-panel .js-plotly-plot {
  max-width: 100%;
}

/* --- Tab Panels --- */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- Value Boxes --- */
.value-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.value-box {
  border-radius: 8px;
  padding: 20px;
  color: #fff;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.value-box .vb-icon { font-size: 2.5em; opacity: 0.7; }

.value-box .vb-content h2 {
  font-size: 1.6em;
  margin-bottom: 2px;
}

.value-box .vb-content p {
  font-size: 0.9em;
  opacity: 0.9;
}

.vb-green { background: #00a65a; }
.vb-yellow { background: #f0ad4e; color: #333; }
.vb-orange { background: #ff851b; }
.vb-red { background: #dd4b39; }
.vb-purple { background: #605ca8; }
.vb-blue { background: var(--primary); }
.vb-maroon { background: #800000; }
.vb-offseason { background: #4a5459; }   /* seasonal monitor shut down */
.vb-navy { background: #001f3f; }
.vb-light-blue { background: var(--info); }

/* --- Cards --- */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 12px 18px;
  font-weight: bold;
  font-size: 1em;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header.info { background: var(--info); color: #fff; }
.card-header.primary { background: var(--primary); color: #fff; }
.card-header.warning { background: var(--warning); color: #fff; }
.card-header.danger { background: var(--danger); color: #fff; }
.card-header.success { background: var(--success); color: #fff; }

.card-body { padding: 18px; }

/* --- Grid Layouts --- */
.row {
  display: grid;
  gap: 20px;
  margin-bottom: 20px;
}

.row.two-col { grid-template-columns: 1fr 1fr; }
.row.three-col { grid-template-columns: 1fr 1fr 1fr; }
.row.sidebar-layout { grid-template-columns: 2fr 1fr; }
.row.full { grid-template-columns: 1fr; }

/* --- Info Boxes (Data Management tab) --- */
.info-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.info-box {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-left: 4px solid var(--primary);
}

.info-box .ib-icon {
  font-size: 1.8em;
  opacity: 0.7;
}

.info-box .ib-content h4 {
  font-size: 0.8em;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-box .ib-content p {
  font-size: 1.2em;
  font-weight: bold;
  color: #333;
}

.info-box.light-blue { border-left-color: var(--info); }
.info-box.purple { border-left-color: #605ca8; }
.info-box.green { border-left-color: var(--success); }
.info-box.red { border-left-color: var(--danger); }
.info-box.yellow { border-left-color: var(--warning); }
.info-box.navy { border-left-color: #001f3f; }
.info-box.orange { border-left-color: #ff851b; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }

table.display {
  width: 100% !important;
  font-size: 0.9em;
}

/* Fix DataTables header alignment */
table.dataTable thead th {
  white-space: nowrap;
  font-size: 0.85em;
}

/* AQI color coding for table cells */
.aqi-good { background-color: #dff0d8 !important; }
.aqi-moderate { background-color: #fcf8e3 !important; }
.aqi-usg { background-color: #f2dede !important; }
.aqi-unhealthy { background-color: #ebcccc !important; }
.aqi-very-unhealthy { background-color: #f5e79e !important; }
.aqi-hazardous { background-color: #e0b0ff !important; }

/* --- Tab Sub-navigation --- */
.sub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #ddd;
  margin-bottom: 16px;
}

.sub-tab {
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  color: #666;
  font-weight: 500;
  transition: all 0.2s;
}

.sub-tab:hover { color: var(--primary); }
.sub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.sub-panel { display: none; }
.sub-panel.active { display: block; }

/* --- About Tab --- */
.about-table {
  width: 100%;
  border-collapse: collapse;
}

.about-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
}

.about-table td:first-child {
  font-weight: bold;
  color: #555;
  width: 40%;
}

/* --- Metrics tables --- */
.metrics-section h4 {
  margin: 16px 0 8px;
  color: #555;
}

.metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
  margin-bottom: 12px;
}

.metrics-table th,
.metrics-table td {
  padding: 6px 10px;
  border: 1px solid #ddd;
  text-align: right;
}

.metrics-table th {
  background: #f5f5f5;
  text-align: center;
  font-weight: 600;
}

.metrics-table td:first-child {
  text-align: left;
  font-weight: 500;
}

.metrics-table tr:nth-child(even) { background: #fafafa; }

/* --- Loading spinner --- */
.loading {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 1.1em;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .row.two-col,
  .row.sidebar-layout { grid-template-columns: 1fr; }
  .row.three-col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    position: relative;
    width: 100%;
    min-width: unset;
  }
  .main-content {
    margin-left: 0;
  }
  body { flex-direction: column; }
  .row.three-col { grid-template-columns: 1fr; }
  .value-boxes { grid-template-columns: 1fr; }
  .info-boxes { grid-template-columns: 1fr; }
}
