/* ============================================================
   RESET E BASE
   ============================================================ */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #363636;
    padding: 10px;
    color: white;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
    width: 100%;
    background-color: rgba(255,255,255,0.6);
    background-image: url('../ondona1.png');
    background-repeat: no-repeat;
    background-size: cover;
    color: #388bfd;
    padding: 10px 20px;

    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 32px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

header img {
    height: 100px;
    background: white;
    padding: 8px;
}

/* ============================================================
   LAYOUT PRINCIPALE
   ============================================================ */
#layout {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: calc(100vh - 140px);
    gap: 10px;
    position: relative;
	margin-top: 10px;



#left-panels-container {
    display: flex;
    flex-direction: column;
    width: 250px;          /* ← IMPORTANTE: riserva spazio */
    gap: 10px;

    /* NON deve essere absolute */
    position: relative;

    z-index: 200;         /* sopra la mappa ma NON blocca la mappa */
    pointer-events: auto;  /* pannello cliccabile */
}

#left-panel,
#left-panel1 {
    pointer-events: auto;
}


#map-container {
    flex-grow: 1;
    position: relative;
}

/* ============================================================
   MAPPA
   ============================================================ */
#map {
	
    width: 100%;
    height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
	 position: relative;  /* ← NON absolute!!! */
}

.leaflet-tile {
    border: none !important;
}

.leaflet-layer,
.leaflet-tile-container,
.leaflet-tile-pane {
    background: #000 !important;
}

/* ============================================================
   PANNELLI SINISTRA (indicatori)
   ============================================================ */
#left-panel,
#left-panel1 {
    background: #808080;
    padding: 10px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: white;
}



.indicator-card,
.indicator-card-spiagge {
    background: #363636;
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);

    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.indicator-label {
    font-size: 15px;
    font-weight: bold;
}

.indicator-value {
    font-size: 80px;
    font-weight: bold;
    color: white;
}

/* ============================================================
   PANNELLO DESTRO
   ============================================================ */
#right-panel {
    width: 420px;
    background: #808080;
    padding: 10px;
    border-radius: 12px;
    overflow-y: auto;
	gap:6px;
}

/* ============================================================
   SWITCH (toggle)
   ============================================================ */
.switch {
    position: relative;
    width: 48px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #bbb;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    content: "";
    height: 18px;
    width: 18px;
    position: absolute;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: .3s;
}

input:checked + .slider {
    background-color: #3fa7ff;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* ============================================================
   BOX TOGGLE + LEGENDA
   ============================================================ */
.legend-toggle-multi {
    display: flex;
    align-items: center;
    justify-content: space-between;

    background:#363636;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 6px;

    font-size: 15px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    gap: 8px;
}


.legend-items {
	display: flex;
	flex-direction: column;
	gap: 6px;
}


.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;              /* 👈 aumenta lo spazio tra quadratino e label */
    width: 100%;
}

.legend-row span {
    flex-grow: 1;           /* 👈 permette alla label di respirare */
    text-align: right;      /* 👈 mantiene allineamento a destra */
    font-size: 11px;
}
.legend-box {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid #777;
	gap:6;
}

.legend-label {
    flex-grow: 1;
    text-align: right;
	
}

/* === CONTENITORE LEGENDA STORM — versione stabilizzata === */

.storm-legend-wrapper {
    display: flex;
    flex-direction: column;     /* uno sopra l’altro */
    align-items: center;        /* 🔥 CENTRA TUTTO ORIZZONTALMENTE */
    justify-content: center;
    
    width: 50px;                /* 🔥 larghezza fissa → nessuna compressione */
    min-width: 50px;
    flex-shrink: 0;

    padding: 0;
    margin: 0;
}


/* === BARRA VERTICALE === */

