/* Custom spinner size for loader */
#loader .spinner-border {
  width: 4rem;
  height: 4rem;
}
/* Custom styles for the map container */
#streams-map,
#streamsMap,
.streams-map {
  min-height: 360px;
  height: 360px;   /* or 50vh */
}

/* Map height (you can keep your old 360px if you prefer) */
#streams-map {
  width: 100%;
  height: 40vh;       /* <-- key fix */
  min-height: 300px;  /* optional floor */
}

/* Big pill tabs */
.app-tabs .nav-link{
  font-weight: 600;
  font-size: 1rem;          /* bump size */
  padding: .65rem 1rem;      /* taller */
  border: 2px solid transparent;
  border-radius: 999px;      /* pill */
  color: #0d6efd;            /* bootstrap primary */
  background-color: #eef5ff; /* subtle bg */
}
.app-tabs .nav-link:hover { background-color: #e2edff; }

.app-tabs .nav-link.active{
  color: #fff;
  background-color: #0d6efd;
  border-color: #0d6efd;
  box-shadow: 0 0 0 .15rem rgba(13,110,253,.25); /* focus ring */
}

/* Make “tabs” bar itself cleaner */
.app-tabs{
  border-bottom: 0;          /* remove default underline */
  gap: .5rem;                /* space between pills (BS5 supports gap on flex) */
}
.info-btn {
  border: none;
  background: none;
  color: #007bff; /* blue */
  cursor: pointer;
  margin-left: .25rem;
  font-size: 0.9rem;
}

/* one global bubble, hidden by default */
#cov-tooltip {
  background: #fff;
  border: 1px solid #888;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  max-width: 280px;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  z-index: 1000;
}
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: #2196F3;
}
input:checked + .slider:before {
  transform: translateX(26px);
}
#temporalMap { width: 100%; height: 40vh; min-height: 320px; }
#temporalChart { height: 40vh; min-height: 320px; }
#streams-map,      /* Ricker tab */
#temporalMap,      /* Temporal tab */
#scenarioMap,      /* Scenarios tab */
#scenarioChart {   /* Scenarios tab */
  width: 100%;
  height: 40vh;
  min-height: 320px;
}

/* Make them stretch evenly when using flex containers */
@media (min-width: 992px) {
  #scenarioMap,
  #scenarioChart {
    flex: 1 1 auto;
    height: auto;        /* let the flexbox control height */
    min-height: 500px;   /* same minimum height for both */
  }
}
/* ─── Model Controls: Balanced Compact Fit ───────────────────── */

/* restore comfortable spacing between each group */
.mb-4, .mb-3 {
  margin-bottom: 0.65rem !important;
}

/* readable but smaller label text */
.form-label {
  margin-bottom: 0.2rem;
  font-size: 0.88rem !important;
  line-height: 1.2;
  font-weight: 600;
  display: block;
  color: #2b2b2b;
}

/* numeric value beside label */
.form-label span[id^="val-"] {
  font-weight: 500;
  font-size: 0.85rem;
  margin-left: 0.25rem;
  color: #444;
}

/* slider with a little more vertical room */
.form-range {
  margin-top: 0.2rem;
  margin-bottom: 0.15rem;
  height: 0.9rem;
}

/* keep min/max clear but less dominant */
.slider-minmax {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #6c757d;
  margin-top: 0.1rem;
  line-height: 1.1;
}

/* info button tuned for alignment */
.info-btn {
  font-size: 0.75rem;
  margin-left: 0.25rem;
  padding: 0;
  background: none;
  border: none;
  color: #0d6efd;
}

/* smaller °C toggle label */
#unit-label {
  font-size: 0.85rem;
}
#unit-toggle-container {
  display: flex;
  align-items: center;
  justify-content: flex-end; /* right aligned */
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.unit-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: #444;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 22px;
}
.slider.round:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider.round {
  background-color: #2196F3;
}
input:checked + .slider.round:before {
  transform: translateX(20px);
}
#futureYearCheckboxes label {
  margin-bottom: 0; /* prevent extra row spacing */
}
#futureYearControls .btn {
  padding: 2px 10px;
  font-size: 0.8rem;
}
/* -------- Plotly + flex/grid layout fix (final clean version) -------- */

