/* ==========================================
   CONFIGURACIÓ I VARIABLES (APPLE STYLE)
   ========================================== */
:root {
    --red: #059600;
    --bg: #000000;
    --glass: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.15);
    --text-main: #ffffff;
    --text-sec: #8e8e93;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.4;
    overflow-x: hidden;
}

/* Fons amb desenfocament dinàmic */
.bg-blur {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(circle at 0% 0%, rgba(52, 199, 89, 0.12), transparent 50%),
            radial-gradient(circle at 100% 100%, rgba(46, 204, 113, 0.08), transparent 50%);

    z-index: -1;
}

/* ==========================================
   ESTRUCTURA DE PÀGINES I CAPÇALERES
   ========================================== */
header {
    padding: 60px 25px 20px;
}

header h1 {
    font-size: 34px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -1px;
}

.subtitle {
    color: var(--red);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.page {
    display: none;
    padding-bottom: 140px;
}

.page.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   TARGETES GLASS I COMPTE ENRERE
   ========================================== */
.glass-card {
    background: var(--glass);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 0.5px solid var(--border);
    border-radius: 24px;
    margin: 0 20px 20px;
    padding: 20px;
}

.label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-sec);
    margin: 25px 25px 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#timer {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.t-unit span {
    display: block;
    font-size: 38px;
    font-weight: 800;
    color: #fff;
}

.t-unit label {
    font-size: 10px;
    color: var(--red);
    font-weight: 700;
    text-transform: uppercase;
}

/* ==========================================
   SCROLL HORITZONTAL I MINI CARDS
   ========================================== */
.scroll-x {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 0 20px;
    gap: 12px;
}

.scroll-x::-webkit-scrollbar { display: none; }

.event-mini-card {
    min-width: 170px;
    background: var(--glass);
    border: 0.5px solid var(--border);
    padding: 18px;
    border-radius: 22px;
    flex-shrink: 0;
}

.event-mini-card b {
    color: var(--red);
    font-size: 15px;
    display: block;
    margin-bottom: 4px;
}

.event-mini-card p {
    margin: 0;
    font-size: 13px;
    color: #eee;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================
   EL TEMPS (WIDGETS I DETALLS)
   ========================================== */
.weather-expanded { cursor: pointer; }

.label-mini { 
    font-size: 10px; 
    color: var(--text-sec); 
    font-weight: 800; 
    margin: 15px 0 10px; 
    text-transform: uppercase;
}

.weather-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.weather-box {
    background: rgba(255,255,255,0.03);
    padding: 15px;
    border-radius: 18px;
    border: 0.5px solid var(--border);
}

.weather-box label { 
    display: block; 
    font-size: 9px; 
    color: var(--text-sec); 
    margin-bottom: 4px; 
    font-weight: 700; 
}

.weather-box span { font-size: 16px; font-weight: 700; }

.hour-item {
    text-align: center;
    min-width: 55px;
    flex-shrink: 0;
}

.hour-item span { font-size: 11px; color: var(--text-sec); }
.hour-item b { font-size: 14px; display: block; margin-top: 2px; }

/* ==========================================
   PROGRAMACIÓ (SELECTOR DIES)
   ========================================== */
.day-tab {
    background: var(--glass);
    padding: 12px 22px;
    border-radius: 16px;
    border: 0.5px solid var(--border);
    white-space: nowrap;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-sec);
    transition: all 0.2s ease;
}

