/* --- Importazione del Font --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap');

:root {
    --primary-color: #007bff;
    --background-color: #f4f7fa;
    --card-background: #ffffff;
    --text-color: #333;
    --light-gray: #ccc;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    overflow-x: hidden; /* Impedisce lo scroll orizzontale della pagina */
}

.main-header {
    background-color: var(--card-background);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    width: 100%;
    box-sizing: border-box;
}

/* Stili per i dettagli utente nell'header */
.user-details {
    text-align: right;
}
#user-role-display {
    display: block;
    font-size: 0.8rem;
    color: #6c757d;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-container img {
    width: 60px;
}

.logo-container h1 {
    font-size: 1.2rem;
    margin: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-button {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 8px 15px;
    border-radius: 6px;
    transition: background-color 0.2s;
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
}

.header-button:hover {
    background-color: #f0f0f0;
}

.dashboard-grid {
    display: grid;
    /* SOLUZIONE: Creiamo una griglia a 2 colonne */
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    padding: 2rem;
}

.card {
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
}

.large-card {
    /* SOLUZIONE: Il riepilogo occupa tutta la larghezza (da colonna 1 a -1) */
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.card-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
}

.card-header a {
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 500;
}

.card > p, .card > .progress-bar-container, .card > ul {
    flex-grow: 1;
}

.large-card {
    grid-column: span 2;
}

.financial-summary {
    display: flex;
    justify-content: space-around;
    text-align: center;
    margin: 10px 0;
    flex-wrap: wrap;
    gap: 15px;
}

.financial-summary span {
    display: block;
    color: #666;
    font-size: 0.9rem;
}

.financial-summary strong {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.total-funds {
    color: var(--primary-color);
}

.income {
    color: var(--success-color);
}

.expenses {
    color: var(--danger-color);
}

.charts-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 25px;
    width: 100%;
}

/* Stili per i contenitori dei grafici (Dashboard e Pagine Interne) */
.chart-wrapper, .chart-wrapper-full {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    position: relative;
    flex: 1;
    min-width: 250px;
    min-height: 250px; /* Altezza minima per sicurezza */
}
.chart-wrapper {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    position: relative;
    /* Assicurati che abbia un'altezza definita, come nel tuo felpe.html */
    height: 250px; 
}
.chart-wrapper-full {
    width: 100%;
    height: 250px;
    margin-top: 2rem;
}
.chart-wrapper.visible, .chart-wrapper-full.visible {
    opacity: 1;
    transform: translateY(0);
}
.charts-container .chart-wrapper:nth-child(2) {
    transition-delay: 0.1s;
}
.chart-wrapper-full {
    transition-delay: 0.2s;
}

.goal-setter {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.goal-setter label {
    font-weight: 500;
}

.goal-setter input {
    width: 80px;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-align: center;
    font-size: 1rem;
}

.progress-bar-container {
    background-color: #e9ecef;
    border-radius: 50px; /* Raggio più proporzionato */
    height: 12px; /* Leggermente più alta */
    margin: 15px 0;
    overflow: hidden; /* SOLUZIONE: Impedisce alla barra blu di "uscire" */
}

.progress-bar {
    background-color: var(--primary-color);
    height: 100%;
    border-radius: 50px;
    /* Aggiungiamo una transizione per un effetto più fluido */
    transition: width 0.3s ease-in-out;
}

.cta-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
    font-size: 0.9rem;
    font-family: 'Poppins', sans-serif;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    box-sizing: border-box;
}

.cta-button.secondary {
    background-color: #6c757d;
}

.event-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.event-list li {
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.event-list li:last-child {
    border-bottom: none;
}

.event-list strong {
    display: block;
}

.event-list span {
    color: #777;
    font-size: 0.9rem;
}

.page-content {
    padding: 2rem;
    margin: 0; /* Rimuove il centraggio automatico */
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.finance-layout {
    display: grid;
    gap: 2rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.full-width-card {
    width: 100%;
    box-sizing: border-box;
}

.table-container {
    width: 100%;
    overflow-x: auto; /* Permette alla tabella di scorrere orizzontalmente */
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

td.status-cell {
    text-align: center;
}

thead th {
    background-color: #f8f9fa;
    font-weight: 500;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

.status-pill {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
    display: inline-block;
}

.status-paid {
    background-color: var(--success-color);
}

.status-unpaid {
    background-color: var(--danger-color);
}

.action-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
}

.remove-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--danger-color);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    padding: 2rem; /* <-- AGGIUNTO: Forza un margine su tutti i lati */
    box-sizing: border-box; /* <-- AGGIUNTO: Assicura che il padding non rompa il layout */
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body .form-group,
.admin-form .form-group {
    margin-bottom: 24px; 
}

.modal-body label,
.admin-form label {
    font-size: 1rem;    
    font-weight: 500;
    color: #1a1a1a;     
    margin-bottom: 10px;
}

.modal-body input, .modal-body select, .modal-body textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

.form-group-inline {
    display: flex;
    gap: 15px;
}

.form-group-inline > div {
    flex: 1;
}

.modal-footer {
    text-align: right;
    margin-top: 20px;
}

.modal-pin-confirm .modal-content {
    max-width: 340px;
    text-align: center;
}

.modal-pin-confirm h2 {
    font-size: 1.2rem;
    font-weight: 500;
}

.modal-pin-confirm p {
    color: #6c757d;
    margin-bottom: 20px;
}

.modal-pin-confirm .pin-display {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
}

.modal-pin-confirm .pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: #e0e0e0;
    transition: background-color 0.2s;
}

.modal-pin-confirm .pin-dot.active {
    background-color: var(--primary-color);
}

.modal-pin-confirm .keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.modal-pin-confirm .key {
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.5em;
    cursor: pointer;
    background-color: #f5f5f5;
    transition: background-color 0.2s;
    margin: 0 auto;
}

.modal-pin-confirm .key:hover {
    background-color: #e0e0e0;
}

.modal-pin-confirm .key-action {
    background-color: transparent;
    font-weight: bold;
}

.modal-pin-confirm .pin-error {
    color: var(--danger-color);
    height: 20px;
    font-weight: 500;
}

.modal-pin-confirm.shake .modal-content {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0) scale(1); }
    25% { transform: translateX(-5px) scale(1); }
    50% { transform: translateX(5px) scale(1); }
    75% { transform: translateX(-5px) scale(1); }
}

/* --- Media Queries per la Responsività --- */
@media (max-width: 768px) {
    .main-header {
        gap: 15px;
        padding: 1rem;
    }
    .user-info {
        width: auto;
        justify-content: flex-end;
    }
    .dashboard-grid {
        padding: 1rem;
        gap: 1rem;
        grid-template-columns: 1fr;
    }
    .large-card {
        grid-column: span 1;
    }
    .logo-container h1 {
        font-size: 1rem;
    }
    .charts-container {
        flex-direction: column;
        gap: 25px;
    }
    .chart-wrapper {
        opacity: 0;
        transform: translateY(20px);
        transition: opacity 0.6s ease-out, transform 0.6s ease-out;
        position: relative;
        flex: 1;
        min-width: 250px;
        height: 250px;
        min-height: 250px; /* Assicura che non sia mai 0px */
    }
    .page-content {
        padding: 1rem;
    }
    /* SOLUZIONE: Rimosso il layout specifico che causava problemi */
    .finance-layout {
        display: flex; /* Usiamo flex per un controllo migliore */
        flex-direction: column;
        gap: 1rem;
    }

    .chart-wrapper-full {
        margin-top: 1rem;
        height: 220px;
    }

    .event-card-content {
        flex-direction: column;
        flex-grow: 0; /* SOLUZIONE: Permette al contenitore di crescere in altezza */
        min-height: auto; /* SOLUZIONE: L'altezza si adatta al contenuto */
    }
}

@media (max-width: 480px) {
    .main-header {
        padding: 1rem 0.5rem;
    }
    .dashboard-grid, .page-content {
        padding: 0.5rem;
    }
    .card {
        padding: 15px;
        margin-bottom: 0; /* Rimuoviamo il margine extra */
    }
    .financial-summary {
        flex-direction: column;
        gap: 15px; /* Aumentiamo un po' lo spazio */
        align-items: center; /* SOLUZIONE: Centra i blocchi */
        text-align: center;  /* SOLUZIONE: Centra il testo */
    }
    .financial-summary strong {
        font-size: 1.4rem;
    }
    .logo-container h1 {
        display: none;
    }
}

/* Nasconde la scrollbar verticale mantenendo lo scroll */
html {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
html::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Stile per il pulsante "Imposta Obiettivo" */
.cta-button.small-button {
    width: auto; /* Larghezza automatica */
    padding: 8px 12px;
    font-size: 0.8rem;
    margin-top: 0; /* Rimuove il margine superiore */
}

/* Aggiungi questo alla fine del tuo style.css */
.event-card {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 1rem;
}
.event-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.event-card-header h3 {
    margin: 0;
}
.event-card-header.past-event h3 {
    text-decoration: line-through;
    color: #6c757d;
}
.event-details {
    font-size: 0.9rem;
    color: #6c757d;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

/* ... (tutto il codice CSS precedente) ... */

/* --- NUOVI STILI: Card Eventi e Calendario --- */

/* --- Stili per Card Eventi e Calendario --- */

.event-card-content {
    display: flex;
    gap: 20px;
    flex-grow: 1;
}

.calendar {
    flex: 1;
    min-width: 220px;
    overflow: hidden; /* Nasconde lo scorrimento durante l'animazione */
    position: relative;
}

/* Contenitore che gestirà l'animazione di scorrimento */
.calendar-body {
    position: relative;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); /* Transizione fluida */
}

/* Classi per l'animazione di scorrimento */
.sliding-out-left {
    transform: translateX(-100%);
}
.sliding-out-right {
    transform: translateX(100%);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    text-align: center;
}

.calendar-header h4 {
    margin: 0;
    font-weight: 500;
    flex-grow: 1;
}

.cal-nav {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0 5px;
    color: var(--primary-color);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 5px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.calendar-day {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: default;
    transition: background-color 0.2s;
    position: relative; /* Necessario per posizionare il puntino */
}

.calendar-day.empty {
    background-color: transparent;
}

.calendar-day.today {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
}

.calendar-day.has-event {
    background-color: transparent;
    font-weight: bold;
}

/* Stile per il puntino colorato sotto il numero del giorno */
.calendar-day.has-event::after {
    content: '';
    position: absolute;
    bottom: 2px; /* Posizionamento più in basso */
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    border-radius: 50%;
    /* Usa il colore definito dalla classe specifica (es. .event-blue) */
    background-color: var(--event-color, var(--primary-color));
}

/* Definizioni dei colori per gli eventi */
.event-blue::after { --event-color: #007bff; }
.event-green::after { --event-color: #28a745; }
.event-red::after { --event-color: #dc3545; }
.event-orange::after { --event-color: #fd7e14; }


.event-list-wrapper {
    flex: 1;
    border-left: 1px solid #eee;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
}

.event-list-wrapper h4 {
    margin: 0 0 10px 0;
    font-weight: 500;
}

.event-list-wrapper .event-list {
    margin-bottom: 1rem;
}

/* Modifiche per mobile */
@media (max-width: 768px) {
    .event-card-content {
        flex-direction: column;
    }
    .event-list-wrapper {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid #eee;
        padding-top: 20px;
    }
}

/* --- Stili per Animazione Calendario e Colori Evento --- */

.calendar-body {
    position: relative; /* Necessario per il posizionamento delle animazioni */
    overflow: hidden; /* Nasconde lo scorrimento durante l'animazione */
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    /* Impostiamo la transizione per l'animazione */
    transition: transform 0.3s ease-in-out;
}

/* Classi per l'animazione di scorrimento */
.slide-out-left { transform: translateX(-100%); }
.slide-out-right { transform: translateX(100%); }
.slide-in-from-left { transform: translateX(-100%); }
.slide-in-from-right { transform: translateX(100%); }


/* Stile per gli indicatori colorati dei giorni */
.calendar-day.has-event {
    background-color: transparent; /* Rimuoviamo lo sfondo generico */
    font-weight: bold;
    position: relative;
}
/* Usiamo un pseudo-elemento per creare un punto colorato sotto il numero */
.calendar-day.has-event::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--event-color, var(--primary-color)); /* Colore di default */
}

/* Definiamo i colori per gli eventi */
.event-blue::after { --event-color: #007bff; }
.event-green::after { --event-color: #28a745; }
.event-red::after { --event-color: #dc3545; }
.event-orange::after { --event-color: #fd7e14; }

/* Stili per la selezione del colore nella modale */
.color-selector { display: flex; gap: 10px; align-items: center; }
.color-selector input[type="radio"] { display: none; }
.color-selector .color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #ccc;
    transition: transform 0.2s;
}
.color-selector input[type="radio"]:checked + .color-dot {
    border-color: #333;
    transform: scale(1.2);
}
.color-dot.blue { background-color: #007bff; }
.color-dot.green { background-color: #28a745; }
.color-dot.red { background-color: #dc3545; }
.color-dot.orange { background-color: #fd7e14; }

/* Animazione per far apparire le pagine interne in modo fluido */
body {
    animation: fadeInPage 0.3s ease-out forwards;
}

@keyframes fadeInPage {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Stile per il pulsante di modifica */
.edit-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--primary-color); /* Colore blu */
}

/* --- Nuova Sezione: Finanze Dashboard Summary Cards --- */
.summary-cards-container {
    display: flex; /* Abilita Flexbox */
    gap: 20px; /* Spazio tra le card */
    margin-bottom: 20px; /* Margine sotto il contenitore */
    flex-wrap: wrap; /* Permette alle card di andare a capo su schermi piccoli */
    justify-content: space-between; /* Distribuisce lo spazio tra le card */
}

.summary-card {
    flex: 1; /* Permette alle card di crescere e occupare spazio equamente */
    min-width: 280px; /* Larghezza minima per evitare che diventino troppo piccole */
    padding: 25px; /* Padding interno aumentato */
    text-align: center; /* Centra il testo */
    border-radius: 12px; /* Angoli più arrotondati */
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.08); /* Ombra più pronunciata */
    background-color: var(--card-bg-color); /* Colore di sfondo della card */
    display: flex; /* Flexbox per allineare h3 e strong */
    flex-direction: column; /* Impila h3 e strong */
    justify-content: center; /* Centra verticalmente */
    align-items: center; /* Centra orizzontalmente */
}

.summary-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--text-color-light); /* Colore più tenue per il titolo */
    font-size: 1.1em; /* Dimensione del titolo */
    font-weight: 500; /* Peso del font */
}

.summary-card strong {
    font-size: 2.2em; /* Dimensione grande per i totali */
    font-weight: 700; /* Molto spesso */
    display: block; /* Assicura che l'importo sia su una nuova riga */
    color: var(--text-color); /* Colore predefinito */
}

.summary-card .total-funds {
    color: var(--primary-color); /* Colore primario per la cassa totale */
}

.summary-card .income {
    color: var(--success-color); /* Colore verde per le entrate */
}

.summary-card .expenses {
    color: var(--error-color); /* Colore rosso per le uscite */
}

/* Regolazioni per i grafici per abbinare il nuovo stile */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); /* Ridisposto per due colonne se c'è spazio */
    gap: 20px;
    margin-bottom: 20px;
}

.chart-card {
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.08);
    background-color: var(--card-bg-color);
    display: flex;
    flex-direction: column;
}

.chart-card .card-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.chart-container {
    flex-grow: 1; /* Permette al canvas di occupare lo spazio disponibile */
    position: relative; /* Necessario per il responsive di Chart.js */
    height: 300px; /* Altezza fissa per i grafici */
}

/* Media Queries per schermi più piccoli */
@media (max-width: 768px) {
    .summary-cards-container {
        flex-direction: column; /* Su schermi piccoli, le card tornano in colonna */
        align-items: center; /* Centra le card */
    }
    .summary-card {
        min-width: 90%; /* Occupano quasi tutta la larghezza */
        max-width: 400px; /* Ma non diventano troppo larghe su schermi molto ampi */
    }
    .charts-grid {
        grid-template-columns: 1fr; /* Un grafico per riga */
    }
}

/* --- Stili per Eventi Layout Forum --- */
.event-card.forum-card {
    display: flex;
    flex-direction: column-reverse; /* Immagine a lato, contenuto dall'altro */
    background-color: #ffffff; /* Sfondo bianco per la card */
    overflow-x: auto; /* scroll orizzontale */
}

.event-forum-image {
    width: 250px;
    height: auto;
    object-fit: cover;
    border-radius: 8px 0 0 8px; /* Arrotonda solo gli angoli a sinistra */
}

.event-card-body {
    flex: 1; /* Occupa il resto dello spazio */
    padding: 20px;
}

.event-card.forum-card h4 {
    font-weight: 500;
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.event-card.forum-card p {
    white-space: pre-wrap; /* Mantiene la formattazione (a capo) del piano esecutivo */
    line-height: 1.6;
}

/* --- Stili per Galleria Allegati Evento (Immagini E File) --- */
.event-attachment-gallery {
    display: flex;
    flex-direction: row; 
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap; /* su desktop può andare a capo se serve */
}

@media (max-width: 600px) {
    .event-attachment-gallery {
        flex-wrap: nowrap;       /* evita che le immagini vadano a capo */
        overflow-x: auto;        /* scroll orizzontale */
        -webkit-overflow-scrolling: touch; /* scroll fluido su iOS */
    }

    .attachment-link {
        flex: 0 0 auto; /* le immagini mantengono larghezza fissa */
    }
}

.attachment-link {
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    display: block;
    transition: transform 0.2s;
}

.attachment-link:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.attachment-thumbnail {
    height: 150px; 
    width: auto;
    object-fit: cover;
    display: block;
}


/* Contenitore dei blocchi file */
.file-gallery {
    display: flex;
    flex-wrap: wrap;      /* su desktop i blocchi vanno a capo */
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.file-block {
    height: 150px;
    width: 200px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-align: center;
    color: var(--primary-color);
    font-weight: 500;
    word-break: break-all; /* Manda a capo nomi file lunghi */
    border: 1px solid #ddd;
    border-radius: 4px;
}

@media (max-width: 600px) {
    .file-gallery {
        flex-wrap: nowrap;              /* tutti in una riga */
        overflow-x: auto;               /* scroll orizzontale */
        -webkit-overflow-scrolling: touch; /* scroll fluido su iOS */
    }

    .file-block {
        flex: 0 0 auto; /* mantieni larghezza fissa e impedisci il resize */
    }
}

/* Aggiunge un'icona finta basata sull'estensione */
.file-block::before {
    content: '📄'; /* Icona generica */
    font-size: 2rem;
    display: block;
    margin-bottom: 10px;
}
.file-block[data-ext="pdf"]::before { content: '📕'; }
.file-block[data-ext="docx"]::before, .file-block[data-ext="doc"]::before { content: '📘'; }
.file-block[data-ext="xlsx"]::before, .file-block[data-ext="xls"]::before { content: '📗'; }


/* --- Stili per l'Anteprima nella MODALE --- */
#attachment-preview-container { /* Questo era #image-preview-container */
    min-height: 50px;
    border: 1px dashed #ccc;
    padding: 10px;
    border-radius: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.preview-attachment-wrapper { /* Questo era .preview-image-wrapper */
    position: relative;
    display: inline-block;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
}
.preview-attachment-wrapper img {
    height: 80px;
    width: auto;
    border-radius: 4px;
    display: block;
}
/* Stile per anteprima file (non immagine) nella modale */
.preview-file-block {
    display: block;
    height: 80px;
    width: 120px;
    padding: 5px;
    font-size: 0.8rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-all;
    color: #333;
}

.remove-img-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: red;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-weight: bold;
    line-height: 18px; /* Centra la 'x' */
    padding: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* --- Override CSS per Modale Eventi Spaziosa (Aggiornato) --- */

/* Larghezza generale della modale */
#event-modal .modal-content {
    width: 90%;            /* così occupa quasi tutta la larghezza */
    max-width: 80%;      /* limite massimo su schermi grandi */
    max-height: 80vh;      /* non supera l'80% dell’altezza visibile */
    
    margin: 0 auto;        /* centrata orizzontalmente */
    padding: 1rem;
    
    border: 1px solid #ccc;
    border-radius: 10px;
    background: #fff;
    
    overflow: auto;
}

@media (max-width: 600px) {
    #event-modal .modal-content {
        width: 100%;         /* occupa tutto lo schermo */
        max-width: none;     /* rimuove il limite */
        
        border: 1px solid #ccc;
        border-radius: 10px;
        background: #fff;
        
        overflow-x: auto; /* scroll orizzontale */
        overflow-y: auto; /* scroll verticale */
    }
}

/* Spazio tra i gruppi di campi */
#event-modal .modal-body .form-group {
    margin-bottom: 25px; 
}
#event-modal .modal-body label {
    font-size: 1.05rem; /* Etichette ancora più grandi */
    font-weight: 600; /* Più in risalto */
    color: #212529; /* Colore scuro */
    margin-bottom: 10px;
}

/* Stile per i campi di input */
#event-modal input[type="text"],
#event-modal input[type="date"],
#event-modal input[type="file"],
#event-modal select,
#event-modal textarea {
    padding: 14px; /* Più padding */
    font-size: 1.1rem; /* Carattere più grande */
    border-radius: 10px; /* Bordi più arrotondati */
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

/* Assicura che la riga inline si comporti bene con elementi di diverse altezze */
.form-group-inline.align-items-stretch {
    align-items: stretch; /* Le colonne si estendono per riempire l'altezza del più alto */
}

/* Contenitore per l'upload e l'anteprima */
#event-modal .form-group > label[for="foto-upload"] {
    margin-bottom: 5px; /* Meno spazio tra etichetta e input file */
}
#event-modal input[type="file"] {
    margin-bottom: 15px; /* Spazio tra input file e etichetta "allegati caricati" */
}

#event-modal #attachment-preview-container {
    padding: 15px;
    border-radius: 10px; /* Bordi più arrotondati */
    background-color: #e9ecef; /* Sfondo leggermente più scuro per l'area anteprima */
}

