/* ── RESET GENERAL ── */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
    background: #d4e8f5;
    font-size: 13px;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

/* ── CAPÇALERA ── */
#header {
    background: #1a5276;
    color: #fff;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 3px solid #ec2e00;
    flex-shrink: 0;
    flex-wrap: wrap;
    min-height: 46px;
}
#header .logo { font-size: 18px; font-weight: bold; letter-spacing: 1px; white-space: nowrap; }
#header .logo span { color: #aad4f5; font-size: 10px; font-weight: normal; margin-left: 5px; }
#header .header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* ── COMPTADOR ENRERE ── */
#countdown-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    padding: 3px 10px;
    font-size: 11px;
    color: #f39c12;
}
#countdown-wrap .cd-label { color: #aad4f5; font-size: 9px; text-transform: uppercase; }
#countdown-val { font-weight: bold; font-size: 13px; font-family: 'Courier New', monospace; }

.btn-pro {
    background: #3a9fff; color: white; padding: 6px 12px; border: none;
    border-radius: 4px; cursor: pointer; font-weight: bold; font-size: 11px;
    transition: background .2s;
}
.btn-pro:hover { background: #2980b9; }

/* ── BARRA VARIABLES ── */
#varbar { background: #1a5276; border-bottom: 3px solid #ec2e00; flex-shrink: 0; }
.var-group-header {
    background: linear-gradient(to right, #1a5276, #2471a3);
    color: #fff; padding: 6px 12px; font-size: 11px; font-weight: bold;
    text-transform: uppercase;
}
.var-group-content { padding: 8px; display: flex; flex-wrap: wrap; gap: 4px; background: #154360; }

.var-btn {
    background: #2c3e50; color: #ecf0f1; border: 1px solid #34495e;
    padding: 5px 12px; cursor: pointer; font-size: 11px; border-radius: 4px;
}
.var-btn.active {
    background: #e67e22; color: #fff; border-color: #d35400; font-weight: bold;
}

/* ── LAYOUT PRINCIPAL ── */
#main { 
    flex: 1; 
    display: flex; 
    overflow: hidden; 
    min-height: 0; 
}

/* ── BARRA D'HORES LATERAL ── */
#hourbar {
    background: #fff; border-right: 1px solid #aab8c2; width: 62px;
    display: flex; flex-direction: column; overflow-y: auto;
    flex-shrink: 0;
}
.hour-column-title {
    font-size: 9px; font-weight: bold; text-align: center; padding: 5px 0;
    background: #f4f4f4; color: #555; border-bottom: 1px solid #ddd;
    position: sticky; top: 0; z-index: 10;
}
.hour-link {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    height: 35px; font-size: 11px; cursor: pointer; color: #1a5276;
    border-bottom: 1px solid #f9f9f9; border-left: 3px solid transparent;
    font-weight: bold;
}
.hour-link:hover { background: #d6eaf8; }
.hour-link.active { background: #ebf5fb; color: #2980b9; border-left: 3px solid #e67e22; }
.hour-dot { width: 6px; height: 6px; border-radius: 50%; background: #aab8c2; }
.hour-link.active .hour-dot { background: #e67e22; }

/* ── ZONA MAPA ── */
#mapzone { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    position: relative; 
    background: #fff;
}

#animbar {
    padding: 6px 12px; display: flex; align-items: center;
    gap: 8px; background: #fff; border-bottom: 1px solid #ddd;
}
#animbar a {
    background: #ecf0f1; color: #2c3e50; border: 1px solid #bdc3c7;
    padding: 3px 10px; border-radius: 3px; cursor: pointer; font-size: 11px;
    text-decoration: none;
}
#curTime { font-size: 13px; font-weight: bold; color: #ec2e00; margin-right: 10px; }

/* ── CONTENIDOR LEAFLET ── */
#canvas-wrap {
    flex: 1;
    position: relative; /* Important per Leaflet */
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    background: #ffffff;
}

/* ── LLEGENDA ── */
#legend {
    position: absolute; bottom: 20px; right: 20px;
    background: rgba(255,255,255,0.9); backdrop-filter: blur(5px);
    border: 1px solid #ccc; padding: 10px; border-radius: 8px;
    width: 280px; z-index: 1000; box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.leg-title { display: block; font-weight: bold; font-size: 10px; margin-bottom: 5px; text-align: center; }
#leg-bar { height: 12px; display: flex; border-radius: 2px; overflow: hidden; border: 1px solid #999; }
.leg-seg { flex: 1; height: 100%; }
#leg-ticks { display: flex; justify-content: space-between; margin-top: 4px; }
.leg-tk { font-size: 9px; color: #333; font-weight: bold; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
    #header .logo { font-size: 14px; }
    #hourbar { width: 50px; }
    #legend { width: 200px; bottom: 10px; right: 10px; }
}




#loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: #0a1628; /* Mateix color que el fons del mapa */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s;
}

#loader-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

#loader-progress {
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
}

