/* --- style.css --- */

/* =========================================
   1. VARIABILI GLOBALI E RESET
   ========================================= */
:root {
    --primary-blue: #1e4896;
    --accent-red: #e6332a;
    --light-gray: #f4f4f4;
    --text-dark: #333;
    --header-height: 80px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Roboto', sans-serif; color: var(--text-dark); line-height: 1.6; overflow-x: hidden; background: var(--light-gray); min-height: 100vh; display: flex; flex-direction: column; }
a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; }
img, video { max-width: 100%; height: auto; display: block; }

/* =========================================
   2. HEADER & NAV (Base / Desktop)
   ========================================= */
header { background: #ffffff; box-shadow: 0 2px 10px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 1000; height: var(--header-height); display: flex; align-items: center; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; width: 100%; }
.navbar { display: flex; justify-content: space-between; align-items: center; height: 100%; width: 100%; }

/* Logo */
.logo a { display: flex; align-items: center; text-decoration: none; }
.logo span { font-size: 1.5rem; font-weight: 700; color: var(--primary-blue); margin-left: 10px; }
.logo img { height: 60px; object-fit: contain; }

/* Pulsanti Base */
.btn-iscriviti { background: var(--accent-red); color: white !important; padding: 8px 15px; border-radius: 5px; font-weight: bold; }
.btn-riservata { border: 2px solid var(--primary-blue); color: var(--primary-blue) !important; padding: 6px 15px; border-radius: 5px; font-weight: bold; }
.btn-riservata:hover { background: var(--primary-blue); color: white !important; }

/* Menu Toggle (Mobile - Nascosto su Desktop) */
.menu-toggle { display: none; font-size: 1.8rem; color: var(--primary-blue); cursor: pointer; z-index: 1001; }

/* Navigazione Desktop */
.nav-links { display: flex; gap: 20px; align-items: center; height: 100%; }
.nav-links li { position: relative; display: flex; align-items: center; height: 100%; }
.nav-links > li > a { font-weight: 500; font-size: 1rem; color: var(--text-dark); display: flex; align-items: center; gap: 5px; }
.nav-links > li > a:hover { color: var(--accent-red); }

/* 1. CREA IL PUNTO DI ANCORAGGIO PER IL MENU (Fondamentale) */
.nav-item-dropdown {
    position: relative; 
}

/* 2. STILE DEL SOTTOMENU */
.dropdown {
    display: none; 
    position: absolute;
    top: 100%; /* <-- MODIFICATO: Si attacca esattamente sotto il bottone genitore */
    left: 0;   /* <-- MODIFICATO: Si allinea perfettamente a sinistra di "Chi Siamo" */
    background: white;
    min-width: 220px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    border-radius: 0 0 8px 8px;
    z-index: 1000;
    padding: 10px 0;
}

.dropdown li { 
    width: 100%; 
    height: auto; 
    display: block; 
}

.dropdown li a {
    padding: 12px 20px !important;
    font-size: 0.9rem !important;
    font-weight: 400;
    color: var(--text-dark);
    display: block;
    border-bottom: 1px solid #f0f0f0;
}

.dropdown li a:hover { 
    background: #f8f8f8; 
    color: var(--accent-red) !important; 
}

/* Mostra il dropdown al passaggio del mouse su Desktop */
@media (min-width: 901px) {
    .nav-item-dropdown:hover .dropdown { 
        display: block; 
    }
}
/* =========================================
   3. MEDIA QUERIES MOBILE (Menu Riparato)
   ========================================= */
@media (max-width: 900px) {
    .menu-toggle { display: block; }
    
    .logo img { height: 50px; }
    .logo span { font-size: 1.2rem; }

    /* Contenitore Menu a scorrimento laterale */
    .nav-links { 
        display: flex; 
        position: fixed; 
        top: var(--header-height); 
        left: -100%; 
        width: 100%; 
        height: calc(100vh - var(--header-height)); 
        background: white; 
        flex-direction: column; 
        align-items: flex-start;
        justify-content: flex-start; 
        padding: 0;
        gap: 0; 
        transition: left 0.3s ease-in-out; 
        box-shadow: 0 4px 6px rgba(0,0,0,0.1); 
        overflow-y: auto; 
    }
    
    /* Quando JS aggiunge "active", scorre dentro */
    .nav-links.active { left: 0; }
    
    /* STRUTTURA A LISTA VERTICALE PER RISOLVERE IL PROBLEMA SOTTOMENU */
    .nav-links li { 
        width: 100%; 
        height: auto; 
        display: block; /* <-- FORZA GLI ELEMENTI AD ANDARE A CAPO, NON DI LATO */
        border-bottom: 1px solid #eee; 
    }
    
    /* Stile per i bottoni "Area Riservata" e "Contattaci" su mobile */
    .mobile-action-btn { padding: 15px 20px; border-bottom: none !important; }
    .btn-iscriviti, .btn-riservata { 
        width: 100%; text-align: center; padding: 12px; display: block;
    }

    .nav-links > li > a { 
        font-size: 1.2rem; 
        padding: 15px 20px; 
        width: 100%;
        display: flex;
        justify-content: space-between; /* Mette la freccia a destra */
    }

    /* --- GESTIONE SOTTOMENU "CHI SIAMO" CHE SCENDE VERSO IL BASSO --- */
    .dropdown {
        position: static !important; /* Fondamentale: lo fa scendere sotto al genitore */
        display: none; 
        box-shadow: none;
        background: #f9f9f9;
        width: 100%;
        padding: 0;
        border-radius: 0;
    }
    
    /* Questo viene attivato dal tocco del dito */
    .dropdown.show { display: block !important; }
    
    .dropdown li a {
        padding: 12px 20px 12px 40px !important; /* Rientranza laterale per far capire che č un sottomenu */
        font-size: 1rem !important;
        border-bottom: 1px solid #eee;
        display: block;
    }
    
    .icon-dropdown { transition: transform 0.3s ease; }
    .icon-dropdown.rotate { transform: rotate(180deg); }
}

@media (max-width: 600px) {
    /* MANTIENE LA SCRITTA VISIBILE SUI CELLULARI RIDUCENDOLA */
    .logo img { height: 40px; }
    .logo span { 
        display: block !important; 
        font-size: 0.95rem; /* Un po' pių piccola per non accavallarsi col menu */
        line-height: 1.1;
    } 
}


/* =========================================
   4. SEZIONI GENERALI E COMPONENTI
   ========================================= */
.hero { background: linear-gradient(to bottom, #1e4896, #f4f4f4); padding: 60px 0 40px; text-align: center; color: white; }
.hero-content { margin-bottom: 30px; padding: 0 10px; }
.hero h1 { font-size: 3rem; margin-bottom: 10px; text-transform: uppercase; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); line-height: 1.2; }
.hero h2 { font-size: 1.5rem; font-weight: 300; margin-bottom: 15px; }
.hero-img-container { max-width: 1000px; margin: 0 auto; border-radius: 15px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.3); border: 4px solid white; }

.section-padding { padding: 60px 0; }
.section-title { text-align: center; margin-bottom: 40px; color: var(--primary-blue); font-size: 2rem; text-transform: uppercase; line-height: 1.3; }
.bg-light { background-color: var(--light-gray); }

/* Documenti */
.docs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 30px; }
.doc-card { background: white; border: 1px solid #ddd; border-radius: 10px; padding: 30px; text-align: center; transition: transform 0.3s, box-shadow 0.3s; }
.doc-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.doc-icon { font-size: 3rem; color: var(--accent-red); margin-bottom: 20px; }
.doc-btn { display: inline-block; margin-top: 20px; padding: 10px 25px; background: var(--primary-blue); color: white; border-radius: 5px; }

/* Galleria (Home) */
.gallery-tools { max-width: 800px; margin: 0 auto 30px auto; display: flex; flex-direction: column; gap: 15px; align-items: center; }
.search-container { position: relative; width: 100%; max-width: 500px; }
.search-container input { width: 100%; padding: 12px 40px 12px 20px; border: 2px solid #ddd; border-radius: 25px; font-size: 1rem; outline: none; }
.search-container input:focus { border-color: var(--primary-blue); }
.search-container i { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: #888; }
.year-filters { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.filter-btn { background: white; border: 1px solid #ddd; padding: 6px 15px; border-radius: 20px; cursor: pointer; font-size: 0.9rem; color: var(--text-dark); }
.filter-btn:hover { background: #eee; }
.filter-btn.active { background: var(--primary-blue); color: white; border-color: var(--primary-blue); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.folder-card { background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.1); cursor: pointer; transition: transform 0.2s; display: none; }
.folder-card.visible { display: block; animation: fadeIn 0.5s ease; }
.folder-card:hover { transform: scale(1.02); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.folder-preview { height: 180px; background-color: #ddd; background-size: cover; background-position: center; position: relative; }
.folder-icon-overlay { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,0.9); padding: 5px 10px; border-radius: 5px; color: var(--primary-blue); font-size: 0.8rem; font-weight: bold; }
.folder-info { padding: 15px; }
.folder-title { font-weight: bold; font-size: 1.1rem; margin-bottom: 5px; text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-date { font-size: 0.85rem; color: #777; display: flex; justify-content: space-between; }
.year-badge { background: var(--light-gray); padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; color: var(--primary-blue); }
.load-more-container { text-align: center; margin-top: 30px; }
.btn-load-more { background: transparent; border: 2px solid var(--primary-blue); color: var(--primary-blue); padding: 10px 30px; border-radius: 25px; font-weight: bold; cursor: pointer; font-size: 1rem; display: none; }
.btn-load-more:hover { background: var(--primary-blue); color: white; }

/* News */
.news-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.news-card { background: white; border: 1px solid #eee; border-radius: 8px; overflow: hidden; transition: transform 0.3s, box-shadow 0.3s; display: flex; flex-direction: column; height: 100%; }
.news-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.news-img { height: 160px; background-size: cover; background-position: center; background-color: #ddd; }
.news-content { padding: 20px; flex-grow: 1; display: flex; flex-direction: column; }
.news-source { font-size: 0.8rem; color: var(--accent-red); font-weight: bold; text-transform: uppercase; margin-bottom: 5px; }
.news-title { font-size: 1.1rem; font-weight: bold; margin-bottom: 10px; line-height: 1.3; }
.news-desc { font-size: 0.9rem; color: #666; margin-bottom: 15px; flex-grow: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.news-date { font-size: 0.8rem; color: #999; margin-top: auto; border-top: 1px solid #eee; padding-top: 10px; }
.btn-leggio { display: inline-block; background: var(--primary-blue); color: white; padding: 8px 15px; border-radius: 5px; text-align: center; margin-top: 10px; font-size: 0.9rem; }
.btn-leggio:hover { background: #153675; }

/* Sponsor Slider */
.sponsor-section { background: white; padding: 40px 0; overflow: hidden; margin-top: 30px; border-top: 1px solid #eee; }
.section-title-sponsor { text-align: center; margin-bottom: 30px; color: var(--primary-blue); font-size: 1.8rem; text-transform: uppercase; font-weight: bold; }
.slider { width: 100%; height: 190px; position: relative; overflow: hidden; display: flex; align-items: center; }
.slide-track { display: flex; animation: scroll 30s linear infinite; }
.slide-track:hover { animation-play-state: paused; }
.slide { height: 160px; width: 300px; display: flex; align-items: center; justify-content: center; padding: 0 20px; }
.slide img { max-height: 140px; max-width: 100%; filter: grayscale(100%); transition: all 0.3s; opacity: 0.7; }
.slide img:hover { filter: grayscale(0%); opacity: 1; transform: scale(1.1); }
@keyframes scroll { 0% { transform: translateX(0); } }

/* Direttivo */
.team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-top: 30px; }
.team-card { background: white; border-radius: 10px; overflow: hidden; text-align: center; box-shadow: 0 4px 10px rgba(0,0,0,0.05); transition: all 0.3s ease; position: relative; padding: 15px 10px; border-top: 3px solid var(--primary-blue); }
.team-card:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0,0,0,0.1); }
.team-img-box { width: 70px; height: 70px; margin: 15px auto 10px; background: linear-gradient(135deg, var(--primary-blue), #3a6abb); border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(30, 72, 150, 0.3); border: 3px solid white; }
.team-icon { font-size: 1.8rem; color: white; }
.team-name { font-size: 1rem; font-weight: 700; color: var(--text-dark); margin: 5px 0 8px 0; line-height: 1.2; }
.team-role-badge { display: inline-block; padding: 3px 10px; background: rgba(230, 51, 42, 0.1); color: var(--accent-red); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border-radius: 15px; }

/* Tesserati */
.tesserati-wrapper { width: 100%; margin-top: 40px; background: white; border-radius: 10px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); border: 1px solid #eee; overflow: hidden; }
.tesserati-trigger { background-color: white; padding: 18px 25px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-left: 6px solid var(--primary-blue); transition: background 0.3s ease; }
.tesserati-trigger:hover { background-color: var(--light-gray); }
.trigger-content { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trigger-content h3 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--primary-blue); text-transform: uppercase; letter-spacing: 0.5px; }
.trigger-content .count-badge { background-color: var(--light-gray); color: var(--text-dark); padding: 2px 10px; border-radius: 15px; font-size: 0.9rem; font-weight: bold; border: 1px solid #ddd; }
.trigger-icon i { color: var(--accent-red); font-size: 1.2rem; transition: transform 0.3s ease; }
.rotate-icon { transform: rotate(180deg); }
#lista-soci-container { display: none; border-top: 1px solid #eee; background-color: white; }
.styled-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; color: var(--text-dark); }
.styled-table thead tr { background-color: var(--primary-blue); color: white; text-transform: uppercase; font-size: 0.85rem; letter-spacing: 1px; }
.styled-table th, .styled-table td { padding: 15px 20px; text-align: left; border-bottom: 1px solid #eee; }
.styled-table tbody tr:hover { background-color: rgba(30, 72, 150, 0.05); }
.cat-badge { background: var(--accent-red); color: white; padding: 4px 10px; border-radius: 4px; font-size: 0.85rem; font-weight: 700; display: inline-block; min-width: 45px; text-align: center; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }

/* Cookie Banner */
#cookie-banner { position: fixed; bottom: -100%; left: 0; width: 100%; background-color: #222; color: white; box-shadow: 0 -4px 10px rgba(0,0,0,0.3); z-index: 9999; padding: 20px; transition: bottom 0.5s ease-in-out; }
#cookie-banner.show { bottom: 0; }
.cookie-content { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 20px; }
.cookie-text { flex: 1; font-size: 0.9rem; line-height: 1.5; color: #ddd; min-width: 280px; }
.cookie-text a { color: var(--primary-blue); text-decoration: underline; font-weight: bold; }
.cookie-buttons { display: flex; gap: 15px; }
.btn-cookie-accept { background-color: var(--primary-blue); color: white; border: none; padding: 10px 25px; border-radius: 5px; font-weight: bold; cursor: pointer; transition: background 0.3s; }
.btn-cookie-accept:hover { background-color: #153675; }
.btn-cookie-deny { background-color: transparent; border: 2px solid #666; color: #ccc; padding: 8px 20px; border-radius: 5px; font-weight: bold; cursor: pointer; transition: all 0.3s; }
.btn-cookie-deny:hover { border-color: var(--accent-red); color: white; }

/* Utilities Varie */
.no-border-card { border-top: none !important; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }

/* Regolazioni Spaziature Mobile */
@media (max-width: 600px) {
    .hero h1 { font-size: 2rem; }
    .hero h2 { font-size: 1.2rem; }
    .section-padding { padding: 40px 0; }
    .section-title { font-size: 1.6rem; margin-bottom: 25px; }
    .docs-grid, .gallery-grid, .gallery-detail, .news-grid { grid-template-columns: 1fr; }
    .container { padding: 0 15px; }
    .tesserati-trigger { padding: 15px; }
    .trigger-content h3 { font-size: 1rem; }
    .styled-table th, .styled-table td { padding: 10px; font-size: 0.85rem; }
}
/* =========================================================
   ?? OTTIMIZZAZIONI GRAFICHE E MOBILE RESPONSIVE
   ========================================================= */

/* --- 1. GRIGLIE DEI FORM (Da multi-colonna a singola colonna su Mobile) --- */
@media (max-width: 768px) {
    .form-grid.cols-2, 
    .form-grid.cols-3, 
    .form-grid.cols-4, 
    .form-grid.cols-5 {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* --- 2. FINESTRE MODALI (A tutto schermo e "Touch Friendly") --- */
    .modal-content {
        width: 95% !important;
        max-width: 100% !important;
        margin: 10px auto !important;
        padding: 15px !important;
        border-radius: 12px !important;
        max-height: 92vh;
        overflow-y: auto;
    }

    /* Chiudi modale pių facile da tappare */
    .close {
        font-size: 32px !important;
        padding: 10px !important;
    }

    /* --- 3. TABELLE RESPONSIVE (Scorrimento orizzontale col dito) --- */
    .table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Scorrimento fluido su iOS */
        border: 1px solid #eee;
        border-radius: 8px;
        margin-bottom: 15px;
        box-shadow: inset -5px 0 9px -7px rgba(0,0,0,0.1); /* Ombretta per far capire che si scorre */
    }

    /* Forza le tabelle ad avere una larghezza minima per non accavallare i testi */
    .utenti-table {
        min-width: 700px; 
    }

    /* --- 4. BARRE DI RICERCA E TITOLI IN COLONNA --- */
    .search-controls, 
    .quote-controls, 
    .log-header,
    div[style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    
    .search-controls input, 
    .search-controls button,
    .search-controls select {
        width: 100% !important;
        margin: 0 !important;
        height: 44px; /* Altezza minima raccomandata da Apple per i bottoni touch */
    }

    /* --- 5. BOTTONI PIŲ LARGHI E SPAZIOSI --- */
    .btn-success, .btn-warning, .btn-info, .btn-danger, .btn-primary {
        padding: 12px 15px !important;
        font-size: 15px !important;
        width: 100%;
        margin-bottom: 8px !important;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    /* Manteniamo i bottoncini delle tabelle compatti, ma pių facili da tappare */
    td .btn-small, td .btn-info, td .btn-success, td .btn-danger, td .btn-primary {
        width: auto !important;
        padding: 10px 12px !important;
        margin-bottom: 4px !important;
        display: inline-flex !important;
    }

    /* --- 6. SCAGLIONI DI PREZZO (Adattamento righe dinamiche) --- */
    .scaglione-row {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 15px !important;
        border: 2px solid #ccc !important;
    }
    .scaglione-row > div {
        width: 100% !important;
        text-align: left !important;
    }
    .scaglione-row button {
        margin-top: 10px;
    }

    /* --- 7. CARDS E SPAZIATURE --- */
    .card, .tab-content {
        padding: 12px !important;
        border-radius: 8px !important;
    }
    
    h3, h4 {
        font-size: 1.2em !important;
        text-align: center;
    }
}

/* Stili migliorativi validi per tutti (Desktop e Mobile) */
input[type="text"], input[type="date"], input[type="number"], input[type="email"], input[type="tel"], input[type="time"], select, textarea {
    box-sizing: border-box;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus, select:focus, textarea:focus {
    border-color: #2E5BBA !important;
    box-shadow: 0 0 0 3px rgba(46, 91, 186, 0.2) !important;
    outline: none;
}
