/*
 * style_fixed.css - Estilos completos y corregidos (Versión Final y Estable)
 * * Cambios aplicados:
 * 1. FIX DE DISTRIBUCIÓN: Fecha y Hora en una sola línea (Sustituye la antigua .top-data-strip).
 * 2. FIX DE DISTRIBUCIÓN: Franja de datos principal con 8 ítems en línea (dataRow1).
 * 3. FIX DE TAMAÑO DE IMAGEN: Las fotos del carrusel llenan el 100% del espacio (object-fit: cover).
 * 4. FIX DE ALTURA: La Galería y las Noticias tienen la misma altura en escritorio (align-items: stretch).
 * 5. FIX AÑADIDO (8 ITEMS POR FILA): Ajuste de Flexbox en .data-strip-item y #dataRowX para asegurar 8 items en la misma línea en escritorio.
 * 6. NUEVO FIX: HORA MÁS PEQUEÑA Y "ÚLTIMA LECTURA" A LA IZQUIERDA.
 * 7. ÚLTIMO FIX: Aumento de tamaño de "Última Lectura" a 1.4em y negrita.
 * 8. **NUEVO FIX: Estilo para la hora en Máxima y Mínima (`.time-detail`).**
 * 9. NUEVO: Estilos para el modal de lectura de noticias.
 * 10. **NUEVO: Estilos para el nuevo contenedor de noticias locales centrado (`.municipio-news-wrapper`).**
 */

/* ──────────────────────────────── */
/* 1. Estilos generales del cuerpo */
/* ──────────────────────────────── */
body {
    font-family: Arial, sans-serif;
    background: #f4f4f4;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ────────────────────────────────────── */
/* 2. Encabezado principal y Header Info */
/* ────────────────────────────────────── */
header {
    background-color: #1e3a8a; /* Azul oscuro */
    color: white;
    padding: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: sticky; /* Fija el header al hacer scroll */
    top: 0;
    z-index: 1000;
}

.header-info {
    display: flex;
    align-items: center;
    justify-content: space-between; 
    padding: 10px 20px;
    background-color: #003399; 
}

.header-info img {
    height: 50px; 
    margin-right: 15px;
    width: auto;
    max-height: none;
}
.bandera {
    height: 40px;
}

.header-info h1 {
    margin: 0;
    font-size: 1.6em; 
    font-weight: bold;
    color: white;
    text-shadow: none;
    position: static;
    transform: none;
    text-align: center; 
    flex: 1; 
}


/* ────────────────────────────────────── */
/* 3. Franja superior para Fecha y Hora (Última lectura) - MODIFICADO ESPACIADO */
/* ────────────────────────────────────── */

/* Contenedor principal para la fecha/hora y "Última lectura" */
.datetime-display-container {
    background-color: #000000;
    color: white;
    padding: 10px 15px; 
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* Wrapper para "Última lectura" y el bloque de Fecha/Hora */
.datetime-wrapper {
    display: flex;
    align-items: center; 
    justify-content: center; 
    position: relative; 
    max-width: 500px; 
    margin: 0 auto; 
    width: 100%;
}

/* Estilos para el texto de 'Última lectura' */
.datetime-wrapper .last-read-text {
    font-size: 1.4em; 
    font-weight: bold; 
    color: #fff; 
    /* Posicionamiento a la izquierda del bloque fecha/hora */
    position: absolute; 
    left: 0; 
    white-space: nowrap; 
}

/* El div interno que contiene la fecha y la hora */
.date-time-inner {
    display: flex; 
    align-items: baseline; 
    font-weight: bold;
    line-height: 1;
    /* Centramos el bloque fecha/hora y lo separamos de "Última lectura" */
    flex-grow: 1; 
    justify-content: center; 
    padding-left: 75px; /* ESPACIO GRANDE A LA IZQUIERDA */
}

/* Estilos específicos para la fecha */
.date-time-inner .date-display {
    margin-right: 30px; /* ESPACIO GRANDE ENTRE FECHA Y HORA */
    font-size: 1.6em; 
    color: #fff; 
}

/* Estilos específicos para la HORA */
.date-time-inner .time-display {
    font-size: 1.8em; 
    color: #fff; 
}


/* ────────────────────────────────── */
/* 4. Franja de Datos (.data-strip) */
/* ────────────────────────────────── */

.data-strip {
    display: flex;
    flex-direction: column; 
    padding: 0; 
    background-color: #000000; 
    color: white; 
    overflow-x: hidden;
}

.data-strip::-webkit-scrollbar {
    display: none;
}

.data-strip-item {
    width: 12.5%; 
    min-width: 80px; 
    flex-shrink: 0; 
    
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px 0px; 
    text-align: center;
    font-weight: bold;
    box-sizing: border-box;
    border-right: none; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#dataRow1 .data-strip-item {
    border-bottom: none; 
}

#dataRow2 .data-strip-item:nth-child(n+9) {
    border-bottom: none;
}


.data-strip-item .icon {
    font-size: 1.1em;
    line-height: 1;
    margin-bottom: 2px;
}

.data-strip-item .value {
    font-size: 1.8em; 
    font-weight: bold;
    line-height: 1.1;
}

/* Estilo específico para la hora de Máxima/Mínima */
.data-strip-item .value .time-detail {
    font-size: 0.5em; /* Tamaño pequeño para la hora */
    font-weight: normal;
    display: block; /* Asegura que vaya debajo del valor principal */
    line-height: 1;
    margin-top: 2px;
    color: #aaa;
}

.data-strip-item .title {
    font-size: 0.95em;
    font-weight: normal;
    opacity: 0.9;
}


/* ───────────────────────────── */
/* 5. Contenido principal */
/* ───────────────────────────── */
.main-content {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 15px;
    flex-grow: 1;
}


/* ───────────────────────────── */
/* 6. Animaciones (Mantenidas) */
/* ───────────────────────────── */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
}

