/* ===== Dropdown Menu Styles ===== */
/* Stili per menu dropdown responsive con effetti moderni */

/* ===== FIX CRITICO PER VISIBILITÀ TESTO ===== */
.dropdown-menu a,
.dropdown-menu .dropdown-link,
.nav-item.dropdown .dropdown-menu a,
.nav-item.dropdown .dropdown-menu .dropdown-link {
    color: #232962 !important;
    opacity: 1 !important;
    visibility: visible !important;
    text-decoration: none !important;
}

/* ===== Variabili per Dropdown ===== */
:root {
    --dropdown-bg: #ffffff;
    --dropdown-shadow: 0 8px 25px rgba(35, 41, 98, 0.15);
    --dropdown-border: 1px solid rgba(35, 41, 98, 0.1);
    --dropdown-radius: 12px;
    --dropdown-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --dropdown-item-hover: rgba(255, 127, 50, 0.1);
    --dropdown-max-width: 200px;
    --dropdown-z-index: calc(var(--z-header) + 5);
}

/* ===== Dropdown Container ===== */
.nav-item.dropdown {
    position: relative;
}

/* ===== Dropdown Toggle Link ===== */
.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--dropdown-transition);
    text-decoration: none;
    color: inherit;
}

.dropdown-icon {
    font-size: 0.75rem;
    transition: var(--dropdown-transition);
    transform: translateY(-1px);
    margin-left: 0.25rem;
}

/* ===== Dropdown Menu ===== */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--dropdown-bg);
    box-shadow: var(--dropdown-shadow);
    border: var(--dropdown-border);
    border-radius: var(--dropdown-radius);
    min-width: var(--dropdown-max-width);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px);
    transition: var(--dropdown-transition);
    z-index: var(--dropdown-z-index);
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    backdrop-filter: blur(10px);
    /* Miglioramenti per visibilità */
    background: #ffffff;
    border: 2px solid rgba(255, 127, 50, 0.2);
}

/* Arrow indicator per dropdown */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: #ffffff;
    border: 2px solid rgba(255, 127, 50, 0.2);
    border-bottom: none;
    border-right: none;
    transform: translateX(-50%) rotate(45deg);
    z-index: -1;
}

/* ===== Dropdown Items ===== */
.dropdown-menu li {
    margin: 0;
}

/* Regole specifiche per forzare la visibilità del testo */
.nav-item.dropdown .dropdown-menu .dropdown-link,
.dropdown-menu .dropdown-link,
.dropdown-menu li a {
    display: block;
    padding: 0.875rem 1.5rem;
    color: #232962 !important;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--dropdown-transition);
    position: relative;
    border-radius: 0;
    line-height: 1.4;
    opacity: 1 !important;
    visibility: visible !important;
}

.dropdown-link {
    display: block;
    padding: 0.875rem 1.5rem;
    color: #232962 !important;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--dropdown-transition);
    position: relative;
    border-radius: 0;
    line-height: 1.4;
    /* Forziamo la visibilità del testo */
    opacity: 1;
}

.dropdown-link:hover {
    background: rgba(255, 127, 50, 0.1);
    color: #FF7F32 !important;
    transform: translateX(4px);
}

.dropdown-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #FF7F32;
    opacity: 0;
    transition: var(--dropdown-transition);
    border-radius: 0 2px 2px 0;
}

.dropdown-link:hover::before {
    opacity: 1;
}

/* ===== Hover States ===== */
.nav-item.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.nav-item.dropdown:hover .dropdown-icon {
    transform: translateY(-1px) rotate(180deg);
    color: #FF7F32;
}

.nav-item.dropdown:hover .dropdown-toggle {
    color: #FF7F32;
}

/* ===== Active States ===== */
.dropdown-toggle.active {
    color: #FF7F32;
}

.dropdown-toggle.active .dropdown-icon {
    transform: translateY(-1px) rotate(180deg);
}