/* Allow main content to flex correctly */
#ricker main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Sidebar and main area stretch equally */
#ricker .row.g-0 {
  display: flex;
  align-items: stretch;
}

/* Sidebar card fills its column height */
#ricker aside .card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Chart area fills height evenly */
#ricker main .charts-grid {
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  flex: 1 1 auto;
}

/* Give both areas a matching base height */
#ricker aside .card,
#ricker main .charts-grid {
  min-height:560px;  /* tweak this for perfect alignment */
}

/* Keep Plotly charts flexible but visible */
#plot-ricker,
#plot-carcap {
  width: 100%;
  height: clamp(320px, 40vh, 560px);
}

/* Prevent card content from clipping */
.card-body {
  min-height: 0;
}

/* ─── Fix Ricker tab vertical alignment ────────────────────────── */
/* ─── Fix Ricker tab vertical alignment (final tested version) ────────────────────────── */
#ricker .container-fluid {
  padding-top: 0 !important;      /* remove the inline 10px padding */
  margin-top: 0 !important;
}

#ricker .row.g-0.align-items-stretch {
  align-items: flex-start !important; /* force columns to align to top */
  margin-top: 0 !important;
}

/* Make both sidebar and main content start at the same vertical line */
#ricker aside,
#ricker main {
  display: flex;
  flex-direction: column;
  align-self: flex-start;
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* Sidebar card adjustment */
#ricker aside .card {
  height: auto;
  flex: 1 1 auto;
  margin-top: 0 !important;
}

/* Remove the main section’s internal top gap */
#ricker main section.charts-grid {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

/* Remove any accidental offset from loader or inner containers */
#ricker #loader {
  top: 0 !important;
}

/* Match visual baseline across tabs */
#ricker main .card:first-of-type,
#ricker aside .card:first-of-type {
  margin-top: 0 !important;
}

/* Give both sections a baseline height, but don’t force a minimum offset */
#ricker aside .card,
#ricker main .charts-grid {
  min-height: auto;
}

/* ─── Temporal tab: match Ricker layout/behavior ───────────────── */
#temporal .container-fluid { padding-top: 0 !important; }
#temporal .row.g-0 { display:flex; align-items:flex-start !important; }

#temporal main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#temporal aside .card { display:flex; flex-direction:column; height:100%; }

#temporal main .charts-grid {
  display:flex;
  flex-direction:column;
  flex:1 1 auto;
}

/* Give sidebar and chart area the same visual baseline height */
#temporal aside .card,
#temporal main .charts-grid { min-height:560px; }

/* Map sizing (reuse your global heights) */
#temporal .map-container { height:40vh; min-height:320px; width:100%; }

/* Nudge consistency with Ricker colors (uses Bootstrap already) */
#temporal #temResetManaged.btn-outline-primary { /* already matches Ricker */ }


/* ─── Temporal tab vertical alignment (mirror Ricker) ─────────── */
#temporal .container-fluid {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

#temporal .row.g-0 {
  display: flex;
  align-items: flex-start !important; /* top-align columns */
  margin-top: 0 !important;
}

/* Start both columns on the same baseline */
#temporal aside,
#temporal main {
  display: flex;
  flex-direction: column;
  align-self: flex-start;
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* Sidebar card behavior */
#temporal aside .card {
  height: auto;
  flex: 1 1 auto;
  margin-top: 0 !important;
}

/* Remove internal top gaps */
#temporal main section.charts-grid {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

/* Optional: if the sidebar gets tall, allow scrolling just there */
#temporal aside .card-body {
  overflow: auto;
}

