/* ==========================================================================
   IW0RQH - SEZIONE SISMICA (Mappa & Terremoti)
   ========================================================================== */

/* 1. CONTENITORE MAPPA 
   -------------------------------------------------------------------------- */
#map { 
    height: 600px; 
    width: 100%; 
    border-radius: 12px; 
    z-index: 1; 
    background: #0a0a0a; /* Sfondo scuro preventivo al caricamento */
    border: 1px solid var(--border);
}

/* --- LEGENDA MAPPA SISMICA --- */
.info.legend {
    padding: 10px 15px;
    font-family: 'Inter', sans-serif;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    line-height: 1.5;
}

.info.legend h4 {
    margin: 0 0 8px 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.2);
}

/* ==========================================================================
   2. ANIMAZIONE ONDE (RIPPLE EFFECT) - DINAMICA E TRASPARENTE
   ========================================================================== */
.ripple-waves-only {
    position: absolute;
}

.ripple-waves-only::before,
.ripple-waves-only::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    opacity: 0;
    /* Dimensioni iniziali da cui partono le onde */
    width: 10px; 
    height: 10px;
    animation: wave-expand 2.5s infinite linear;
}

.ripple-waves-only::after { animation-delay: 1.25s; }

@keyframes wave-expand {
    0% { width: 10px; height: 10px; opacity: 1; }
    100% { width: 60px; height: 60px; opacity: 0; }
}

