/* ==========================================================================
   METEODIEGO — Hoja de estilos ultraligera
   Optimizada para MacBook Air 2013 (1366x768 / 1440x900 no-Retina, Intel HD 5000)
   Cero blur GPU, cero animaciones continuas, alto contraste y lectura nítida.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg-page: #f2f5f7;
  --bg-surface: #ffffff;
  --bg-subtle: #e8eef2;
  --bg-hover: #dde6ec;

  --text-primary: #14222d;
  --text-secondary: #425666;
  --text-muted: #5d7283;

  --border-color: #cfdbe3;
  --border-strong: #b2c4d1;

  --brand-primary: #1b4d6e;
  --brand-primary-fg: #ffffff;
  --accent-link: #155885;

  /* Estados del Semáforo de Calma */
  --calm-bg: #eaf5ee;
  --calm-border: #8ac4a0;
  --calm-title: #14532d;
  --calm-pill-bg: #1c6b3d;

  --watch-bg: #fdf6e7;
  --watch-border: #e0b96b;
  --watch-title: #6b4708;
  --watch-pill-bg: #94620a;

  --alert-bg: #fceee9;
  --alert-border: #de9783;
  --alert-title: #7a2713;
  --alert-pill-bg: #9e3319;

  /* Colores de modelos (accesibles y distinguibles) */
  --color-ecmwf: #1967b2;
  --color-gfs: #1d8a4e;
  --color-icon: #8b3fb8;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;

  --shadow-card: 0 1px 3px rgba(20, 34, 45, 0.06);
}

html[data-theme="dark"] {
  --bg-page: #11181f;
  --bg-surface: #19232d;
  --bg-subtle: #22303d;
  --bg-hover: #2b3c4c;

  --text-primary: #ecf2f6;
  --text-secondary: #b6c6d4;
  --text-muted: #8ea3b5;

  --border-color: #2e3f4f;
  --border-strong: #41586d;

  --brand-primary: #3b82b6;
  --brand-primary-fg: #ffffff;
  --accent-link: #6db3e8;

  --calm-bg: #152b20;
  --calm-border: #2f6848;
  --calm-title: #9be2b5;
  --calm-pill-bg: #256d44;

  --watch-bg: #2d2412;
  --watch-border: #785b22;
  --watch-title: #f5d287;
  --watch-pill-bg: #8c6314;

  --alert-bg: #311a15;
  --alert-border: #823c2c;
  --alert-title: #f7b2a1;
  --alert-pill-bg: #9e3822;

  --color-ecmwf: #56a8f5;
  --color-gfs: #46c980;
  --color-icon: #c58af0;

  --shadow-card: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.48;
  background-color: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: subpixel-antialiased;
}

h1, h2, h3, p, dl, dd {
  margin: 0;
}

a {
  color: var(--accent-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  opacity: 0.85;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Barra superior */
.topbar {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background-color: var(--brand-primary);
  color: var(--brand-primary-fg);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.select-input,
.btn {
  font-family: inherit;
  font-size: 14px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  padding: 0 12px;
  cursor: pointer;
}

.select-input {
  min-width: 245px;
  font-weight: 600;
}

.btn {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover,
.select-input:hover {
  background-color: var(--bg-subtle);
}

.btn:focus-visible,
.select-input:focus-visible,
.pill-btn:focus-visible,
.day-card:focus-visible,
.tab-btn:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.btn-secondary {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--brand-primary-fg);
}

.btn-secondary:hover {
  opacity: 0.92;
  background-color: var(--brand-primary);
}

/* Contenedor principal optimizado para 1366px - 1440px */
.container {
  max-width: 1340px;
  margin: 0 auto;
  padding: 14px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Barra de estado */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}

.official-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Botones rápidos de circuitos turísticos */
.circuit-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.pill-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.pill-btn.active {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--brand-primary-fg);
}

/* Tira de 7 días */
.days-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-header-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-weight: 700;
}

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
}

.badge-high {
  border-color: var(--calm-border);
  background-color: var(--calm-bg);
  color: var(--calm-title);
}

.badge-medium {
  border-color: var(--watch-border);
  background-color: var(--watch-bg);
  color: var(--watch-title);
}

