/* assets/style.css */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-blue: #2E5BBA;
    --secondary-red: #D32F2F;
    --light-gray: #f8f9fa;
    --border-gray: #e0e0e0;
    --success-green: #28a745;
    --warning-orange: #ffc107;
    --info-cyan: #17a2b8;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--primary-blue) 0%, #1976D2 100%);
    min-height: 100vh;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 100%; /* Occupa tutta la larghezza disponibile */
    margin: 0 auto;
    padding: 0 20px; /* Mantiene solo un po' di respiro interno a destra e sinistra */
}
.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    animation: fadeInUp 0.6s ease-out forwards;
}

/* ====== SEZIONE COMUNICAZIONI SOCIETARIE & BADGE (NUOVO) ====== */
.comunicazioni-icon-wrapper {
    position: relative;
    display: inline-block;
    font-size: 28px;
    margin-right: 10px;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -12px;
    background: var(--secondary-red);
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    padding: 2px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 10;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.full-pdf-viewer { width: 100%; height: 75vh; border: none; border-radius: 8px; }
.full-img-viewer { max-width: 100%; height: auto; border-radius: 10px; }

/* ====== CERTIFICATI ALERT COMPATTO ====== */
.certificati-alert-compact {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 2px solid var(--warning-orange);
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(255, 193, 7, 0.3);
    overflow: hidden;
}

.alert-header {
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(45deg, #ffc107, #ffca28);
    color: #856404;
    font-weight: bold;
    transition: background 0.3s ease;
}

.alert-header:hover {
    background: linear-gradient(45deg, #ffb300, #ffc107);
}

.cert-count {
    background: var(--secondary-red);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9em;
    margin-left: 10px;
}

.toggle-arrow {
    font-size: 20px;
    transition: transform 0.3s ease;
}

.cert-details {
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
}

.cert-item {
    margin: 10px 0;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid var(--warning-orange);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.cert-status.scaduto {
    color: var(--secondary-red);
    font-weight: bold;
}

.cert-status.scadenza {
    color: var(--warning-orange);
    font-weight: bold;
}

/* ====== NAVIGAZIONE GARE ====== */
.gare-navigation h2 {
    margin-bottom: 20px;
    color: var(--primary-blue);
    text-align: center;
}

.navigation-buttons {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 200px;
    text-align: center;
    touch-action: manipulation;
}

.nav-btn.active {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.nav-btn:hover::before {
    left: 100%;
}

.badge {
    background: var(--primary-blue);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    margin-left: 10px;
}

/* ====== SEZIONI GARE ====== */
.gare-section {
    display: block;
}

.gare-section[style*="none"] {
    display: none !important;
}

/* ====== RICERCA ====== */
.search-section {
    background: white;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 2px solid var(--light-gray);
}

.search-section h4 {
    color: var(--primary-blue);
    margin-bottom: 20px;
    font-size: 1.2em;
    text-align: center;
}

.search-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.search-controls input[type="text"],
.search-controls input[type="date"],
.search-controls select {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    border: 2px solid var(--border-gray);
    border-radius: 25px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: white;
}

.search-controls input:focus,
.search-controls select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(46, 91, 186, 0.1);
}

/* ====== GARE CARD COMPATTE ====== */
/* Sostituisci la regola .gara-grid esistente con questa */
.gare-grid {
    display: grid;
    /* Usa auto-fit ma con un limite massimo per evitare card giganti */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); 
    gap: 20px;
    margin-top: 20px;
    justify-content: center; /* Centra le card se sono poche */
}

/* Modifica .gara-card aggiungendo margin: 0 auto; */
.gara-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* AGGIUNTA FONDAMENTALE: */
    max-width: 450px; /* Non farla mai diventare più larga di così */
    width: 100%;      /* Occupa lo spazio disponibile fino al max */
    margin: 0 auto;   /* Centra la card nella sua colonna */
}
.gara-card.compact {
    min-height: 300px;
    max-height: 400px;
}

.gara-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

/* ====== LOCANDINE COMPATTE ====== */

.gara-locandina {
    position: relative;
    width: 100%;
    
    /* ⬇️ MODIFICA QUI: Riduciamo l'altezza */
    height: 180px; /* Era 250px. 180px è un'altezza standard per le card */
    
    border-radius: 15px 15px 0 0;
    overflow: hidden;
    
    /* ⬇️ MODIFICA QUI: Sfondo Bianco */
    background-color: #ffffff; /* Mettiamo bianco così lo spazio vuoto non sembra un "bordo" */
    
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-bottom: 1px solid #f0f0f0;
}

.gara-locandina img {
    width: 100%;
    height: 100%;
    
    /* Mantiene l'immagine intera */
    object-fit: contain; 
    
    /* Opzionale: Allinea l'immagine in basso se preferisci che "poggi" sul testo */
    /* object-position: center bottom; */
    
    transition: transform 0.5s ease;
}

.gara-locandina img:hover {
    transform: scale(1.05);
}

/* --- VERSIONE MOBILE --- */
@media (max-width: 768px) {
    .gara-locandina {
        /* Su cellulare la facciamo ancora più bassa per risparmiare spazio */
        height: 150px; 
    }
}
.gara-locandina.compact {
    height: 100px;
}
.default-runner-image {
    font-size: 60px;
    color: var(--primary-blue);
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
}

.default-runner-image:hover {
    transform: scale(1.1);
    color: #1976D2;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
}

/* ====== CONTENUTO GARA COMPATTO ====== */
.gara-content {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.deadline-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 10px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: bold;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.deadline-open {
    background: linear-gradient(45deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 1px solid #b8dacd;
}

.deadline-closed {
    background: linear-gradient(45deg, #f8d7da, #f1b0b7);
    color: #721c24;
    border: 1px solid #f1b0b7;
}

.gara-header {
    margin-bottom: 12px;
}

.gara-header.compact {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.gara-title {
    font-size: 1.1em;
    font-weight: bold;
    color: #333;
    line-height: 1.3;
    flex: 1;
}

.gara-date {
    background: linear-gradient(45deg, var(--primary-blue), #1976D2);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(46, 91, 186, 0.3);
}

.gara-details.compact {
    margin-bottom: 10px;
}

.detail-item {
    margin: 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.0em;
}

.detail-icon {
    font-size: 1em;
    width: 20px;
    text-align: center;
    color: var(--primary-blue);
}

/* ====== ISCRITTI SECTION COMPATTA ====== */
.iscritti-section {
    margin: 15px 0;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 10px;
    border: 1px solid #dee2e6;
}

.iscritti-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    flex-wrap: wrap; /* FONDAMENTALE: Permette di andare a capo su mobile */
    gap: 10px;       /* Crea spazio tra gli elementi quando vanno a capo */
}
/* OTTIMIZZAZIONE SPECIFICA PER IL TASTO CLASSIFICA SU MOBILE */
@media (max-width: 768px) {
    .iscritti-header {
        justify-content: center; /* Centra tutto su mobile */
    }
    
    /* Rende il bottone classifica bello grande e cliccabile su mobile */
    .iscritti-header button {
        width: 100%;             /* Occupa tutta la larghezza */
        justify-content: center; /* Centra il testo nel bottone */
        margin-left: 0 !important; /* Rimuove margini laterali forzati */
        margin-top: 5px;         /* Un po' di spazio sopra */
        padding: 8px !important; /* Più facile da premere col dito */
    }
}

.iscritti-count {
    background: linear-gradient(45deg, var(--primary-blue), #1976D2);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.8em;
    box-shadow: 0 2px 8px rgba(46, 91, 186, 0.3);
    border: none;
    touch-action: manipulation;
}

.iscritti-count:hover {
    background: linear-gradient(45deg, #1976D2, #1565C0);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(46, 91, 186, 0.4);
}

/* ====== AZIONI GARA ====== */
.gara-actions {
    margin-top: 15px;
    text-align: center;
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.9em;
    border-radius: 25px;
    font-weight: bold;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    touch-action: manipulation;
}

/* ====== FORM AGGIUNTA UTENTE ====== */
.add-user-form {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-radius: 15px;
    padding: 25px;
    border-left: 4px solid var(--info-cyan);
    margin-top: 20px;
}

.add-user-form h4,
.compact-form h4,
.card h4,
form h4 {
    color: var(--primary-blue);
    margin: 30px 0 20px 0;
    font-size: 1.1em;
    border-bottom: 2px solid var(--primary-blue);
    padding-bottom: 8px;
    font-weight: bold;
}

.add-user-form h4:first-of-type,
.compact-form h4:first-of-type {
    margin-top: 10px;
}

.documents-upload-section {
    background: rgba(255, 255, 255, 0.8);
    padding: 25px;
    border-radius: 10px;
    margin: 30px 0;
    border: 1px solid #dee2e6;
}

.documents-upload-section h4 {
    color: var(--warning-orange) !important;
    margin-bottom: 20px !important;
    border-color: var(--warning-orange) !important;
}

/* Stili per codice fiscale */
#cf_status {
    font-size: 12px;
    font-weight: bold;
}

/* Select e textarea styling */
select, textarea {
    width: 100%;
    padding: 18px 15px 8px 15px;
    border: 2px solid var(--border-gray);
    border-radius: 8px;
    font-size: 16px;
    background: white;
    transition: all 0.3s ease;
}

select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(46, 91, 186, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Form field label per select e textarea */
.form-field select + label,
.form-field textarea + label {
    position: absolute;
    top: -8px;
    left: 12px;
    font-size: 12px;
    color: var(--primary-blue);
    font-weight: bold;
    background: white;
    padding: 0 8px;
}

/* Documenti grid */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.document-card {
    transition: transform 0.3s ease;
}

.document-card:hover {
    transform: translateY(-3px);
}

/* ====== FORM AGGIUNTA GARA ====== */
.add-gara-form {
    background: linear-gradient(135deg, #e8f5e8, #f1f8e9);
    border-radius: 15px;
    padding: 25px;
    border-left: 4px solid var(--success-green);
    margin-top: 20px;
}

.file-upload-section {
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border: 1px solid #dee2e6;
}

.file-upload-section h4 {
    color: var(--info-cyan);
    margin-bottom: 15px;
    font-size: 1.1em;
}

/* ====== UPLOAD FILE ====== */
.file-upload-wrapper {
    position: relative;
    margin: 15px 0;
}

.file-upload-wrapper label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.file-upload-wrapper input[type="file"] {
    width: 100%;
    padding: 15px;
    border: 2px dashed var(--border-gray);
    border-radius: 8px;
    background: #f9f9f9;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.file-upload-wrapper input[type="file"]:hover {
    border-color: var(--primary-blue);
    background: #f0f8ff;
    border-style: solid;
}

.file-upload-wrapper small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

/* ====== PREVIEW IMMAGINI ====== */
.image-preview {
    margin-top: 15px;
    padding: 15px;
    border: 1px solid var(--border-gray);
    border-radius: 10px;
    background: white;
    text-align: center;
}

.image-preview img {
    max-width: 200px;
    max-height: 150px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

/* ====== CERTIFICATO UPLOAD ====== */
.certificate-upload-section {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 25px;
    border-radius: 15px;
    border-left: 4px solid var(--info-cyan);
    margin: 20px 0;
}

.certificate-upload-section h4 {
    color: var(--info-cyan);
    margin-bottom: 15px;
    font-size: 1.1em;
}

/* ====== FORM GRIDS E CAMPI ====== */
.form-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 15px;
}

.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.form-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }

/* ====== FORM COMPATTO ADMIN ====== */
.compact-form {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border-left: 4px solid var(--success-green);
}

.compact-form h3 {
    color: var(--success-green);
    margin-bottom: 15px;
    font-size: 1.1em;
}

.form-field {
    position: relative;
    width: 100%;
}

.form-field input,
.form-field textarea,
.form-field select {
    padding: 18px 15px 8px 15px;
    border: 2px solid var(--border-gray);
    border-radius: 8px;
    font-size: 16px;
    width: 100%;
    background: white;
    transition: all 0.3s ease;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(46, 91, 186, 0.1);
}

.form-field label {
    position: absolute;
    top: 18px;
    left: 15px;
    background: white;
    padding: 0 8px;
    color: #888;
    font-size: 16px;
    pointer-events: none;
    transition: all 0.3s ease;
    transform-origin: left top;
}

.form-field input:focus + label,
.form-field input:not(:placeholder-shown) + label,
.form-field select:focus + label {
    top: -8px;
    left: 12px;
    font-size: 12px;
    color: var(--primary-blue);
    font-weight: bold;
}

/* ====== BOTTONI ====== */
button, .btn-primary, .btn-success, .btn-danger, .btn-warning, .btn-info {
    padding: 15px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
    min-width: 110px;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    touch-action: manipulation;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

button:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary { background: var(--primary-blue); color: white; }
.btn-success { background: var(--success-green); color: white; }
.btn-danger { background: var(--secondary-red); color: white; }
.btn-warning { background: var(--warning-orange); color: #333; }
.btn-info { background: var(--info-cyan); color: white; }

button:hover:not(:disabled), .btn-primary:hover, .btn-success:hover, .btn-danger:hover, .btn-warning:hover, .btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* ====== ISCRITTO BADGE & ALERTS ====== */
.iscritto-badge {
    background: linear-gradient(45deg, var(--success-green), #218838);
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    margin: 3px;
    display: inline-block;
}

.alert {
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: bold;
    border-left: 5px solid;
    white-space: pre-line;
}

.alert-success { background: #d4edda; color: #155724; border-color: var(--success-green); }
.alert-error { background: #f8d7da; color: #721c24; border-color: var(--secondary-red); }
.alert-warning { background: #fff3cd; color: #856404; border-color: var(--warning-orange); }

/* ====== USER INFO & STATUS ====== */
.user-info {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 25px;
    text-align: center;
    border: 2px solid var(--primary-blue);
}

.certificato-status {
    padding: 18px;
    border-radius: 12px;
    margin: 15px 0;
    font-weight: bold;
    text-align: center;
    border-left: 5px solid;
}

.certificato-valido { background: #d4edda; color: #155724; border-color: var(--success-green); }
.certificato-scadenza { background: #fff3cd; color: #856404; border-color: var(--warning-orange); }
.certificato-scaduto { background: #f8d7da; color: #721c24; border-color: var(--secondary-red); }

/* ====== MODALS ====== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    backdrop-filter: blur(8px);
    animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 25px;
    border-radius: 20px;
    max-width: 1000px; width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.3);
}

/* ====== TABELLE ====== */
.table-container {
    overflow-x: auto;
    margin-top: 20px;
    border-radius: 12px;
    border: 1px solid #dee2e6;
}

.utenti-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.utenti-table th, .utenti-table td {
    padding: 18px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-gray);
}

.utenti-table th {
    background: linear-gradient(135deg, var(--light-gray), #e9ecef);
    font-weight: bold;
    text-transform: uppercase;
}


/* ====== ARCHIVIO & TABS ====== */
.archivio-anno-header {
    cursor: pointer;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
}

.tab-button {
    padding: 12px 20px;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-weight: bold;
    background: var(--light-gray);
}

.tab-button.active {
    background: var(--primary-blue);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ====== STATS & REPORTS ====== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
	grid-template-columns: repeat(4, 1fr);
}

.stat-card {
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.report-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #dee2e6;
}
/* QUANDO SIAMO SU TABLET O MOBILE (Schermi sotto 768px) */
    @media (max-width: 768px) {
        .stats-grid {
            /* Passa a 2 colonne (griglia 2x2) che è perfetta per il mobile */
            grid-template-columns: repeat(2, 1fr);
            gap: 10px; /* Riduciamo leggermente lo spazio */
        }
        
        /* Opzionale: Se lo schermo è piccolissimo (sotto 350px), va a 1 colonna */
        @media (max-width: 350px) {
            .stats-grid {
                grid-template-columns: 1fr;
            }
        }
        
        .stat-card {
            padding: 15px !important; /* Meno padding su mobile */
        }
        .stat-number {
            font-size: 1.5em !important; /* Numero un po' più piccolo */
        }
    }

/* Stile Select Pagamento */
.payment-select {
    padding: 6px 10px;
    border-radius: 20px;
    border: 1px solid #ddd;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
    text-align-last: center; /* Per centrare il testo dentro la select */
    width: 130px;
    appearance: none; /* Rimuove la freccia standard brutta su alcuni browser */
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right .7em top 50%;
    background-size: .65em auto;
}

/* Stile quando NON è pagato (Rosso) */
.payment-select.unpaid {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Stile quando È pagato (Verde) */
.payment-select.paid {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.payment-select:hover {
    filter: brightness(0.95);
}

.payment-select:focus {
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.25);
}
/* ====== BADGES FIDAL/SOCIETARIA ====== */
.fidal-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #0066CC, #004499);
    color: white;
    padding: 8px 14px;
    border-radius: 18px;
    font-size: 12px;
    font-weight: bold;
}

.fidal-logo { width: 20px; height: 18px; background: white; padding: 2px; border-radius: 4px; }

.societaria-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #28a745, #1e7e34);
    color: white;
    padding: 8px 14px;
    border-radius: 18px;
    font-size: 12px;
    font-weight: bold;
}

.societaria-logo { width: 20px; height: 20px; background: white; padding: 2px; border-radius: 4px; }
/* ====== BADGES FIDAL/SOCIETARIA & LOGHI GARA ====== */

/* Contenitore flessibile per i loghi */
.badges-row {
    display: flex;
    flex-wrap: nowrap; /* Forza su una riga */
    gap: 8px;
    align-items: center;
    margin: 10px 0;
    overflow-x: auto; /* Permette scroll orizzontale se necessario su schermi minuscoli */
    -webkit-overflow-scrolling: touch; /* Scroll fluido su iOS */
    padding-bottom: 2px; /* Spazio per scrollbar se appare */
}

/* Stile base unificato per tutti i badge (Crono, Fidal, Societaria) */
.badge-crono {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: white;
    padding: 6px 12px;
    border-radius: 18px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap; /* Impedisce al testo di andare a capo */
    flex-shrink: 0; /* Impedisce al badge di schiacciarsi */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.badge-crono img {
    width: 20px;
    height: 20px;
    background: white;
    padding: 2px;
    border-radius: 50%; /* Icone tonde sono più carine */
    object-fit: contain;
}

/* Colori Specifici */
.bg-pizzano { background: linear-gradient(135deg, #FF6B35, #E55A2B); }
.bg-icron   { background: linear-gradient(135deg, #28A745, #1E7E34); }
.bg-camelot { background: linear-gradient(135deg, #2E5BBA, #1A237E); }
.bg-fidal   { background: linear-gradient(135deg, #005eb8, #00448a); }
.bg-societaria { background: linear-gradient(135deg, #6f42c1, #59359a); }

/* --- OTTIMIZZAZIONE MOBILE (RIMPICCIOLIMENTO) --- */
@media (max-width: 768px) {
    .badges-row {
        gap: 4px; /* Meno spazio tra i badge */
        justify-content: flex-start; /* Allinea a sinistra */
    }

    .badge-crono {
        font-size: 9px !important; /* Testo molto più piccolo */
        padding: 4px 8px !important; /* Padding ridotto */
        gap: 4px !important;
        border-radius: 12px;
        height: 24px; /* Altezza fissa ridotta */
    }

    .badge-crono img {
        width: 14px !important; /* Icone minuscole */
        height: 14px !important;
        padding: 1px !important;
    }
}
/* ====== CHIP & CONFERME ====== */
.chip-info-section {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #2196f3;
}

.conferma-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: bold;
}

.conferma-badge.confermata { background: #d4edda; color: #155724; }
.conferma-badge.da-confermare { background: #fff3cd; color: #856404; }

.stats-conferme { display: flex; gap: 15px; justify-content: center; margin: 20px 0; flex-wrap: wrap; }
.stat-conferma { background: white; padding: 15px 20px; border-radius: 12px; text-align: center; border: 2px solid; min-width: 120px; }
.stat-conferma.confermate { border-color: #28a745; background: #d4edda; }
.stat-conferma.da-confermare { border-color: #ffc107; background: #fff3cd; }

/* ====== ADMIN ACTION BUTTONS ====== */
.admin-action-buttons {
    display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; align-items: center;
}

.admin-action-buttons button, .admin-action-buttons a {
    flex: 0 0 auto; white-space: nowrap; border-radius: 4px; font-weight: bold; display: inline-flex; align-items: center; justify-content: center;
}

/* ====== DELETE QUOTA BUTTON ====== */
.delete-quota-btn {
    position: absolute; top: 5px; right: 5px; background: #dc3545; color: white; border: none; border-radius: 50%;
    width: 16px; height: 16px; cursor: pointer; font-size: 10px; display: flex; align-items: center; justify-content: center;
    z-index: 10; opacity: 0.8;
}

.delete-quota-btn:hover { background: #c82333; transform: scale(1.2); opacity: 1; }

/* ====== PASSWORD REQUIREMENTS & STRENGTH (DETTAGLIATO) ====== */
.password-requirements { background: rgba(255, 255, 255, 0.9); border: 1px solid var(--border-gray); border-radius: 8px; padding: 15px; margin-top: 10px; font-size: 14px; }
.requirement { display: flex; align-items: center; margin-bottom: 8px; }
.req-icon { width: 16px; height: 16px; margin-right: 10px; display: flex; align-items: center; justify-content: center; }
.requirement.valid { color: var(--success-green); }
.requirement.invalid { color: var(--danger-red); }

.strength-bar { height: 6px; background: #e0e0e0; border-radius: 3px; overflow: hidden; margin-bottom: 5px; }
.strength-fill { height: 100%; transition: all 0.3s ease; }
.strength-weak { background: var(--danger-red); width: 25%; }
.strength-fair { background: var(--warning-orange); width: 50%; }
.strength-good { background: var(--info-cyan); width: 75%; }
.strength-strong { background: var(--success-green); width: 100%; }

.password-match { padding: 8px 12px; border-radius: 6px; font-size: 14px; font-weight: bold; text-align: center; margin-top: 10px; }
.password-match.match { background: rgba(40, 167, 69, 0.1); color: var(--success-green); border: 1px solid var(--success-green); }
.password-match.no-match { background: rgba(220, 53, 69, 0.1); color: var(--danger-red); border: 1px solid var(--danger-red); }

/* ====== DOCUMENT VIEW MODAL ====== */
#existing_documents { max-height: 400px; overflow-y: auto; }
.loading-docs { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
    .admin-action-buttons { flex-direction: column; width: 100%; }
    .admin-action-buttons button, .admin-action-buttons a { width: 100%; font-size: 10px !important; }
}

@media (max-width: 768px) {
    .header h1 { font-size: 1.8em; }
    .navigation-buttons, .tabs { flex-direction: column; }
    .nav-btn, .tab-button { width: 100%; }
    .gare-grid, .stats-grid, .report-grid { grid-template-columns: 1fr; }
    .table-container { margin: 10px -15px; border-radius: 0; }
    .utenti-table th, .utenti-table td { padding: 10px 8px; font-size: 0.9em; }
    .notification-badge { right: 50%; margin-right: -25px; }
}


.btn-backup-manuale {
                background-color: #ff9800; /* Arancione per attenzione */
                color: white !important;
                padding: 10px 20px;
                border-radius: 5px;
                text-decoration: none;
                font-weight: bold;
                font-size: 14px;
                display: inline-flex;
                align-items: center;
                gap: 8px;
                box-shadow: 0 2px 5px rgba(0,0,0,0.2);
                transition: all 0.3s ease;
            }
            .btn-backup-manuale:hover {
                background-color: #e65100; /* Arancione più scuro */
                transform: translateY(-2px);
                box-shadow: 0 4px 8px rgba(0,0,0,0.3);
            }
            /* Su mobile il bottone va sotto il titolo */
            @media (max-width: 600px) {
                .card > div:first-child {
                    flex-direction: column;
                    gap: 15px;
                    align-items: flex-start !important;
                }
                .btn-backup-manuale {
                    width: 100%;
                    justify-content: center;
                }
            }
/* ====== SCROLLBAR & ANIMATION ====== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--primary-blue); border-radius: 4px; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}
/* =========================================
   STILE CARD COMUNICAZIONI (LATO UTENTE)
   ========================================= */

/* Contenitore scorrevole (Desktop e Mobile) */
.scrolling-wrapper {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 15px;
    padding-bottom: 15px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding-right: 20px;
}

/* Scrollbar sottile */
.scrolling-wrapper::-webkit-scrollbar { height: 6px; }
.scrolling-wrapper::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
.scrolling-wrapper::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* CARD BASE (Desktop) */
.scrolling-card {
    flex: 0 0 auto;
    width: 240px; /* Larghezza desktop */
    margin-bottom: 0 !important;
    font-size: 0.9em;
}

/* Icona standard */
.compact-icon {
    height: 100px;
    font-size: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compact-title {
    font-size: 1.1em;
    line-height: 1.3;
    height: auto;
    margin-bottom: 5px;
}

/* ==================================================
   OTTIMIZZAZIONE MOBILE (MAX 768px)
   ================================================== */

@media (max-width: 768px) {

    /* --- 1. LATO UTENTE: Card Super Compatte --- */
    
    .scrolling-wrapper {
        gap: 10px; /* Spazio ridotto */
    }

    .scrolling-card {
        width: 160px !important; /* LARGHEZZA RIDOTTA: Permette di vederne 2.5 */
        border-radius: 10px;
    }

    /* Icona molto più bassa per risparmiare spazio */
    .scrolling-card .gara-locandina {
        height: 70px !important;
    }
    
    .compact-icon {
        height: 70px !important;
        font-size: 28px !important;
    }

    /* Contenuto interno compatto */
    .scrolling-card .gara-content {
        padding: 8px !important;
    }

    /* Titolo max 2 righe */
    .compact-title {
        font-size: 0.85rem !important;
        line-height: 1.2 !important;
        height: 2.4em; /* Forza altezza fissa per allineamento */
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        margin-bottom: 5px !important;
    }
    
    /* Data e Badge piccoli */
    .scrolling-card .gara-date { font-size: 0.7rem !important; padding: 2px 6px !important; }
    .scrolling-card .badge { font-size: 0.7rem !important; padding: 2px 5px !important; }

    /* Bottone "Leggi" alto e facile da premere */
    .scrolling-card .btn-info {
        padding: 0 !important;
        font-size: 0.8rem !important;
        height: 34px !important; /* Altezza fissa touch-friendly */
        min-height: 34px !important;
        margin-bottom: 5px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
    }

    /* Checkbox e testo "Confermo" */
    .scrolling-card .presa-visione-wrapper {
        padding: 6px !important;
        background: #fff8e1;
        border: 1px solid #ffecb3;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .scrolling-card .presa-visione-wrapper input {
        transform: scale(1.2) !important;
        margin-right: 5px;
    }
    
    .scrolling-card .presa-visione-wrapper span {
        font-size: 0.75rem !important;
        color: #856404;
        font-weight: bold;
    }


    /* --- 2. LATO ADMIN: Trasformazione Tabella in Card --- */

    /* Nascondi intestazione tabella */
    #comunicazioniTab table thead { display: none; }

    /* Riga diventa Card */
    #comunicazioniTab table tbody tr {
        display: flex;
        flex-direction: column;
        background: #fff;
        border: 1px solid #eee;
        border-radius: 10px;
        margin-bottom: 15px;
        padding: 15px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }

    #comunicazioniTab table td {
        display: block;
        width: 100% !important;
        text-align: left;
        padding: 5px 0;
        border: none;
    }

    /* Data in alto grigia */
    #comunicazioniTab table td:nth-child(1) {
        font-weight: bold; color: #666; font-size: 0.85em; margin-bottom: 5px;
    }

    /* Titolo grande */
    #comunicazioniTab table td:nth-child(2) {
        font-size: 1.1em; margin-bottom: 10px;
    }

    /* Barra statistiche */
    #comunicazioniTab table td:nth-child(3) {
        background: #f8f9fa; padding: 10px; border-radius: 8px; margin-bottom: 10px;
    }

    /* Pulsante "Vedi chi" bello grande */
    #comunicazioniTab td:nth-child(3) .btn-small {
        padding: 8px 15px !important;
        font-size: 13px !important;
        height: auto !important;
        background: #17a2b8;
        color: white;
        border-radius: 20px;
        margin-top: 5px;
        display: inline-block;
        width: 100%; /* Larghezza piena */
        text-align: center;
    }

    /* Bottoni Azione (Griglia 3 colonne) */
    #comunicazioniTab table td:last-child {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 10px;
        border-top: 1px solid #eee;
        padding-top: 10px;
        margin-top: 5px;
    }

    #comunicazioniTab td:last-child .btn-small {
        width: 100% !important;
        height: 40px !important; /* Alti per il dito */
        font-size: 18px !important; /* Icone grandi */
        border-radius: 8px;
        margin: 0 !important;
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Colori bottoni */
    #comunicazioniTab td:last-child a.btn-info { background-color: #17a2b8; }
    #comunicazioniTab td:last-child button.btn-success { background-color: #28a745; }
    #comunicazioniTab td:last-child a.btn-danger { background-color: #dc3545; }

    /* Form caricamento verticale */
    #comunicazioniTab .form-grid.cols-3 {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    #comunicazioniTab .file-upload-wrapper { margin-top: 0 !important; }
}
/* =========================================
   FIX MOBILE USER INFO (Benvenuto + Tasti)
   ========================================= */

@media (max-width: 768px) {
    /* Trasforma la barra in verticale */
    .user-info {
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px;
        text-align: center;
    }

    /* Il contenitore dei bottoni occupa tutto lo spazio */
    .user-info > div:last-child {
        width: 100%;
        display: flex;
        flex-direction: column; /* Bottoni uno sotto l'altro */
        gap: 10px;
    }

    /* Rende i bottoni grandi e facili da premere */
    .user-info .btn-info, 
    .user-info .btn-warning {
        width: 100%;
        display: flex;
        justify-content: center;
        margin: 0 !important;
        padding: 12px !important;
    }
    
    /* Riduce leggermente il testo di benvenuto se serve */
    .user-info strong {
        font-size: 1.1em;
        display: block;
        margin-bottom: 5px;
    }
}
/* =========================================
   FIX MOBILE DATI ANAGRAFICI (Form Responsivo)
   ========================================= */

@media (max-width: 768px) {

    /* 1. Trasforma tutte le griglie in UNA sola colonna */
    .form-grid, 
    .form-grid.cols-2, 
    .form-grid.cols-3, 
    .form-grid.cols-4,
    .form-grid.cols-5 {
        grid-template-columns: 1fr !important; /* 1 colonna che occupa tutto */
        gap: 15px !important; /* Spazio verticale tra i campi */
        display: grid !important;
    }

    /* 2. Riduci il padding del contenitore bianco per guadagnare spazio */
    .add-user-form, 
    .compact-form,
    .card {
        padding: 15px !important; /* Meno bordo bianco ai lati */
        border-radius: 10px; /* Angoli meno arrotondati per sembrare più app nativa */
    }

    /* 3. Ottimizza gli Input per il tocco */
    .form-field input, 
    .form-field select, 
    .form-field textarea {
        font-size: 16px !important; /* Evita che iPhone faccia lo zoom automatico */
        padding: 15px 10px 5px 10px !important; /* Spazio interno ottimizzato */
        min-height: 50px; /* Altezza minima per facilitare il tocco */
    }

    /* 4. Sistema le etichette (Label) flottanti */
    /* Assicura che stiano in alto e non sopra il testo */
    .form-field label {
        font-size: 11px !important;
        top: 5px !important;
        left: 10px !important;
    }
    
    .form-field input:focus + label,
    .form-field input:not(:placeholder-shown) + label,
    .form-field select:focus + label,
    .form-field select + label {
        top: 2px !important;
    }

    /* 5. Se hai il pulsante Calcola Codice Fiscale, mandalo a capo e allargalo */
    .cf-button-wrapper, 
    button[onclick*="calcolaCF"] {
        width: 100% !important;
        margin-top: 5px !important;
        display: block;
    }
    
    /* 6. Titoli delle sezioni più piccoli */
    h4 {
        font-size: 1.1em !important;
        margin-top: 20px !important;
    }
}
/* ==============================================
   FIX RADIO BUTTONS (Ordini e Moduli)
   ============================================== */

/* Contenitore per le opzioni radio */
.radio-options-container {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-bottom: 20px;
}

/* Titolo della domanda */
.radio-question-label {
    display: block;
    font-weight: bold;
    color: var(--primary-blue);
    margin-bottom: 10px;
    font-size: 1.1em;
}

/* La singola riga cliccabile (pallino + testo) */
.custom-radio-item {
    display: flex !important;
    align-items: center !important;
    background: white;
    border: 1px solid #ccc;
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-radio-item:hover {
    background: #e3f2fd;
    border-color: var(--primary-blue);
}

/* Il pallino vero e proprio */
.custom-radio-item input[type="radio"] {
    appearance: auto !important; /* Forza aspetto nativo del browser */
    -webkit-appearance: radio !important;
    width: 20px !important;
    height: 20px !important;
    margin: 0 10px 0 0 !important;
    position: static !important; /* Non assoluto */
    opacity: 1 !important;
    pointer-events: auto !important; /* Fondamentale per il click */
    cursor: pointer;
}

/* Il testo accanto al pallino */
.custom-radio-item span {
    font-size: 15px;
    color: #333;
    pointer-events: none; /* Il click passa al contenitore label */
}
/* =========================================
   STILE BOTTONI EXPORT (PDF & CSV)
   ========================================= */

.btn-export-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Stile Base Bottone con Icona */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Spazio tra icona e testo */
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    color: white !important; /* Testo sempre bianco */
}

.btn-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Colore PDF (Rosso Adobe) */
.btn-pdf {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}
.btn-pdf:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
}

/* Colore CSV/Excel (Verde Excel) */
.btn-csv {
    background: linear-gradient(135deg, #27ae60, #219150);
}
.btn-csv:hover {
    background: linear-gradient(135deg, #219150, #1e8449);
}

/* Dimensione Icone SVG */
.btn-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor; /* Prende il colore del testo (bianco) */
}
/* ========================================================== */
/* FIX ULTIMO: SOLUZIONE SOVRAPPOSIZIONE MODULO UTENTE */
/* ========================================================== */

/* 1. Forza il contenitore del campo ad essere un blocco solido */
#userModuloModal .form-field {
    display: flex !important;
    flex-direction: column !important; /* Mette etichetta sopra e input sotto */
    margin-bottom: 25px !important;    /* Spazio abbondante sotto */
    position: relative !important;
    border: none !important;
    padding: 0 !important;
    height: auto !important;
    width: 100% !important;
}

/* 2. Forza l'etichetta (Label) a stare SOPRA e BEN VISIBILE */
#userModuloModal .form-field label {
    position: relative !important; /* Disabilita posizionamenti assoluti strani */
    top: auto !important;
    left: auto !important;
    transform: none !important;
    display: block !important;
    margin-bottom: 8px !important; /* Spazio tra scritta e casella */
    font-weight: bold !important;
    color: #333 !important;
    font-size: 15px !important;
    background: transparent !important;
    padding: 0 !important;
    width: 100% !important;
    text-align: left !important;
    z-index: 10 !important; /* Assicura che stia sopra */
}

/* 3. Aggiusta la casella Select e Input */
#userModuloModal select,
#userModuloModal input[type="text"] {
    display: block !important;
    width: 100% !important;
    height: 50px !important; /* Altezza comoda per il dito */
    padding: 10px 15px !important;
    font-size: 16px !important;
    line-height: normal !important;
    background-color: #fff !important;
    border: 2px solid #ddd !important; /* Bordo ben visibile */
    border-radius: 8px !important;
    box-sizing: border-box !important;
    margin-top: 0 !important;
    box-shadow: none !important;
    color: #000 !important;
    -webkit-appearance: menulist !important; /* Ripristina la freccina standard su mobile */
    appearance: menulist !important;
}

/* 4. Effetto Focus (quando clicchi) */
#userModuloModal select:focus,
#userModuloModal input:focus {
    border-color: #2E5BBA !important;
    outline: none !important;
    box-shadow: 0 0 0 4px rgba(46, 91, 186, 0.1) !important;
}
/* =======================================================
   FIX 1: ALLINEAMENTO BOTTONI TABELLA MOVIMENTI
   ======================================================= */

/* Target specifico per l'ultima colonna della tabella movimenti */
#tabella-movimenti td:last-child {
    display: flex !important;           /* Usa Flexbox */
    align-items: center !important;     /* Centra verticalmente */
    justify-content: center !important; /* Centra orizzontalmente */
    gap: 5px !important;                /* Spazio tra i bottoni */
    height: 100%;                       /* Occupa tutta l'altezza della cella */
    border-bottom: none;                /* Rimuove doppio bordo se presente */
}

/* Uniforma l'altezza dei bottoni dentro quella cella */
#tabella-movimenti td:last-child .btn-info,
#tabella-movimenti td:last-child .btn-danger,
#tabella-movimenti td:last-child span { /* Per l'icona lucchetto */
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 30px !important;            /* Altezza fissa uniforme */
    width: auto !important;             /* Larghezza automatica */
    min-width: 30px !important;         /* Larghezza minima per il quadrato */
    padding: 0 8px !important;          /* Padding laterale */
    font-size: 12px !important;
    line-height: 1 !important;
}

/* =======================================================
   FIX 2: LABEL SOVRAPPOSTE (SCHEDA CONFIGURAZIONE)
   ======================================================= */

/* In questa sezione, disabilitiamo l'effetto floating.
   Le etichette staranno fisse SOPRA i campi input. */

#configurazioneTab .form-field {
    display: flex !important;
    flex-direction: column !important;
    margin-bottom: 15px !important;
}

#configurazioneTab .form-field label {
    position: relative !important;      /* Non più assoluto */
    top: auto !important;
    left: auto !important;
    transform: none !important;         /* Rimuove animazioni */
    
    display: block !important;
    margin-bottom: 5px !important;      /* Spazio tra etichetta e campo */
    
    font-size: 14px !important;         /* Dimensione fissa */
    font-weight: bold !important;
    color: var(--primary-blue) !important;
    background: transparent !important; /* Rimuove lo sfondo bianco che copriva */
    padding: 0 !important;
    width: 100% !important;
    text-align: left !important;
    pointer-events: auto !important;    /* Riabilita click se necessario */
}

/* Rimuove lo spostamento in alto che si attivava al focus */
#configurazioneTab .form-field input:focus + label,
#configurazioneTab .form-field input:not(:placeholder-shown) + label {
    top: auto !important;
    left: auto !important;
}

/* Aggiusta l'input per non avere spazi strani */
#configurazioneTab .form-field input,
#configurazioneTab .form-field select {
    margin-top: 0 !important;
    padding: 10px 15px !important;      /* Padding standard */
    height: 45px !important;            /* Altezza fissa */
}
/* STILE LABEL FISSE (PER CONFIGURAZIONE E FORNITORI) */
#configurazioneTab .form-field, 
#fornitoriTab .form-field {
    display: flex !important;
    flex-direction: column !important;
    margin-bottom: 15px !important;
}

#configurazioneTab .form-field label, 
#fornitoriTab .form-field label {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    display: block !important;
    margin-bottom: 5px !important;
    font-size: 14px !important;
    font-weight: bold !important;
    color: var(--primary-blue) !important;
    background: transparent !important;
    padding: 0 !important;
    width: 100% !important;
    text-align: left !important;
}

#configurazioneTab .form-field input, 
#configurazioneTab .form-field select,
#fornitoriTab .form-field input, 
#fornitoriTab .form-field select {
    margin-top: 0 !important;
    padding: 10px 15px !important;
    height: 45px !important;
}
/* =============================================================
   FIX DEFINITIVO ADMIN - MODAL EDIT ORDINE (Radio Button)
   Questo agisce SOLO sul modal di modifica ordine admin
   ============================================================= */

/* 1. Contenitore specifico per i radio button */
#editOrdineModal .radio-admin-container {
    display: block !important;
    position: static !important;
    background: #f8f9fa !important;
    padding: 15px !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 8px !important;
    margin-bottom: 20px !important;
}

/* 2. Titolo della domanda */
#editOrdineModal .radio-admin-title {
    font-weight: bold !important;
    color: var(--primary-blue) !important;
    margin-bottom: 10px !important;
    display: block !important;
}

/* 3. La riga dell'opzione (pallino + testo) */
#editOrdineModal .radio-admin-option {
    display: flex !important;
    align-items: center !important;
    padding: 8px 10px !important;
    background: white !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    margin-bottom: 8px !important;
    cursor: pointer !important;
    position: static !important; /* Importante: rimuove absolute */
    pointer-events: auto !important; /* Importante: abilita click */
    transform: none !important;
}

#editOrdineModal .radio-admin-option:hover {
    background: #e3f2fd !important;
    border-color: var(--primary-blue) !important;
}

/* 4. Il pallino vero e proprio */
#editOrdineModal .radio-admin-option input[type="radio"] {
    position: static !important;
    opacity: 1 !important;
    appearance: auto !important;
    -webkit-appearance: radio !important;
    width: 20px !important;
    height: 20px !important;
    margin: 0 10px 0 0 !important;
    cursor: pointer !important;
    z-index: 100 !important;
    pointer-events: auto !important;
}

#editOrdineModal .radio-admin-option span {
    font-size: 15px !important;
    color: #333 !important;
}
/* ==========================================================
   FIX MODULO UTENTE (Lato Atleta) - Radio Buttons
   ========================================================== */

/* Rimuove i blocchi ereditati dai form standard */
#userModuloModal .radio-user-wrapper {
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

/* Titolo della domanda */
#userModuloModal .radio-user-label {
    display: block;
    font-weight: bold;
    color: #333;
    margin-bottom: 12px;
    font-size: 1.1em;
}

/* La riga cliccabile */
#userModuloModal .radio-user-item {
    display: flex !important;
    align-items: center !important;
    background: white;
    border: 1px solid #ced4da;
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#userModuloModal .radio-user-item:hover {
    background-color: #e3f2fd;
    border-color: #2E5BBA;
}

/* Il pallino input */
#userModuloModal .radio-user-item input[type="radio"] {
    appearance: auto !important;
    -webkit-appearance: radio !important;
    width: 24px !important;
    height: 24px !important;
    margin: 0 15px 0 0 !important;
    cursor: pointer;
    position: static !important;
    opacity: 1 !important;
    pointer-events: auto !important; /* SBLOCCA IL CLICK */
}

#userModuloModal .radio-user-item span {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}
/* =======================================================
   FIX MOBILE: APPROVAZIONE CERTIFICATI (Card View)
   ======================================================= */

/* Stile base per il form di approvazione */
.cert-approval-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.approval-date-wrapper {
    display: flex;
    flex-direction: column;
}

.approval-date-wrapper label {
    font-size: 11px;
    font-weight: bold;
    color: #666;
    margin-bottom: 2px;
}

/* MEDIA QUERY MOBILE (Sotto i 768px) */
@media (max-width: 768px) {
    
    /* 1. Nascondi l'intestazione della tabella (chi, documento, azioni) */
    .admin-notifications-table thead {
        display: none;
    }

    /* 2. Trasforma ogni riga (TR) in una CARD */
    .admin-notifications-table tr {
        display: flex;
        flex-direction: column;
        background: #fff;
        border-left: 5px solid #ff9800; /* Bordo arancione laterale */
        border-radius: 8px;
        margin-bottom: 20px;
        padding: 15px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    }

    /* 3. Stile celle (TD) */
    .admin-notifications-table td {
        display: block;
        width: 100%;
        padding: 10px 0;
        border-bottom: 1px dashed #eee;
        text-align: left !important; /* Forza allineamento a sinistra */
    }

    .admin-notifications-table td:last-child {
        border-bottom: none;
        padding-top: 15px;
    }

    /* 4. Bottone "Vedi Documento" bello grande */
    .admin-notifications-table .btn-info {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 12px;
        font-size: 16px;
        background-color: #17a2b8;
        margin-top: 5px;
    }

    /* 5. Form di Approvazione Verticale */
    .cert-approval-form {
        flex-direction: column;
        width: 100%;
        gap: 15px;
    }

    .approval-date-wrapper, 
    .approval-date-wrapper input {
        width: 100%;
    }

    /* Input data più alto per il dito */
    .approval-date-wrapper input {
        padding: 12px;
        font-size: 16px; /* Evita zoom su iPhone */
        border: 1px solid #ccc;
        border-radius: 5px;
        background: #f9f9f9;
    }

    /* Checkbox Cartaceo più visibile */
    .cert-approval-form label {
        font-size: 14px !important;
        padding: 10px;
        background: #fff3e0;
        border-radius: 5px;
        width: 100%;
        display: flex;
        align-items: center;
    }

    .cert-approval-form input[type="checkbox"] {
        transform: scale(1.5); /* Checkbox più grande */
        margin-right: 10px !important;
    }

    /* Bottone Approva gigante verde */
    .cert-approval-form button {
        width: 100%;
        padding: 15px;
        font-size: 18px;
        margin-top: 5px;
        border-radius: 8px;
    }
}

.cron-time-row {
        display: flex;
        gap: 10px;
        margin-top: 10px;
    }
    .cron-time-col {
        flex: 1;
    }
    
    /* Quando lo schermo è piccolo (Mobile), metti in colonna */
    @media (max-width: 768px) {
        .cron-time-row {
            flex-direction: column; /* Impila verticalmente */
            gap: 15px; /* Più spazio tra uno e l'altro */
        }
        .cron-time-col {
            width: 100%; /* Larghezza piena */
        }
        /* Rende gli input più alti per essere cliccati col dito */
        .cron-time-col input {
            padding: 10px; 
            font-size: 16px; /* Evita lo zoom automatico su iPhone */
        }
    }
/* CONTENITORE PULITO E CENTRATO */
.alert-cartaceo {
    display: flex;           /* Flexbox */
    justify-content: center; /* <--- CENTRA ORIZZONTALMENTE */
    align-items: center;     /* Centra verticalmente */
    width: 100%;             /* Occupa tutta la larghezza disponibile */
    
    gap: 10px;               
    margin-top: 10px;        
    font-size: 0.95em;
    border: none;            
    background: transparent; 
}

/* TESTO CHE LAMPEGGIA (Resta uguale) */
.flash-text {
    color: #dc3545;          
    font-weight: 700;        
    text-transform: uppercase;
    animation: text-blink 2.5s infinite ease-in-out;
}

/* ANIMAZIONE LAMPEGGIO (Resta uguale) */
@keyframes text-blink {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* TESTO CHE LAMPEGGIA */
.flash-text {
    color: #dc3545;          /* Rosso vivo */
    font-weight: 700;        /* Grassetto */
    text-transform: uppercase;
    animation: text-blink 1.5s infinite ease-in-out;
}

/* ANIMAZIONE LAMPEGGIO */
@keyframes text-blink {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}
/* --- FOTO PROFILO HEADER (PICCOLA) --- */
.header-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #e0e0e0;
    overflow: hidden;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px; /* Per l'omino */
    flex-shrink: 0;
}

.header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- SEZIONE CARICAMENTO FOTO (GRANDE) --- */
.profile-photo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px dashed #ccc;
}

.photo-preview {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #f0f0f0;
    border: 4px solid white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-preview img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-placeholder {
    font-size: 60px;
    color: #bbb;
}

/* Pulsante Fotocamera */
.camera-btn {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: var(--primary-blue);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid white;
    font-size: 18px;
    transition: transform 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.camera-btn:hover {
    transform: scale(1.1);
    background: #1565C0;
}

/* Adattamento Mobile per Header */
@media (max-width: 768px) {
    .header-avatar {
        width: 60px;
        height: 60px;
    }
}

/* ==========================================================
   STILI BOTTONI AZIONI (Base Desktop & Mobile Shared)
   ========================================================== */

/* Contenitore Bottoni */
.azioni-conferma {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: flex-end; /* Desktop: allineati a destra */
}

/* Stile Base Bottone (Uniforme per button e a) */
.btn-conferma {
    /* Dimensioni fisse per renderli identici su Desktop */
    min-width: 90px;
    height: 32px;
    
    /* Layout interno */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    
    /* Stile */
    padding: 0 10px;
    font-size: 11px;
    font-family: inherit;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    text-decoration: none; /* Toglie sottolineatura dai link */
    line-height: 1;
    
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-conferma:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
    opacity: 0.9;
}

/* Colori */
.btn-conferma.confermate { 
    background: linear-gradient(135deg, #28a745, #218838); 
    color: white; 
}
.btn-conferma.annulla { 
    background: linear-gradient(135deg, #ffc107, #e0a800); 
    color: #333; 
}
.btn-conferma.elimina { 
    background: linear-gradient(135deg, #dc3545, #c82333); 
    color: white; 
}


/* ==========================================================
   OTTIMIZZAZIONE MOBILE DEFINITIVA (Admin - Gestione Iscritti)
   ========================================================== */

@media (max-width: 768px) {
    
    /* 1. Header Strumenti in colonna */
    .admin-tools-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tools-right {
        flex-direction: column;
        width: 100%;
        gap: 15px;
    }

    /* 2. Filtro a larghezza piena */
    .filter-box {
        width: 100%;
        justify-content: space-between;
        padding: 10px;
    }
    .filter-box select {
        flex: 1;
        text-align: right;
    }

    /* 3. Bottoni PDF/CSV grandi */
    .btn-export-group {
        display: flex;
        width: 100%;
        gap: 10px;
    }
    .btn-export-group .btn-icon {
        flex: 1;
        justify-content: center;
        padding: 12px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* 4. Tabella Responsive (Card View) */
    .mobile-responsive-table thead {
        display: none;
    }

    .mobile-responsive-table tr {
        display: block;
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 12px;
        margin-bottom: 20px;
        padding: 15px;
        box-shadow: 0 4px 8px rgba(0,0,0,0.05);
        position: relative;
    }

    /* Checkbox selezione */
    .mobile-responsive-table td.mobile-check-cell {
        position: absolute;
        top: 15px;
        right: 15px;
        width: auto !important;
        padding: 0 !important;
        border: none !important;
        z-index: 10;
    }
    .mobile-responsive-table .conferma-checkbox {
        transform: scale(1.8);
        width: 20px;
        height: 20px;
    }

    /* Celle normali */
    .mobile-responsive-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px dashed #eee;
        text-align: right;
        width: 100%;
    }
    
    /* Ultima cella (Azioni) */
    .mobile-responsive-table td:last-child {
        border-bottom: none;
        padding-top: 15px;
        margin-top: 5px;
        border-top: 2px solid #f0f0f0;
        justify-content: center;
        display: block !important; /* Importante per contenere i bottoni */
    }

    /* Label dati */
    .mobile-responsive-table td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #666;
        font-size: 0.9em;
        text-transform: uppercase;
        text-align: left;
    }
    
    /* Nascondi label non necessarie */
    .mobile-responsive-table td[data-label="Azioni"]::before,
    .mobile-responsive-table td.mobile-check-cell::before,
    .mobile-responsive-table td[data-label="Atleta"]::before {
        display: none;
    }

    /* Nome Utente */
    .mobile-responsive-table td[data-label="Atleta"] {
        display: block;
        text-align: left;
        padding-right: 40px;
        margin-bottom: 5px;
    }

    /* Select Pagamento */
    .payment-select {
        width: 100% !important;
        max-width: 200px;
        padding: 12px;
        font-size: 16px;
        height: auto;
    }

    /* 5. BOTTONI AZIONE AFFIANCATI SU MOBILE (FIX DEFINITIVO) */
    .azioni-conferma {
        display: flex !important;
        flex-direction: row !important; /* Forza orizzontale */
        flex-wrap: nowrap !important;   /* Impedisce a capo */
        gap: 10px !important;
        width: 100% !important;
    }
    
    .btn-conferma {
        flex: 1 1 0px !important; /* Forza larghezza uguale (grow, shrink, basis) */
        width: 100% !important;   /* Occupa tutto lo spazio disponibile */
        min-width: 0 !important;  /* Permette di restringersi se necessario */
        
        padding: 12px 5px !important; 
        font-size: 13px !important;
        height: 45px !important; /* Più alti su mobile */
        border-radius: 8px !important;
        
        white-space: nowrap !important; 
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* 6. INFO (Email/Tel) A SINISTRA */
    .mobile-responsive-table td[data-label="Info"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        justify-content: flex-start !important;
    }
    
    .mobile-responsive-table td[data-label="Info"] a {
        text-align: left;
    }
}
/* =========================================
   FIX MOBILE: CLASSIFICA E MODAL TEMPI
   ========================================= */

@media (max-width: 768px) {
    /* Trasforma la tabella risultati in card */
    .results-mobile-card thead {
        display: none; /* Nasconde l'intestazione su mobile */
    }

    .results-mobile-card tr {
        display: block;
        background: #fff;
        border: 1px solid #eee;
        border-radius: 12px;
        margin-bottom: 15px;
        padding: 12px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    }

    .results-mobile-card td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 8px 0 !important;
        border-bottom: 1px dashed #f0f0f0;
        width: 100% !important;
    }

    .results-mobile-card td:last-child {
        border-bottom: none;
        justify-content: center; /* Centra i bottoni azione */
        background: #f8f9fa;
        margin-top: 5px;
        border-radius: 0 0 8px 8px;
    }

    /* Inserisce il nome della colonna prima del dato */
    .results-mobile-card td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #666;
        text-transform: uppercase;
        font-size: 11px;
        float: left;
        text-align: left;
    }

    /* Sistema il modulo "Inserisci Tempo" su mobile */
    #editRisultatoModal .form-grid {
        grid-template-columns: 1fr !important; /* Una colonna sola */
        gap: 10px;
    }
}
/* =========================================
   FIX DEFINITIVO MOBILE: COSTO, DISTANZA E SCAGLIONI
   ========================================= */

@media (max-width: 768px) {
    /* 1. Forza ogni campo del form ad avere la sua riga senza interferenze */
    #editGaraModal .form-grid, 
    #addGaraSection .form-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important; /* Aumentiamo lo spazio tra i campi */
    }

    /* 2. Sistemiamo il contenitore Costo Base + Bottone */
    .costo-scaglioni-wrapper {
        display: flex !important;
        flex-direction: column !important; /* Su mobile: input sopra, bottone sotto */
        grid-column: auto !important; /* Rimuove il disturbo sulla griglia */
        gap: 10px !important;
        width: 100% !important;
    }

    /* Assicuriamoci che l'input del costo non "scappi" */
    .costo-scaglioni-wrapper .form-field {
        width: 100% !important;
    }

    /* 3. Sistemiamo il campo Distanza (che spesso sparisce) */
    #edit_distanza_gara, #distanza_gara {
        width: 100% !important;
        height: 50px !important;
    }

    /* 4. Il pannello scaglioni deve apparire come un blocco separato */
    #scaglioniPanel_edit, #scaglioniPanel_add {
        grid-column: auto !important;
        width: 100% !important;
        margin-top: 10px !important;
        padding: 15px !important;
        box-sizing: border-box !important;
    }

    /* 5. Card degli scaglioni più pulite */
    .scaglione-row-card {
        padding: 15px !important;
        margin-bottom: 20px !important;
        padding-top: 35px !important; /* Spazio per la X */
        border: 2px solid #ffcc80 !important;
    }

    /* Forza le etichette a stare al loro posto */
    .form-field label {
        z-index: 5 !important;
    }
}

/* Fix per allineamento etichette quando il campo è pieno */
.form-field input:not(:placeholder-shown) + label,
.form-field input:focus + label {
    background: white !important; /* Evita che le linee degli altri campi passino dietro il testo */
    padding: 0 4px !important;
}

