/**
 * WooCommerce Mega Menu - Frontend Styles
 */

/* CSS Variables - Will be overridden by inline styles from settings */
.wc-mega-menu {
    --menu-bg-color: #ffffff;
    --menu-text-color: #333333;
    --menu-hover-bg-color: #f5f5f5;
    --menu-hover-text-color: #000000;
    --dropdown-bg-color: #ffffff;
    --dropdown-text-color: #333333;
    --dropdown-border-color: #e0e0e0;
    --animation-speed: 300ms;
}

/* Main Menu Container */
.wc-mega-menu {
    position: relative;
    width: 100%;
    background-color: var(--menu-bg-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    z-index: 1000;
}

/* Menu List */
.wc-mega-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

/* Fix for desktop layout: make wrappers transparent to flex layout */
.wc-mega-menu-content,
.wc-mega-menu-level {
    display: contents;
}

/* Menu Items */
.wc-mega-menu-item {
    position: relative;
    margin: 0;
    padding: 0;
}

/* Menu Links */
.wc-mega-menu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px 20px;
    color: var(--menu-text-color);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all var(--animation-speed) ease;
    white-space: nowrap;
}

.wc-mega-menu-link:hover,
.wc-mega-menu-link:focus {
    background-color: var(--menu-hover-bg-color);
    color: var(--menu-hover-text-color);
}

/* Product Count */
.wc-mega-menu-link .product-count {
    font-size: 13px;
    opacity: 0.7;
    font-weight: 400;
}

/* Dropdown Indicator */
.wc-mega-menu-link .dropdown-indicator {
    font-size: 10px;
    margin-left: 4px;
    transition: transform var(--animation-speed) ease;
}

.wc-mega-menu-item.active>.wc-mega-menu-link .dropdown-indicator,
.wc-mega-menu-item:hover>.wc-mega-menu-link .dropdown-indicator {
    transform: rotate(180deg);
}

/* Dropdown Container */
.wc-mega-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 250px;
    background-color: var(--dropdown-bg-color);
    border: 1px solid var(--dropdown-border-color);
    border-top: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--animation-speed) ease;
    z-index: 1001;
}

/* Show dropdown on hover or active state */
.wc-mega-menu-item:hover>.wc-mega-menu-dropdown,
.wc-mega-menu-item.active>.wc-mega-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown Inner */
.dropdown-inner {
    padding: 20px;
}

/* Subcategories Grid */
.subcategories-grid {
    display: grid;
    gap: 30px;
    width: 100%;
}

/* Subcategory Column */
.subcategory-column {
    min-width: 200px;
}

/* Subcategory List */
.subcategory-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Nested Menu Items */
.subcategory-list .wc-mega-menu-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.subcategory-list .wc-mega-menu-item:last-child {
    border-bottom: none;
}

.subcategory-list .wc-mega-menu-link {
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 400;
    color: var(--dropdown-text-color);
}

.subcategory-list .wc-mega-menu-link:hover {
    background-color: var(--menu-hover-bg-color);
    color: var(--menu-hover-text-color);
    padding-left: 20px;
}

/* Nested Dropdowns */
.subcategory-list .wc-mega-menu-dropdown {
    left: 100%;
    top: 0;
    margin-left: 1px;
}

/* Depth-specific styles */
.wc-mega-menu-item.depth-1 .wc-mega-menu-link {
    font-weight: 500;
}

.wc-mega-menu-item.depth-2 .wc-mega-menu-link {
    font-size: 13px;
    padding-left: 25px;
}

.wc-mega-menu-item.depth-3 .wc-mega-menu-link {
    font-size: 12px;
    padding-left: 35px;
}

/* Mobile Toggle Button - Breadcrumb Style */
.wc-mega-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--dropdown-border-color);
    padding: 12px 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    color: var(--menu-text-color);
    width: 100%;
    text-align: left;
    transition: all 0.2s ease;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.wc-mega-menu-toggle:hover {
    color: var(--menu-hover-text-color);
}

.wc-mega-menu-toggle-text {
    font-size: 14px;
    text-transform: capitalize;
}

.wc-mega-menu-toggle-text::before {
    content: '›';
    margin-right: 6px;
    font-size: 16px;
    opacity: 0.7;
}

