/* 17A brand-aligned dashboard overrides.
   Cobalt header band, Carolina active-state pills, Charcoal body text.
   Map colorway (RdYlBu_r) is set in figures.py — do NOT override here. */

html, body, #react-entry-point {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Source Sans 3', Arial, sans-serif;
  color: #3B3B3B;
  background-color: #FFFFFF;
}

.app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Header band — Cobalt */
.app-header {
  background-color: #1F1FD6;
  color: #FFFFFF;
  padding: 14px 24px;
  border-bottom: 4px solid #21A8E0;
  flex-shrink: 0;
}
.app-header-inner {
  max-width: 1600px;
  margin: 0 auto;
}
.app-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}
.app-subtitle {
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.85;
  margin-top: 2px;
}

/* Control bar — light grey, below header */
.control-bar {
  background-color: #F4F4F6;
  border-bottom: 1px solid #D9D9DE;
  padding: 10px 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Dimension toggle — pill row */
.dimension-toggle {
  display: flex;
  align-items: center;
}
.dimension-pills {
  display: inline-flex;
  gap: 6px;
}
.dimension-pill {
  background-color: #FFFFFF !important;
  color: #3B3B3B !important;
  border: 1px solid #D9D9DE !important;
  border-radius: 999px !important;
  padding: 6px 16px !important;
  font-size: 0.85rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.dimension-pill:hover {
  border-color: #21A8E0 !important;
  color: #1F1FD6 !important;
}
.dimension-pill-active {
  background-color: #1F1FD6 !important;
  color: #FFFFFF !important;
  border-color: #1F1FD6 !important;
}

/* Map container — fills remaining space */
.map-container {
  flex: 1 1 auto;
  position: relative;
  width: 100%;
  min-height: 0;
  display: flex;
}
/* Make the dcc.Loading wrapper (NOT the legend!) fill the container.
   Earlier `> div { height:100% }` was applying to the legend too and
   confusing its absolute positioning. */
.map-container > .dash-loading-callback,
.map-container > .dash-spinner,
.map-container > div:not(.coverage-legend):not(.map-graph-wrapper) {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
}

/* Session 14 — two stacked map wrappers (risk-map for heatmap/flag,
   source-basin-map for the imported-water overlay). Absolute positioning
   so they overlay each other; visibility toggled by display:block/none
   in the _toggle_map_visibility callback. Each wrapper takes the full
   container so Plotly inside computes correct dimensions. */
.map-graph-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
}

/* Suppress dash undo/redo bar that appears on graph click */
._dash-undo-redo {
  display: none !important;
}

/* Header row: title + methodology link */
.app-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.methodology-link {
  color: #FFFFFF;
  font-size: 0.85rem;
  text-decoration: underline;
  opacity: 0.9;
  cursor: pointer;
  white-space: nowrap;
}
.methodology-link:hover {
  opacity: 1;
  color: #FFFFFF;
}

/* Region picker — session 8 (geography expansion). Sits leftmost in the
   control bar; "what region am I looking at" frames everything else. */
.region-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.region-picker-label {
  color: #3B3B3B;
  font-weight: 500;
  white-space: nowrap;
}
.region-picker-dropdown {
  min-width: 180px;
  font-size: 0.85rem;
}

/* View picker — session 9 (converted from radio pills to dropdown).
   Sits between the region picker and the horizon picker; selects which
   composite/dimension drives the choropleth. */
.view-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-left: 12px;
}
.view-picker-label {
  color: #3B3B3B;
  font-weight: 500;
  white-space: nowrap;
}
.view-picker-dropdown {
  min-width: 160px;
  font-size: 0.85rem;
}

/* Spatial-unit picker — session 10 (HUC12 toggle). Leftmost in the control
   bar; switches between county and HUC12 watershed views. */
.spatial-unit-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-right: 12px;
}
.spatial-unit-picker-label {
  color: #3B3B3B;
  font-weight: 500;
  white-space: nowrap;
}
.spatial-unit-picker-dropdown {
  min-width: 170px;
  font-size: 0.85rem;
}