/* Dimensioni per le Textarea (Descrizione e Piano Esecutivo) */
#event-modal #descrizione {
    height: 120px; /* Altezza fissa generosa per la descrizione */
    min-height: 120px;
    resize: vertical; /* Permetti all'utente di ridimensionare verticalmente */
}
#event-modal #piano_esecutivo {
    height: 150px; /* Altezza fissa molto generosa per il piano */
    min-height: 150px;
    resize: vertical;
}

/* Stili per le anteprime dei singoli allegati nella modale */
.preview-attachment-wrapper {
    background-color: #fff; /* Sfondo bianco per ogni preview */
    padding: 5px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.preview-attachment-wrapper img {
    height: 70px; /* Leggermente più piccole per l'anteprima */
    width: auto;
    max-width: 100px; /* Limite massimo per evitare img giganti */
}
.preview-file-block {
    height: 70px;
    width: 100px; /* Larghezza adeguata per il blocco file */
    font-size: 0.9rem;
    padding: 5px;
}

/* Posizionamento del bottone 'x' di rimozione */
.remove-img-btn {
    top: -10px;
    right: -10px;
    width: 24px; /* Bottone più grande */
    height: 24px;
    font-size: 1.1rem;
    line-height: 22px;
}

/* --- Stili Colore Card Eventi --- */

/* Applica un bordo sinistro spesso e colorato */
.event-card.forum-card {
    border-left-width: 6px;
    border-left-style: solid;
}

/* Definisce i colori del bordo in base alla classe */
.forum-card.color-blue { border-left-color: #007bff; }
.forum-card.color-green { border-left-color: #28a745; }
.forum-card.color-red { border-left-color: #dc3545; }
.forum-card.color-orange { border-left-color: #fd7e14; }

/* Assicura che gli stili dei dot per il selettore (che avevamo già)
   funzionino bene nel nuovo layout della modale */
#event-modal .color-selector {
    display: flex;
    gap: 15px; /* Spazio tra i pallini */
    align-items: center;
    padding-top: 5px;
}

/* Aggiungi questo stile alla fine di `style.css` per colorare il nuovo stato "In Discussione" */
.status-pending {
    background-color: #fd7e14; /* Arancione (lo stesso di Eventi) */
}

/* --- Stili per Sommaria Proposte --- */

/* Crea la griglia 4x4 per i filtri di stato */
.proposals-summary-grid {
    display: grid;
    /* Crea 4 colonne su schermi grandi, 2 su tablet, 1 su mobile */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Stile per i riquadri piccoli dei filtri */
.summary-card.status-filter {
    padding: 20px;
    text-align: center;
    min-width: 0; /* Permette alla griglia di funzionare correttamente */
}
.summary-card.status-filter h3 {
    font-size: 1rem;
    font-weight: 500;
    color: #6c757d;
    margin: 0 0 5px 0;
}
.summary-card.status-filter strong {
    font-size: 2rem;
}

/* Riquadro del totale (sotto la griglia) */
#card-status-totale {
    margin-top: 20px; /* Distanzia dalla griglia sopra */
}

/* Colore per lo stato "In Discussione" (Warning) */
.warning-text {
    color: #fd7e14 !important; /* Arancione */
}

.expenses {
    color: red !important;
}

.status-highlight {
    background-color: yellow; /* Colore blu primario */
}

.highlight-text {
    color: yellow !important;
}

/* --- Stili per Widget Feed Attività --- */
.activity-feed-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px; /* Altezza massima, poi scroll */
    overflow-y: auto;
}

.feed-item {
    display: flex;
    align-items: flex-start; /* Allinea all'inizio (per testo lungo) */
    gap: 15px;
    padding: 15px 5px; /* Spaziatura verticale */
    border-bottom: 1px solid #f0f0f0;
}
.feed-item:last-child {
    border-bottom: none;
}

.feed-icon {
    font-size: 1.5rem;
    line-height: 1.2;
}

.feed-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1; /* Occupa lo spazio rimanente */
}

.feed-meta {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
}

.feed-text {
    font-size: 0.95rem;
    color: #333;
}

/* Stile per il link dell'allegato nella lista delle comunicazioni */
.attachment-display {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed #eee;
}
.attachment-display strong {
    color: #333;
}
.attachment-display a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}
.attachment-display a:hover {
    text-decoration: underline;
}

/* --- Stili per Header Utente Dinamico e Dropdown Admin --- */
.user-info {
    position: relative; /* Contenitore per la tendina */
}

.user-details-button {
    background: none;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 5px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s, border-color 0.2s;
}
.user-details-button:hover,
.user-details-button:focus {
    background-color: #f4f7fa;
    border-color: #f4f7fa;
    outline: none;
}
.dropdown-arrow {
    width: 20px;
    height: 20px;
    fill: #6c757d;
    transition: transform 0.2s;
}

/* Regola per la tendina nascosta */
.dropdown-content {
    display: none; 
    position: absolute;
    right: 0;
    top: 110%; 
    background-color: white;
    min-width: 200px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    border-radius: 8px;
    z-index: 100;
    overflow: hidden;
    border: 1px solid #eee;
}

/* QUESTA È LA REGOLA MANCANTE: Mostra la tendina quando ha la classe .active */
.dropdown-content.active {
    display: block;
}

/* Ruota la freccia quando il menu è attivo */
.user-details-button:has(+ .dropdown-content.active) .dropdown-arrow {
     transform: rotate(180deg);
}

.dropdown-item {
    display: block;
    padding: 12px 20px;
    text-decoration: none;
    color: #333;
    font-size: 0.95rem;
    font-weight: 500;
}
.dropdown-item:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
}
.dropdown-item.logout {
    border-top: 1px solid #f0f0f0;
    color: var(--danger-color);
}