.days-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.day-card {
  font-family: inherit;
  text-align: left;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

.day-card:hover {
  background-color: var(--bg-subtle);
}

.day-card.active {
  border: 2px solid var(--brand-primary);
  padding: 9px 10px;
  background-color: var(--bg-surface);
}

.day-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.day-name {
  font-weight: 700;
  font-size: 14px;
}

.day-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.day-dot.calm { background-color: #228b4e; }
.day-dot.watch { background-color: #c98a18; }
.day-dot.alert { background-color: #c44325; }

.day-temps {
  font-size: 14px;
  font-weight: 600;
}

.day-temps span {
  color: var(--text-muted);
  font-weight: 500;
}

.day-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tarjetas generales */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

.eyebrow {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
}

.card-title-sm {
  font-size: 16px;
  font-weight: 700;
}

/* Grilla Superior: Filtro Anti-Catastrofismo (66%) + Ahora en Terreno (34%) */
.top-grid {
  display: grid;
  grid-template-columns: 1.9fr 1fr;
  gap: 14px;
  align-items: stretch;
}

.calm-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-width: 2px;
}

.calm-card.calm-level-calm {
  background-color: var(--calm-bg);
  border-color: var(--calm-border);
}

.calm-card.calm-level-watch {
  background-color: var(--watch-bg);
  border-color: var(--watch-border);
}

.calm-card.calm-level-alert {
  background-color: var(--alert-bg);
  border-color: var(--alert-border);
}

.calm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.calm-title {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
}

.calm-level-calm .calm-title { color: var(--calm-title); }
.calm-level-watch .calm-title { color: var(--watch-title); }
.calm-level-alert .calm-title { color: var(--alert-title); }

.consensus-pill {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.calm-level-calm .consensus-pill { background-color: var(--calm-pill-bg); }
.calm-level-watch .consensus-pill { background-color: var(--watch-pill-bg); }
.calm-level-alert .consensus-pill { background-color: var(--alert-pill-bg); }

.calm-summary {
  font-size: 15.5px;
  font-weight: 500;
  color: var(--text-primary);
}

.calm-points {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding-top: 4px;
}

.calm-point {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13.5px;
}

.calm-point strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13px;
  color: var(--text-primary);
}

.scale-note {
  margin-top: auto;
  font-size: 13px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  padding-top: 9px;
}

/* Panel Actual */
.current-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.current-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
}

.current-temp-block {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.cur-temp {
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
}

.cur-desc {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.current-feels {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.current-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-box {
  background-color: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.metric-box dt {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.metric-box dd {
  font-size: 14px;
  font-weight: 700;
}

/* Panel 2: Ventanas de Guiada */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.circuit-note {
  font-size: 13.5px;
  color: var(--text-secondary);
  max-width: 540px;
}

.tour-windows-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.window-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  background-color: var(--bg-page);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.window-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.window-title {
  font-weight: 700;
  font-size: 15px;
}

.window-hours {
  font-size: 12.5px;
  color: var(--text-muted);
}

.window-status {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.status-ideal {
  background-color: var(--calm-bg);
  color: var(--calm-title);
  border: 1px solid var(--calm-border);
}

.status-caution {
  background-color: var(--watch-bg);
  color: var(--watch-title);
  border: 1px solid var(--watch-border);
}

.status-indoor {
  background-color: var(--alert-bg);
  color: var(--alert-title);
  border: 1px solid var(--alert-border);
}

.window-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 13.5px;
  padding: 8px 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.window-stats span {
  color: var(--text-secondary);
}

.window-stats strong {
  color: var(--text-primary);
}

.window-advice {
  font-size: 13.5px;
  color: var(--text-primary);
  line-height: 1.42;
}

/* Panel 3: Comparador Multimodelo */
.metric-tabs {
  display: inline-flex;
  background-color: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.tab-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}

.tab-btn.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.model-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  margin-bottom: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 4px;
  border-radius: 2px;
}

.dot-ecmwf { background-color: var(--color-ecmwf); }
.dot-gfs { background-color: var(--color-gfs); }
.dot-icon { background-color: var(--color-icon); }

.legend-ref {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12.5px;
}

.chart-wrapper {
  position: relative;
  background-color: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px 6px;
  margin-bottom: 14px;
}

.models-chart {
  width: 100%;
  height: auto;
  display: block;
  max-height: 250px;
}

.chart-tooltip {
  position: absolute;
  top: 12px;
  right: 14px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12.5px;
  pointer-events: none;
  box-shadow: var(--shadow-card);
}

.table-scroll {
  overflow-x: auto;
}

.models-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}

.models-table caption {
  text-align: left;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.models-table th,
.models-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-color);
}

.models-table th {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
}

/* Nota educativa / tranquilidad */
.calm-guide-footer .tips-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 10px;
}

/* ==========================================================================
   Panel de Radar 2D, Topes Nubosos y Diagnóstico de Granizo
   ========================================================================== */
.radar-grid {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 16px;
  align-items: start;
}

.leaflet-wrap,
.goes-hd-wrap {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-page);
  overflow: hidden;
}

.radar-map {
  width: 100%;
  height: 360px;
  background-color: #dce6ee;
  z-index: 1;
}

html[data-theme="dark"] .radar-map {
  background-color: #16222c;
}

.radar-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
}

.radar-nav-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-sm {
  height: 30px;
  font-size: 12.5px;
  padding: 0 10px;
}

.radar-timestamp-box {
  font-size: 13px;
  color: var(--text-secondary);
}

.radar-map-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-color);
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin: 0 2px 0 6px;
  vertical-align: middle;
}

.sw-light { background-color: #38a3d1; }
.sw-mod { background-color: #2eb85c; }
.sw-heavy { background-color: #e0532b; }

/* Vista GOES HD estática */
.goes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.goes-subtabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.goes-img-frame {
  width: 100%;
  max-height: 370px;
  overflow: auto;
  background-color: #0d141a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.goes-img-frame img {
  width: 100%;
  height: auto;
  display: block;
}

.goes-caption {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
}

/* Columna de evaluación de granizo y lluvias fuertes */
.storm-eval-col {
  display: flex;
  flex-direction: column;
  gap: 11px;
  background-color: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px 14px;
}

.eval-status-box {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.eval-status-box strong {
  display: block;
  font-size: 14.5px;
  margin-bottom: 3px;
}

.eval-status-box p {
  font-size: 13px;
  line-height: 1.4;
}

.eval-metrics-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.eval-metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-color);
}

.eval-metric-row dt {
  color: var(--text-secondary);
}

.eval-metric-row dd {
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
}

.visual-guide-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.visual-guide-box h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-primary);
}

.visual-guide-box ul {
  margin: 0;
  padding-left: 16px;
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Etiquetas limpias sobre el mapa Leaflet */
.ring-label {
  background: rgba(20, 34, 45, 0.78);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  border: none;
}

.calm-guide-footer h3 {
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.calm-guide-footer p {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.footer {
  text-align: center;
  padding: 14px 20px 26px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Adaptación para pantallas más chicas o ventana partida */
@media (max-width: 1060px) {
  .top-grid,
  .radar-grid {
    grid-template-columns: 1fr;
  }
  .days-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .tour-windows-grid,
  .calm-guide-footer .tips-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .days-strip,
  .calm-points {
    grid-template-columns: 1fr 1fr;
  }
}

