﻿:root {
    --mega-header-h: 95px;
}

/* FIX BOX MODEL */
#megaMenu, #megaMenu * {
    box-sizing: border-box;
}

/* OVERLAY */
#megaMenuOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    z-index: 1100;
}

    #megaMenuOverlay.visible {
        opacity: 1;
        pointer-events: auto;
    }

/* MEGA MENU */
#megaMenu {
    margin-top: var(--mega-header-h);
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
    overflow: hidden;
}

    #megaMenu.open {
        opacity: 1;
        pointer-events: auto;
    }

/* COLUMNS WRAPPER */
.mega-columns {
    flex: 1;
    display: flex;
    overflow: hidden; /* ok: tooltip sarà globale (fixed), quindi non si taglia */
}

/* COLUMN BASE */
.mega-col {
    width: 35%;
    min-width: 0;
    background: #fff;
    border-right: 1px solid #ddd;
    display: none; /* default hidden */
    flex-direction: column; /* layout colonna */
    opacity: 0;
    transform: translateX(24px);
    transition: width .25s ease, transform .25s ease, opacity .2s ease;
}

    .mega-col.active {
        display: flex; /* IMPORTANT: non block */
        opacity: 1;
        transform: translateX(0);
    }

    .mega-col:last-child {
        border-right: none;
    }

    /* COMPACT */
    .mega-col.compact {
        flex: 0 0 55px;
        width: 55px;
    }
        .mega-col.compact .mega-item span {
            display: none;
        }

        .mega-col.compact .mega-item {
            justify-content: center;
        }

        .mega-col.compact .col-all-link {
            display: none !important;
        }
/* richiesto: nascondi "Tutti i prodotti" quando compact */

/* HEADER */
.col-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 3;
}

.col-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Se colonna non attiva, non mostrare titolo */
.mega-col:not(.active) .col-title {
    display: none;
}

.btn-back {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

/* ALL LINK in header */
.col-all-link {
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

    .col-all-link[hidden] {
        display: none !important;
    }

/* LIST (area scrollabile) */
.mega-list {
    list-style: none;
    margin: 0;
    padding: 10px;
    overflow-x: hidden;
    flex: 1;
    overflow-y: hidden; /* default */
}

/* Scroll SOLO colonna attiva NON compact */
.mega-col.active:not(.compact) .mega-list {
    overflow-y: auto;
}

/* FOOTER fisso in basso (sticky dentro colonna) */
.col-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: #fff;
    border-top: 1px solid #ddd;
    padding: 10px;
    display: flex;
    gap: 14px;
    justify-content: flex-start;
}

.mega-col.compact .col-footer {
    display: none;
}
/* quando compact non ha senso */

.col-footer-link {
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

    .col-footer-link[hidden] {
        display: none !important;
    }

/* ITEMS */
.mega-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 28px 8px 8px;
    cursor: pointer;
    position: relative;
    min-width: 0;
}

    .mega-item span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mega-item:hover {
        background: #f2f2f2;
        font-weight: 600;
    }

    /* richiesto: active con border-bottom */
    .mega-item.active {
        background: none;
        font-weight: 600;
        border-bottom: 1px solid #f2f2f2;
    }

    /* freccia */
    .mega-item::after {
        content: "›";
        position: absolute;
        right: 10px;
        color: #999;
        pointer-events: none;
    }

/* ICON */
.mega-icon {
    width: 30px;
    height: 30px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ==== SKELETON ==== */
.skeleton {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

.skeleton-icon {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    background: #e5e7eb;
    flex-shrink: 0;
}

.skeleton-text {
    height: 14px;
    width: 100%;
    border-radius: 4px;
    background: #e5e7eb;
}

.skeleton-line {
    width: 70%;
}

.skeleton-short {
    width: 40%;
}

.skeleton-icon, .skeleton-text {
    position: relative;
    overflow: hidden;
}

    .skeleton-icon::after, .skeleton-text::after {
        content: "";
        position: absolute;
        inset: 0;
        transform: translateX(-100%);
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
        animation: skeleton-loading 1.2s infinite;
    }

@keyframes skeleton-loading {
    100% {
        transform: translateX(100%);
    }
}

/* ==== TOOLTIP GLOBALE (non viene tagliato da overflow) ==== */
#megaTooltip {
    position: fixed;
    z-index: 2000; /* sopra overlay+menu */
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .12s ease, transform .12s ease;
    background: #1f2937;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

    #megaTooltip.visible {
        opacity: 1;
        transform: translateY(0);
    }



    /* ================= FAMIGLIE MULTI-COLUMN ================= */

.mega-col.col-famiglie.active {
    flex: 1 1 auto;
    width: auto;
}

/* Le altre colonne restano compatte */
.mega-col.compact {
    flex: 0 0 55px;
}

.col-famiglie .mega-list {
    column-count: 2;
    column-gap: 32px; /* spazio tra colonne */
    column-fill: auto;
    /* scroll verticale se serve */
    overflow-y: auto;
    max-height: calc(100vh - 160px); /* header + footer */
    padding-right: 12px;
}

    /* ogni item non deve spezzarsi tra colonne */
    .col-famiglie .mega-item {
        break-inside: avoid;
        -webkit-column-break-inside: avoid;
        margin-bottom: 6px;
    }
@media (min-width: 1400px) {
    .col-famiglie .mega-list {
        column-count: 3;
    }
}

@media (max-width: 992px) {
    .col-famiglie .mega-list {
        column-count: 1;
    }
}
/* Quando compatta, nascondi titolo*/
.mega-col.compact .col-title {
    display: none !important;
}




