/**
 * Mega Menu Stylesheet for Flatsome Child Theme
 * Design: Premium, modern Korean Ginseng red color palette, clean typography, smooth animations, and responsive layout.
 */

:root {
    --mm-primary: #B80E22;
    /* Red theme */
    --mm-primary-hover: #e22636;
    --mm-accent-new: #ef4444;
    /* Alert Red for New badge */
    --mm-accent-sale: #f59e0b;
    /* Amber/Orange for Sale badge */
    --mm-text: #1f2937;
    /* Off-black */
    --mm-text-muted: #6b7280;
    /* Gray */
    --mm-bg: #ffffff;
    --mm-border: #f3f4f6;
    --mm-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
    --mm-transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Wrapper */
.custom-mega-menu-wrapper {
    position: relative;
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Toggle Button */
.mega-menu-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffffff !important;
    border: none;
    border-radius: 4px;
    padding: 3px 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: var(--mm-transition);
    outline: none;
}

.text-mobile {
    display: none;
}

/* Icon rotation and transition */
.toggle-icon-wrap {
    position: relative;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-icon-wrap svg {
    transition: transform 0.3s ease, opacity 0.2s ease;
}

/* Arrow rotating on open */
.toggle-arrow {
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.mega-menu-toggle.is-active .toggle-arrow {
    transform: rotate(180deg);
}

/* Dropdown Panel */
.mega-menu-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    z-index: 99999;
    width: 860px;
    background: var(--mm-bg);
    border: 1px solid var(--mm-border);
    border-radius: 8px;
    box-shadow: var(--mm-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: var(--mm-transition);
    pointer-events: none;
    overflow: hidden;
}

/* Open states */
.custom-mega-menu-wrapper.is-open .mega-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* For hover interactions on desktop */
@media (min-width: 993px) {
    .custom-mega-menu-wrapper:hover .mega-menu-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
    }

    .custom-mega-menu-wrapper:hover .toggle-arrow {
        transform: rotate(180deg);
    }
}

/* Inner Layout */
.mega-menu-inner {
    display: flex;
    padding: 0;
    gap: 0;
    min-height: 420px;
    background: #ffffff;
}

/* Left Pane - Parent Categories List */
.mega-menu-left-pane {
    width: 280px;
    background-color: #fcfcfc;
    border-right: 1px solid #eeeeee;
    flex-shrink: 0;
    padding: 10px 0;
}

.parent-categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.parent-cat-item {
    display: block;
    margin: 0;
    padding: 0;
    transition: var(--mm-transition);
}

.parent-cat-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #333333 !important;
    text-decoration: none !important;
    font-size: 14.5px;
    font-weight: 500;
    transition: var(--mm-transition);
}

.mobile-chevron {
    display: none;
}

.mobile-child-dropdown {
    display: none;
}

.mega-menu-drawer-header {
    display: none;
}

/* Thumbnail wrapper */
.cat-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    overflow: hidden;
    background-color: #eeeeee;
    flex-shrink: 0;
    transition: var(--mm-transition);
}

.cat-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cat-icon-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: #f3f4f6;
    color: #9ca3af;
    transition: var(--mm-transition);
}

.cat-icon-placeholder svg {
    display: block;
}

/* Active & Hover states for Parent Item */
.parent-cat-item:hover,
.parent-cat-item.is-active {
    background-color: var(--mm-primary);
}

.parent-cat-item:hover .parent-cat-link,
.parent-cat-item.is-active .parent-cat-link {
    color: #ffffff !important;
}

.parent-cat-item:hover .cat-icon-wrap,
.parent-cat-item.is-active .cat-icon-wrap {
    background-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.parent-cat-item:hover .cat-icon-placeholder,
.parent-cat-item.is-active .cat-icon-placeholder {
    background-color: transparent;
    color: var(--mm-primary);
}

/* Right Pane - Child Categories List */
.mega-menu-right-pane {
    flex-grow: 1;
    background-color: #ffffff;
    padding: 24px 30px;
    overflow-y: auto;
}

.child-categories-panel {
    display: none;
    animation: mmFadeIn 0.25s ease-out;
}

.child-categories-panel.is-active {
    display: block;
}

.child-categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px 24px;
}

.child-cat-item {
    display: block;
}

.child-cat-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #333333 !important;
    text-decoration: none !important;
    font-size: 14.5px;
    font-weight: 500;
    transition: var(--mm-transition);
    padding: 4px 0;
}

.child-cat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: var(--mm-primary);
    color: #ffffff;
    flex-shrink: 0;
    transition: var(--mm-transition);
}

.child-cat-icon svg {
    display: block;
    width: 8px;
    height: 8px;
    stroke-width: 4.5px;
}

.child-cat-link:hover {
    color: var(--mm-primary) !important;
    transform: translateX(5px);
}

.child-cat-link:hover .child-cat-icon {
    background-color: var(--mm-primary-hover);
    transform: scale(1.1);
}

.child-cat-empty {
    color: var(--mm-text-muted);
    font-size: 14px;
    font-style: italic;
    padding: 10px 0;
}