/* ===== Focus States per Accessibilità ===== */
.dropdown-toggle:focus {
    outline: 2px solid #FF7F32;
    outline-offset: 2px;
    border-radius: 4px;
}

.dropdown-link:focus {
    background: rgba(255, 127, 50, 0.1);
    color: #FF7F32;
    outline: 2px solid #FF7F32;
    outline-offset: -2px;
}

/* ===== Responsive Design ===== */

/* Tablet e Desktop (769px+) */
@media screen and (min-width: 769px) {
    /* Aggiustamenti per schermi medi */
    .dropdown-menu {
        min-width: 180px;
    }
    
    /* Positioning per dropdown a destra dello schermo */
    .nav-item.dropdown:nth-last-child(-n+2) .dropdown-menu {
        left: auto;
        right: 0;
        transform: translateX(0) translateY(-10px);
    }
    
    .nav-item.dropdown:nth-last-child(-n+2):hover .dropdown-menu {
        transform: translateX(0) translateY(0);
    }
    
    .nav-item.dropdown:nth-last-child(-n+2) .dropdown-menu::before {
        left: auto;
        right: 1.5rem;
        transform: translateX(50%) rotate(45deg);
    }
}

/* Mobile e Tablet (768px e meno) */
@media screen and (max-width: 768px) {
    /* Reset dropdown per mobile - usa accordion style */
    .nav-item.dropdown {
        position: static;
        width: 100%;
    }
    
    .dropdown-toggle {
        justify-content: space-between;
        width: 100%;
        padding: 1rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--dark-gray);
        font-size: 1.2rem;
    }
    
    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: rgba(35, 41, 98, 0.05);
        backdrop-filter: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        padding: 0;
        margin-top: 0.5rem;
        border-left: 3px solid #FF7F32;
    }
    
    .dropdown-menu::before {
        display: none;
    }
    
    .dropdown-menu.show {
        max-height: 200px;
        padding: 0.5rem 0;
    }
    
    .dropdown-link {
        padding: 0.75rem 2rem;
        color: #232962 !important;
        font-size: 1rem;
        font-weight: 500;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .dropdown-link:hover {
        background: rgba(255, 127, 50, 0.15);
        color: #FF7F32 !important;
        transform: translateX(8px);
    }
    
    .dropdown-link::before {
        display: none;
    }
    
    /* Stili per quando il menu mobile è attivo */
    .nav-menu.active .dropdown-toggle {
        color: var(--dark-gray);
        border-bottom: 1px solid rgba(35, 41, 98, 0.1);
    }
    
    .nav-menu.active .dropdown-menu {
        background: rgba(245, 245, 245, 0.8);
        border-left: 3px solid #FF7F32;
    }
    
    .nav-menu.active .dropdown-link {
        color: #232962 !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .nav-menu.active .dropdown-link:hover {
        background: rgba(255, 127, 50, 0.15);
        color: #FF7F32 !important;
    }
}

/* Mobile molto piccoli (480px e meno) */
@media screen and (max-width: 480px) {
    .dropdown-link {
        padding: 0.625rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .dropdown-toggle {
        padding: 0.875rem 0;
        font-size: 1.1rem;
    }
    
    .dropdown-icon {
        font-size: 0.7rem;
    }
}

/* ===== Animazioni Avanzate ===== */

/* Pulse effect per notificare presenza dropdown */
@keyframes dropdownPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 127, 50, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(255, 127, 50, 0.1);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 127, 50, 0);
    }
}

.dropdown-toggle:hover {
    animation: dropdownPulse 1.5s ease-in-out;
}

/* Stagger animation per dropdown items */
.dropdown-menu li:nth-child(1) .dropdown-link {
    transition-delay: 0.05s;
}

.dropdown-menu li:nth-child(2) .dropdown-link {
    transition-delay: 0.1s;
}

.dropdown-menu li:nth-child(3) .dropdown-link {
    transition-delay: 0.15s;
}