/* Give chart/map predictable heights */
#temporal #temporalChart {
  height: 40vh;
  min-height: 320px;
}
#temporal .map-container {
  height: 40vh;
  min-height: 320px;
  width: 100%;
}

/* Stack & space the Temporal sliders */
#temManagedSlidersRow{
  display: flex;              /* force vertical stack */
  flex-direction: column;
  gap: 1.25rem;               /* <-- main control for space between sliders */
  /* if you prefer not to use gap, you can use margin-bottom on children instead */
}

/* Whatever each slider wrapper is (col-*, div, etc.) => full width and spaced */
#temManagedSlidersRow > *{
  flex: 0 0 100% !important;
  max-width: 100% !important;
}

/* Give the Temporal tab looser default spacing than the global .mb-3 reduction */
#temporal .mb-3{ 
  margin-bottom: 1rem !important;   /* override our earlier 0.65rem just in this tab */
}

/* Optional: add a subtle separator for readability */
#temManagedSlidersRow > * + *{
  padding-top: .25rem;
  border-top: 1px dashed #eaecef;
}

/* Tweak the internal pieces so they breathe a bit */
#temporal .form-range{
  margin-top: .4rem;
  margin-bottom: .25rem;
}
#temporal .slider-minmax{
  margin-top: .2rem;
  font-size: .8rem;
}
/* ─── Temporal sliders: match Ricker style and width ─────────────── */
#temManagedSlidersRow > div {
  flex: 0 0 100% !important;
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-bottom: 1rem; /* consistent vertical spacing */
}

#temporal .form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem !important;
}

#temporal .form-range {
  width: 100%;
  margin-top: 0.4rem;
  margin-bottom: 0.3rem;
}

#temManagedSlidersRow > div {
  background-color: #fff;
  border: 1px solid #e9edf5;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  box-shadow: 0 0 2px rgba(0,0,0,0.05);
}

#temManagedSlidersRow {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

#temporal .badge.bg-light.text-dark {
  background-color: #f8f9fa !important;
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.3rem;
}
#temporal .form-label {
  display: inline-block; /* make the label inline so the value follows naturally */
  width: 100%; /* but still respect full width for wrapping */
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  margin-bottom: 0.35rem !important;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* inline value directly after label */
#temporal .form-label .slider-value-text {
  display: inline;
  margin-left: 0.25rem;
  font-weight: 600;
  color: #111827;
}

/* keep min/max row aligned as before */
#temporal .slider-minmax {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #6c757d;
}
/* info button tuned for alignment (temporal tab version) */
.tem-info-btn {
  font-size: 0.75rem;
  margin-left: 0.25rem;
  padding: 0;
  background: none;
  border: none;
  color: #0d6efd;
  cursor: pointer;
}

.tem-info-btn:hover {
  color: #084298; /* subtle darker blue on hover */
}
/* ─── Override Temporal slider cards to match Ricker compact style ─── */
#temManagedSlidersRow > div {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  margin-bottom: 0.65rem !important; /* match global .mb-4 compact spacing */
}

#temManagedSlidersRow > * + * {
  border-top: none !important;
  padding-top: 0 !important;
}

#temporal .form-label {
  font-size: 0.88rem !important;
  font-weight: 600;
  margin-bottom: 0.2rem !important;
}

#temporal .form-range {
  margin-top: 0.2rem !important;
  margin-bottom: 0.15rem !important;
}

#temporal .slider-minmax {
  margin-top: 0.1rem !important;
  font-size: 0.78rem !important;
}
/* ─── Final spacing fix: make Temporal sliders match Ricker ─── */
#temManagedSlidersRow {
  gap: 0.25rem !important; /* much tighter vertical spacing */
}

#temManagedSlidersRow > div {
  margin-bottom: 0.4rem !important;
}

#temporal .form-label {
  margin-bottom: 0.2rem !important;
}

#temporal .form-range {
  margin-top: 0.15rem !important;
  margin-bottom: 0.15rem !important;
}

