/* ==========================================================================
   Navigation Component CSS - Header, Megamenu, Mobile Drawer & Bottom App Nav
   ========================================================================== */

/* Zero scrollbars on desktop navigation */
.no-scrollbar,
.header-nav-container {
    -ms-overflow-style: none !important;
    scrollbar-width: none !important;
}

.no-scrollbar::-webkit-scrollbar,
.header-nav-container::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* --------------------------------------------------------------------------
   1. Desktop Mega Menu (Hidden on Mobile/Tablet)
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
    .mega-menu-wrapper {
        position: static;
    }

    .mega-menu-dropdown {
        position: absolute;
        top: calc(100% + 8px);
        left: 1.5rem;
        right: 1.5rem;
        max-width: 1200px;
        margin: 0 auto;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid rgba(226, 232, 240, 0.9);
        border-radius: 1.75rem;
        box-shadow: 0 30px 65px -15px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(241, 245, 249, 0.8);
        z-index: 50;
        opacity: 0;
        visibility: hidden;
        transform: translateY(12px) scale(0.99);
        transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s;
        overflow: hidden;
    }

    .mega-menu-wrapper:hover .mega-menu-dropdown,
    .mega-menu-dropdown:hover,
    .mega-menu-wrapper.is-open .mega-menu-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
    }

    .mega-category-item {
        transition: all 0.18s ease;
        border-radius: 0.875rem;
    }

    .mega-category-item:hover,
    .mega-category-item.active {
        background-color: #ffffff;
        color: var(--theme-primary, #4f46e5);
        box-shadow: 0 4px 14px rgba(79, 70, 229, 0.1);
    }
}

@media (max-width: 1023px) {
    /* Hard prevention of desktop megamenu appearing on mobile screens */
    .mega-menu-dropdown {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   2. Mobile Category Off-Canvas Drawer (Slide from Right in RTL)
   -------------------------------------------------------------------------- */
#mobileCategoryDrawer {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
    transition: visibility 0.3s ease;
    visibility: hidden;
}

#mobileCategoryDrawer.is-active {
    pointer-events: auto;
    visibility: visible;
}

#mobileDrawerBackdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#mobileCategoryDrawer.is-active #mobileDrawerBackdrop {
    opacity: 1;
}

#mobileDrawerPanel {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 85%;
    max-width: 340px;
    background-color: #ffffff;
    box-shadow: -10px 0 25px -5px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

#mobileCategoryDrawer.is-active #mobileDrawerPanel {
    transform: translateX(0);
}

/* --------------------------------------------------------------------------
   3. Modern CSS Grid Accordion for Mobile Categories (0fr -> 1fr)
   -------------------------------------------------------------------------- */
.mobile-accordion-item {
    border-bottom: 1px solid #f1f5f9;
}

.mobile-accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    font-size: 0.8125rem;
    font-weight: 700;
    color: #1e293b;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.mobile-accordion-header:active {
    background-color: #f8fafc;
}

.mobile-accordion-header .chevron-icon {
    transition: transform 0.25s var(--theme-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
}

.mobile-accordion-item.is-open .mobile-accordion-header .chevron-icon {
    transform: rotate(-90deg);
}

.mobile-accordion-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.mobile-accordion-item.is-open .mobile-accordion-wrapper {
    grid-template-rows: 1fr;
}

.mobile-accordion-inner {
    min-height: 0;
    background-color: #f8fafc;
    padding: 0 1rem;
}

.mobile-accordion-item.is-open .mobile-accordion-inner {
    padding: 0.5rem 1rem 0.875rem 1rem;
}

.mobile-sub-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    color: #475569;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
}

.mobile-sub-link:hover, .mobile-sub-link:active {
    color: var(--theme-primary, #4f46e5);
    background-color: #eef2ff;
}

/* --------------------------------------------------------------------------
   4. Fixed Bottom App Navigation Bar (Pinterest/Mobile-App Style)
   -------------------------------------------------------------------------- */
#mobileBottomNav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.05);
    z-index: 45;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 0.5rem;
}

@media (min-width: 1024px) {
    #mobileBottomNav {
        display: none !important;
    }
}

.mobile-nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: #64748b;
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.4rem 0;
    position: relative;
    transition: color 0.18s ease, transform 0.18s var(--theme-spring, ease);
    cursor: pointer;
    background: transparent;
    border: none;
}

.mobile-nav-tab:active {
    transform: scale(0.92);
}

.mobile-nav-tab.is-active {
    color: var(--theme-primary, #4f46e5);
}

.mobile-nav-tab .tab-icon-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-nav-tab.is-active .tab-indicator {
    position: absolute;
    top: -6px;
    width: 20px;
    height: 3px;
    border-radius: 9999px;
    background: var(--theme-primary, #4f46e5);
}

/* --------------------------------------------------------------------------
   5. Mobile Search Expandable Overlay
   -------------------------------------------------------------------------- */
#mobileSearchOverlay {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    padding: 0.75rem 1rem;
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 39;
}

#mobileSearchOverlay.is-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}