/* --- COLORI DINAMICI ONDE E TOOLTIP --- */
/* Livello 1: Giallo (Mag < 2.0) */
.ripple-level-1::before, .ripple-level-1::after { border: 2px solid #fcbf49; }
.mag-badge-1 { background-color: #fcbf49; color: #000; }

/* Livello 2: Arancio (Mag 2.0 - 2.9) */
.ripple-level-2::before, .ripple-level-2::after { border: 2px solid #f77f00; }
.mag-badge-2 { background-color: #f77f00; color: #fff; }

/* Livello 3: Rosso (Mag >= 3.0) */
.ripple-level-3::before, .ripple-level-3::after { border: 2px solid #d62828; }
.mag-badge-3 { background-color: #d62828; color: #fff; }

/* 3. POPUP LEAFLET (OVERRIDE SDR STYLE)
   -------------------------------------------------------------------------- */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: var(--card) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5) !important;
}

/* Respiro interno del popup e distanziamento dal tasto X */
.leaflet-popup-content {
    margin: 15px 28px 12px 15px !important; 
    line-height: 1.4;
}

/* Tasto di chiusura (X) - Posizionamento e Stile */
.leaflet-container a.leaflet-popup-close-button {
    color: var(--text-dim) !important;
    padding: 4px !important;
    top: 8px !important;
    right: 10px !important;
    font-size: 1.1rem !important;
    transition: color 0.2s ease;
}

.leaflet-container a.leaflet-popup-close-button:hover {
    color: var(--accent) !important;
}

/* 4. CONTENUTO INTERNO TOOLTIP (Dati Terremoto)
   -------------------------------------------------------------------------- */
.eq-popup-container { 
    min-width: 180px; 
    padding: 2px 0;
}

.eq-popup-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 10px;
    display: block;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-right: 10px; /* Protezione ulteriore dalla X */
}

.eq-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.eq-label { 
    color: var(--text-dim); 
    font-size: 0.7rem; 
    font-weight: 700; 
    text-transform: uppercase; 
}

.eq-value { 
    color: var(--text-main); 
    font-size: 0.85rem; 
    font-weight: 600; 
}

/* 4. CONTENUTO INTERNO TOOLTIP (Dati Terremoto) - Base Badge */
.mag-badge {
    padding: 2px 10px;
    border-radius: 4px;
    font-weight: 900;
    display: inline-block;
    font-family: 'Inter', monospace;
}

/* --- COLORI DINAMICI TOOLTIP E ONDE --- */
/* Livello 1: Giallo (Mag < 2.0) */
.ripple-level-1::before, .ripple-level-1::after { border: 2px solid #fcbf49; }
.mag-badge-1 { 
    background: rgba(252, 191, 73, 0.1) !important; 
    color: #fcbf49 !important; 
    border: 1px solid #fcbf49 !important; 
}

/* Livello 2: Arancio (Mag 2.0 - 2.9) */
.ripple-level-2::before, .ripple-level-2::after { border: 2px solid #f77f00; }
.mag-badge-2 { 
    background: rgba(247, 127, 0, 0.15) !important; 
    color: #f77f00 !important; 
    border: 1px solid #f77f00 !important; 
}

/* Livello 3: Rosso (Mag >= 3.0) */
.ripple-level-3::before, .ripple-level-3::after { border: 2px solid #d62828; }
.mag-badge-3 { 
    background: rgba(214, 40, 40, 0.2) !important; 
    color: #d62828 !important; 
    border: 1px solid #d62828 !important; 
    text-shadow: 0 0 8px rgba(214, 40, 40, 0.4); 
}

/* ==========================================================================
   5. STILI TABELLA TERREMOTI (SDR STYLE + SCROLL)
   ========================================================================== */

/* Contenitore con altezza fissa per ~10 righe e barra di scorrimento */
.radio-table-wrapper { 
    width: 100%; 
    max-height: 520px; /* Altezza calibrata per circa 10 eventi + Intestazione */
    overflow-y: auto; 
    border-radius: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    margin-top: 15px;
}

/* Scrollbar personalizzata stile SDR (Dark) */
.radio-table-wrapper::-webkit-scrollbar { width: 8px; }
.radio-table-wrapper::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 8px; }
.radio-table-wrapper::-webkit-scrollbar-thumb { background-color: var(--accent); border-radius: 8px; }

/* Formattazione base tabella */
.radio-table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0; 
    font-size: 0.9rem; 
}

/* Intestazione fissa (Sticky) in alto durante lo scroll */
.radio-table thead th {
    position: sticky; 
    top: 0;
    background: var(--card);
    z-index: 10;
    border-bottom: 2px solid var(--border);
    padding: 15px 10px;
    color: var(--text-dim); 
    font-size: 0.75rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Celle della tabella */
.radio-table td { 
    padding: 12px 10px; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); 
    color: var(--text-main); 
    text-align: center;
    vertical-align: middle;
}

/* Allineamento specifico per la colonna località */
.radio-table td:nth-child(4) { text-align: left; }

/* Effetto cliccabile sulla riga */
#eq-table tbody tr { 
    cursor: pointer; 
    transition: background-color 0.2s ease; 
}
#eq-table tbody tr:hover { 
    background-color: rgba(16, 185, 129, 0.15) !important; 
}

/* --- CLASSI DI FORMATTAZIONE DATI (Senza inline style) --- */
.td-date b { color: var(--text-main); font-weight: 700; margin-right: 5px; }
.td-date small { color: var(--text-dim); }
.td-utc { color: var(--text-dim); font-size: 0.85rem; }


.badge-call {
    background: rgba(255, 215, 0, 0.1); 
    color: #ffd700; 
    padding: 4px 10px; 
    border-radius: 6px; 
    border: 1px solid rgba(255, 215, 0, 0.2);
    font-weight: 700;
    font-size: 0.85rem;
}

.td-dist { color: var(--accent) !important; font-weight: 800; font-size: 1rem; }
.td-dist small, .td-depth small { font-size: 0.7rem; opacity: 0.7; font-weight: normal; }

/* Rende le righe della tabella terremoti chiaramente cliccabili */
#eq-table tbody tr {
    cursor: pointer;
    transition: all 0.2s ease;
}

#eq-table tbody tr:hover {
    background: rgba(16, 185, 129, 0.15) !important; /* Effetto hover Emerald */
}

/* Ottimizzazione colonne strette */
#eq-table th, #eq-table td {
    text-align: center;
    vertical-align: middle;
}

/* La colonna località la teniamo allineata a sinistra come nel logbook SDR */
#eq-table td:nth-child(4) {
    text-align: left;
}

/* --- CELLE MAGNITUDO DINAMICHE (TABELLA) --- */
.mag-cell {
    border-right: 1px dotted var(--border);
    border-left: 1px dotted var(--border);
    text-align: center;
}

.mag-cell small { font-size: 0.6rem; opacity: 0.8; margin-right: 3px; }
.mag-cell b { font-size: 1.1rem; font-weight: 900; }

/* I tre livelli di allerta */
.mag-level-1 { 
    color: #fcbf49 !important; 
    background: rgba(252, 191, 73, 0.1) !important; 
}
.mag-level-2 { 
    color: #f77f00 !important; 
    background: rgba(247, 127, 0, 0.15) !important; 
}
.mag-level-3 { 
    color: #d62828 !important; 
    background: rgba(214, 40, 40, 0.2) !important; 
    text-shadow: 0 0 8px rgba(214, 40, 40, 0.4); /* Effetto glow per le scosse forti */
}