.megamenu-container {
    display: flex;
    min-height: 300px;
    max-height: 72vh;
    /* Non occupa tutto lo schermo */
    font-size: 20px;
    overflow: hidden;
}

.megamenu-sidebar {
    width: 300px;
    min-width: 300px;
    border-right: 2px solid rgba(255, 255, 255, 0.12);
    overflow-y: auto;
    overflow-x: hidden;
}

.megamenu-category-item {
    padding: 11px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
    transition: background .15s, border-color .15s;
}

.megamenu-category-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-left-color: var(--e-global-color-accent);
}

.megamenu-category-item.active {
    background: rgba(255, 255, 255, 0.10);
    border-left-color: var(--e-global-color-accent);
    font-weight: 700;
}

.category-image {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.category-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-name {
    flex: 1;
    font-size: 20px !important;
}

.category-arrow {
    margin-left: auto;
    font-size: 14px;
    flex-shrink: 0;
    color: var(--e-global-color-accent);
    opacity: 0.7;
}

.category-count {
    font-size: 11px;
    opacity: 0.5;
}

.megamenu-search {
    margin-bottom: 16px;
}

.megamenu-content {
    flex: 1;
    display: flex;
    max-height: 72vh;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    border-left: 2px solid rgba(255, 255, 255, 0.12);
}

.megamenu-level-column {
    flex: 0 0 280px;
    width: 280px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    max-height: 72vh;
}

.megamenu-level-column+.megamenu-level-column {
    border-left: 2px solid rgba(255, 255, 255, 0.12);
}

.megamenu-placeholder {
    color: #999;
    text-align: center;
    padding: 40px 20px;
    width: 100%;
    font-size: 13px;
}

.megamenu-subcategories {
    display: flex;
    flex-direction: column;
    padding-bottom: 60px;
}

.megamenu-subcategory-item {
    padding: 10px 14px 10px 20px;
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 3px solid transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background .15s, border-color .15s;
}

.megamenu-subcategory-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-left-color: var(--e-global-color-accent);
}

.megamenu-subcategory-item.active {
    background: rgba(255, 255, 255, 0.10);
    border-left-color: var(--e-global-color-accent);
    font-weight: 600;
}

.subcategory-name {
    flex: 1;
    font-weight: 400;
    font-size: 20px !important;
}

.subcategory-arrow {
    margin-left: auto;
    font-size: 13px;
    color: var(--e-global-color-accent);
    opacity: 0.7;
}

.megamenu-no-children {
    text-align: center;
    padding: 20px;
}

.view-category-link {
    display: inline-block;
    padding: 10px 20px;
    background-color: #0066cc;
    color: white;
    text-decoration: none;
    border-radius: 4px;
}

.view-category-link:hover {
    background-color: #0052a3;
}

.mobile-back-button {
    display: none;
    padding: 15px;
    background-color: #f5f5f5;
    border-bottom: 2px solid #ddd;
    cursor: pointer;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.mobile-back-button:hover {
    background-color: #e8e8e8;
}

.back-icon {
    font-size: 24px;
    line-height: 1;
}

.back-text {
    font-size: 20px;
}

/* =========================
   MOBILE (qui lo scroll è GIUSTO)
   ========================= */
@media (max-width: 768px) {

    /* ★ Forza la catena di parent a occupare tutto il viewport */
    [id^="megamenu-app-"] {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        /* override con dynamic viewport su browser moderni */
    }

    .megamenu-container {
        flex-direction: column;
        min-height: 0;
        max-height: none;
        flex: 1;
        overflow: hidden;
    }

    .megamenu-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: none;
        display: none;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        border: none !important;
    }

    .megamenu-sidebar.mobile-visible {
        display: flex;
        flex-direction: column;
    }

    /* ★ Scrollbar visibile su mobile */
    .megamenu-sidebar::-webkit-scrollbar {
        width: 4px;
    }

    .megamenu-sidebar::-webkit-scrollbar-track {
        background: transparent;
    }

    .megamenu-sidebar::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.25);
        border-radius: 4px;
    }

    .megamenu-content {
        flex-direction: column;
        flex: 0;
        min-height: 0;
        overflow: hidden;
        display: none;
    }

    /* ★ Mostra megamenu-content solo quando ha sottocategorie (classe da Vue) */
    .megamenu-content.has-content {
        display: flex;
        flex: 1;
    }

    /* ★ Scrollbar visibile su mobile anche per sottocategorie */
    .megamenu-level-column::-webkit-scrollbar {
        width: 4px;
    }

    .megamenu-level-column::-webkit-scrollbar-track {
        background: transparent;
    }

    .megamenu-level-column::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.25);
        border-radius: 4px;
    }

    .mobile-back-button {
        display: flex;
    }

    .megamenu-level-column {
        display: none;
        min-width: 100%;
        border-right: none;
        overflow-y: auto;
        flex: 1;
    }

    .megamenu-level-column.mobile-active {
        display: flex;
    }

    body:has(.megamenu-content .megamenu-level-column) .megamenu-sidebar,
    .megamenu-container:has(.megamenu-level-column) .megamenu-sidebar {
        display: none;
    }
}







