/* =================================
   CONCORRENZA CLASSI - STILE MODERNO (v1.0.2)
   ================================= */

/* Header della pagina */
.competition-header {
    text-align: center;
    padding: 2rem 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-bottom: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}
.competition-header h1 { font-size: 2.5rem; font-weight: 800; margin: 0 0 0.5rem 0; text-shadow: 2px 2px 4px rgba(0,0,0,0.2); }
.competition-header p { font-size: 1.1rem; opacity: 0.95; margin: 0; font-weight: 400; }

/* SEZIONE DA CERCARE E SOSTITUIRE NEL TUO FILE */

/* ======================
   CARD DEL GRAFICO
   ====================== */
.chart-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    margin: 2rem 0;
    overflow: visible; /* CAMBIATO da hidden a visible */
    border: 1px solid rgba(255,255,255,0.2);
    position: relative;
    z-index: 1;
}

.chart-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
    z-index: 2;
}

.chart-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.chart-title h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 0.25rem 0;
}

.chart-title p {
    font-size: 0.875rem;
    color: #718096;
    margin: 0;
}

/* **FIX CURSORE E HOVER SUL BOTTONE** */
.chart-controls .btn-secondary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    pointer-events: auto; /* AGGIUNTO */
    z-index: 10; /* AGGIUNTO */
}

.chart-controls .btn-secondary:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* **FIX GRAFICO CHE TOCCA I BORDI** */
.chart-container {
    padding: 2.5rem 2rem 2rem 2rem;
    position: relative;
    height: 450px;
    box-sizing: border-box;
    pointer-events: auto; /* AGGIUNTO */
    z-index: 1;
}

#trend-chart {
    width: 100% !important;
    height: 100% !important;
    pointer-events: auto; /* AGGIUNTO */
    display: block; /* AGGIUNTO */
}

/* FILTRI - ASSICURA CHE SIANO CLICCABILI */
#chart-filters {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
    position: relative;
    z-index: 5; /* AGGIUNTO */
    pointer-events: auto; /* AGGIUNTO */
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    background: #f7fafc;
    color: #4a5568;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    pointer-events: auto; /* AGGIUNTO */
    z-index: 5; /* AGGIUNTO */
    position: relative;
}

.filter-btn:hover {
    border-color: #cbd5e0;
    background: #edf2f7;
    transform: translateY(-2px);
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.filter-btn svg {
    width: 16px;
    height: 16px;
    pointer-events: none; /* AGGIUNTO */
}

/* EFFETTI SPECIALI - DISABILITA SE CAUSA PROBLEMI */
.chart-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
    pointer-events: none; /* AGGIUNTO - CRITICO */
    z-index: 0; /* AGGIUNTO - SOTTO TUTTO */
}

.chart-card:hover::after {
    animation: shimmer 1.5s ease-in-out;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
        opacity: 0;
    }
}

/* Smooth scrolling per tutta la pagina */
html {
    scroll-behavior: smooth;
}

/* Focus states per accessibilità */
.btn-secondary:focus,
.leaderboard-item:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    pointer-events: auto; /* AGGIUNTO */
}

.filter-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* RESPONSIVE - ASSICURA CHE I FILTRI RESTINO CLICCABILI */
@media (max-width: 768px) {
    .chart-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        padding: 1rem 1.5rem;
    }
    
    .chart-container {
        padding: 2rem 1rem 1rem 1rem;
        height: 350px;
    }
    
    #chart-filters {
        margin-top: 12px;
        gap: 10px;
    }
    
    .filter-btn {
        flex: 1;
        min-width: 100px;
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* ======================
   GRIGLIA CLASSIFICHE
   ====================== */
.leaderboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.leaderboard-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.leaderboard-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

.leaderboard-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leaderboard-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
}