/* ───────────────────────────── */
/* 7. Cámaras en vivo (.webcam-container) */
/* ───────────────────────────── */
.webcam-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px; /* Espacio extra para el nuevo bloque de noticias */
}

.webcam-card {
    flex: 1 1 45%;
    max-width: 500px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    text-align: center;
}

.webcam-card img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.webcam-card p {
    margin: 10px 0;
    font-size: 1em;
    font-weight: bold;
}

.webcam-card a {
    color: #1e3a8a;
    text-decoration: none;
}

.webcam-card a:hover {
    text-decoration: underline;
}

/* ───────────────────────────── */
/* 8. Contenedor de Noticias Locales (NUEVO) */
/* ───────────────────────────── */
.municipio-news-wrapper {
    max-width: 600px; /* Limita el ancho para centrar */
    margin: 0 auto 30px auto; /* Centrar y añadir margen */
    padding: 15px;
    background: #fff; 
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.municipio-news-wrapper .municipio-news-title {
    text-align: center;
    color: #cc3d00;
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #f4f4f4;
}

/* Los items dentro del contenedor local */
#municipioNews {
    padding: 5px 0;
}

/* ───────────────────────────── */
/* 9. Enlaces rápidos (.links-container) */
/* ───────────────────────────── */
.links-container {
    max-width: 800px;
    margin: 30px auto;
    padding: 20px 0;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

.links-container a img {
    width: auto;
    height: 45px;
    margin: 0;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.links-container a img:hover {
    opacity: 1;
}

/* ───────────────────────────── */
/* 10. Noticias y carrusel       */
/* ───────────────────────────── */
.media-news-wrapper {
  max-width: 1200px;
  margin: 40px auto;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.carousel-container,
.news-section {
  flex: 1 1 500px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  padding: 14px;
}

/* Carrusel */
.carousel-container {
  position: relative;
  overflow: hidden;
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.carousel-track {
  display: flex;
  transition: transform 0.6s ease;
  height: 100%;
}

.carousel-item {
  flex: 0 0 100%;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  background: rgba(0,0,0,0.4);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
}

.carousel-btn.left { left: 10px; }
.carousel-btn.right { right: 10px; }

.news-section h2 { text-align: center; margin-top: 0; }

.feed-selector { text-align: center; margin: 20px; }
.feed-selector select { padding: 5px 10px; font-size: 1em; }

.news-item { border-bottom: 1px solid #ddd; padding: 10px 0; }
.news-item:last-child { border-bottom: none; }
.news-item a { color: #0077cc; text-decoration: none; font-weight: bold; }
.news-item a:hover { text-decoration: underline; }
.news-date { font-size: 0.85em; color: #777; }

iframe[name="iframe_aemet_id33044"] {
    width: 100%;
    height: 200px;
    border: 1px solid #ccc;
    border-radius: 8px;
    display: block;
    margin-top: 20px;
    margin-bottom: 0px !important; 
}

/* ───────────────────────────── */
/* 11. Pie de página */
/* ───────────────────────────── */
footer {
    text-align: center;
    padding: 15px;
    background: #333;
    color: white;
    font-size: 0.9em;
    margin-top: auto;
}

/* ───────────────────────────── */
/* 12. Estilos de EstacionInfo (Sobre esta estación) */
/* ───────────────────────────── */
#estacionInfo h2 {
    color: #1e3a8a;
}
#estacionInfo p {
    margin-bottom: 10px;
}

/* ───────────────────────────── */
/* 13. Responsive */
/* ───────────────────────────── */
@media (max-width: 900px) {
    .media-news-wrapper { 
        flex-direction: column;
        flex-wrap: wrap;
    }
    .carousel-container,
    .news-section {
        flex: none;
        width: 100%;
    }
    
    .data-strip-item {
        width: calc(25% - 10px); 
        min-width: 90px;
    }
    
    #dataRow1 .data-strip-item {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    #dataRow1 .data-strip-item:nth-child(n+5) { 
        border-bottom: none;
    }
    #dataRow2 .data-strip-item {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    #dataRow2 .data-strip-item:nth-child(n+5) { 
        border-bottom: none;
    }
}

@media (max-width: 600px) {
    .header-info {
        flex-direction: column;
        text-align: center;
        padding: 10px;
    }

    .header-info h1 {
        font-size: 1.3em;
        margin-top: 5px;
    }
    .bandera {
        height: 30px;
    }

    .webcam-container {
        flex-direction: column;
        gap: 15px;
    }

    .webcam-card {
        width: 100%;
        max-width: none;
    }
    
    .data-strip-item {
        width: calc(25% - 10px);
    }
    
    .center-item {
        font-size: 1em;
        padding: 10px 0;
    }
    
    /* Responsive para la fecha/hora en pantallas pequeñas */
    .datetime-wrapper {
        flex-direction: column; /* Apila "Última lectura" y la fecha/hora */
        align-items: center;
        padding: 5px 0;
    }
    .datetime-wrapper .last-read-text {
        position: static; /* Restablece el posicionamiento */
        margin-right: 0;
        margin-bottom: 5px; /* Espacio debajo del texto */
        font-size: 1em; /* Reducimos el tamaño en móvil */
        color: #fff;
    }
    .date-time-inner {
        flex-grow: 0; 
        padding-left: 0; 
    }
    .date-time-inner .date-display {
        font-size: 1.2em; 
        margin-right: 20px; /* Reducido para móvil, pero suficiente */
    }
    .date-time-inner .time-display {
        font-size: 1.4em; 
    }

    .data-strip-item .value {
        font-size: 1.5em; 
    }
    .data-strip-item .title {
        font-size: 0.8em;
    }
}

/* --- Ajustes de las filas de datos - FIX para 8 ítems en línea --- */
#dataRow1, #dataRow2 {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between; 
  gap: 0px; 
  background: #000;
  padding: 6px 10px; 
}
.toggle-container {
  text-align: center;
  background: #000;
  padding: 4px 0 10px 0; 
}
.toggle-btn {
  background: #cc3d00;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.3s;
}
.toggle-btn:hover { background: #e34d00; }


/* ───────────────────────────── */
/* 14. Estilos para Noticias del Municipio */
/* ───────────────────────────── */
.municipio-item {
    padding: 15px 10px;
    background: #e6f7ff; /* Fondo azul claro para distinguirlo */
    border-left: 5px solid #1e3a8a; /* Barra lateral azul */
    border-bottom: 1px solid #cceeff !important; 
    border-radius: 4px;
    margin-bottom: 10px;
    /* Se elimina el borde inferior y padding de la sección antigua, ahora gestionado por el wrapper */
}
/* Estilo para el título de la noticia (que ahora es el único elemento visible y clicable) */
.municipio-item .municipio-title {
    color: #1e3a8a;
    font-size: 1.1em;
    font-weight: bold;
    margin: 0 0 5px 0;
    cursor: pointer;
    transition: color 0.2s;
}
.municipio-item .municipio-title:hover {
    color: #cc3d00;
    text-decoration: underline;
}

/* Ajuste para separar RSS de Noticias Locales */
.feed-rss-wrapper {
    padding-top: 15px; /* Espacio si hay noticias locales arriba */
}

/* ───────────────────────────── */
/* 15. Estilos para el MODAL de Noticias (NUEVOS) */
/* ───────────────────────────── */
.modal {
    display: none; 
    position: fixed; 
    z-index: 10000; /* Alto para que esté sobre todo */
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.7); /* Fondo oscuro transparente */
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; /* 10% desde arriba y centrado horizontalmente */
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Ancho en escritorio */
    max-width: 600px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.modal-content h3 {
    color: #1e3a8a;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
    margin-top: 0;
}

.modal-content #modalBody {
    margin-top: 15px;
    line-height: 1.6;
    color: #333;
    /* Estilo para los saltos de línea (<br />) generados por nl2br */
    white-space: pre-wrap; 
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 5px;
    right: 15px;
}

.close-btn:hover,
.close-btn:focus {
    color: #cc3d00;
    text-decoration: none;
    cursor: pointer;
}

/* Ajuste responsive para el modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
}
/*
 * NUEVOS ESTILOS PARA NOTICIAS CON IMAGEN (Miniatura)
 * ----------------------------------------------------
 */
.municipio-item {
    display: flex; 
    align-items: center;
    border-bottom: 1px solid #eee;
    padding: 8px 0;
}
.news-image-thumb {
    width: 80px; 
    height: 60px;
    flex-shrink: 0; 
    margin-right: 15px;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer; /* Indica que la imagen es clicable */
}
.news-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Asegura que la imagen cubra el espacio sin deformarse */
}
.news-content-wrapper {
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
}
.municipio-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: bold;
    color: #1e3a8a;
    transition: color 0.2s;
}
.municipio-title:hover {
    color: #cc3d00;
}

@media (max-width: 600px) {
    .news-image-thumb {
        width: 60px;
        height: 45px;
        margin-right: 10px;
    }
}