/* Effetto di comparsa sequenziale */
.nav-item.dropdown:hover .dropdown-menu li:nth-child(1) {
    animation: fadeInSlide 0.3s ease forwards 0.1s;
    opacity: 0;
}

.nav-item.dropdown:hover .dropdown-menu li:nth-child(2) {
    animation: fadeInSlide 0.3s ease forwards 0.2s;
    opacity: 0;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Accessibilità ===== */

/* Focus visible per keyboard navigation */
.dropdown-toggle:focus-visible {
    outline: 2px solid #FF7F32;
    outline-offset: 2px;
    border-radius: 4px;
}

.dropdown-link:focus-visible {
    background: rgba(255, 127, 50, 0.1);
    color: #FF7F32;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dropdown-menu {
        border: 2px solid #232962;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
        background: #ffffff;
    }
    
    .dropdown-link {
        color: #000000;
    }
    
    .dropdown-link:hover {
        background: #FF7F32;
        color: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .dropdown-menu,
    .dropdown-link,
    .dropdown-icon,
    .dropdown-toggle {
        transition: none !important;
        animation: none !important;
    }
    
    .nav-item.dropdown:hover .dropdown-icon {
        transform: none !important;
    }
}

/* ===== Dark Mode Support (Future) ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --dropdown-bg: #1a1a1a;
        --dropdown-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
        --dropdown-border: 1px solid rgba(255, 255, 255, 0.1);
        --dropdown-item-hover: rgba(255, 127, 50, 0.1);
    }
    
    .dropdown-menu {
        background: #1a1a1a;
        border: 2px solid rgba(255, 127, 50, 0.2);
    }
    
    .dropdown-menu::before {
        background: #1a1a1a;
        border-color: rgba(255, 127, 50, 0.2);
    }
    
    .dropdown-link {
        color: #ffffff;
    }
}

/* ===== Performance Optimizations ===== */
.dropdown-menu {
    will-change: opacity, visibility, transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

.dropdown-link {
    will-change: transform, background-color, color;
}

/* ===== Miglioramenti di Stile ===== */
.dropdown-menu {
    /* Gradiente sottile per maggiore eleganza */
    background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
    
    /* Ombra più sofisticata */
    box-shadow: 
        0 8px 25px rgba(35, 41, 98, 0.12),
        0 2px 8px rgba(35, 41, 98, 0.08);
}

/* Hover state più raffinato per i link */
.dropdown-link:hover {
    background: linear-gradient(135deg, rgba(255, 127, 50, 0.1) 0%, rgba(255, 127, 50, 0.05) 100%);
    font-weight: 600;
}

/* Separatore tra elementi dropdown se necessario */
.dropdown-menu li + li {
    border-top: 1px solid rgba(35, 41, 98, 0.05);
}

/* ===== FIX MENU MOBILE - ELIMINA DROPDOWN E ALLINEA TESTI ===== */

/* Aggiungi questo CSS al file dropdown-menu.css ALLA FINE */

/* DISABILITA COMPLETAMENTE I DROPDOWN SU MOBILE */
@media screen and (max-width: 768px) {
    
    /* NASCONDE TUTTI I DROPDOWN SU MOBILE */
    .nav-item.dropdown .dropdown-menu {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        max-height: 0 !important;
        overflow: hidden !important;
    }
    
    /* TRASFORMA I DROPDOWN TOGGLE IN LINK NORMALI */
    .nav-item.dropdown .dropdown-toggle {
        /* Rimuovi la freccia e comportamento dropdown */
        cursor: pointer;
        justify-content: center !important;
        text-align: center !important;
        width: 100% !important;
        padding: 1rem 0 !important;
        border-bottom: none !important;
        background: none !important;
        
        /* Styling come link normale */
        color: var(--dark-gray) !important;
        font-size: 1.2rem !important;
        font-weight: 500 !important;
        opacity: 1 !important;
        visibility: visible !important;
        
        /* Allineamento centro */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* NASCONDE LA FRECCIA DEL DROPDOWN */
    .nav-item.dropdown .dropdown-toggle .dropdown-icon {
        display: none !important;
    }
    
    /* HOVER EFFECT PER DROPDOWN TOGGLE SU MOBILE */
    .nav-item.dropdown .dropdown-toggle:hover {
        color: var(--primary-orange) !important;
        transform: scale(1.05) !important;
        background: none !important;
    }
    
    /* ASSICURA CHE TUTTI I LINK DEL MENU SIANO ALLINEATI AL CENTRO */
    .nav-menu.active {
        background-color: #ffffff !important;
        backdrop-filter: none !important;
        z-index: 9998 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
    }
    
    .nav-menu.active li {
        width: 100% !important;
        text-align: center !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .nav-menu.active .nav-link {
        color: var(--dark-gray) !important;
        font-size: 1.2rem !important;
        font-weight: 500 !important;
        padding: 1rem 0 !important;
        opacity: 1 !important;
        visibility: visible !important;
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }
    
    .nav-menu.active .nav-link:hover {
        color: var(--primary-orange) !important;
        transform: scale(1.05) !important;
    }
    
    /* DISABILITA EVENTI CLICK SUI DROPDOWN */
    .nav-item.dropdown {
        pointer-events: auto !important;
    }
    
    .nav-item.dropdown .dropdown-toggle {
        pointer-events: auto !important;
    }
    
    /* IMPEDISCE L'APERTURA DEI DROPDOWN */
    .nav-item.dropdown:hover .dropdown-menu,
    .nav-item.dropdown.active .dropdown-menu,
    .nav-item.dropdown .dropdown-menu.show {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        max-height: 0 !important;
    }
}

/* OVERRIDE COMPLETO PER ELEMENTI DROPDOWN SU MOBILE */
@media screen and (max-width: 768px) {
    /* RESET COMPLETO DROPDOWN STYLES */
    .dropdown-menu,
    .dropdown-link,
    .dropdown-menu li,
    .dropdown-menu ul {
        display: none !important;
    }
    
    /* FORZA TUTTI I MENU ITEM AD ESSERE VISIBILI E ALLINEATI */
    .nav-menu li {
        opacity: 1 !important;
        visibility: visible !important;
        color: var(--dark-gray) !important;
    }
    
    /* DISABILITA JAVASCRIPT DROPDOWN FUNCTIONALITY */
    .nav-item.dropdown .dropdown-toggle[aria-expanded="true"] + .dropdown-menu {
        display: none !important;
    }
}

/* ASSICURA CHE IL MENU MOBILE SIA SEMPRE SOPRA TUTTO */
@media screen and (max-width: 768px) {
    .nav-menu {
        z-index: 99999 !important;
    }
    
    .nav-menu.active {
        z-index: 99999 !important;
        background: #ffffff !important;
        opacity: 1 !important;
    }
    
    .nav-toggle {
        z-index: 100000 !important;
    }
}

/* ===== OPZIONALE: Trasforma dropdown toggle in link diretti ===== */
/* Se vuoi che "Servizi" e "Prodotti" linkino a pagine specifiche, 
   dovrai modificare anche l'HTML per aggiungere href appropriati */

@media screen and (max-width: 768px) {
    /* Assicura che tutti i toggle siano cliccabili come link normali */
    .nav-item.dropdown .dropdown-toggle {
        text-decoration: none !important;
        cursor: pointer !important;
    }
    
    /* Se hai bisogno di aggiungere href specifici ai dropdown toggle,
       fallo nell'HTML modificando:
       <a href="#" class="dropdown-toggle"> 
       in:
       <a href="/servizi" class="dropdown-toggle"> (per Servizi)
       <a href="/prodotti" class="dropdown-toggle"> (per Prodotti)
    */
}