/* ===================================================
   1. PALETA DE COLORES Y VARIABLES (Tema Claro y Oscuro)
   =================================================== */
:root {
  --bg-color: #f7f6f3;       
  --text-main: #111111;      
  --text-muted: #555555;     
  --line-color: #bbbbbb;     
  --accent-blue: #0044cc;    
  --panel-bg: #ffffff;
}

/* Cuando cambiamos a tema oscuro con JS, estos colores toman el control */
[data-theme="dark"] {
  --bg-color: #121212;       
  --text-main: #e0e0e0;      
  --text-muted: #a0a0a0;     
  --line-color: #444444;     
  --accent-blue: #6699ff;    
  --panel-bg: #1e1e1e;
}

/* ===================================================
   2. REGLAS BASE Y RESETEO BÁSICO
   =================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.main-header, .content-container, .main-footer {
  width: 100%;
  max-width: 800px;
}

/* ===================================================
   3. CABECERA Y NAVEGACIÓN
   =================================================== */
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 25px;
}

.logo-area h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-area .dot { color: #d46a00; }
.subtitle { color: var(--text-muted); font-size: 0.95rem; margin-top: 2px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.top-link { color: var(--accent-blue); text-decoration: underline; font-size: 0.9rem; }

/* Botón flotante del tema */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--line-color);
  color: var(--text-main);
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}
.theme-toggle-btn:hover { background-color: var(--line-color); }
.theme-toggle-btn svg { width: 16px; height: 16px; }

.main-nav {
  border-top: 1px solid var(--line-color);
  border-bottom: 1px solid var(--line-color);
  padding: 12px 0;
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 40px;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: underline;
}

.nav-btn.active { color: var(--text-main); text-decoration: none; font-weight: bold; }
.separator { color: var(--line-color); }

.hero-section { margin-bottom: 45px; }
.hero-section h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 10px; }
.hero-section p { color: var(--text-muted); font-size: 1.1rem; max-width: 600px; }

.list-section h3 {
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--text-main);
  padding-bottom: 6px;
  margin-bottom: 15px;
}

/* ===================================================
   4. FILAS DE LA LISTA DE MUNICIPIOS
   =================================================== */
.clima-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px dashed var(--line-color);
  cursor: pointer;
  transition: background 0.2s;
}

.clima-row:hover { background-color: var(--line-color); }

.clima-row.selected {
  background-color: var(--line-color);
  padding-left: 8px;
  padding-right: 8px;
  border-left: 3px solid var(--text-main);
}

.row-left { display: flex; flex-direction: column; }
.municipio-name { color: var(--accent-blue); font-weight: 600; font-size: 1.1rem; text-decoration: none; pointer-events: none; }
.municipio-info { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.municipio-info svg { width: 16px; height: 16px; }
.row-right { display: flex; align-items: center; gap: 10px; }
.temp-val { font-size: 1.2rem; font-weight: 700; }
.loading { color: var(--text-muted); font-style: italic; padding: 20px 0; }

/* ===================================================
   5. PANEL EXTENDIBLE (MEDIDORES Y MAPA)
   =================================================== */
.panel-detalles {
  margin-bottom: 40px; 
  border: 1px solid var(--text-main);
  background-color: var(--panel-bg);
  padding: 24px;
  display: none; /* Se activa con JS cuando seleccionas un municipio */
  transition: background-color 0.3s ease;
}

.panel-detalles h4 { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }

.panel-detalles .depto-tag {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: block;
}

.grid-detalles { display: flex; flex-direction: column; gap: 25px; }

.medidores-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 600px) {
  .medidores-container { grid-template-columns: repeat(3, 1fr); }
}

.medidor-card { display: flex; flex-direction: column; gap: 8px; }

.medidor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 600;
}

.medidor-label { display: flex; align-items: center; gap: 6px; color: var(--text-main); }
.medidor-label svg { width: 18px; height: 18px; color: var(--text-muted); }

.medidor-track {
  width: 100%;
  height: 12px;
  background-color: var(--bg-color);
  border: 1px solid var(--line-color);
  overflow: hidden;
}

/* Barras animadas */
.medidor-fill {
  height: 100%;
  background-color: var(--text-main); 
  width: 0%; 
  transition: width 0.6s cubic-bezier(0.1, 0.8, 0.3, 1), background-color 0.4s ease;
}

/* Estilos del contenedor del mapa */
.mapa-wrapper { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.mapa-header-line { display: flex; justify-content: space-between; align-items: center; }
.mapa-title { font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.mapa-title svg { width: 18px; height: 18px; color: var(--text-muted); }

.radar-alert-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border: 1px solid var(--text-main);
}

#mapa-visor {
  width: 100%;
  height: 320px;
  border: 1px solid var(--text-main);
  z-index: 1; 
}

/* Ajustes visuales para Leaflet */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background-color: var(--panel-bg) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--line-color);
}

.leaflet-control-layers {
  background-color: var(--panel-bg) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--text-main) !important;
  border-radius: 4px !important;
  font-family: inherit;
  font-size: 0.85rem;
  box-shadow: none !important;
}

/* ===================================================
   6. ICONOS PERSONALIZADOS DE ESTACIÓN (Triángulos)
   =================================================== */
.estacion-triangulo {
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 18px solid #b0b0b0; 
  filter: drop-shadow(0px 2px 2px rgba(0,0,0,0.3));
  transition: border-bottom-color 0.3s ease, transform 0.2s ease;
}

/* Animaciones de palpitación según el clima */
.titilo-lento { animation: pulsacion-alerta 2.5s infinite ease-in-out; }
.titilo-medio { animation: pulsacion-alerta 1.2s infinite ease-in-out; }
.titilo-rapido { animation: pulsacion-alerta 0.5s infinite cubic-bezier(0.4, 0, 0.6, 1); }

.estacion-triangulo.seleccionado { transform: scale(1.4); }

@keyframes pulsacion-alerta {
  0% { opacity: 1; }
  50% { opacity: 0.25; }
  100% { opacity: 1; }
}

.main-footer {
  border-top: 1px solid var(--line-color);
  margin-top: 60px;
  padding-top: 15px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.main-footer a { color: var(--accent-blue); text-decoration: underline; }


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

.brand-logo {
  height: 70px;
  width: auto;
  object-fit: contain;
}


/* ===================================================
   ESTILOS DEL PRONÓSTICO POR HORAS Y GRID EXTENDIDO
   =================================================== */
.hourly-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px dashed var(--line-color);
  padding-top: 18px;
}

.hourly-container {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.hourly-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--line-color);
  background-color: var(--bg-color);
  min-width: 75px;
  text-align: center;
}

.hourly-card .h-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hourly-card svg {
  width: 18px;
  height: 18px;
}

.hourly-card .h-temp {
  font-size: 0.95rem;
  font-weight: 700;
}


/* ===================================================
   ESTILOS EXCLUSIVOS - MEDIDOR RÍO SINÚ
   =================================================== */
#card-rio-sinu {
  grid-column: 1 / -1; /* Ocupa todo el ancho del grid para destacar */
  border: 1px solid var(--accent-blue);
  padding: 12px;
  background-color: var(--bg-color);
}

.fill-rio-sinu {
  background: linear-gradient(90deg, #0044cc, #0099ff, #00e400);
  background-size: 200% 100%;
  animation: olas-rio 4s ease infinite;
}

@keyframes olas-rio {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.rio-status-bar {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.badge-status-rio {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid var(--line-color);
}