/* Hide hamburger icon completely */
.wc-mega-menu-toggle-icon {
    display: none !important;
}

/* Tablet Responsive (768px - 1024px) */
@media (max-width: 1024px) {
    .wc-mega-menu-link {
        padding: 12px 15px;
        font-size: 14px;
    }

    .subcategories-grid {
        gap: 20px;
    }
}

/* Mobile Responsive (max-width: 768px) */
@media (max-width: 768px) {

    /* Show mobile toggle button */
    .wc-mega-menu-toggle {
        display: flex;
    }

    /* Hide menu by default on mobile */
    .wc-mega-menu-list {
        display: none;
        flex-direction: column;
        width: 100%;
        max-height: 70vh;
        overflow-y: auto;
        background: var(--menu-bg-color);
        border: 1px solid var(--dropdown-border-color);
        border-top: none;
    }

    /* Show menu when open */
    .wc-mega-menu.menu-open .wc-mega-menu-list {
        display: flex;
    }

    .wc-mega-menu-item {
        width: 100%;
        border-bottom: 1px solid var(--dropdown-border-color);
    }

    .wc-mega-menu-item:last-child {
        border-bottom: none;
    }

    .wc-mega-menu-link {
        width: 100%;
        justify-content: space-between;
        padding: 15px 20px;
        font-size: 15px;
        white-space: normal;
    }

    /* Larger touch targets for mobile */
    .wc-mega-menu-link {
        min-height: 48px;
    }

    .wc-mega-menu-dropdown {
        position: static;
        width: 100%;
        transform: none;
        border: none;
        box-shadow: none;
        background-color: rgba(0, 0, 0, 0.03);
        border-left: 3px solid var(--menu-hover-bg-color);
    }

    .dropdown-inner {
        padding: 10px 0;
    }

    .subcategories-grid {
        grid-template-columns: 1fr !important;
        gap: 0;
    }

    .subcategory-list .wc-mega-menu-link {
        padding-left: 30px;
    }

    .subcategory-list .wc-mega-menu-link:hover {
        padding-left: 35px;
    }

    .subcategory-list .wc-mega-menu-dropdown {
        left: 0;
        margin-left: 0;
        background-color: rgba(0, 0, 0, 0.05);
        border-left-width: 2px;
    }

    /* Mobile: Show/hide with max-height animation */
    .wc-mega-menu-dropdown {
        max-height: 0;
        overflow: hidden;
        transition: max-height var(--animation-speed) ease;
    }

    .wc-mega-menu-item.active>.wc-mega-menu-dropdown {
        max-height: 2000px;
    }

    /* Depth-specific mobile padding */
    .wc-mega-menu-item.depth-1 .wc-mega-menu-link {
        padding-left: 30px;
    }

    .wc-mega-menu-item.depth-2 .wc-mega-menu-link {
        padding-left: 45px;
        font-size: 14px;
    }

    .wc-mega-menu-item.depth-3 .wc-mega-menu-link {
        padding-left: 60px;
        font-size: 13px;
    }

    /* Product count on mobile */
    .wc-mega-menu-link .product-count {
        font-size: 12px;
    }

    /* Dropdown indicator on mobile */
    .wc-mega-menu-link .dropdown-indicator {
        font-size: 12px;
        margin-left: auto;
    }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .wc-mega-menu-toggle {
        padding: 10px 15px;
        font-size: 15px;
    }

    .wc-mega-menu-link {
        padding: 12px 15px;
        font-size: 14px;
    }

    .wc-mega-menu-item.depth-1 .wc-mega-menu-link {
        padding-left: 25px;
    }

    .wc-mega-menu-item.depth-2 .wc-mega-menu-link {
        padding-left: 40px;
        font-size: 13px;
    }

    .wc-mega-menu-item.depth-3 .wc-mega-menu-link {
        padding-left: 55px;
        font-size: 12px;
    }
}


/* Accessibility */
.wc-mega-menu-link:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Loading State */
.wc-mega-menu.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Empty State */
.wc-mega-menu-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Animation for smooth appearance */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wc-mega-menu-item:hover>.wc-mega-menu-dropdown,
.wc-mega-menu-item.active>.wc-mega-menu-dropdown {
    animation: fadeInDown var(--animation-speed) ease;
}