/* --- VARIABLES --- */
:root {
  --bg-gradient: linear-gradient(180deg, #5b9bd5 0%, #87ceeb 100%);
  --text-color: #1a1a1a;
  --card-bg: rgba(255, 255, 255, 0.22); 
  --nav-bg: rgba(255, 255, 255, 0.35);
  --blur: blur(25px);
  --text-shadow: none; 
  --nav-indicator-bg: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --nav-indicator-shadow: rgba(0, 242, 254, 0.4);
  --nav-text-active: #ffffff;
}

[data-theme="dark"] {
  --bg-gradient: linear-gradient(180deg, #1e3c72 0%, #2a5298 100%);
  --text-color: #ffffff;
  --card-bg: rgba(0, 0, 0, 0.35);
  --nav-bg: rgba(0, 0, 0, 0.45);
  --nav-indicator-bg: linear-gradient(135deg, #0061ff 0%, #60efff 100%);
  --nav-indicator-shadow: rgba(0, 97, 255, 0.6);
  --nav-text-active: #ffffff;
  --text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0; padding: 0;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-color);
  text-shadow: var(--text-shadow); 
  min-height: 100vh;
  padding-bottom: 110px; 
  overflow-x: hidden;
}

.container { max-width: 700px; margin: 0 auto; padding: 0 20px; box-sizing: border-box; }

/* --- BUSCADOR --- */
.main-header { padding: 30px 0 10px; text-align: center; }
.search-bar {
    display: flex; align-items: center;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px; padding: 5px 15px;
    max-width: 500px; margin: 0 auto 25px;
}
#buscador-input { 
    flex: 1; background: transparent; border: none; padding: 12px 5px; 
    color: var(--text-color); outline: none; font-size: 1rem; 
}
#buscador-input::placeholder { color: var(--text-color); opacity: 0.7; }

#btn-buscar, #btn-gps { 
    background: transparent; border: none; font-size: 1.2rem; 
    cursor: pointer; color: var(--text-color); 
}

/* --- HERO --- */
.weather-hero { text-align: center; padding: 20px 0 10px; }
.hero-pueblo { font-size: 2.2rem; margin: 0; font-weight: 400; text-transform: capitalize; }
.hero-temp { font-size: 5.5rem; font-weight: 200; margin: 5px 0; }
.hero-icon { font-size: 4rem; display: block; filter: drop-shadow(0 2px 5px rgba(0,0,0,0.2)); }
.hero-range { font-size: 1.1rem; font-weight: 500; margin-bottom: 15px; display: block; }

/* --- COLUMNAS (CONTENEDORES) --- */
.column {
  background: var(--card-bg) !important;
  backdrop-filter: var(--blur); border-radius: 20px; 
  border: 1px solid rgba(255, 255, 255, 0.25);
  margin-bottom: 20px; overflow: hidden;
}
.column h2 { font-size: 0.75rem; text-transform: uppercase; background: rgba(255, 255, 255, 0.15); padding: 10px 15px; margin: 0; }

/* --- HORAS (SCROLL) --- */
.scroll-x { display: flex; overflow-x: auto; padding: 20px 10px; gap: 25px; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.hora-item { display: flex; flex-direction: column; align-items: center; min-width: 50px; text-align: center; }

/* --- 7 DÍAS --- */
.lista-vertical { padding: 0 15px; }
.dia-fila { 
    display: flex; justify-content: space-between; align-items: center; 
    padding: 14px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.15); 
    cursor: pointer; transition: background 0.2s;
}
.dia-fila:hover { background: rgba(255, 255, 255, 0.05); }
.dia-nom { flex: 1.5; text-transform: capitalize; font-weight: 500; }
.dia-temps { flex: 1.5; text-align: right; font-weight: 500; }

/* --- DETALLES GRID --- */
.detalles-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 20px 0; }
.detalle-card { 
    background: var(--card-bg); backdrop-filter: var(--blur); 
    border-radius: 18px; padding: 12px 8px; border: 1px solid rgba(255, 255, 255, 0.2); text-align: center;
}
.detalle-card h3 { font-size: 0.55rem; opacity: 0.8; text-transform: uppercase; margin: 0; }
.detalle-valor { font-size: 1.1rem; font-weight: 600; margin-top: 6px; display: block; }

/* --- NAVEGACIÓN --- */
nav {
    position: fixed; bottom: 15px; left: 50%;
    transform: translateX(-50%);
    width: 95%; max-width: 500px;
    background: var(--nav-bg);
    backdrop-filter: blur(15px);
    display: flex; align-items: center;
    padding: 8px 5px; border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 9999;
}
#nav-indicator {
    position: absolute; height: 44px;
    background: var(--nav-indicator-bg);
    border-radius: 18px; top: 50%; transform: translateY(-50%);
    z-index: 0; transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 4px 15px var(--nav-indicator-shadow);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-decoration: none; color: var(--text-color);
    background: none !important; border: none !important; 
    position: relative; z-index: 1;
    transition: color 0.3s; opacity: 0.7;
}
.nav-item.active { color: var(--nav-text-active) !important; opacity: 1; font-weight: bold; }
.nav-icon { font-size: 1.2rem; }
.nav-label { font-size: 0.65rem; }

/* --- ALERTAS --- */
.alerta-card {
    border-radius: 20px; padding: 18px; margin: 15px 0 25px 0;
    color: #000 !important; text-shadow: none;
}

