/**
 * Category Menu Styles
 *
 * Provides styling for hierarchical category navigation menu
 * with dropdown functionality for desktop and mobile views.
 *
 * Features:
 * - Nested category display (up to 3 levels)
 * - Animated dropdown transitions
 * - Responsive design for mobile and desktop
 * - Icon rotation animations
 */

/* Base Category Item Wrapper */
.category-item-wrapper,
.category-item-wrapper-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

/* Category Link Styles */
.category-link {
    flex: 1;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* Dropdown Toggle Icon */
.dropdown-toggle-icon {
    cursor: pointer;
    padding: 4px 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    color: inherit;
    user-select: none;
    border-radius: 4px;
    min-width: 28px;
    min-height: 28px;
}

.dropdown-toggle-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

.dropdown-toggle-icon.active {
    transform: rotate(180deg);
}

.dropdown-toggle-icon i {
    font-size: 14px;
    transition: transform 0.2s ease;
}

/* Nested Submenu Styles */
.submenu-nested,
.submenu-nested-mobile {
    display: none;
    padding-left: 20px;
    margin-top: 5px;
    list-style: none;
    overflow: hidden;
}

.submenu-nested.show,
.submenu-nested-mobile.show {
    display: block;
    animation: slideDown 0.3s ease;
}

/* Slide Down Animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 1000px;
    }
}

/* Parent Category with Dropdown Indicator */
.has-dropdown > .category-item-wrapper,
.has-dropdown > .category-item-wrapper-mobile {
    position: relative;
}

/* Nested List Items */
.submenu-nested li,
.submenu-nested-mobile li {
    margin: 5px 0;
}

/* Nested Category Links */
.submenu-nested a,
.submenu-nested-mobile a {
    display: block;
    padding: 8px 12px;
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.submenu-nested a:hover,
.submenu-nested-mobile a:hover {
    background: rgba(0, 0, 0, 0.05);
    padding-left: 16px;
}

/* Deep Nested Categories (Level 3+) */
.submenu-nested .submenu-nested {
    padding-left: 15px;
    border-left: 2px solid rgba(0, 0, 0, 0.1);
    margin-left: 5px;
}

/* Mobile Specific Styles */
@media (max-width: 1199px) {
    .category-item-wrapper-mobile {
        padding: 4px 0;
    }

    .submenu-nested-mobile {
        padding-left: 15px;
        background: rgba(0, 0, 0, 0.02);
        border-radius: 4px;
        margin-top: 8px;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .submenu-nested-mobile a {
        padding: 10px 12px;
        font-size: 14px;
    }

    .dropdown-toggle-icon {
        padding: 6px 10px;
    }
}

/* Desktop Menu Specific Styles */
@media (min-width: 1200px) {
    /* Make main submenu scrollable */
    .menu > li > .submenu {
        max-height: 70vh;
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 8px;
    }

    /* Custom scrollbar styling for desktop menu */
    .menu > li > .submenu::-webkit-scrollbar {
        width: 6px;
    }

    .menu > li > .submenu::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 3px;
    }

    .menu > li > .submenu::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 3px;
        transition: background 0.2s ease;
    }

    .menu > li > .submenu::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.3);
    }

    /* Firefox scrollbar styling */
    .menu > li > .submenu {
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.05);
    }

    .submenu .category-item-wrapper {
        padding: 2px 0;
    }

    .submenu-nested {
        padding-left: 16px;
        margin-top: 8px;
    }

    .submenu-nested a {
        font-size: 14px;
    }

    /* Add fade effect at bottom when scrollable */
    .menu > li > .submenu::after {
        content: '';
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        height: 30px;
        background: linear-gradient(to bottom, transparent, white);
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .menu > li > .submenu.is-scrollable::after {
        opacity: 1;
    }
}

/* Active State for Categories */
.category-link.active,
.category-link:active {
    font-weight: 600;
}

/* Focus Styles for Accessibility */
.dropdown-toggle-icon:focus,
.category-link:focus {
    outline: 2px solid rgba(0, 0, 0, 0.2);
    outline-offset: 2px;
}

/* RTL Support (Right-to-Left Languages) */
[dir="rtl"] .submenu-nested,
[dir="rtl"] .submenu-nested-mobile {
    padding-left: 0;
    padding-right: 20px;
}

[dir="rtl"] .submenu-nested a:hover,
[dir="rtl"] .submenu-nested-mobile a:hover {
    padding-left: 12px;
    padding-right: 16px;
}

[dir="rtl"] .submenu-nested .submenu-nested {
    padding-right: 15px;
    padding-left: 0;
    border-left: none;
    border-right: 2px solid rgba(0, 0, 0, 0.1);
    margin-left: 0;
    margin-right: 5px;
}

/* Loading State (Optional) */
.category-item-wrapper.loading .dropdown-toggle-icon {
    pointer-events: none;
    opacity: 0.5;
}

/* Empty State */
.submenu-nested:empty,
.submenu-nested-mobile:empty {
    display: none;
}
