/* Menu Mobile Ottimizzato con Gruppi */

/* Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--text-dark);
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
    position: relative;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

/* Navigation Menu - Desktop */
.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 1.5rem;
    align-items: center;
}

.nav-menu li {
    position: relative;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    display: block;
}

.nav-menu a:hover,
.nav-menu a.active {
    color: var(--primary-color);
    background: rgba(30, 60, 114, 0.1);
}

/* Dropdown Styles - Desktop */
.dropdown-toggle::after {
    content: '';
    margin-left: 0.5rem;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 200px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    padding: 0.5rem 0;
}

.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu li {
    width: 100%;
}

.dropdown-menu a {
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    font-size: 0.95rem;
}

.dropdown-menu a:hover {
    background: var(--primary-color);
    color: white;
}

/* Close button - hidden by default */
.mobile-menu-close {
    display: none;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
        order: 2;
    }
    
    .nav-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 300px;
        height: 100vh;
        background: white;
        flex-direction: column;
        padding: 80px 0 0 0;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease;
        z-index: 1000;
        gap: 0;
        align-items: stretch;
        overflow-y: auto;
    }
    
    .nav-menu.mobile-active {
        left: 0;
    }
    
    .mobile-menu-close {
        display: block;
        position: absolute;
        top: 20px;
        right: 20px;
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-dark);
        cursor: pointer;
        padding: 0.5rem;
        border-radius: 50%;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-close:hover {
        background: rgba(30, 60, 114, 0.1);
        color: var(--primary-color);
    }
    
    .nav-menu li {
        width: 100%;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .nav-menu > li > a {
        padding: 1rem 1.5rem;
        font-size: 1.1rem;
        border-radius: 0;
        color: var(--text-dark);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .nav-menu > li > a:hover,
    .nav-menu > li > a.active {
        background: var(--primary-color);
        color: white;
    }
    
    /* Mobile Dropdown Styles */
    .dropdown-toggle i {
        transition: transform 0.3s ease;
        font-size: 0.9rem;
    }
    
    .dropdown.mobile-open .dropdown-toggle i {
        transform: rotate(180deg);
    }
    
    .dropdown-menu {
        position: static;
        background: rgba(30, 60, 114, 0.05);
        box-shadow: none;
        border-radius: 0;
        opacity: 1;
        visibility: visible;
        transform: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
        padding: 0;
    }
    
    .dropdown.mobile-open .dropdown-menu {
        max-height: 200px;
        padding: 0.5rem 0;
    }
    
    .dropdown-menu a {
        padding: 0.75rem 2.5rem;
        font-size: 0.95rem;
        color: var(--text-dark);
        border-left: 3px solid transparent;
    }
    
    .dropdown-menu a:hover,
    .dropdown-menu a.active {
        background: var(--primary-color);
        color: white;
        border-left-color: rgba(255, 255, 255, 0.5);
    }
    
    /* Overlay when menu is open */
    .nav-menu.mobile-active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 300px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
    
    /* Animation for menu items */
    .nav-menu.mobile-active > li {
        animation: slideInRight 0.3s ease-out forwards;
        opacity: 0;
    }
    
    .nav-menu.mobile-active > li:nth-child(1) { animation-delay: 0.1s; }
    .nav-menu.mobile-active > li:nth-child(2) { animation-delay: 0.15s; }
    .nav-menu.mobile-active > li:nth-child(3) { animation-delay: 0.2s; }
    .nav-menu.mobile-active > li:nth-child(4) { animation-delay: 0.25s; }
    .nav-menu.mobile-active > li:nth-child(5) { animation-delay: 0.3s; }
    .nav-menu.mobile-active > li:nth-child(6) { animation-delay: 0.35s; }
    .nav-menu.mobile-active > li:nth-child(7) { animation-delay: 0.4s; }
    .nav-menu.mobile-active > li:nth-child(8) { animation-delay: 0.45s; }
    
    @keyframes slideInRight {
        from {
            opacity: 0;
            transform: translateX(-20px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
}

/* Tablet adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .nav-menu {
        gap: 1rem;
    }
    
    .nav-menu a {
        padding: 0.4rem 0.8rem;
        font-size: 0.95rem;
    }
    
    .dropdown-menu {
        min-width: 180px;
    }
}

/* Very small mobile devices */
@media (max-width: 480px) {
    .nav-menu {
        width: 100%;
        left: -100%;
    }
    
    .nav-menu.mobile-active::before {
        left: 100%;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .nav-menu {
        padding-top: 60px;
    }
    
    .nav-menu > li > a {
        padding: 0.8rem 1.5rem;
    }
    
    .dropdown-menu a {
        padding: 0.6rem 2.5rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .nav-menu > li > a {
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    .mobile-menu-toggle {
        min-height: 48px;
        min-width: 48px;
    }
    
    .dropdown-menu a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}
