/* ========================================
   TABELLA HEAD TO HEAD (SCONTRI DIRETTI)
   ======================================== */

/* Container tabella desktop */
.st-h2h-table-desktop {
    display: block;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 18px;
    padding: 0;
    max-width: 1200px;
    margin: 20px auto;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

/* Header della tabella */
.st-h2h-header {
    display: grid;
    grid-template-columns: 1fr 60px 30px 60px 1fr 90px;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(207, 174, 112, 0.15), rgba(207, 174, 112, 0.05));
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid var(--primary-color);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary-color);
    align-items: center;
}

/* Celle header */
.st-h2h-head-logo1,
.st-h2h-head-logo2 {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.st-h2h-head-gr-coachteam1,
.st-h2h-head-gr-coachteam2 {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.st-h2h-head-gr-h2h {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Righe dati */
.st-h2h-grid-row {
    display: grid;
    grid-template-columns: 1fr 60px 30px 60px 1fr 90px;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    align-items: center;
    transition: all 0.3s ease;
}

.st-h2h-grid-row:hover {
    background: rgba(207, 174, 112, 0.08);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.st-h2h-grid-row:last-child {
    border-radius: 0 0 8px 8px;
}

/* Colonne Logo */
.st-h2h-col-logo1,
.st-h2h-col-logo2 {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.st-h2h-col-logo1 img,
.st-h2h-col-logo2 img {
    width: 45px;
    height: 45px;
    object-fit: contain;
    padding: 3px;
    transition: all 0.3s ease;
}

/* Colonne Coach/Team */
.st-h2h-col-gr-coachteam1,
.st-h2h-col-gr-coachteam2 {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    min-width: 150px;
}

.st-h2h-col-team1,
.st-h2h-col-team2 {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    letter-spacing: 0.3px;
}

.st-h2h-col-coach1,
.st-h2h-col-coach2 {
    font-size: 0.85rem;
    color: var(--primary-color);
}

/* Colonna Head to Head */
.st-h2h-col-gr-h2h {
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    justify-content: center;
    align-items: center;
    background: rgba(207, 174, 112, 0.1);
    padding: 10px;
    border-radius: 6px;
}

.st-h2h-col-h2ht {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.st-h2h-col-h2hc {
    font-size: 0.85rem;
    color: var(--primary-color);
}

/* =====================================================
   TABELLA HEAD-TO-HEAD MATRIX (Stagione)
   Tabella con Nickname1 sulle righe, Nickname2 sulle colonne
   e valori WLD all'incrocio
   ===================================================== */

.st-h2h-matrix-table {
    background: rgba(0, 0, 0, 0.65);
    border-radius: var(--radius-lg);
    padding: 20px;
    max-width: 100%;
    margin: 20px auto;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
    overflow-x: auto;
}

/* Header della tabella */
.st-h2h-matrix-header {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 2px;
    margin-bottom: 2px;
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10;
}

/* Cella angolo vuota (in alto a sinistra) */
.st-h2h-matrix-corner {
    width: 1fr;
    background: rgba(31, 41, 55, 0.9);
    border-radius: 8px 0 0 0;
}

/* Header colonne (Nickname2) */
.st-h2h-matrix-head-col {
    background: rgba(31, 41, 55, 0.9);
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 12px 8px;
    text-align: center;
    border-radius: 8px 8px 0 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Righe della matrice */
.st-h2h-matrix-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 2px;
    margin-bottom: 2px;
}

/* Header riga (Nickname1) */
.st-h2h-matrix-row-header {
    width: 1fr;
    background: rgba(31, 41, 55, 0.9);
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 12px;
    text-align: left;
    display: flex;
    align-items: center;
    border-radius: 8px 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    left: 0;
    z-index: 5;
}

/* Celle della matrice (valori WLD) */
.st-h2h-matrix-cell {
    background: rgba(15, 23, 42, 0.6);
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 12px 8px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.st-h2h-matrix-cell:hover {
    background: rgba(207, 174, 112, 0.15);
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(207, 174, 112, 0.3);
}

/* Celle diagonali (stesso nickname) */
.st-h2h-matrix-cell-diagonal {
    background: rgba(31, 41, 55, 0.5);
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

.st-h2h-matrix-cell-diagonal:hover {
    background: rgba(31, 41, 55, 0.6);
    transform: none;
    box-shadow: none;
}

.st-h2h-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    margin-top: 30px;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(207, 174, 112, 0.4);
}

/* Prima sezione (prima tabella) non ha margine superiore */
.st-h2h-section-title:first-of-type {
    margin-top: 10;
}

.st-h2h-speech-bubble-icon {
    width: 28px;
    height: 28px;
    margin-left: 12px;
    vertical-align: middle;
    fill: var(--primary-color);
    display: inline-block;
}

/* =====================================================
   NUVOLETTA FUMETTO (Speech Bubble Icon)
   ===================================================== */

.st-h2h-speech-bubble-icon {
    width: 28px;
    height: 28px;
    margin-left: 12px;
    vertical-align: middle;
    fill: var(--primary-color);
    display: inline-block;
    cursor: pointer;
    transition: all 0.3s ease;
}

.st-h2h-speech-bubble-icon:hover {
    fill: #fff;
    transform: scale(1.15);
    filter: drop-shadow(0 0 8px var(--primary-color));
}

/* =====================================================
   POPUP LEGENDA H2H
   ===================================================== */

.st-legend-popup {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.st-legend-popup-content {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(31, 41, 55, 0.95));
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-lg);
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 50px rgba(207, 174, 112, 0.3), 0 0 100px rgba(0, 0, 0, 0.8);
    animation: kickoffZoom 0.4s ease-out;
}

.st-legend-close-popup {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.st-legend-close-popup:hover {
    color: #fff;
    transform: rotate(90deg) scale(1.2);
}

/* Grid della legenda */
.st-legend-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}

.st-legend-item {
    display: grid;
    grid-template-columns: 100px 30px 1fr;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 10px;
    border: 1px solid rgba(207, 174, 112, 0.2);
    transition: all 0.2s ease;
}

.st-legend-item:hover {
    background: rgba(31, 41, 55, 0.8);
    border-color: var(--primary-color);
    transform: translateX(5px);
}

.st-legend-key {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1rem;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.st-legend-arrow {
    color: var(--primary-color);
    font-size: 1.2rem;
    text-align: center;
    opacity: 0.6;
}

.st-legend-value {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: left;
}

/* Scrollbar personalizzata per il popup */
.st-legend-popup-content::-webkit-scrollbar {
    width: 8px;
}

.st-legend-popup-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.st-legend-popup-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.st-legend-popup-content::-webkit-scrollbar-thumb:hover {
    background: #fff;
}

/* Contenitore principale dei navigatori in stats.php */
.stats-nav {
    display: flex;
    /*justify-content: flex-start;*/
    /* Allineamento a sinistra per permettere lo scroll corretto */
    gap: 10px;
    padding: 10px 5px;
    margin-bottom: 1rem;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;

    justify-content: safe center;
    align-content: center;
}

.stats-nav.stats-second-level {
    background: transparent;
    /* Rimosso lo sfondo chiaro */
    border-radius: 0;
    /* Rimosso l'arrotondamento */
    padding: 10px 5px;
    /* Allineato al padding del primo livello */
    margin-top: -10px;
    /* Opzionale: riduce lo spazio tra i due navigatori */
}

/* Stile specifico per i bottoni dei navigatori stats */
.stats-tab-btn {
    flex: 0 0 auto;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Montserrat Alternates', sans-serif;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.stats-tab-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
}

.stats-tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.2);
}

/* Nasconde la scrollbar per un look più pulito */
.stats-nav::-webkit-scrollbar {
    height: 4px;
}

.stats-nav::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

#legendPopupTitle {
    margin-bottom: 12px;
}

/* ============================================
   MEDIA QUERIES PER MOBILE - HEAD TO HEAD
   Da aggiungere alla fine di style-stats-h2h.css
   ============================================ */

/* Tablet e smartphone (max-width: 768px) */
@media screen and (max-width: 768px) {
    
    /* =====================================================
       TABELLA H2H - NASCONDI LOGHI SU MOBILE
       Quando activeWeek != 0 && activeSeason != 0
       ===================================================== */
    
    /* Header tabella - Layout senza loghi (4 colonne invece di 6) */
    .st-h2h-header {
        grid-template-columns: 1fr 30px 1fr 80px;
        gap: 8px;
        padding: 10px 12px;
        font-size: 0.75rem;
    }
    
    /* Righe tabella - Layout senza loghi (4 colonne invece di 6) */
    .st-h2h-grid-row {
        grid-template-columns: 1fr 30px 1fr 80px;
        gap: 8px;
        padding: 12px;
    }
    
    /* NASCONDI le colonne logo su mobile */
    .st-h2h-head-logo1,
    .st-h2h-head-logo2,
    .st-h2h-col-logo1,
    .st-h2h-col-logo2 {
        display: none !important;
    }
    
    /* Ottimizzazione generale per mobile */
    .st-h2h-table-desktop {
        max-width: 100%;
        padding: 0;
        margin: 10px auto;
        border-radius: 12px;
    }
    
    /* Colonne Coach/Team più compatte */
    .st-h2h-col-gr-coachteam1,
    .st-h2h-col-gr-coachteam2 {
        min-width: auto;
        gap: 2px;
    }
    
    .st-h2h-col-team1,
    .st-h2h-col-team2 {
        font-size: 0.9rem;
    }
    
    .st-h2h-col-coach1,
    .st-h2h-col-coach2 {
        font-size: 0.75rem;
    }
    
    /* Colonna Head to Head */
    .st-h2h-col-gr-h2h {
        padding: 8px;
        gap: 2px;
    }
    
    .st-h2h-col-h2ht {
        font-size: 1rem;
    }
    
    .st-h2h-col-h2hc {
        font-size: 0.75rem;
    }
    
    /* Titoli sezioni */
    .st-h2h-section-title {
        font-size: 1.2rem;
        margin-top: 20px;
        margin-bottom: 15px;
        letter-spacing: 1.5px;
    }
    
    .st-h2h-speech-bubble-icon {
        width: 24px;
        height: 24px;
        margin-left: 8px;
    }
    
    /* =====================================================
       TABELLA MATRICE H2H - Ottimizzazione Mobile
       ===================================================== */
    
    .st-h2h-matrix-table {
        padding: 15px;
        margin: 15px auto;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Header colonne più compatto */
    .st-h2h-matrix-head-col {
        font-size: 0.75rem;
        padding: 10px 6px;
        letter-spacing: 0.3px;
    }
    
    /* Header righe più compatto */
    .st-h2h-matrix-row-header {
        font-size: 0.75rem;
        padding: 10px 8px;
        letter-spacing: 0.3px;
    }
    
    /* Celle matrice più compatte */
    .st-h2h-matrix-cell {
        font-size: 0.8rem;
        padding: 10px 6px;
    }
    
    /* Celle diagonali */
    .st-h2h-matrix-cell-diagonal {
        font-size: 0.75rem;
    }
    
    /* Popup legenda */
    .st-legend-popup-content {
        padding: 25px;
        max-width: 90%;
    }
    
    .st-legend-item {
        grid-template-columns: 90px 25px 1fr;
        gap: 10px;
        padding: 10px 14px;
    }
    
    .st-legend-key {
        font-size: 0.9rem;
    }
    
    .st-legend-value {
        font-size: 0.9rem;
    }
}

/* Smartphone piccoli (max-width: 480px) */
@media screen and (max-width: 480px) {
    
    /* =====================================================
       TABELLA H2H - Layout ancora più compatto
       ===================================================== */
    
    /* Header ancora più compatto - senza loghi */
    .st-h2h-header {
        grid-template-columns: 1fr 25px 1fr 75px;
        gap: 6px;
        padding: 8px 10px;
        font-size: 0.7rem;
    }
    
    /* Righe ancora più compatte - senza loghi */
    .st-h2h-grid-row {
        grid-template-columns: 1fr 25px 1fr 75px;
        gap: 6px;
        padding: 10px;
    }
    
    /* Colonne Coach/Team */
    .st-h2h-col-team1,
    .st-h2h-col-team2 {
        font-size: 0.85rem;
    }
    
    .st-h2h-col-coach1,
    .st-h2h-col-coach2 {
        font-size: 0.7rem;
    }
    
    /* Colonna Head to Head */
    .st-h2h-col-gr-h2h {
        padding: 6px;
    }
    
    .st-h2h-col-h2ht {
        font-size: 0.95rem;
    }
    
    .st-h2h-col-h2hc {
        font-size: 0.7rem;
    }
    
    /* Titoli sezioni */
    .st-h2h-section-title {
        font-size: 1.05rem;
        margin-top: 15px;
        margin-bottom: 10px;
        letter-spacing: 1px;
    }
    
    .st-h2h-speech-bubble-icon {
        width: 20px;
        height: 20px;
        margin-left: 6px;
    }
    
    /* =====================================================
       TABELLA MATRICE H2H - Smartphone piccoli
       ===================================================== */
    
    .st-h2h-matrix-table {
        padding: 10px;
        margin: 10px auto;
    }
    
    /* Header colonne */
    .st-h2h-matrix-head-col {
        font-size: 0.7rem;
        padding: 8px 4px;
        letter-spacing: 0.2px;
    }
    
    /* Header righe */
    .st-h2h-matrix-row-header {
        font-size: 0.7rem;
        padding: 8px 6px;
        letter-spacing: 0.2px;
    }
    
    /* Celle matrice */
    .st-h2h-matrix-cell {
        font-size: 0.75rem;
        padding: 8px 4px;
    }
    
    /* Celle diagonali */
    .st-h2h-matrix-cell-diagonal {
        font-size: 0.7rem;
    }
    
    /* =====================================================
       POPUP LEGENDA - Smartphone piccoli
       ===================================================== */
    
    .st-legend-popup-content {
        padding: 20px;
        max-width: 95%;
    }
    
    .st-legend-item {
        grid-template-columns: 75px 20px 1fr;
        gap: 8px;
        padding: 8px 12px;
    }
    
    .st-legend-key {
        font-size: 0.85rem;
    }
    
    .st-legend-value {
        font-size: 0.85rem;
    }
    
    .st-legend-close-popup {
        font-size: 28px;
        top: 10px;
        right: 15px;
    }
}

/* =====================================================
   NOTE IMPLEMENTAZIONE
   ===================================================== */

/*
IMPORTANTE: Le colonne logo sono SEMPRE nascoste su mobile 
(sia per max-width: 768px che per max-width: 480px)

La struttura si riduce da 6 colonne a 4 colonne:
- Desktop: Logo1 | Team1/Coach1 | VS | Logo2 | Team2/Coach2 | H2H
- Mobile:         Team1/Coach1 | VS |         Team2/Coach2 | H2H

Non è necessario aggiungere classi condizionali nel JavaScript,
le media queries nascondono automaticamente i loghi su schermi piccoli.

Se in futuro volessi mostrare i loghi su tablet ma non su smartphone,
potresti modificare così:

@media screen and (max-width: 768px) and (min-width: 481px) {
    // Loghi visibili su tablet
    .st-h2h-header {
        grid-template-columns: 50px 1fr 30px 50px 1fr 80px;
    }
}

@media screen and (max-width: 480px) {
    // Loghi nascosti su smartphone
    .st-h2h-head-logo1,
    .st-h2h-head-logo2,
    .st-h2h-col-logo1,
    .st-h2h-col-logo2 {
        display: none !important;
    }
}
*/