/*
 * FIX: Sfondo pagina in cover su schermi extra large
 * 
 * Problema: Lo sfondo della pagina viene ripetuto su schermi XL
 * Soluzione: Forza background-size: cover su tutti gli elementi con sfondo
 * 
 * INSTALLAZIONE:
 * 1. Aggiungi questo CSS nel tema (Aspetto > Personalizza > CSS Aggiuntivo)
 * 2. Oppure crea un file custom-background-fix.css e includilo nel tema
 */

/* FIX: Sfondo body e container principali */
body,
.site,
.site-content,
.elementor,
.elementor-page {
    background-size: cover !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-attachment: fixed !important;
}

/* FIX: Sezioni Elementor con sfondo */
.elementor-section.elementor-section-boxed>.elementor-container,
.elementor-section.elementor-section-full_width>.elementor-container,
.elementor-section {
    background-size: cover !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
}

/* FIX: Colonne Elementor con sfondo */
.elementor-column,
.elementor-column-wrap,
.elementor-widget-wrap {
    background-size: cover !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
}

/* FIX: Container generale WordPress */
.page,
.single,
.archive,
.woocommerce,
.single-product {
    background-size: cover !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
}

/* FIX SPECIFICO: Scheda prodotto WooCommerce */
.single-product .product,
.woocommerce-page .product,
.product-template-default {
    background-size: cover !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
}

/* FIX SPECIFICO: Megamenu */
.megamenu-container,
.megamenu-overlay {
    background-size: cover !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
}

/* MEDIA QUERY: Applica solo su schermi XL e oltre (1920px+) */
@media (min-width: 1920px) {

    body,
    .site,
    .site-content,
    .elementor,
    .elementor-page,
    .elementor-section,
    .page,
    .single,
    .archive,
    .woocommerce,
    .single-product,
    .single-product .product,
    .megamenu-container {
        background-size: cover !important;
        background-repeat: no-repeat !important;
        background-position: center center !important;
        background-attachment: fixed !important;
    }
}

/* ALTERNATIVA: Se vuoi che lo sfondo si adatti invece di essere fisso */
/*
@media (min-width: 1920px) {
    body,
    .site,
    .elementor-page {
        background-size: 100% auto !important;
        background-repeat: no-repeat !important;
        background-position: top center !important;
        background-attachment: scroll !important;
    }
}
*/

/* DEBUG: Rimuovi questo dopo il test */
/*
@media (min-width: 1920px) {
    body::before {
        content: "XL SCREEN - Background fix attivo";
        position: fixed;
        top: 10px;
        right: 10px;
        background: red;
        color: white;
        padding: 10px;
        z-index: 99999;
        font-size: 12px;
    }
}
*/












@media (min-width: 768px) {
    #megamenu-app-1 {

        padding-top: 30px !important;


    }
}

/* ── Desktop: limita altezza overlay principale a 85vh ── */
@media (min-width: 769px) {
    #ave-megamenu-2026-overlay {
        max-height: 85vh !important;
        overflow-y: auto !important;
    }
}

/* ── Blocca scroll pagina quando il megamenu è aperto ── */
body:has(#ave-megamenu-2026-overlay) {
    overflow: hidden !important;
}

/* ── Overlay scuro sulla pagina sotto il megamenu (solo quando è aperto) ── */
body.megamenu-open::after {
    content: '';
    position: fixed;
    top: 85vh;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 99998;
    pointer-events: none;
}

/* ── Blocca scroll chaining: impedisce che lo scroll del megamenu 
   si propaghi alla pagina sottostante ── */
#ave-megamenu-2026-overlay {
    overscroll-behavior: contain;
}

.megamenu-sidebar,
.megamenu-content,
.megamenu-level-column {
    overscroll-behavior: contain;
}