.storm-gradient {
    width: 16px;
    height: 60px;              /* puoi adattare */
    background: linear-gradient(to bottom, #ff0000, #ffff00, #00ff00);
    border-radius: 6px;
    margin: 0;
}



.storm-gradient1 {
    width: 16px;
    height: 60px;              /* puoi adattare */
    background: linear-gradient(to bottom, #35b779, #31688e, #440154);
    border-radius: 6px;
    margin: 0;
}




/* === VALORI MIN E MAX === */

.storm-legend-value {
    font-size: 13px;
    color: white;
    margin: 0;
    padding: 0;
    line-height: 1;
    text-align: center;
    width: 100%;                /* 🔥 il valore si allinea alla barra */
    display: block;
}


/* === UNITÀ DI MISURA === */

.storm-legend-unit {
    font-size: 11px;
    color: white;
    margin-top: 2px;
    line-height: 1;
    text-align: center;
    width: 100%;                /* 🔥 allineato al centro */
}

/* ============================================================
   MENU A TENDINA EVENTI
   ============================================================ */
   
.event-legend-wrapper {
    padding: 4px;
    margin-bottom: 4px;
   
}
   
   
   
.event-menu-container {
    background: #7d7d7d;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 4px;
    font-weight: 600;
}

#eventoSelect {
    width: 100%;
    background: #222;
    color: white;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #555;
    margin-top: 4px;
}

#eventoVarSelect {
    width: 100%;
    background: #222;
    color: white;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #555;
    margin-top: 4px;
}

#scenario-select {
    width: 100%;
    background: #222;
    color: white;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #555;
    margin-top: 4px;
}


#scenario-select-water-level {
    width: 100%;
    background: #222;
    color: white;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #555;
    margin-top: 4px;
}    
    
#scenario-select-runup {
    width: 100%;
    background: #222;
    color: white;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #555;
    margin-top: 4px;
}    

#scenario-select-wavepower {
    width: 100%;
    background: #222;
    color: white;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #555;
    margin-top: 4px;
}        


#eventi-dynamic-toggle {
    background: #7d7d7d;
    border-radius: 10px;
    padding: 4px;
}


.event-legend-box {
    width: 10px;
    height: 10px;
    border-radius: 4px;
    margin-right: 6px;
}

.event-legend-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.event-legend-label {
    font-size: 12px;
    margin-left: 4px;
}







/* =====================================================
   LEGENDA SOVRALZO
   ===================================================== */

.water-level-legend.horizontal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #222; /* o il colore del tuo pannello */
    padding: 8px;
    gap: 10px;
    border-radius: 4px;
}

#water-level-gradient {
    flex: 1;
    min-width: 120px;
    height: 14px;

    border: 1px solid rgba(100, 100, 100, 0.7);
    border-radius: 7px;

    /* Massimo rosso a sinistra, minimo blu a destra */
    background: linear-gradient(
        to right,
        #B2182B 0%,
        #D6604D 12.5%,
        #F4A582 25%,
        #FDDBC7 37.5%,
        #FFFFBF 50%,
        #C7EAE5 62.5%,
        #5AB4AC 75%,
        #2166AC 87.5%,
        #053061 100%
    );
}

.water-level-value {
    min-width: 38px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.water-level-unit {
    font-size: 12px;
    white-space: nowrap;
}












    

/* ============================================================
   POPUP BASE
   ============================================================ */

/* popup sopra tutti i layer */
.leaflet-popup,
.leaflet-popup-pane {
    z-index: 99999 !important;
}

/* popup piccoli */
.leaflet-popup-content-wrapper.popup-small {
    padding: 8px !important;
}

.popup-small table td {
    padding: 2px 4px;
}

/* ============================================================
   POPUP GRANDI (grafici)
   ============================================================ */

.popup-large canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 350px;
    object-fit: contain;
}


.popup-large .leaflet-popup-content-wrapper {
    max-width: 700px !important;
    width: 600px !important;
}

.popup-large .leaflet-popup-content {
    width: 500px !important;
}




/* ============================================================
   POPUP MEDI (grafici mareggiate)
   ============================================================ */