/* --- Stili Pagina Admin --- */

/* Contenitore del form utenti */
.admin-form { 
    padding: 25px; 
    background: #fdfdfd; 
    border: 1px solid #eee; 
    border-radius: 12px; 
}

/* Stile per la colonna "permessi" nella tabella utenti */
.user-perms { 
    font-size: 0.85rem; 
    color: #555; 
    word-break: break-all; /* Manda a capo la lista se è troppo lunga */
    line-height: 1.6;
}

/* Contenitore del log: altezza massima con scroll */
.log-container { 
    max-height: 600px; 
    overflow-y: auto; 
    border: 1px solid #eee;
    border-radius: 8px;
}
.audit-log-table { 
    font-size: 0.9rem; 
}

/* Stili per colorare le azioni nel log */
.log-action { 
    font-weight: bold; 
    font-family: monospace; 
    font-size: 0.95rem;
    padding: 3px 6px;
    border-radius: 4px;
    color: white;
}
.log-action.DELETE_FINANZE,
.log-action.DELETE_FELPE,
.log-action.DELETE_EVENTO,
.log-action.DELETE_PROPOSTA,
.log-action.DELETE_COMUNICAZIONE,
.log-action.DELETE_USER,
.log-action.DELETE_CLASS_ORDER { 
    background-color: var(--danger-color); 
}
.log-action.CREATE_USER { 
    background-color: var(--success-color); 
}
.log-action.UPDATE_USER { 
    background-color: var(--primary-color); 
}