/* Time-horizon picker — session 9 (projection feature). Sits to the right
   of the view pills; switches between current snapshot and 2036 projection. */
.horizon-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-left: 12px;
}
.horizon-picker-label {
  color: #3B3B3B;
  font-weight: 500;
  white-space: nowrap;
}
.horizon-picker-dropdown {
  min-width: 200px;
  font-size: 0.85rem;
}

/* Composite + overlay controls in the bar */
.control-spacer {
  flex: 1 1 auto;
}
.composite-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #3B3B3B;
}
.composite-toggle .form-check-label {
  font-size: 0.85rem;
  color: #3B3B3B;
}
.composite-switch {
  margin-bottom: 0;
}
.overlay-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.overlay-label {
  color: #3B3B3B;
  font-weight: 500;
  white-space: nowrap;
}
.overlay-dropdown {
  min-width: 280px;
  font-size: 0.85rem;
}

/* Radio picker (M3 — replaces the M2 multi-select dropdown). Inline horizontal
   radio with subtle padding; the active option highlights via Bootstrap's
   form-check-input checked state. */
.overlay-radio {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 0.82rem;
  margin-bottom: 0;
}
.overlay-radio .form-check {
  margin-right: 0;
  padding-left: 1.5rem;
}
.overlay-radio-label {
  color: #3B3B3B;
  cursor: pointer;
  user-select: none;
}
.overlay-radio .form-check-input:checked {
  background-color: #C61D1D;
  border-color: #C61D1D;
}

/* Coverage legend — pinned to viewport bottom-left so it stays put
   regardless of the Loading wrapper's positioning context. */
.coverage-legend {
  position: fixed !important;
  left: 14px;
  bottom: 14px;
  top: auto !important;
  right: auto !important;
  background-color: rgba(255, 255, 255, 0.92);
  border: 1px solid #D9D9DE;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.4;
  max-width: 320px;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.coverage-legend-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: #1F1FD6;
}
.coverage-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}
.coverage-swatch {
  width: 16px;
  height: 12px;
  border: 1px solid #D9D9DE;
  flex-shrink: 0;
  display: inline-block;
}
.swatch-decile {
  background: linear-gradient(
    90deg,
    #4575b4 0%,
    #abd9e9 25%,
    #ffffbf 50%,
    #fdae61 75%,
    #d73027 100%
  );
  border-color: transparent;
}
.coverage-legend-note {
  margin-top: 6px;
  color: #666;
  font-size: 0.7rem;
  font-style: italic;
}

/* Drill-down offcanvas — bottom-anchored (M3 refactor from right-anchored).
   Width is full viewport; height ~40vh for content breathing room without
   eating the map. Bootstrap's bs-offcanvas-height var controls offcanvas-bottom. */
.drilldown-panel {
  --bs-offcanvas-height: 40vh;
  font-size: 0.85rem;
}

/* 2-column landscape grid for the bottom-anchored content.
   Left col: header + dim scores + composite + chips (stable height, ~360px).
   Right col: factor breakdown (scrollable per-dim collapsible groups). */
