:root {
    --calendar-header-height: 80px;
    --calendar-time-col-width: 60px;
    --calendar-row-height: 30px;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f3f4f6;
}

.page { display: none; }
.page.active { display: block; }

.modal-backdrop { background-color: rgba(0,0,0,0.5); }
.modal { transition: all 0.3s ease-in-out; }

/* Classi di utilità per colori primari dell'app */
.app-bg-primary { 
    background-color: #16a34a;
}
.app-text-primary { 
    color: #16a34a;
}
.app-ring-primary:focus { 
    --tw-ring-color: rgb(34 197 94 / 0.5);
    box-shadow: 0 0 0 2px rgb(34 197 94 / 0.5);
    outline: none;
}

/* Stile pulsanti di navigazione */
.nav-btn {
    padding: 0.5rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-width: 1px;
}

/* Stile per i pulsanti cache refresh */
.cache-refresh-btn {
    opacity: 0.6;
    transition: all 0.2s ease;
    background: none;
    border: none;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.cache-refresh-btn:hover {
    opacity: 1;
    text-decoration-style: solid;
    transform: translateY(-1px);
}

.cache-refresh-btn:active {
    transform: translateY(0);
}

@media (min-width: 768px) {
    .nav-btn {
        padding-left: 1rem;
        padding-right: 1rem;
        font-size: 0.875rem;
    }
}

/* Stili generici per i pulsanti */
.btn-primary {
    background-color: #16a34a;
    color: #ffffff;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: background-color 0.2s ease-in-out;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: #15803d;
}

.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.75);
}

.btn-secondary {
    background-color: #e5e7eb;
    color: #374151;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s ease-in-out;
    border: none;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: #d1d5db;
}

.btn-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.75);
}

.btn-pill-primary {
    background-color: #16a34a;
    color: #ffffff;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: background-color 0.2s ease-in-out;
    border: none;
    cursor: pointer;
}

.btn-pill-primary:hover {
    background-color: #15803d;
}

.btn-pill-primary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.75);
}

.btn-pill-secondary {
    background-color: #ffffff;
    color: #dc2626;
    border: 1px solid #ef4444;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    transition: background-color 0.2s ease-in-out;
    cursor: pointer;
}

.btn-pill-secondary:hover {
    background-color: #fef2f2;
}

.btn-pill-secondary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.75);
}

/* Stili per le card e i campi di input */
.card {
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
}

.input-field {
    width: 100%;
    border: 1px solid #d1d5db;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease-in-out;
}

.input-field:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.5);
}

/* Stili per l'importazione file CSV */
#csv-dropzone {
    border: 2px dashed #cbd5e1; 
    padding: 2rem; 
    text-align: center; 
    cursor: pointer; 
    border-radius: 0.5rem; 
    transition: background-color 0.2s;
}

#csv-dropzone.dragover { 
    background-color: #e2e8f0; 
    border-color: #16a34a; 
}

/* Stile per la modalità sola lettura */
.read-only .action-button {
    display: none !important;
}

.read-only .schedule-event {
    cursor: default !important;
}

/* Stili per la sezione Presenze */
.athlete-row.is-absent .athlete-name { 
    color: #ef4444; 
    text-decoration: line-through; 
}

.presence-checkbox { 
    height: 1.5rem; 
    width: 1.5rem; 
    border-radius: 0.25rem; 
    border-color: #d1d5db; 
    color: #16a34a;
    -webkit-appearance: none;
    appearance: none;
    background-color: #fff;
    border: 1px solid #d1d5db;
    padding: 0;
    display: inline-block;
    position: relative;
}

.presence-checkbox:checked {
    background-color: #16a34a;
    border-color: #16a34a;
}

.presence-checkbox:checked::after {
    content: '✓';
    font-size: 1.25rem;
    color: white;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

.presence-checkbox:focus {
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.5);
    outline: none;
    border-color: #16a34a;
}

/* Stili Sezione Calendario */
#calendar-container {
    position: relative;
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background-color: #fff;
}

#calendar-grid {
    display: grid;
    position: relative;
}

.calendar-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: #4b5563;
}

.time-slot {
    grid-column: 1;
    font-size: 0.75rem;
    text-align: right;
    padding-right: 0.5rem;
    color: #6b7281;
    transform: translateY(-50%);
    border-right: 1px solid #e5e7eb;
    background-color: #f9fafb;
}

.grid-cell {
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.2s;
}

.grid-cell:hover:not(.has-event) { 
    background-color: #f0fdf4; 
    cursor: pointer; 
}