.modal-body input[type="text"],
.modal-body input[type="date"],
.modal-body input[type="file"],
.modal-body select,
.modal-body textarea,
.admin-form input[type="text"],
.admin-form input[type="date"],
.admin-form select,
.admin-form textarea {
    padding: 14px; 
    font-size: 1.1rem; 
    border-radius: 10px; 
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    width: 100%; /* Assicurati che occupino tutta la larghezza */
    box-sizing: border-box; /* Previene problemi di padding */
}

.modal-body input[type="text"]:focus,
.modal-body input[type="date"]:focus,
.modal-body input[type="file"]:focus,
.modal-body select:focus,
.modal-body textarea:focus,
.admin-form input[type="text"]:focus,
.admin-form input[type="date"]:focus,
.admin-form select:focus,
.admin-form textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
    outline: none;
    background-color: #fff;
}

/* Colori per le azioni CREATE (Verde) */
.log-action.CREATE_FINANZE,
.log-action.CREATE_FELPA,
.log-action.CREATE_EVENTO,
.log-action.CREATE_PROPOSTA,
.log-action.CREATE_COMUNICAZIONE,
.log-action.CREATE_USER,
.log-action.CREATE_CLASS_ORDER {
    background-color: var(--success-color); /* Verde */
}

/* Colori per le azioni UPDATE (Blu) */
.log-action.UPDATE_FINANZE,
.log-action.UPDATE_FELPA,
.log-action.UPDATE_EVENTO,
.log-action.UPDATE_PROPOSTA,
.log-action.UPDATE_COMUNICAZIONE,
.log-action.UPDATE_USER,
.log-action.UPDATE_CLASS_ORDER,
.log-action.UPDATE_CLASS_ORDER_STATUS {
    background-color: var(--primary-color); /* Blu */
}