.drilldown-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) 1.2fr;
  gap: 24px;
  height: 100%;
}
.drilldown-col-left,
.drilldown-col-right {
  min-width: 0;  /* allow grid children to shrink below content size */
  overflow-y: auto;
}
.drilldown-col-right .factor-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
  align-content: start;
}
.drilldown-empty {
  color: #888;
  padding: 12px 0;
}
.drilldown-header {
  border-bottom: 2px solid #21A8E0;
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.drilldown-county {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  color: #1F1FD6;
}
.drilldown-fips {
  font-size: 0.75rem;
  color: #666;
}
.drilldown-small-county-note {
  margin-top: 6px;
  padding: 6px 8px;
  background-color: #FFF8E1;
  border-left: 3px solid #B8860B;
  font-size: 0.72rem;
  color: #6A4C00;
  line-height: 1.35;
}
.section-title {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: #1F1FD6;
  letter-spacing: 0.04em;
  margin: 14px 0 6px 0;
}

/* Dimension score rows */
.dim-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dim-row, .composite-row {
  display: grid;
  grid-template-columns: 110px 40px 1fr;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid #F4F4F6;
}
.composite-row {
  border-bottom: none;
  border-top: 1px solid #21A8E0;
  margin-top: 8px;
  padding-top: 8px;
}
.composite-name {
  font-weight: 600;
  color: #1F1FD6;
}
.composite-score {
  font-weight: 600;
}
.dim-name { color: #3B3B3B; }
.dim-score {
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dim-coverage {
  color: #888;
  font-size: 0.75rem;
}

/* Chip badges */
.chips-section {
  margin-top: 12px;
}
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip {
  display: inline-block;
  background-color: #FFF3E0;
  color: #6A2C00;
  border: 1px solid #E07B00;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
}
.chips-empty {
  color: #888;
  font-size: 0.78rem;
  font-style: italic;
}

/* Factor breakdown */
.factor-groups {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.factor-group {
  border: 1px solid #F4F4F6;
  border-radius: 4px;
  padding: 4px 8px;
}
.factor-group summary {
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  color: #3B3B3B;
}
.factor-group summary:hover {
  color: #1F1FD6;
}
.factor-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}
.factor-line {
  font-size: 0.78rem;
  padding: 6px 0;
  border-bottom: 1px dotted #F4F4F6;
}
.factor-line-head {
  display: grid;
  grid-template-columns: 28px 1fr 50px;
  gap: 6px;
  align-items: baseline;
}
.factor-line-body {
  margin-left: 34px;
  margin-top: 2px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.factor-id {
  color: #888;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.factor-name {
  color: #3B3B3B;
  white-space: normal;
  line-height: 1.25;
}
.factor-pct {
  font-weight: 600;
  text-align: right;
  color: #1F1FD6;
  font-variant-numeric: tabular-nums;
}
.factor-val-plain {
  color: #3B3B3B;
  font-size: 0.74rem;
  font-style: italic;
}
.factor-cov {
  font-size: 0.7rem;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.factor-cov-full { color: #2A8E4A; }
.factor-cov-partial { color: #B8860B; }
.factor-cov-insufficient { color: #999; font-style: italic; }

/* Methodology modal — readability tweaks */
.methodology-body h5 {
  font-family: 'Source Serif 4', Georgia, serif;
  color: #1F1FD6;
  font-size: 1rem;
  margin-top: 18px;
  margin-bottom: 6px;
}
.methodology-body h5:first-child { margin-top: 0; }
.methodology-body p, .methodology-body li {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #3B3B3B;
}
.methodology-body ul {
  padding-left: 1.2rem;
}

/* Coverage legend — slightly smaller, anchored bottom-left */
.coverage-legend {
  font-size: 0.74rem;
  padding: 8px 10px;
  max-width: 280px;
}
.coverage-legend-title {
  font-size: 0.78rem;
}

/* ----------------------------------------------------------------------
   Sensitivity tuner panel (session 7)
   ---------------------------------------------------------------------- */

/* Top-bar "Tune weights" button — sits between view pills and overlays */
.tune-weights-btn {
  margin-right: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Right-anchored offcanvas — wider than the drilldown to fit slider rows */
.sensitivity-panel {
  width: 460px !important;
  font-size: 0.88rem;
}

.sensitivity-intro {
  font-size: 0.82rem;
  color: #555;
  margin-bottom: 14px;
  line-height: 1.4;
}

.sensitivity-controls {
  margin-bottom: 12px;
}

.preset-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.preset-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #3B3B3B;
}
.preset-dropdown {
  font-size: 0.85rem;
}

.reset-row {
  display: flex;
  justify-content: flex-end;
}

/* Apply-row hosts the dim-multipliers sum indicator + Reset + Apply buttons */
.apply-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 8px;
  background-color: #FAFAFC;
  border-radius: 4px;
  border: 1px solid #ECECEF;
}
.dim-sum-top {
  flex-grow: 1;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
}
.reset-btn {
  flex-shrink: 0;
}
.run-btn {
  flex-shrink: 0;
  font-weight: 600;
}
.run-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Warn state — sums diverging from 100% */
.dim-sum-warn {
  color: #C0392B !important;
  font-weight: 700;
}

/* Accordion — the 5 dimension blocks. dbc.Accordion handles base styling;
   we add brand-aligned tints. */
.sensitivity-accordion .accordion-button {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 14px;
  background-color: #F4F4F6;
}
.sensitivity-accordion .accordion-button:not(.collapsed) {
  background-color: #E8F4FB;
  color: #1F1FD6;
  box-shadow: none;
}
.sensitivity-accordion .accordion-button:focus {
  box-shadow: none;
  border-color: transparent;
}

.accordion-dim-name {
  font-weight: 600;
}
.accordion-dim-sep {
  color: #999;
  margin: 0 4px;
}
.accordion-dim-sum {
  font-weight: 400;
  font-size: 0.8rem;
  color: #555;
  font-family: 'Source Sans 3', Arial, sans-serif;
}

/* Body of each accordion item */
.dim-multiplier-block {
  background-color: #FAFAFC;
  padding: 8px 10px;
  border-left: 3px solid #21A8E0;
  margin-bottom: 8px;
}
.dim-multiplier-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
  margin-bottom: 6px;
}

.accordion-divider {
  margin: 6px 0 10px 0;
  border-top: 1px dashed #DDD;
}

.factor-sliders-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.factor-slider-row {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.factor-slider-label {
  font-size: 0.8rem;
  color: #3B3B3B;
}
.factor-slider-control {
  /* slider container — pad to match dcc.Slider's internal margin */
  padding: 0 8px;
}

/* Disabled (placeholder) slider — visually grayed */
.weight-slider-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.weight-slider-disabled + * {
  /* no-op; reserved for future placeholder badge */
}

/* Decile preview — bottom of panel */
.decile-preview-block {
  margin-top: 10px;
}
.decile-preview-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
  margin-bottom: 4px;
}

/* Imported-water source-basin section — only renders for curated CRB
   importer counties (Maricopa, LA, Denver, etc.). The drilldown wrap
   stacks the existing 2-col grid above this row; both fit inside the
   bottom-anchored offcanvas (40vh). Visual treatment uses Carolina blue
   border to mark it as a distinct overlay context. */
.drilldown-content-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 12px;
}
.drilldown-content-wrap > .drilldown-grid {
  flex: 1 1 auto;
  min-height: 0;
}
.source-basin-section {
  flex-shrink: 0;
  border-top: 2px solid #21A8E0;
  padding-top: 10px;
  margin-top: 4px;
}
.source-basin-head {
  margin-bottom: 8px;
}
.source-basin-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1F1FD6;
}
.source-basin-subtitle {
  font-size: 0.72rem;
  color: #555;
  margin-top: 2px;
  line-height: 1.4;
}
.source-basin-table {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-color: #F9F9FB;
  border: 1px solid #E2E2E8;
  border-radius: 4px;
  padding: 6px 10px;
}
.source-basin-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.8fr) minmax(60px, 0.6fr) minmax(110px, 0.9fr) minmax(80px, 0.7fr) minmax(90px, 0.8fr);
  gap: 10px;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px solid #EDEDF1;
  font-size: 0.82rem;
}
.source-basin-row:last-child {
  border-bottom: none;
}
.source-basin-row-head .source-basin-cell {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #1F1FD6;
}
.source-basin-row-agg {
  border-top: 2px solid #21A8E0;
  margin-top: 2px;
  padding-top: 6px;
  font-weight: 600;
}
.source-basin-cell-label {
  color: #444;
}
.source-basin-cell-v {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.source-basin-footer {
  font-size: 0.7rem;
  color: #777;
  font-style: italic;
  margin-top: 6px;
  line-height: 1.45;
}