#temporal .slider-minmax {
  margin-top: 0.1rem !important;
}
/* ─── Temporal slider stack: exact match to Ricker spacing ─── */
#temManagedSlidersRow {
  gap: 0.25rem !important;
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
}

#temManagedSlidersRow > div {
  margin: 0 !important;
  padding: 0 !important;
}

#temManagedSlidersRow .mb-3,
#temManagedSlidersRow .mb-4,
#temManagedSlidersRow .form-group {
  margin-bottom: 0.25rem !important; /* compress extra inner spacing */
}

#temporal .form-range {
  margin-top: 0.15rem !important;
  margin-bottom: 0.15rem !important;
}

#temporal .slider-minmax {
  margin-top: 0.05rem !important;
  margin-bottom: 0 !important;
}

#temporal .form-label {
  margin-bottom: 0.15rem !important;
}
/* --- Temporal Tab: compact "Select Stream" dropdown --- */
#temporal #temporalStreamSelect {
  max-width: 250px;           /* same width feel as Ricker tab */
  display: inline-block;
  margin-left: 0.5rem;
  vertical-align: middle;
}

#temporal label[for="temporalStreamSelect"] {
  font-weight: 600;
  font-size: 0.9rem;
  margin-right: 0.25rem;
  margin-bottom: 0;
  vertical-align: middle;
}

#temporal .stream-select-wrapper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}


/* --- Ensure tab bar is visible and scrollable --- */
.app-tabs {
  position: sticky;
  top: 56px; /* sits directly below navbar */
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  background-color: #fff;
  border-bottom: 1px solid #dee2e6;
  z-index: 1025; /* above maps and charts */
  min-height: 48px; /* prevent collapse */
}

/* --- Prevent tabs from shrinking --- */
.app-tabs .nav-item {
  flex: 0 0 auto;
}

/* --- Visible scrollbar for touch scroll --- */
.app-tabs::-webkit-scrollbar {
  height: 6px;
}
.app-tabs::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

/* --- Keep main content below it cleanly --- */
.tab-content {
  margin-top: 0.5rem;
}
/* === Responsive scaling for chart + map === */
@media (max-width: 1600px) {
  #temporal .charts-grid .card,
  #temporal .charts-grid .card-body,
  #temporal .js-plotly-plot {
    height: 420px !important;     /* smaller for laptop screens */
  }

  #temporal .map-wrap {
    height: 400px !important;
  }

  #temporal .map-wrap .leaflet-container {
    height: 100% !important;
  }
}

@media (max-width: 1200px) {
  #temporal .charts-grid .card,
  #temporal .charts-grid .card-body,
  #temporal .js-plotly-plot {
    height: 360px !important;     /* smaller for mid-size laptops */
  }

  #temporal .map-wrap {
    height: 340px !important;
  }
}

@media (max-width: 992px) {
  /* When layout stacks vertically */
  #temporal .charts-grid .card,
  #temporal .charts-grid .card-body,
  #temporal .js-plotly-plot {
    height: 320px !important;
  }

  #temporal .map-wrap {
    height: 320px !important;
  }
}
/* --- Fix extra white space under Plotly chart --- */
#temporalChart {
  height: auto !important;
  min-height: 300px;
}

#temporalChart > .plot-container {
  height: auto !important;
}

.card-body.d-flex {
  align-items: stretch !important;
}

.charts-grid .card-body {
  flex: 0 1 auto !important; /* don't force fill space */
  padding-bottom: 0 !important;
}
/* --- Tighten the Temporal Chart card layout --- */
#temporalChart {
  height: auto !important;
  min-height: 280px;
}

#temporalChart > .plot-container {
  height: auto !important;
}

/* Let card body shrink to the Plotly content instead of stretching full height */
.charts-grid .card-body {
  flex: 0 1 auto !important;
  padding-bottom: 0 !important;
}