/* Fade in animation */
@keyframes mmFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile & Tablet responsive adjustments */
@media (max-width: 992px) {
    .custom-mega-menu-wrapper {
        display: inline-block;
        width: auto;
        position: relative;
    }

    .text-desktop {
        display: none !important;
    }

    .text-mobile {
        display: inline !important;
    }

    .mega-menu-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        background-color: var(--mm-primary) !important;
        border-radius: 4px;
        padding: 6px 12px;
        height: 36px;
        width: auto;
        box-sizing: border-box;
    }

    .mega-menu-toggle .toggle-icon-wrap {
        display: flex;
        align-items: center;
        width: 14px;
        height: 14px;
        flex-shrink: 0;
    }

    .mega-menu-toggle .toggle-icon-wrap svg {
        width: 14px;
        height: 14px;
        display: block;
    }

    .mega-menu-toggle .toggle-text {
        font-size: 12.5px;
        text-transform: none;
        font-weight: 600;
        color: #ffffff;
        white-space: nowrap;
    }

    .mega-menu-toggle .toggle-arrow {
        margin-left: 6px;
        font-size: 10px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }

    .mega-menu-toggle .toggle-arrow svg {
        width: 10px;
        height: 10px;
        display: block;
    }

    .mega-menu-dropdown {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 300px !important;
        max-width: 85vw;
        height: 100vh;
        background-color: #ffffff;
        z-index: 999999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.3s;
        border-radius: 0;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
        opacity: 1 !important;
        /* Keep opaque during transition */
        visibility: hidden !important;
        /* Hidden when closed to allow clicking behind */
        pointer-events: none !important;
    }

    .custom-mega-menu-wrapper.is-open .mega-menu-dropdown {
        transform: translateX(0);
        visibility: visible !important;
        /* Visible when open */
        pointer-events: auto !important;
    }

    /* Screen overlay when menu is open */
    .custom-mega-menu-wrapper.is-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999998;
        pointer-events: auto;
        animation: mmFadeIn 0.3s ease;
    }

    /* Mobile Drawer Header */
    .mega-menu-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background-color: var(--mm-primary);
        color: #ffffff;
        font-weight: 700;
        font-size: 15px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        flex-shrink: 0;
        box-sizing: border-box;
    }

    .drawer-close-btn {
        background: none;
        border: none;
        color: #ffffff;
        padding: 4px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: opacity 0.2s;
    }

    .drawer-close-btn:hover {
        opacity: 0.8;
    }

    .mega-menu-inner {
        flex-direction: column;
        flex-grow: 1;
        height: calc(100vh - 54px);
        min-height: auto;
        max-height: none;
    }

    .mega-menu-left-pane {
        width: 100% !important;
        border-right: none;
        height: 100%;
        max-height: none;
        overflow-y: auto;
        padding: 0;
    }

    .mega-menu-right-pane {
        display: none !important;
        /* Hide desktop side panel on mobile */
    }

    .parent-cat-link {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 20px;
        font-size: 14.5px;
        font-weight: 500;
        color: #333333 !important;
        border-bottom: 1px solid #eeeeee;
        background-color: #ffffff;
        box-sizing: border-box;
    }

    /* Override parent hover/active background on mobile */
    .parent-cat-item:hover,
    .parent-cat-item.is-active {
        background-color: #ffffff !important;
    }

    .parent-cat-item:hover .parent-cat-link,
    .parent-cat-item.is-active .parent-cat-link {
        color: #333333 !important;
    }

    .parent-cat-item:hover .cat-icon-wrap,
    .parent-cat-item.is-active .cat-icon-wrap {
        background-color: #eeeeee !important;
        box-shadow: none !important;
    }

    .parent-cat-item:hover .cat-icon-placeholder,
    .parent-cat-item.is-active .cat-icon-placeholder {
        background-color: transparent !important;
        color: #9ca3af !important;
    }

    /* Mobile Chevron styling */
    .mobile-chevron {
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--mm-primary);
        transition: transform 0.25s ease;
        flex-shrink: 0;
        margin-left: auto;
    }

    .mobile-chevron svg {
        display: block;
        width: 12px;
        height: 12px;
        stroke-width: 3.5px;
    }

    /* Rotate chevron when active/open */
    .parent-cat-item.is-open .mobile-chevron {
        transform: rotate(90deg);
    }

    /* Mobile Accordion Child list styles */
    .mobile-child-dropdown {
        display: none;
        background-color: #fafafa;
        border-bottom: 1px solid #eeeeee;
    }

    .mobile-child-list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .mobile-child-item {
        border-bottom: 1px solid #f1f1f1;
    }

    .mobile-child-item:last-child {
        border-bottom: none;
    }

    .mobile-child-link {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 30px;
        color: #555555 !important;
        font-size: 13.5px;
        font-weight: 500;
        text-decoration: none !important;
        transition: var(--mm-transition);
    }

    .mobile-child-link:hover {
        color: var(--mm-primary) !important;
        padding-left: 34px;
    }
}