/* =================================
   STILI NAVBAR (MODERN & FIX MOBILE)
   ================================= */

/* Base Navbar */
.navbar {
    background-color: #ffffff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 15px 0;
    font-family: 'Inter', sans-serif;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* --- LOGO --- */
.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    font-weight: 800;
    font-size: 24px;
    color: #333;
    gap: 10px;
    z-index: 1002;
}

.logo i {
    font-size: 28px;
    color: #667eea;
}

.logo span {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- NAV LINKS (Desktop) --- */
.nav-links {
    display: flex;
    align-items: center;
    gap: 30px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-link {
    text-decoration: none;
    color: #555;
    font-weight: 600;
    font-size: 15px;
    transition: color 0.3s ease;
}

.nav-link:hover { color: #667eea; }

/* Pulsanti Speciali Desktop */
.nav-link-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    padding: 10px 25px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}
.nav-link-primary:hover { transform: translateY(-2px); }

/* --- USER MENU (Desktop) --- */
.nav-user-menu { position: relative; margin-left: 10px; }

.nav-user-btn {
    background: none; border: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    padding: 5px 10px; font-size: 15px; color: #333;
    font-weight: 600; border-radius: 8px;
}
.nav-user-btn:hover { background-color: #f8f9fa; }
.nav-user-btn i.fa-user-circle { font-size: 28px; color: #667eea; }

.role-badge {
    font-size: 10px; padding: 3px 8px; border-radius: 12px;
    font-weight: 700; text-transform: uppercase; vertical-align: middle;
}
.role-badge-admin { background: #ffe5e5; color: #c0152f; }
.role-badge-vip { background: #fff3cd; color: #856404; }
.role-badge-free { background: #e2e6ea; color: #495057; }

/* Dropdown Menu Desktop */
.user-dropdown-menu {
    position: absolute; top: 120%; right: 0;
    background: white; min-width: 220px; border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12); padding: 10px 0;
    display: none; z-index: 1001; border: 1px solid #f0f0f0;
}
.user-dropdown-menu.active { display: block; }

.user-menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; color: #444; text-decoration: none;
    font-size: 14px; font-weight: 500;
}
.user-menu-item:hover { background-color: #f8f9fa; color: #667eea; }
.user-menu-item.logout { color: #dc3545; border-top: 1px solid #f0f0f0; margin-top: 5px; }
.user-menu-item.logout:hover { background-color: #fff5f5; }

/* --- HAMBURGER TOGGLE --- */
.mobile-menu-toggle {
    display: none; background: none; border: none;
    cursor: pointer; flex-direction: column; gap: 6px; z-index: 1100;
}
.mobile-menu-toggle span {
    width: 30px; height: 3px; background-color: #333;
    border-radius: 3px; transition: all 0.3s ease;
}

/* =========================================
   RESPONSIVE MOBILE (CORREZIONE SOTTOMENU)
   ========================================= */
@media (max-width: 900px) {
    .mobile-menu-toggle { display: flex; }

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: white;
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        margin: 0;
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        border-top: 1px solid #f0f0f0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
        display: flex;
    }

    .nav-links.active {
        max-height: 800px; /* Aumentato per essere sicuri che si veda tutto */
        overflow-y: auto;
    }

    .nav-link {
        padding: 15px 20px;
        border-bottom: 1px solid #f9f9f9;
        width: 100%;
        display: block;
        color: #333; /* Assicura colore scuro */
    }

    /* === CORREZIONE VISIBILITÀ MENU UTENTE === */
    .nav-user-menu {
        display: block !important; /* Forza visibilità del contenitore */
        width: 100%;
        margin: 0;
        padding: 0;
        background: #fcfcfc; /* Leggermente diverso per stacco visivo */
        border-top: 2px solid #eee;
    }

    .nav-user-btn {
        display: none !important; /* Nasconde il pulsante desktop */
    }

    /* Forza la visualizzazione della lista link */
    .user-dropdown-menu {
        display: block !important; /* Fondamentale: sovrascrive il display:none desktop */
        position: static !important; /* Non flottante */
        box-shadow: none !important;
        border: none !important;
        width: 100%;
        padding: 10px 0;
        background: transparent;
    }

    .user-menu-item {
        padding: 15px 20px;
        font-size: 16px;
        color: #555;
        border-bottom: 1px solid #eee;
        display: flex;
        width: 100%;
    }

    .user-menu-item i {
        margin-right: 10px;
        width: 20px;
        text-align: center;
        color: #667eea;
    }

    /* Pulsante Esci Mobile */
    .user-menu-item.logout {
        color: #dc3545;
        background-color: #fff5f5;
        font-weight: 700;
        margin-top: 0; /* Rimuove margini extra desktop */
    }

    /* Animazione Hamburger */
    .mobile-menu-toggle.open span:nth-child(1) { transform: rotate(45deg) translate(7px, 6px); }
    .mobile-menu-toggle.open span:nth-child(2) { opacity: 0; }
    .mobile-menu-toggle.open span:nth-child(3) { transform: rotate(-45deg) translate(7px, -6px); }
}