/* ==========================================
   RESET E VARIABILI 
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #0056b3;    /* Blu Istituzionale CoreDigitale */
    --secondary-color: #165A26;  /* Verde Successo */
    --bg-light: #f8f9fa;
    --text-dark: #333;
    --border-color: #ddd;
    --ad-bg: #f0f0f0;
    --modebadgeadd: #165A26; 
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    /* Spazio per il banner fisso in basso */
    padding-bottom: 100px; 
}

/* ==========================================
   NAVBAR (Gestita da header.js)
   ========================================== */
.navbar {
    height: 70px;
    background: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5%;
    border-bottom: 2px solid var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1; /* Permette alle sezioni laterali di occupare spazio equo */
}

.nav-right {
    justify-content: flex-end;
}

/* Menu a tendina */
.dropdown-menu, .user-profile-dropdown {
    position: relative;
}

.menu-btn, .profile-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary-color);
    padding: 10px;
    display: flex;
    align-items: center;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.dropdown-content.right {
    left: auto;
    right: 0;
}

.dropdown-content a {
    color: var(--text-dark);
    padding: 12px 20px;
    text-decoration: none;
    display: block;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.dropdown-content a:hover {
    background-color: #f1f5f9;
}

/* Attivazione Hover Menu */
.dropdown-menu:hover .dropdown-content, 
.user-profile-dropdown:hover .dropdown-content {
    display: block;
}

/* Barra di Ricerca */
.search-container {
    margin-left: 20px;
    display: flex;
    align-items: center;
    background: #f1f3f4;
    padding: 5px 15px;
    border-radius: 20px;
    position: relative;
    width: 450px; /* Allargato */
}

#searchInput {
    border: none;
    background: none;
    outline: none;
    padding: 5px;
    width: 100%; /* Allargato */
}

.suggestions-box {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border-radius: 0 0 10px 10px;
    z-index: 1000;
    /* FUNZIONALITÀ SCROLL */
    max-height: 300px; /* Altezza massima del menu */
    overflow-y: auto;  /* Abilita lo scroll verticale se necessario */
}

.suggestion-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer; /* Cursore a manina */
}

.suggestion-item:hover {
    background: #f8f9fa;
}

#courseSearch {
    padding: 10px 20px;
    width: 250px; /* Ridotto leggermente per far spazio al logo centrale */
    border: 1px solid var(--border-color);
    border-radius: 25px;
    outline: none;
    font-size: 0.9rem;
    transition: all 0.3s;
}

#courseSearch:focus {
    width: 280px;
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(0,86,179,0.2);
}



/* --- LOGO CENTRALE --- */
.logo-container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto; /* Impedisce al logo di restringersi */
}

.logo-wrapper {
    height: 60px; /* Quasi tutta l'altezza della navbar (70px) */
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-logo {
    height: 100%;
    width: auto;
    object-fit: contain;
    /* Rimosso il transform scale per evitare sgranature */
}

/* --- MODALE LOGIN --- */
.auth-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.auth-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
}

.auth-content h2 { margin-bottom: 20px; color: var(--primary-color); }

.auth-input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.btn-auth-submit {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 10px;
}