/* POPUP MEDIO — mareggiate */
.popup-medium .leaflet-popup-content-wrapper {
    max-width: 500px !important;  /* popup stretto */
    width: auto !important;
}

.popup-medium .leaflet-popup-content {
    width: auto !important;
}

.popup-medium canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 200px;
    object-fit: contain;
}



/* ============================================================
   TABS DENTRO I POPUP (se usati)
   ============================================================ */

.tabs-container {
    width: 100%;
}

.tabs-header {
    display: flex;
    border-bottom: 1px solid #ccc;
    margin-bottom: 6px;
}

.tab-button {
    flex: 1;
    padding: 6px;
    cursor: pointer;
    background: #ddd;
    border: none;
    font-weight: bold;
    color: #003f7f;
}

.tab-button.active {
    background: #fff;
    border-bottom: 2px solid #fff;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ============================================================
   LAYER TURISMO – garantire click su poligoni
   ============================================================ */

.leaflet-pane.turismoPane,
.leaflet-pane.turismoPane * {
    pointer-events: auto !important;
    cursor: pointer !important;
}


/* ============================
   FIX COLORI PER LEAFLET-MEASURE
   ============================ */

/* Contenitore pannello (quello che si apre) */
.leaflet-control-measure {
    background: #fff !important;   /* sfondo bianco */
    color:  #2b2b2b !important;           /* testo scuro */
}

/* NON sovrascrivere lo sfondo dell’icona */
.leaflet-control-measure-toggle {
    border: 1px solid #444 !important;
    background-size: 20px 20px !important; /* mantiene ben visibile l’icona */
    background-repeat: no-repeat !important;
    background-position: center !important;
}

.leaflet-control-measure-toggle svg path {
    stroke: black !important;
}

/* Quando il pulsante è attivo */
.leaflet-control-measure-toggle.active {
    background: white!important;
}

/* Testo dei pulsanti ("Start", "Finish", "Cancel") */
.leaflet-control-measure-actions a {
    background: #1e90ff !important;         /* blu leggibile */
    color: #fff !important;                 /* testo bianco */
    border: 1px solid #0c4a80 !important;
    font-weight: bold;
}

/* Hover */
.leaflet-control-measure-actions a:hover {
    background: #106fca !important;
    color: #fff !important;
}

/* Il pannello del tool */
.leaflet-control-measure-interaction {
    background: white !important;
    color: black !important;
}

/* Testo dei risultati (lunghezza, area) */
.leaflet-control-measure-resultmeasure-area,
.leaflet-control-measure-resultmeasure-length,
.leaflet-measure-path-measure {
    color: #fff !important;
    font-weight: bold;
}

/* Tooltip mentre si misura */
.leaflet-control-measure-tooltip {
    background: rgba(40,40,40,0.9) !important;
    color: white !important;
    border: 1px solid #aaa !important;
}

/* Linea disegnata durante la misura */
.leaflet-measure-path {
    stroke: #ffcc00 !important;  /* giallo visibile */
    stroke-width: 3px !important;
}

/* Vertici punti durante la misura */
.leaflet-measure-path-node {
    fill: #ffcc00 !important;
    stroke: #000 !important;
}





.leaflet-turismoPane-pane,
.leaflet-turismoPane-pane * {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/*

.arrow-icon {
    pointer-events: none !important;   non blocca i click sulle palline

}*/

/* 
.arrow {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 12px solid black;  /* colore freccia 
    transform-origin: center bottom;
    position: absolute;
    top: 0px;
    left: 5px;
}

*/
.event-icon {
    position: relative;
    width: 26px;
    height: 26px;
}

/* pallino centrato */
.event-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* freccia: base in basso, punta in alto */
.event-arrow {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;

    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 10px solid black; /* triangolo che punta verso l’alto */

    transform-origin: 50% 100%; /* origine = centro della base del triangolo */
}