/* Ensure the main column doesn't force all children to fill remaining space */
main.d-flex.flex-column {
  align-items: stretch;
}

main.d-flex.flex-column > section.charts-grid {
  flex: 0 1 auto !important;
}
#scenarioChart .legend text {
  font-size: clamp(8px, 1.1vw, 11px) !important;
  white-space: nowrap !important;
}

#scenarioChart .legend {
  display: flex !important;
  flex-wrap: nowrap !important;
  justify-content: center !important;
  align-items: center !important;
  overflow-x: auto !important;
  scrollbar-width: thin;
}
/* New stable wrapper for slider + marker */
.slider-track-wrap {
  position: relative;
  width: 100%;
}

/* Stabilize bootstrap slider height and prevent responsive shifts */
.form-range {
  height: 26px;
  margin: 0 !important;
  position: relative;
  z-index: 2;
}

/* Default marker anchored to the actual track */
/* base marker — visible only when .active */
.slider-default-marker {
  position: absolute;
  top: calc(50% - 6px);
  left: 0;
  width: 10px;          /* slightly bigger click target */
  height: 10px;
  border-radius: 50%;
  background: #555;
  
  opacity: 0;
  pointer-events: none; /* default: no hitbox */
  z-index: 5;

  transform: translateX(-50%);
}

/* when active — allow click and float above slider */
.slider-default-marker.active {
  opacity: 1;
  pointer-events: auto; /* <-- clickable ONLY when visible */
  z-index: 20;          /* <-- above track, below thumb */
}


/* === Perfect vertical centering for slider thumbs + default markers === */

/* Center the blue thumb on the actual bar */
.form-range::-webkit-slider-thumb {
  margin-top: -6px !important;  /* Chrome/Safari */
}
.form-range::-moz-range-thumb {
  transform: translateY(-2px);  /* Firefox */
}

/* Center the default marker perfectly on the bar */
.slider-default-marker {
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
}
.form-range {
  height: 20px !important;
}
/* --- FINAL pixel-perfect slider alignment --- */

/* Pull the blue thumb DOWN slightly */
.form-range::-webkit-slider-thumb {
  margin-top: -4px !important;   /* was -6px */
}
.form-range::-moz-range-thumb {
  transform: translateY(0px) !important; /* was -2px */
}

/* Lift the grey default marker UP slightly */
.slider-default-marker {
  top: calc(50% - 6px) !important;  /* raise marker 2px */
  transform: translateX(-50%) !important;
}

/* Reduce overall slider height so track is treated consistently */
.form-range {
  height: 22px !important;  /* compromise height */
}
.map-container {
  position: relative;
}

.map-control-box {
  position: absolute;
  top: 12px;     /* ⬅ moved down a bit */
  left: 60px;
  z-index: 1000;

  background: white;
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);

  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  width: auto;
}


.map-control-box label {
  font-size: 0.70rem;     /* slightly smaller to match Leaflet text weight */
  font-weight: 600;
  margin-bottom: 0px;     /* no extra vertical height */
  color: #444;
  text-transform: uppercase;
}

.map-control-box select {
  width: max-content;
  min-width: 220px;
  max-width: 340px;

  font-size: 0.85rem;
  padding: 3px 6px;       /* same height feel as zoom controls */
  border-radius: 6px;
  border: 1px solid #ccc;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.stream-info-btn {
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: #ffffff;
  border-radius: 999px;   /* matches your pill-style tabs */
  font-weight: 600;
}

.stream-info-btn:hover,
.stream-info-btn:focus {
  background-color: #0b5ed7;  /* Bootstrap primary hover shade */
  border-color: #0b5ed7;
}
/* Navbar stays on top */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1030;
}

/* Tabs stick directly under navbar (dynamic height) */
.app-tabs {
  position: sticky;
  top: var(--nav-h, 56px);  /* fallback if JS hasn’t run yet */
  z-index: 1020;
  background: #fff;
}