/* Cilli Mega Menu - Vertical Tabs Style */

/* Base reset for our container */
.cilli-megamenu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 900px;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    border-top: 3px solid #ff6600;
    box-sizing: border-box;
    overflow: hidden;
    max-width: calc(100vw - 20px);
}

/* Show on hover of the parent LIs */
li.cilli-has-megamenu:hover .cilli-megamenu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Parent LI is positioned relative so the dropdown aligns to it */
li.cilli-has-megamenu {
    position: relative !important;
}

/* Dark overlay behind the mega menu on hover */
li.cilli-has-megamenu::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

li.cilli-has-megamenu:hover::before {
    opacity: 1;
    visibility: visible;
}

.cilli-megamenu-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

.cilli-megamenu-wrapper {
    display: flex;
    min-height: 400px;
    overflow: hidden;
}

/* Left Sidebar - Tabs */
.cilli-megamenu-tabs {
    flex: 0 0 250px;
    background: #f9f9f9;
    border-right: 1px solid #eee;
    padding: 20px 0;
}

.cilli-megamenu-tabs ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cilli-tab-link {
    cursor: pointer;
}

.cilli-tab-link a {
    display: block !important;
    padding: 12px 25px;
    color: #444;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.cilli-tab-link:hover a,
.cilli-tab-link.cilli-active a {
    background: #fff;
    color: #ff6600;
    border-left-color: #ff6600;
}

/* Right Content Area */
.cilli-megamenu-content {
    flex: 1;
    position: relative;
    padding: 30px;
    background: #fff;
}

.cilli-megamenu-content .cilli-pane {
    display: none !important;
    /* Hide all panes by default */
    animation: cilliFadeIn 0.3s ease forwards;
}

.cilli-megamenu-content .cilli-pane.cilli-active {
    display: block !important;
    /* Show only the active pane */
}

@keyframes cilliFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pane Body - Flexbox to separate subcats and image */
.cilli-pane-body {
    display: flex;
    gap: 30px;
}

/* Subcategories Grid */
.cilli-pane-subcats {
    flex: 1;
    /* Takes available space */
}

.cilli-pane-subcats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Accordion Support */
.cilli-subcat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.cilli-subcat-title {
    font-weight: bold;
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
    line-height: 1.2;
}

.cilli-subcat-title:hover {
    color: #ff6600;
}

.cilli-accordion-toggle {
    background: none;
    border: 1px solid #ddd;
    color: #888;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    border-radius: 3px;
    padding: 0;
    transition: all 0.2s;
}

.cilli-accordion-toggle:hover {
    background: #f0f0f0;
    color: #ff6600;
    border-color: #ff6600;
}

.cilli-accordion-toggle.cilli-open {
    background: #ff6600;
    color: #fff;
    border-color: #ff6600;
}

.cilli-accordion-content {
    display: none;
    /* Hidden by default */
    padding-left: 10px;
    margin-bottom: 10px;
}

/* Grandchildren */
.cilli-pane-grandchildren {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cilli-pane-grandchildren li {
    margin-bottom: 6px;
}

.cilli-pane-grandchildren a {
    color: #666;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
    display: block;
}

.cilli-pane-grandchildren a:hover {
    color: #ff6600;
    text-decoration: underline;
}

/* Macrocategoria Image */
.cilli-pane-image {
    flex: 0 0 300px;
    /* Fixed width for the image column */
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    align-self: flex-start;
    /* Prevent stretching if content is short */
}

.cilli-pane-image a {
    display: block;
    position: relative;
}

.cilli-macrocategoria-img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.4s ease;
}

.cilli-pane-image:hover .cilli-macrocategoria-img {
    transform: scale(1.05);
}

.cilli-image-overlay-text {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 10px;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* ========================================================
   MOBILE DRAWER
   ======================================================== */

/* Hide drawer on desktop */
.cilli-mobile-overlay,
.cilli-mobile-drawer {
    display: none;
}

@media screen and (max-width: 991px) {

    /* Hide the desktop dropdown on mobile */
    .cilli-megamenu-dropdown {
        display: none !important;
    }

    /* Show drawer elements on mobile */
    .cilli-mobile-overlay,
    .cilli-mobile-drawer {
        display: block;
    }

    /* Overlay */
    .cilli-mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .cilli-mobile-overlay.cilli-overlay-open {
        opacity: 1;
        visibility: visible;
    }

    /* Drawer Panel */
    .cilli-mobile-drawer {
        position: fixed;
        top: 0;
        left: -100%;
        width: 90%;
        max-width: 400px;
        height: 100%;
        background: #fff;
        z-index: 99999;
        transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .cilli-mobile-drawer.cilli-drawer-open {
        left: 0;
    }

    /* Drawer Header */
    .cilli-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background: #f8f8f8;
        border-bottom: 1px solid #eee;
        flex-shrink: 0;
    }

    .cilli-drawer-title {
        font-size: 18px;
        font-weight: 700;
        color: #333;
    }

    .cilli-drawer-close {
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px;
        color: #666;
        transition: color 0.2s;
        line-height: 1;
    }

    .cilli-drawer-close:hover {
        color: #ff6600;
    }

    /* Drawer Body */
    .cilli-drawer-body {
        flex: 1;
        position: relative;
        overflow: hidden;
    }

    /* Drill-down Levels */
    .cilli-drawer-level {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: #fff;
    }

    .cilli-drawer-level-1 {
        transform: translateX(0);
    }

    .cilli-drawer-level-active {
        transform: translateX(0) !important;
    }

    .cilli-drawer-level-exit {
        transform: translateX(-30%) !important;
    }

    /* Drawer List Items */
    .cilli-drawer-list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .cilli-drawer-item {
        display: flex;
        align-items: center;
        padding: 14px 20px;
        cursor: pointer;
        border-bottom: 1px solid #f0f0f0;
        transition: background 0.15s;
    }

    .cilli-drawer-item:active {
        background: #f5f5f5;
    }

    .cilli-drawer-thumb {
        width: 40px;
        height: 40px;
        border-radius: 6px;
        object-fit: cover;
        margin-right: 14px;
        flex-shrink: 0;
    }

    .cilli-drawer-item-text {
        flex: 1;
        font-size: 16px;
        font-weight: 600;
        color: #333;
    }

    .cilli-drawer-arrow {
        flex-shrink: 0;
        color: #bbb;
        margin-left: 10px;
    }

    /* Back Button */
    .cilli-drawer-back {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 14px 20px;
        cursor: pointer;
        background: #f8f8f8;
        border-bottom: 1px solid #eee;
        font-size: 16px;
        font-weight: 700;
        color: #ff6600;
        transition: background 0.15s;
    }

    .cilli-drawer-back:active {
        background: #efefef;
    }

    /* "Vedi tutto" link */
    .cilli-drawer-viewall {
        display: block;
        padding: 10px 20px;
        background: #fff8f0;
        color: #ff6600;
        text-decoration: none;
        font-weight: 600;
        font-size: 14px;
        border-bottom: 1px solid #f0f0f0;
    }

    .cilli-drawer-viewall:active {
        background: #ffeddb;
    }

    /* Subcategory items inside Level 2 */
    .cilli-drawer-subcat-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 20px;
        border-bottom: 1px solid #f0f0f0;
    }

    .cilli-drawer-subcat-link {
        flex: 1;
        font-size: 15px;
        font-weight: 600;
        color: #444;
        text-decoration: none;
    }

    .cilli-drawer-subcat-link:active {
        color: #ff6600;
    }

    .cilli-drawer-accordion-toggle {
        background: none;
        border: 1px solid #ddd;
        color: #888;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border-radius: 4px;
        padding: 0;
        flex-shrink: 0;
        margin-left: 10px;
        transition: all 0.2s;
    }

    .cilli-drawer-accordion-toggle.cilli-open {
        background: #ff6600;
        color: #fff;
        border-color: #ff6600;
    }

    .cilli-drawer-accordion-content {
        display: none;
        background: #fafafa;
        padding: 0;
    }

    .cilli-drawer-grandchildren {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .cilli-drawer-grandchildren li {
        border-bottom: 1px solid #f0f0f0;
    }

    .cilli-drawer-grandchildren a {
        display: block;
        padding: 10px 20px 10px 36px;
        color: #666;
        text-decoration: none;
        font-size: 14px;
        transition: color 0.15s;
    }

    .cilli-drawer-grandchildren a:active {
        color: #ff6600;
        background: #f5f5f5;
    }

    /* Prevent body scroll when drawer is open */
    body.cilli-drawer-body-lock {
        overflow: hidden !important;
    }
}