/* Colore per le azioni RESTORE (Verde Acqua/Teal) */
.log-action.RESTORE_ITEM {
    background-color: #20c997;
}

.log-action.UPDATE_GOAL{
    background-color: burlywood;
}

.log-action.APPROVE_DEVICE_REGISTRATION{
    background-color: gold;
}

.log-action.UPDATE_PUNTEGGIO{
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.log-action.UPDATE_SQUADRA{
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.log-action.UPDATE_CARD_VISIBILITY{
    background-color: #667eea;
}

.log-action.UPDATE_BADGE_STATUS{
    background: linear-gradient(135deg, #0026ff, #0077ff);
}

.log-action.VERIFY_BADGE{
    background: linear-gradient(135deg, #00ff62, #fffb00);
}
.log-action.CREATE_BADGE{
    background: linear-gradient(135deg, #ff8800, #ffe600);
}
.log-action.DELETE_BADGE{
    background: linear-gradient(135deg, #ff0800, #ff640b);
}
.log-action.UPDATE_BADGE{
    background: linear-gradient(135deg, #8c00ff, #f70bff);
}
.log-action.BULK_ENABLE_BADGES{
    background: linear-gradient(135deg, #00a6ff, #0bffe3);
}
.log-action.BULK_DISABLE_BADGES{
    background: linear-gradient(135deg, #ff0019, #ff0b85);
}

.log-action.REGISTER_SQUADRA{
    background: linear-gradient(135deg, #ff0095, #ff0b2c);
}
.log-action.AVANZA_MESE_CONCORRENZA{
    background: linear-gradient(135deg, #00d9ff, #0bffde);
}
.log-action.ADD_TREASURE_HINT{
    background: linear-gradient(135deg, #00ff6a, #0bffc2);
}
.log-action.GENERATE_TREASURE_QR{
    background: linear-gradient(135deg, #00ff11, #0bff54);
}
.log-action.SCAN_TREASURE_QR{
    background: linear-gradient(135deg, #00b7ff, #0bffde);
}
.log-action.UPDATE_TREASURE_HUNT_SETTINGS{
    background: linear-gradient(135deg, #80ff00, #c6ff0b);
}
.log-action.DELETE_TREASURE_HINT{
    background: linear-gradient(135deg, #ff0000, #ff340b);
}

.log-action.UPDATE_CLASS{
    background: linear-gradient(135deg, #0026ff, #0077ff);
}
.log-action.CREATE_CLASS{
    background: linear-gradient(135deg, #00ff11, #0bff54);
}
.log-action.DELETE_CLASS{
    background: linear-gradient(135deg, #ff0000, #ff340b);
}

.log-action.CREATE_SONDAGGIO{
    background: linear-gradient(135deg, #00ff11, #0bff54);
}
.log-action.SUBMIT_SONDAGGIO{
    background: linear-gradient(135deg, #ff0084, #ff0bef);
}
.log-action.CLOSE_SONDAGGIO{
    background: linear-gradient(135deg, #4c00ff, #850bff);
}
/* --- Stili Migliorati per Testo Header Utente --- */

/* Stile per il nome */
#welcome-message {
    display: block; /* Assicura che stia sopra il ruolo */
    font-size: 1rem;
    font-weight: 700; /* Grassetto (Peso 700 di Poppins) */
    color: #1a1f33; /* Un colore scuro e professionale */
    line-height: 1.2; /* Migliore interlinea */
}

/* Stile per il ruolo (Rappresentante d'Istituto) */
/*#user-role-display {}*/

/* Stile per il nuovo bottone Registra Passkey (icona chiave) */
.passkey-reg-btn svg {
    width: 18px;
    height: 18px;
    fill: #ffc107; /* Colore Giallo/Oro */
}

/* --- *** NUOVI STILI MODERNI PER POPOVER DI MODIFICA *** --- */

/* Backdrop scuro con transizione fluida */
.popover-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 22, 41, 0.7); /* Blu scuro semitrasparente */
    backdrop-filter: blur(5px);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.popover-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Card di modifica con animazione di entrata */
.popover-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%); /* Leggermente più in alto all'inizio */
    width: 90%;
    max-width: 700px; /* Più spaziosa */
    background: #f8f9fa; /* Sfondo leggermente grigio, meno duro del bianco */
    border-radius: 16px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);
    z-index: 1051;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
.popover-card.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid #dee2e6;
}
.popover-header h3 { margin: 0; font-size: 1.3rem; font-weight: 600; }
.popover-header h3 span { color: var(--primary-color); }
.popover-header .close-button {
    background: #e9ecef;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}
.popover-header .close-button:hover {
    background-color: #ced4da;
    transform: rotate(90deg);
}

.popover-content {
    padding: 2rem;
    overflow-y: auto;
    max-height: 70vh;
}
.popover-content h4 { margin-top: 0; margin-bottom: 1rem; font-size: 1.1rem; color: var(--light-text-color); }

.popover-details-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem; /* Spazio ridotto tra le righe */
    margin-bottom: 1.5rem;
}

/* Nuovo layout a griglia per la riga dello studente */
.popover-student-row {
    display: grid;
    grid-template-columns: 1fr 110px 130px 40px;
    gap: 12px;
    align-items: center;
}

/* Nuovo stile moderno per input e select */
.popover-student-row input, .popover-student-row select, #popover-payment-status {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    background-color: white;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.popover-student-row input {
    background-image: none; /* Rimuove la freccia dall'input di testo */
}

.popover-student-row input:focus, .popover-student-row select:focus, #popover-payment-status:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.popover-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    margin: 1.5rem 0;
    font-weight: 500;
}
.popover-summary strong {
    font-size: 1.2rem;
    color: var(--primary-color);
}
.secondary-button.small-button {
    font-size: 0.9rem;
    font-weight: 500;
    width: auto;
    padding: 8px 15px;
}

/* --- Stili per i Pulsanti di Azione Specifici --- */

.action-button.restore-btn svg {
    fill: var(--success-color); /* Colore verde per l'icona di ripristino */
    width: 20px; /* Dimensione icona */
    height: 20px;
}

.action-button.restore-btn:hover {
    background-color: rgba(40, 167, 69, 0.1); /* Sfondo verde leggero al passaggio del mouse */
}

.card-icon-large {
    font-size: 4rem;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--primary-color);
}

.user-code {
    font-family: monospace;
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
}

/* NOTIFICHE */
.notification-item {
    position: relative;
    padding-right: 60px; /* Spazio per i bottoni */
}
.notification-actions {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}
.notification-item:hover .notification-actions {
    opacity: 1;
}
.notification-action-btn {
    background: #e9ecef;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 28px;
}
.notification-action-btn:hover { background: #ced4da; }

/* Fix per il click sulle notifiche */
.notification-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.notification-link:hover {
    text-decoration: none;
    color: #007bff;
}

.notification-item {
    position: relative;
    cursor: pointer;
}

.notification-item.unread {
    background: linear-gradient(90deg, #fff3cd 0%, #ffffff 100%);
    border-left: 4px solid #ffc107;
}

.notification-item:hover {
    background: #f8f9fa;
}

.notification-item.unread:hover {
    background: linear-gradient(90deg, #fff0b3 0%, #f8f9fa 100%);
}

/* Animazioni migliorate */
.notification-item-enter {
    animation: slideInNotification 0.3s ease-out;
}

.notification-item-exit {
    animation: slideOutNotification 0.3s ease-in forwards;
}

@keyframes slideInNotification {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutNotification {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Stile per la cella delle azioni nelle tabelle admin */
.action-buttons-cell {
    width: 120px; /* Larghezza fissa per la colonna azioni */
    text-align: center; /* Centra il contenuto (il bottone) */
    vertical-align: middle;
}

/* --- STILI MIGLIORATI PER MODALE GESTIONE SQUADRA --- */
#squadra-modal .modal-content {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#squadra-modal .modal-body {
    flex-grow: 1;
    overflow-y: auto;
}

#squadra-modal .tabs-container {
    padding: 0 !important;
    border: none !important;
    background: none !important;
}

#squadra-modal .tab-button {
    background: #e9ecef;
    border: 1px solid #dee2e6;
    color: #495057;
    font-weight: 600;
}

#squadra-modal input[type="radio"]:checked + .tab-button {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

#squadra-modal .tab-content {
    padding: 1.5rem 0.5rem;
    border-top: 1px solid #dee2e6;
    margin-top: -1px; /* Sovrappone il bordo per un effetto più pulito */
}

/* Stile per la cronologia punti */
#punti-history-container {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    max-height: 250px;
    overflow-y: auto;
}
#punti-history-container p {
    font-size: 0.9rem;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
    margin-bottom: 8px;
}
#punti-history-container p:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
#punti-history-container strong {
    color: var(--primary-color);
}
#punti-history-container em {
    color: #6c757d;
}

/* --- STILI MODALI A SCHEDE --- */
.modal-tabs {
    display: flex;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 1.5rem;
}
.tab-button {
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-size: 1rem;
    font-weight: 500;
    color: #6c757d;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px; /* Allinea con il bordo inferiore */
    transition: all 0.2s ease;
}
.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}
.tab-button:hover:not(.active) {
    background-color: #f8f9fa;
}

/* Gestione visibilità schede */
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: fadeInTab 0.4s ease;
}
@keyframes fadeInTab {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stile Data Admin Concorrenza*/

.assign-points-form {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.form-group input[type="date"] {
    color: #4a5568;
    cursor: pointer;
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator {
    color: #667eea;
    cursor: pointer;
    filter: brightness(0) saturate(100%) invert(41%) sepia(94%) saturate(1040%) hue-rotate(225deg) brightness(97%) contrast(97%);
}

.form-hint {
    display: block;
    color: #718096;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-style: italic;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #edf2f7;
    transform: translateY(-1px);
}

.squadra-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid #f0f0f0;
    transition: all 0.3s ease;
}

.squadra-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.squadra-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.squadra-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.squadra-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.squadra-info h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #2d3748;
}

.squadra-info p {
    margin: 0;
    color: #718096;
    font-size: 0.875rem;
}

.squadra-punteggio {
    text-align: center;
}

.punteggio {
    font-size: 2rem;
    font-weight: 800;
    color: #667eea;
    display: block;
}

.squadra-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.squadra-non-registrata {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
}

/* Responsive design */
@media (max-width: 768px) {
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        justify-content: center;
    }
    
    .squadra-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .squadra-actions {
        flex-direction: column;
    }
}

/* =================================
   ADMIN CONCORRENZA - STILI AGGIUNTIVI
   ================================= */

/* Container statistiche */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
    padding: 0;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: transform 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stili tabella squadre migliorati */
.squadra-row {
    transition: all 0.2s ease;
}

.squadra-row:hover {
    background: linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
    transform: translateX(4px);
}

.classe-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.lega-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lega-badge.biennio {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.lega-badge.triennio {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

.nome-squadra-cell .squadra-registrata {
    font-weight: 600;
    color: #2d3748;
}

.nome-squadra-cell .squadra-non-registrata {
    color: #a0aec0;
    font-style: italic;
}

.punteggio-cell {
    text-align: center;
}

.punteggio-numero {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: #667eea;
}

.btn-gestisci {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-gestisci.enabled {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-gestisci.enabled:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-gestisci.disabled {
    background: #f7fafc;
    color: #a0aec0;
    cursor: not-allowed;
}

/* Form data evento */
#data-evento-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: white;
    color: #4a5568;
    font-family: 'Poppins', sans-serif;
}

#data-evento-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

#data-evento-input::-webkit-calendar-picker-indicator {
    color: #667eea;
    cursor: pointer;
    filter: brightness(0) saturate(100%) invert(41%) sepia(94%) saturate(1040%) hue-rotate(225deg) brightness(97%) contrast(97%);
}

/* Storia punti migliorata */
.history-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: #edf2f7;
    transform: translateX(4px);
}

.history-timestamp {
    font-size: 0.75rem;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.history-details {
    font-weight: 500;
    color: #2d3748;
    margin-bottom: 0.25rem;
}

.history-user {
    font-size: 0.75rem;
    color: #718096;
    font-style: italic;
}

.no-history {
    text-align: center;
    color: #a0aec0;
    padding: 2rem;
    background: #f9fafb;
    border-radius: 8px;
    font-style: italic;
}

/* Loading spinner */
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Messaggio di successo */
.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(72, 187, 120, 0.3);
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.success-message.show {
    transform: translateX(0);
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .classe-cell {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .success-message {
        right: 10px;
        left: 10px;
        transform: translateY(-100px);
    }
    
    .success-message.show {
        transform: translateY(0);
    }
}

/* Form hint per il campo data */
.form-group small.form-hint {
    display: block;
    color: #718096;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-style: italic;
}

/* Migliora lo stile dei bottoni di submit */
button[type="submit"] {
    position: relative;
    overflow: hidden;
}

button[type="submit"]:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

button[type="submit"]:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* --- STILI PER MODALE INSTALLAZIONE PWA --- */
.pwa-install-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 22, 41, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 2000;
}

.pwa-install-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.pwa-install-modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 15px 50px rgba(0,0,0,0.2);
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.pwa-install-modal-overlay.active .pwa-install-modal-content {
    transform: scale(1);
    opacity: 1;
}

.pwa-modal-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.pwa-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
    color: #333;
}

.pwa-modal-text {
    color: #6c757d;
    margin: 0 0 2rem 0;
    line-height: 1.6;
}

.pwa-modal-actions {
    display: flex;
    gap: 1rem;
}

/* --------------------------------------------- */
/* ------         CACCIA AL TESORO          ---- */
/* --------------------------------------------- */
.treasure-widget-content {
    padding: 1rem 0;
}

.treasure-stats-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.treasure-stat-mini {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

.treasure-stat-mini .stat-icon {
    font-size: 2rem;
    line-height: 1;
}

.treasure-stat-mini .stat-info {
    display: flex;
    flex-direction: column;
}

.treasure-stat-mini .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3748;
    line-height: 1;
}

.treasure-stat-mini .stat-label {
    font-size: 0.75rem;
    color: #718096;
    font-weight: 500;
}

.treasure-progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.treasure-progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #cea936 0%, #d4af37 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.treasure-status {
    text-align: center;
    font-size: 0.875rem;
    color: #718096;
    font-style: italic;
    margin: 0;
}