/* ===============================
   STILE BASE GENERALE
   =============================== */

body {
    font-family: "Segoe UI", Roboto, sans-serif;
    background: #f4f6f7;
    margin: 0;
    padding: 20px;
    color: #2c3e50;
}

h1, h2, h3 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 10px;
}

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.2s, transform 0.1s;
}

button:hover {
    background: #2980b9;
}

button:active {
    transform: scale(0.95);
}

/* ===============================
   CONTENITORI PRINCIPALI
   =============================== */

#lista-gruppi, #lista-studenti, #lista-sorteggiati {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

#lista-studenti {
    min-height: 50px;
}

/* ===============================
   GRUPPI
   =============================== */

.gruppo {
    padding: 10px;
    margin: 6px 0;
    background: #ecf0f1;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    font-weight: bold; /* Aggiunto per grassetto */
}

.gruppo:hover {
    background: #dfe6e9;
}

.btn-modifica {
    background: #f39c12;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-modifica:hover {
    background: #e67e22;
}


/* ===============================
   STUDENTI — CARD
   =============================== */

.studente-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ecf0f1;
    padding: 12px;
    margin: 6px 0;
    border-radius: 8px;
    transition: background 0.3s, transform 0.2s;
}

.studente-item:hover {
    transform: translateX(4px);
}

/* Stato: badge cliccabile */
.stato-cliccabile {
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s, color 0.3s, transform 0.2s;
}

/* Libero */
.libero .stato-cliccabile {
    background: #2ecc71;
    color: white;
}

.libero .stato-cliccabile:hover {
    background: #27ae60;
    transform: scale(1.05);
}

/* Interrogato */
.interrogato {
    opacity: 0.75;
}

.interrogato .stato-cliccabile {
    background: #e74c3c;
    color: white;
}

.interrogato .stato-cliccabile:hover {
    background: #c0392b;
    transform: scale(1.05);
}

/* Nome studente */
.nome-studente {
    font-size: 1.1em;
    font-weight: 600;
}

/* Data */
.data-sorteggio {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-left: 10px;
}

.btn-elimina {
    background: #ff4444 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 20px !important;
    height: 20px !important;
    font-size: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    margin-left: 5px !important;
}

/* ===============================
   POPUP DI CONFERMA (singolo e multiplo)
   =============================== */

#conferma-sorteggio,
#conferma-multipla {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.92);
    color: white;
    padding: 35px;
    border-radius: 15px;
    text-align: center;
    z-index: 2000;
    width: 90%;
    max-width: 480px;
    border: 3px solid #ffd700;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6);
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

#conferma-sorteggio h1,
#conferma-multipla h1 {
    font-size: 2.8em;
    margin: 15px 0;
    color: #ff6b6b;
    text-shadow: 0 0 12px rgba(255, 107, 107, 0.7);
}

#conferma-sorteggio h2,
#conferma-multipla h2 {
    font-size: 2em;
    color: #ffd700;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
}

#conferma-sorteggio button,
#conferma-multipla button {
    background: #ff6b6b;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 1.2em;
    margin-top: 20px;
    transition: background 0.2s, transform 0.1s;
}

#conferma-sorteggio button:hover,
#conferma-multipla button:hover {
    background: #e74c3c;
}

#conferma-sorteggio button:active,
#conferma-multipla button:active {
    transform: scale(0.95);
}

/* ===============================
   EFFETTI SLOT-MACHINE
   =============================== */

.slot-highlight {
    font-size: 2.5em; /* Leggermente ridotto per schermi piccoli */
    color: #ffd700;
    text-align: center;
    padding: 20px; /* Ridotto il padding per dare spazio al testo */
    animation: glowPulse 0.6s infinite alternate;
    /* Aggiunto per il wrapping */
    white-space: normal;
    word-wrap: break-word;
    display: block;
    width: 100%;
}

@keyframes glowPulse {
    from {
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
    to {
        text-shadow: 0 0 25px rgba(255, 215, 0, 1);
    }
}

/* Effetto shake finale */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}

.shake {
    animation: shake 0.4s ease-out;
}

/* ===============================
   LISTA SORTEGGIATI
   =============================== */

#lista-sorteggiati ol {
    padding-left: 20px;
}

#lista-sorteggiati li {
    font-size: 1.1em;
    margin: 6px 0;
    color: #2c3e50;
}

#lista-sorteggiati li::marker {
    color: #ffd700;
    font-weight: bold;
}

/* ===============================
   SEZIONE ESPORTA / IMPORTA DATI (VERSIONE PULITA)
   =============================== */

#data-tools {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    margin-top: 25px;
    text-align: center;
}

#data-tools h3 {
    margin-top: 0;
    color: #2c3e50;
    margin-bottom: 15px;
}

/* Contenitore per i bottoni Esporta/Importa */
.data-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

/* Stile per i bottoni (Esporta e Importa) */
.data-btn {
    flex: 1 1 calc(50% - 10px); /* 2 per riga su mobile */
    min-width: 140px;
    padding: 12px 10px;
    background: #8e44ad; /* Viola attuale */
    color: white;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9em;
    transition: background 0.2s, transform 0.1s;
}

.data-btn:hover {
    background: #732d91;
}