.day-tab.active {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

/* ==========================================
   DETALL A PANTALLA COMPLETA (MODAL)
   ========================================== */
.modal { 
    display: none; 
    position: fixed; 
    z-index: 10000; /* Per damunt de la Tab Bar i tot l'altre */
    left: 0; 
    top: 0; 
    width: 100%; 
    height: 100vh; 
    background: #000000; /* Fons sòlid, zero transparències */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: pageIn 0.3s ease-out;
}

@keyframes pageIn {
    from { transform: translateX(100%); } /* Entra des de la dreta com en iOS */
    to { transform: translateX(0); }
}

.modal-content { 
    width: 100%; 
    min-height: 100%;
    display: flex;
    flex-direction: column;
    background: #000;
}

.modal-header {
    width: 100%;
    background: #111;
    display: flex;
    flex-direction: column;
}

.modal-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(to top, #000, transparent);
}

.modal-img { 
    width: 100%;
    height: auto; /* Deja que la imagen mande sobre la altura */
    max-height: 60vh; /* Pero que no ocupe toda la pantalla */
    object-fit: contain; 
}

/* Botó de "Tornar" tipus fletxa, no una X de tancar finestra */
.close-modal { 
    position: absolute; 
    top: calc(40px + env(safe-area-inset-top, 0px)); 
    left: 20px; 
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.5); /* Fondo oscuro para que contraste con cualquier foto */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 14px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    z-index: 101; /* Asegúrate de que esté por encima de todo */
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0.5px solid rgba(255, 255, 255, 0.2); /* Un borde fino tipo cristal */
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.modal-body { 
    padding: 30px 25px 100px; /* Molt d'espai baix */
    background: #000;
    position: relative;
    flex-grow: 1;
}

.modal-body h2 { 
    font-size: 32px; 
    font-weight: 800; 
    margin: 0 0 15px 0; 
    color: #fff;
}

.event-time-badge {
    display: inline-flex;
    align-items: center;
    background: var(--red);
    color: white;
    padding: 8px 16px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 25px;
}

.modal-desc {
    font-size: 17px;
    line-height: 1.6;
    color: #a1a1a6; /* Gris tipus Apple */
}

/* ==========================================
   TAB BAR (NAVBAR INFERIOR)
   ========================================== */
.tab-bar {
    position: fixed;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    height: 70px;
    background: rgba(28, 28, 30, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 35px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border: 0.5px solid var(--border);
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.tab {
    background: none;
    border: none;
    font-size: 26px;
    opacity: 0.3;
    color: white;
    padding: 10px;
    transition: all 0.3s ease;
}

.tab.active {
    opacity: 1;
    filter: drop-shadow(0 0 8px var(--red));
}

.map-container {
    width: 100%;
    height: 250px;
    background: var(--glass);
    border-radius: 18px;
    overflow: hidden;
    border: 0.5px solid var(--border);
    margin-top: 10px;
}

.btn-map-sec {
    display: block;
    text-align: center;
    color: var(--text-sec);
    font-size: 13px;
    margin-top: 15px;
    text-decoration: none;
    font-weight: 600;
}

.btn-map-sec:active {
    color: var(--red);
}

/* AVISOS */
.avís-card {
    background: rgba(255, 152, 0, 0.15); /* Taronja suau */
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: 20px;
    margin: 0 20px 20px;
    padding: 15px 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    animation: pulse 2s infinite;
}

.avís-card.important {
    background: rgba(255, 59, 48, 0.15); /* Roig suau */
    border-color: rgba(255, 59, 48, 0.3);
}

.avís-icon { font-size: 24px; }
.avís-contingut b { display: block; font-size: 15px; color: #fff; margin-bottom: 2px; }
.avís-contingut p { margin: 0; font-size: 13px; color: #ccc; line-height: 1.3; }

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

.ads-container {
    margin: 20px;
    text-align: center;
}

.ads-placeholder {
    width: 100%;
    min-height: 100px; /* Alçada estàndard de banner mòbil */
    background: rgba(255, 255, 255, 0.03); /* Molt suau */
    border-radius: 15px;
    border: 0.5px dashed var(--border); /* Ratlletes per saber on va */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Estilos para el banner de instalación */
.install-card {
    border: 1px solid var(--red); /* Un toque de color para que resalte */
    margin-top: 10px;
    margin-bottom: 30px;
}

.btn-install-action {
    background: var(--red);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}

/* Ocultar en ordenadores (pantallas mayores a 1024px) */
@media (min-width: 1025px) {
    #install-container {
        display: none !important;
    }
}

.event-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass);
    padding: 15px;
    border-radius: 18px;
    margin-bottom: 12px;
    border: 0.5px solid var(--border);
    cursor: pointer;
}

.event-info {
    flex: 1; /* El texto ocupa todo el espacio menos la estrella */
}

.fav-button {
    font-size: 24px;
    color: var(--text-sec);
    padding: 10px;
    transition: transform 0.2s;
}
.fav-button.is-fav {
    color: #ffcc00; /* Color oro para favoritos */
    transform: scale(1.2);
}

.emergencies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.emergency-card {
    background: var(--glass);
    border: 0.5px solid var(--border);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 15px;
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
}

.emergency-icon { font-size: 24px; margin-right: 12px; }
.emergency-info b { display: block; font-size: 16px; }
.emergency-info p { margin: 0; font-size: 12px; color: var(--text-sec); }

.purple-point {
    background: rgba(160, 32, 240, 0.15);
    border-color: rgba(160, 32, 240, 0.3);
}

.fav-card {
    background: rgba(255, 204, 0, 0.1) !important;
    border: 0.5px solid rgba(255, 204, 0, 0.3) !important;
    min-width: 140px;
}

/* Para ocultar secciones suavemente */
section {
    transition: opacity 0.3s ease;
}

.fav-item {
    background: rgba(255, 204, 0, 0.1) !important; /* Un toque amarillento muy sutil */
    border: 0.5px solid rgba(255, 204, 0, 0.3) !important;
    min-width: 150px;
}

/* ==========================================
   BUSCADOR DE EVENTOS (APPLE GLASS STYLE)
   ========================================== */
.search-container {
    width: 100%;
}

#search-input {
    width: 100%;
    padding: 14px 18px;
    background: var(--glass);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 0.5px solid var(--border);
    border-radius: 18px;
    color: var(--text-main);
    font-size: 15px;
    font-weight: 500;
    outline: none;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#search-input::placeholder {
    color: var(--text-sec);
    font-weight: 400;
}

#search-input:focus {
    border-color: var(--red);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 12px rgba(5, 150, 0, 0.3);
}