/* --- MODAL DETALLE --- */
#modal-detalle {
    position: fixed; bottom: -100%; left: 0; width: 100%; height: 85vh;
    background: linear-gradient(to bottom, #1a2a44, #0f172a); 
    border-top-left-radius: 30px; border-top-right-radius: 30px;
    z-index: 20000; transition: bottom 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    padding: 25px; box-sizing: border-box; overflow-y: auto; color: white;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
}
#modal-detalle.active { bottom: 0; }

#modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
    display: none; z-index: 19999;
}
#modal-overlay.active { display: block; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.btn-cerrar { background: rgba(255,255,255,0.1); border: none; color: white; font-size: 1.5rem; padding: 5px 15px; border-radius: 12px; cursor: pointer; }

.resumen-lluvia { 
    background: rgba(255,255,255,0.08); padding: 15px; border-radius: 15px; 
    margin-bottom: 20px; text-align: center; font-size: 0.9rem;
}
.resumen-lluvia strong { display: block; font-size: 1.4rem; color: #4facfe; margin-top: 5px; }

/* --- GRÁFICOS DE BARRAS (CORREGIDO) --- */
.chart-section { 
    margin-top: 25px; 
}

.chart-label { 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    opacity: 0.6; 
    display: block; 
    margin-bottom: 10px; 
}

.bar-row {
    display: flex; 
    flex-direction: row; /* Alineación horizontal */
    align-items: flex-end; /* Las barras crecen desde abajo */
    gap: 12px; 
    height: 160px; /* Altura fija para el gráfico */
    overflow-x: auto; /* Habilita el scroll horizontal */
    padding: 15px 10px; 
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    -webkit-overflow-scrolling: touch; /* Scroll suave en móviles */
}

/* Ocultar scrollbar pero mantener funcionalidad */
.bar-row::-webkit-scrollbar { 
    display: none; 
}
.bar-row { 
    scrollbar-width: none; 
}

.bar-item { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    min-width: 35px; /* Importante para que no se encojan */
    height: 100%;
    justify-content: flex-end; 
}

.bar { 
    width: 14px; 
    border-radius: 10px; 
    min-height: 2px; 
    transition: height 0.5s ease;
}

.bar-temp { background: linear-gradient(to top, #f6d365, #fda085); }
.bar-precip { background: linear-gradient(to top, #4facfe, #00f2fe); }

.bar-val { font-size: 0.7rem; margin-bottom: 5px; font-weight: bold; }
.bar-time { font-size: 0.6rem; margin-top: 8px; opacity: 0.5; }

/* --- OTROS --- */
.modal-full {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.85); /* Fondo oscuro detrás */
    backdrop-filter: blur(12px);
    z-index: 30000; 
    display: none; /* Se cambia a 'flex' por JS */
    align-items: center; 
    justify-content: center; 
    padding: 20px;
    box-sizing: border-box;
}
.seo-card {
    background: var(--card-bg); backdrop-filter: blur(10px);
    border-radius: 20px; padding: 20px; margin: 20px auto; max-width: 800px;
    border: 1px solid rgba(255, 255, 255, 0.1); font-size: 0.9rem; color: var(--text-color);
}
iframe { 
    width: 100%; 
    height: 600px; /* Aumentado de 450px a 600px */
    border: none; 
    display: block; 
    border-radius: 0 0 20px 20px;
}

.modal-privacitat-content {
    background: var(--bg-gradient); /* O un color sólido si prefieres */
    background-color: #2a5298; /* Color de respaldo */
    padding: 30px;
    border-radius: 25px;
    max-width: 450px;
    width: 100%;
    text-align: center;
    color: white;
    box-shadow: 0 15px 50px rgba(0,0,0,0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.privacitat-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.privacitat-lista {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    text-align: left;
}

.privacitat-lista li {
    margin-bottom: 12px;
    font-size: 0.95rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.btn-primari {
    background: #4facfe;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    transition: transform 0.2s;
}

.btn-primari:active {
    transform: scale(0.98);
}

.nota-peu {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-top: 15px;
}

/* --- CONTENEDOR DE MAPA --- */
.map-wrapper {
    position: relative;
    width: 100%;
}

/* Botón de Pantalla Completa */
.btn-fullscreen {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    font-size: 0.8rem;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-fullscreen:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Ajuste específico para móviles muy pequeños */
@media (max-height: 700px) {
    iframe { height: 500px; }
}

/* Estilos para el selector de radar */
.radar-selector {
    justify-content: center;
}

.btn-capa {
    background: var(--card-bg);
    backdrop-filter: var(--blur);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    flex: 1;
    max-width: 150px;
}

.btn-capa.active {
    background: var(--nav-indicator-bg);
    color: white;
    box-shadow: 0 4px 15px var(--nav-indicator-shadow);
    border: none;
}

.btn-capa:hover:not(.active) {
    background: rgba(255, 255, 255, 0.3);
}

/* Estilos para la barra de deslizamiento */
.modal-header {
    flex-direction: column; /* Alinea la barra arriba del título */
    gap: 15px;
    padding-top: 10px;
    cursor: grab;
}

.drag-handle {
    width: 40px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    margin: 0 auto;
}

/* Evitamos que el scroll interno del modal interfiera con el gesto si el usuario desliza desde arriba */
#modal-detalle {
    touch-action: pan-x pan-y; /* Permite control de gestos */
}