.league-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.league-badge.biennio {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.league-badge.triennio {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

/* ======================
   LISTA CLASSIFICA
   ====================== */
.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid #f7fafc;
    transition: all 0.2s ease;
    position: relative;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-item:hover .team-color-dot {
    transform: scale(1.3); /* Ingrandisce leggermente */
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.leaderboard-item .rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.875rem;
    margin-right: 1rem;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.leaderboard-item:nth-child(1) .rank {
    background: linear-gradient(135deg, #ffd700, #ffb347);
    color: #b45309;
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
    font-size: 1rem;
}

.leaderboard-item:nth-child(2) .rank {
    background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
    color: #4a5568;
    box-shadow: 0 4px 12px rgba(192, 192, 192, 0.4);
}

.leaderboard-item:nth-child(3) .rank {
    background: linear-gradient(135deg, #cd7f32, #b8860b);
    color: white;
    box-shadow: 0 4px 12px rgba(205, 127, 50, 0.4);
}

.team-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    border: 2px solid white;
    flex-shrink: 0; /* Impedisce che si schiacci */
    transition: all 0.3s ease; /* Aggiunge transizione smooth */
}

.team-info {
    flex: 1;
}

.team-name {
    font-weight: 600;
    font-size: 1rem;
    color: #2d3748;
    margin-bottom: 0.25rem;
}

.class-name {
    font-size: 0.875rem;
    color: #718096;
    font-weight: 500;
}

.score {
    font-weight: 700;
    font-size: 1.25rem;
    color: #667eea;
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    min-width: 60px;
    text-align: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

/* ======================
   ANIMAZIONI DI CARICAMENTO
   ====================== */
.loading-item {
    display: flex;
    align-items: center;
    padding: 1rem 2rem;
    color: #718096;
    font-style: italic;
}

.loading-animation {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Stato vuoto per le classifiche */
.empty-leaderboard {
    text-align: center;
    padding: 3rem 2rem;
    color: #718096;
}

.empty-leaderboard svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ======================
   RESPONSIVE DESIGN
   ====================== */
@media (max-width: 768px) {
    .competition-header {
        padding: 1.5rem 1rem;
        margin-bottom: 1.5rem;
        border-radius: 12px;
    }
    
    .competition-header h1 {
        font-size: 2rem;
    }
    
    .chart-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
        padding: 1rem 1.5rem;
    }
    
    .chart-container {
        padding: 2rem 1rem 1rem 1rem; /* Padding superiore maggiore anche su mobile */
        height: 350px;
    }
    
    .leaderboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin: 1.5rem 0;
    }
    
    .leaderboard-header {
        padding: 1rem 1.5rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .leaderboard-item {
        padding: 0.75rem 1.5rem;
    }
    
    .team-name {
        font-size: 0.9rem;
    }
    
    .score {
        font-size: 1.1rem;
        padding: 0.375rem 0.75rem;
    }
}

/* ======================
   EFFETTI SPECIALI
   ====================== */
.chart-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.chart-card:hover::after {
    animation: shimmer 1.5s ease-in-out;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
        opacity: 0;
    }
}

/* Smooth scrolling per tutta la pagina */
html {
    scroll-behavior: smooth;
}

/* Focus states per accessibilità */
.btn-secondary:focus,
.leaderboard-item:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Modal dettagli squadra */
.details-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.details-modal.active {
    opacity: 1;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.details-modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 0.25rem 0;
}

.modal-subtitle {
    font-size: 0.875rem;
    color: #718096;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: #718096;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f7fafc;
    color: #2d3748;
}

.modal-body {
    padding: 2rem;
    max-height: calc(85vh - 150px);
    overflow-y: auto;
}

.punteggio-totale {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    margin-bottom: 2rem;
}

.punteggio-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.punteggio-valore {
    font-size: 3rem;
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.eventi-container h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 1.5rem 0;
}

.evento-item {
    background: #f8fafc;
    border-left: 4px solid #667eea;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}

.evento-item:hover {
    background: #edf2f7;
    transform: translateX(4px);
}

.evento-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.evento-mese {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4a5568;
    text-transform: capitalize;
}

.evento-punti {
    font-size: 1rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

.evento-punti.positivo {
    background: #c6f6d5;
    color: #22543d;
}

.evento-punti.negativo {
    background: #fed7d7;
    color: #742a2a;
}

.evento-motivo {
    font-size: 1rem;
    color: #2d3748;
    font-weight: 500;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.evento-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #718096;
}

.no-eventi {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 2rem;
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-header,
    .modal-body {
        padding: 1.5rem;
    }
    
    .punteggio-totale {
        padding: 1.5rem;
    }
    
    .punteggio-valore {
        font-size: 2.5rem;
    }
    
    .evento-item {
        padding: 1rem;
    }
}

/* Hover effect sulle squadre nella classifica */
.leaderboard-item {
    transition: all 0.3s ease;
}

.leaderboard-item:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.leaderboard-item:active {
    transform: translateX(2px);
}

/* Controlli mese */
.mese-controls {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.mese-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.mese-label {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-right: 0.5rem;
}

.mese-valore {
    font-size: 1.125rem;
    font-weight: 700;
    text-transform: capitalize;
}

/* Modal per scroll interno */
.modal-overlay.active {
    overflow: hidden;
}

.modal-content {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-body {
    overflow-y: auto;
    flex: 1;
}

/* Stile per lista squadre mancanti */
.squadre-mancanti-list {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.squadre-mancanti-list ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1.5rem;
}

.squadre-mancanti-list li {
    color: #856404;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.avanzamento-success {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
}

.avanzamento-success h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
}

@media (max-width: 768px) {
    .mese-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .mese-display {
        text-align: center;
    }
}

/* Previeni scroll body quando modal attivo */
body.modal-open {
    overflow: hidden;
}

/* Assicura che il modal content scrolli */
.modal-overlay {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    margin: auto;
    max-height: 90vh;
    overflow-y: visible;
}

.modal-body {
    overflow-y: auto;
    max-height: calc(90vh - 120px);
}

/* Animazione spin per loading */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.header-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;  /* AGGIUNTO per centrare il contenuto */
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    font-weight: 600;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.header-button:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.header-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.header-button svg {
    flex-shrink: 0;
    display: block;  /* AGGIUNTO per eliminare spazi bianchi */
}

/* Mobile: mostra solo l'icona */
@media (max-width: 768px) {
    .header-button {
        padding: 10px;
        width: 40px;  /* LARGHEZZA FISSA */
        height: 40px;  /* ALTEZZA FISSA */
    }
    
    .header-button .button-text {
        display: none;
    }
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    color: #4a5568;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
    transform: translateY(-2px);
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.filter-btn svg {
    width: 16px;
    height: 16px;
}

/* ========== SIDEBAR BUTTONS IN HEADER ========== */
.main-header .sidebar-btn {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    text-decoration: none;
    font-size: 24px;
}

.main-header .sidebar-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.main-header .sidebar-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
    stroke-width: 2;
    fill: none;
}

@media (max-width: 768px) {
    .main-header .sidebar-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
}

#chart-filters {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 2px solid #e2e8f0;
    background: #f7fafc;
    color: #4a5568;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: #cbd5e0;
    background: #edf2f7;
    transform: translateY(-2px);
}

.filter-btn.active {
    background: #6610f2;
    color: #fff;
    border-color: #6610f2;
    box-shadow: 0 4px 12px rgba(102, 16, 242, 0.3);
}

.filter-btn svg {
    width: 16px;
    height: 16px;
}