.day-header { 
    grid-row: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

.location-header { 
    grid-row: 2; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 0.75rem; 
    font-weight: 500;
}

.schedule-event {
    position: absolute;
    z-index: 10;
    border-radius: 0.375rem;
    border-left: 4px solid;
    padding: 0.25rem 0.5rem;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.schedule-event:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

.schedule-event p { 
    font-size: 0.75rem; 
    line-height: 1.2; 
}


/* Stili Sezione Partite */
#partite-filters-container .team-filter-btn {
    transition: all 0.2s ease-in-out;
    opacity: 0.5;
}

#partite-filters-container .team-filter-btn.selected {
    opacity: 1;
    border-color: #16a34a; /* green-600 */
    background-color: #f0fdf4; /* green-50 */
}

/* Aumenta altezza celle mese */
#partite-calendar .fc-daygrid-day-frame {
    min-height: 120px;
}

/* Stili per rendering custom evento partita */
.fc-event-custom-render .partido-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.fc-event-custom-render .partido-time,
.fc-event-custom-render .partido-location {
    font-size: 0.8em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.partido-title {
    font-weight: 600;
}

.partido-location {
    color: #6b7280; /* gray-500 */
}

/* Responsive per la toolbar del calendario */
@media (max-width: 767px) {
    #partite-calendar .fc-header-toolbar.fc-toolbar {
        flex-direction: column;
        gap: 0.75rem;
        margin-bottom: 1rem !important;
    }
    #partite-calendar .fc-toolbar-chunk {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    #partite-calendar .fc-toolbar-chunk:nth-child(2) { /* title */
        justify-content: center;
    }
     #partite-calendar .fc-toolbar-chunk:nth-child(3) { /* button group */
        justify-content: center;
    }
    #partite-calendar .fc-toolbar-title {
        font-size: 1.25rem;
    }
    #partite-calendar .fc-button {
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
    }
    #partite-calendar .fc-button-group {
        display: flex;
        flex-grow: 1;
    }
    #partite-calendar .fc-dayGridMonth-button,
    #partite-calendar .fc-timeGridWeek-button,
    #partite-calendar .fc-listWeek-button {
        flex-grow: 1;
    }
}

/* Nasconde il testo del giorno duplicato nella vista agenda */
#partite-calendar .fc-list-day-side-text {
    display: none;
}

/* MODIFICA: Forzatura per evitare l'overflow del titolo nella vista agenda */
#partite-calendar .fc-list-event-title {
    overflow: hidden;
    width: 100%;
}

/* Stili aggiuntivi per i nuovi filtri allenamenti (Versione Definitiva) */
.filter-wrapper {
    position: relative;
}

.allenamenti-filter-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    text-align: left;
    background-color: #e5e7eb;
    color: #374151;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    user-select: none; /* Impedisce la selezione del testo al click */
    transition: background-color 0.2s ease-in-out;
}
.allenamenti-filter-btn:hover {
    background-color: #d1d5db;
}

.filter-dropdown {
    position: absolute;
    z-index: 30;
    top: 100%;
    left: 0;
    width: 100%;
    margin-top: 0.25rem;
    background-color: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
}

.filter-dropdown label,
.filter-dropdown .search-result-item {
    display: block;
    padding: 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.filter-dropdown label:hover,
.filter-dropdown .search-result-item:hover {
    background-color: #f3f4f6;
}

/* ================================================================== */
/* FIX DEFINITIVO PER FILTRI CLICCABILI IN MODALITA' SOLA LETTURA */
/* ================================================================== */

/* Questa regola assicura che il contenitore dei nostri pulsanti
   non venga reso "trasparente" ai click. */
.read-only .filter-wrapper {
    pointer-events: auto !important;
}

/* Questa regola forza i nostri pulsanti ad essere sempre cliccabili,
   ripristinando il cursore a puntatore e gli eventi di click. */
.read-only .allenamenti-filter-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Stili per la lista atleti mobile */
.team-color-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 9999px;
    display: inline-block;
    margin-right: 0.3rem;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Stili per il filtro mobile-friendly */
.mobile-filter-option {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease-in-out;
}
.mobile-filter-option.selected {
    background-color: #dcfce7; /* green-100 */
    border-color: #22c55e; /* green-500 */
    font-weight: 600;
}
.mobile-filter-option .checkbox-icon {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #9ca3af; /* gray-400 */
    border-radius: 0.375rem;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease-in-out;
}
.mobile-filter-option.selected .checkbox-icon {
    background-color: #16a34a; /* green-600 */
    border-color: #16a34a;
    color: white;
}

.teams-list-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem; /* 8px */
    justify-content: flex-end;
    text-align: right;
    max-width: 70%;
}

.read-only .training-card-clickable {
    pointer-events: auto !important;
    cursor: pointer !important;
}