.social-auth-btns {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-social:hover { background: #f8f9fa; }
.btn-google i { color: #db4437; }
.btn-facebook i { color: #4267B2; }

.close-auth {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 20px;
    cursor: pointer;
}

/* ==========================================
   LAYOUT PRINCIPALE E BANNER
   ========================================== */
.main-layout {
    display: grid;
    /* Colonna centrale flessibile, laterali fisse per i banner */
    grid-template-columns: 180px 1fr 180px; 
    gap: 20px;
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
    align-items: start;
}

.content-center {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==========================================
   CARD CORSI E AZIONI
   ========================================== */

/* Animazione per evidenziare la card cercata dai suggerimenti*/
.highlight-card {
    border-left-color: var(--secondary-color) !important; /* Diventa verde */
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.4) !important;
    transform: scale(1.02);
    transition: all 0.4s ease;
}

.course-card {
    background: white;
    padding: 25px 40px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 8px solid var(--primary-color);
    display: flex;
    flex-direction: row; /* Layout orizzontale */
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 140px; /* Altezza minima per l'aspetto rettangolare */
}

.course-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.12);
}

.course-info {
    flex: 2; /* Prende più spazio per testo e descrizione */
    padding-right: 30px;
}

.course-info h2 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1.4rem;
}

.course-info p {
    color: #555;
    font-size: 0.95rem;
}

.course-card h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.course-card p {
    color: #666;
    font-size: 0.95rem;
}

.courses-grid .course-card {
    margin-bottom: 10px; 
}

/* Contenitore pulsanti doppia modalità */
.course-actions {
    flex: 1;
    display: flex;
    flex-direction: column; /* Pulsanti uno sopra l'altro dentro la card */
    gap: 10px;
    min-width: 220px;
}

/* Pulsanti specifici */
.btn-mode {
    flex: 1; /* Rende i pulsanti della stessa larghezza */
    padding: 12px 15px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    font-size: 0.85rem;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: filter 0.2s;
}

.btn-mode:hover {
    filter: brightness(90%);
}

/* Colore Modalità Apprendimento (Verde) */
.btn-learning {
    background-color: var(--secondary-color);
    color: white;
}

/* Colore Modalità Esame (Blu) */
.btn-exam {
    background-color: var(--primary-color);
    color: white;
}

.course-card.disabled {
    border-left-color: #adb5bd;
    background-color: #fcfcfc;
    opacity: 0.7;
}

.course-card.disabled .btn-mode {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Pulsante Standard */
.login-btn, .start-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.start-btn:hover {
    background-color: #004494;
}

/* Pubblicità */
.ads-vertical {
    background-color: var(--ad-bg);
    border: 1px dashed #bbb;
    height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 0.75rem;
    position: sticky;
    top: 90px; /* Resta visibile durante lo scroll dopo la navbar */
    border-radius: 8px;
}

.sticky-ad-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 90px;
    background: #f9f9f9;
    border-top: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999; /* Sempre sopra */
}

.ad-label {
    font-size: 10px;
    color: #666;
    margin-bottom: 5px;
    text-transform: uppercase;
}

/* ==========================================
   RESPONSIVE 
   ========================================== */
@media (max-width: 1100px) {
    .main-layout {
        grid-template-columns: 1fr; /* Nasconde i banner laterali su schermi medi/piccoli */
    }
    .ads-vertical {
        display: none;
    }
}

@media (max-width: 768px) {
    .course-card {
        flex-direction: column; /* Torna verticale su mobile */
        text-align: center;
        padding: 20px;
    }
    .course-info {
        padding-right: 0;
        margin-bottom: 15px;
    }
}

/* Stili per Pagine Legali (Privacy e Termini) */
.legal-content {
    text-align: left;
    max-width: 800px;
    margin: 40px auto;
    line-height: 1.8;
    color: #333;
}

.legal-content h1 {
    margin-bottom: 30px;
    color: var(--primary-color);
}

.legal-content h3 {
    margin-top: 25px;
    margin-bottom: 10px;
    color: #000;
}

.legal-content p {
    margin-bottom: 15px;
}

/* --- ANTI AD-BLOCK STYLES AGGIORNATI --- */
.blur-content {
    filter: blur(12px) grayscale(100%);
    pointer-events: none !important;
    user-select: none;
    transition: filter 0.5s ease;
}

#adblock-modal {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9); /* Sfondo chiaro per leggere meglio */
    z-index: 99999; /* Sopra tutto, anche sopra i quiz */
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content-adblock {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 450px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    border: 1px solid #eee;
}

.modal-content-adblock i {
    font-size: 60px;
    color: #e74c3c;
    margin-bottom: 25px;
}

/* Animazione puntini di caricamento */
.loader-dots span {
    font-size: 40px;
    animation: blink 1s infinite;
}
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}