.data-btn:active {
    transform: scale(0.95);
}

/* Colore specifico per IMPORTA (Blu) */
.data-btn-import {
    background: #2980b9;
}

.data-btn-import:hover {
    background: #2471a3;
}

/* Tasto PULISCI: Piccolo, grigio e separato */
.btn-pulisci-discreto {
    background: transparent;
    color: #95a5a6;
    border: 1px solid #bdc3c7;
    font-size: 0.75em;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 20px;
    display: inline-block;
    transition: all 0.2s;
}

.btn-pulisci-discreto:hover {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

/* Desktop: tutti in riga se lo schermo è largo */
@media (min-width: 600px) {
    .data-btn {
        flex: 0 1 auto;
        padding: 10px 20px;
    }
}

/* ===============================
   GRAFICI E STATISTICHE
   =============================== */

#stats-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 25px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

#stats-container h3 {
    margin-top: 0;
}

#stats-chart {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* ===============================
   MODALITÀ SPECIALI
   =============================== */

#modal-classe-intera,
#modal-verifica-sorpresa {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 20, 0.95);
    color: white;
    padding: 35px;
    border-radius: 15px;
    text-align: center;
    z-index: 3000;
    width: 90%;
    max-width: 500px;
    border: 3px solid #3498db;
    box-shadow: 0 0 25px rgba(52, 152, 219, 0.6);
    opacity: 0;
}

#modal-classe-intera h2,
#modal-verifica-sorpresa h2 {
    color: #3498db;
    margin-bottom: 20px;
}

.special-btn {
    background: #3498db;
    padding: 12px 22px;
    border-radius: 8px;
    font-size: 1.1em;
    margin: 10px;
    transition: background 0.2s, transform 0.1s;
}

.special-btn:hover {
    background: #2980b9;
}

.special-btn:active {
    transform: scale(0.95);
}

/* ===============================
   ANIMAZIONI AGGIUNTIVE
   =============================== */

/* Fade-in generico */
.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* Fade-out generico */
.fade-out {
    animation: fadeOut 0.4s ease-out forwards;
}

@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.95); }
}

/* Pulsazione morbida */
@keyframes softPulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.pulse {
    animation: softPulse 0.6s ease-out;
}

/* Glow blu per modalità speciali */
.glow-blue {
    animation: glowBlue 1s infinite alternate;
}

@keyframes glowBlue {
    from { text-shadow: 0 0 10px rgba(52,152,219,0.4); }
    to   { text-shadow: 0 0 25px rgba(52,152,219,1); }
}

/* ===============================
   MODIFICHE PER COLORI E SELEZIONE
   =============================== */

/* Spazio intorno ai nomi degli studenti */
.studente-item {
    padding-left: 15px !important;
}

/* Spazio tra i pulsanti */
#azioni {
    margin: 20px 0;
}

#azioni button {
    margin: 10px 0;
    padding: 12px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

/* Colore studente */
.colore-studente {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin: 0 5px;
    flex-shrink: 0;
}

/* Checkbox per selezione studenti */
.checkbox-selezione {
    margin: 0 10px;
    cursor: pointer;
}

/* Stile per studenti selezionati */
.studente-selezionato {
    opacity: 1;
    background: #e8f4f8;
}

.studente-non-selezionato {
    opacity: 0.6;
    background: #f0f0f0;
}

/* Spazio intorno ai nomi degli studenti */
.studente-item span {
    flex: 1;
    margin: 0 10px;
    /* Rimosso white-space: nowrap per permettere l'andata a capo */
    white-space: normal; 
    word-wrap: break-word;
    overflow: visible;
    text-overflow: clip;
    min-width: 0;
    line-height: 1.2;
    font-size: 1.1em;

/* Il nome deve essere bello visibile */    
.studente-item span:first-child { 
    font-size: 1.2em; 
    font-weight: bold;
    color: #2c3e50;
    display: block;
}

/* La data deve essere discreta ma leggibile */
.data-sorteggio, .studente-item span:nth-child(2) {
    font-size: 0.85em;
    color: #7f8c8d;
    margin: 2px 0 0 0 !important;
}

}#lista-sorteggiati li {
    font-size: 1.1em;
    margin: 8px 0;
    color: #2c3e50;
    white-space: normal;    /* Permette l'andata a capo */
    word-wrap: break-word;  /* Spezza le parole se troppo lunghe */
    line-height: 1.3;       /* Rende la lettura più comoda se va su due righe */
}

/* Se lo schermo è in orizzontale, distribuiamo meglio gli elementi */
@media (orientation: landscape) {
    #app {
        display: grid;
        grid-template-columns: 1fr 1fr; /* Divide lo schermo in due colonne */
        gap: 20px;
    }
    
    #container-slot-fisso {
        grid-column: span 2; /* Lo slot occupa tutta la larghezza in alto */
    }
    
    body {
        padding: 10px;
    }
}

/* Forza i pulsanti ad andare "sotto" nei telefoni stretti */
@media (max-width: 400px) {
    .studente-item {
        padding: 10px;
    }
    /* I pulsanti occupano la riga sotto e si allineano a destra */
    #azioniContenitore { 
        border-top: 1px solid #ddd;
        padding-top: 8px;
    }
}