/* === Modern FirstCry Style Header - Complete Redesign === */

/* === CSS Variables for Easy Customization === */
:root {
    --header-primary: #FFC107;
    --header-primary-dark: #FFB300;
    --header-accent: #FF6B6B;
    --header-text: #333;
    --header-text-light: #666;
    --header-bg: #fff;
    --mega-menu-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Colorful Icon Colors */
    --icon-pink: #E91E63;
    --icon-red: #F44336;
    --icon-orange: #FF9800;
    --icon-yellow: #FFC107;
    --icon-green: #4CAF50;
    --icon-teal: #009688;
    --icon-blue: #2196F3;
    --icon-indigo: #3F51B5;
    --icon-purple: #9C27B0;
}

/* === Colorful Menu Icons === */
.menu-icon-pink {
    color: var(--icon-pink) !important;
}

.menu-icon-red {
    color: var(--icon-red) !important;
}

.menu-icon-orange {
    color: var(--icon-orange) !important;
}

.menu-icon-yellow {
    color: var(--icon-yellow) !important;
}

.menu-icon-green {
    color: var(--icon-green) !important;
}

.menu-icon-teal {
    color: var(--icon-teal) !important;
}

.menu-icon-blue {
    color: var(--icon-blue) !important;
}

.menu-icon-indigo {
    color: var(--icon-indigo) !important;
}

.menu-icon-purple {
    color: var(--icon-purple) !important;
}

/* Submenu Item Icons Styling */
.allcat-menu.mega-menu>li>.mega-menu-category>ul a i,
.allcat-menu.mega-menu>li>ul a i {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.04);
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.allcat-menu.mega-menu>li>.mega-menu-category>ul a:hover i,
.allcat-menu.mega-menu>li>ul a:hover i {
    transform: scale(1.15);
    background: rgba(255, 193, 7, 0.2);
}

/* === Fixed Header for All Devices === */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1055;
    background: #ffffff !important;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: auto;
}

/* When category bar is hidden, reduce header height */
.header.category-hidden {
    height: 50px !important;
    /* Only show upper header height */
}

/* Normal header height with category bar */
.header:not(.category-hidden) {
    height: auto;
    /* Allow natural height with category bar */
}

body {
    padding-top: 90px !important;
    background: #ffffff !important;
    transition: padding-top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reduce body padding when category bar is hidden */
body:has(.header.category-hidden) {
    padding-top: 50px !important;
    /* Match reduced header height */
}

/* === Header Top Section === */
.header-top {
    padding: 8px 0 !important;
    min-height: 50px !important;
    background: #ffffff !important;
    border-bottom: 1px solid #f0f0f0;
}

.header-top .container {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 20px !important;
    max-width: 1400px;
    padding: 0 20px;
}

/* === Logo Section === */
.header-logo {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
}

.header-logo a {
    display: inline-block !important;
    transition: var(--transition-smooth);
}

.header-logo a:hover {
    transform: scale(1.02);
}

.header-logo img {
    height: 40px !important;
    max-width: 150px !important;
    width: auto !important;
    object-fit: contain !important;
}

/* === Modern Search Bar === */
.header-search {
    flex-grow: 1 !important;
    max-width: 550px !important;
    margin: 0 30px !important;
}

.header-search form {
    display: flex !important;
    width: 100% !important;
    position: relative;
    background: #f5f5f5;
    border-radius: 50px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: var(--transition-smooth);
}

.header-search form:focus-within {
    border-color: var(--header-primary);
    background: #fff;
    box-shadow: 0 4px 20px rgba(255, 193, 7, 0.2);
}

.header-search .form-control {
    border: none !important;
    background: transparent !important;
    padding: 12px 20px !important;
    font-size: 14px !important;
    flex: 1;
    color: var(--header-text);
}

.header-search .form-control::placeholder {
    color: #999;
}

.header-search .form-control:focus {
    box-shadow: none !important;
    outline: none !important;
}

.header-search .search-btn {
    background: var(--header-primary) !important;
    border: none !important;
    padding: 12px 25px !important;
    color: #000 !important;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.header-search .search-btn:hover {
    background: var(--header-primary-dark) !important;
}

.header-search .search-btn i {
    font-size: 16px;
}

/* === Search Autocomplete Dropdown === */
.header-search {
    position: relative !important;
    z-index: 10000 !important;
}

.search-autocomplete-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    min-width: 350px !important;
    background: #ffffff !important;
    border-radius: 12px !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3) !important;
    z-index: 2147483647 !important;
    max-height: 450px;
    overflow-y: auto;
    border: 1px solid #ddd !important;
    display: none;
    /* Prevent touch action conflicts on mobile */
    touch-action: auto !important;
}

.search-suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--header-text);
    transition: var(--transition-smooth);
    border-bottom: 1px solid #f5f5f5;
    /* Mobile touch optimization */
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255, 193, 7, 0.2);
    user-select: none;
    -webkit-user-select: none;
}

.search-suggestion-item:last-of-type {
    border-bottom: none;
}

.search-suggestion-item:hover,
.search-suggestion-item.selected,
.search-suggestion-item:active {
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
}

.suggestion-image {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    background: #f5f5f5;
    flex-shrink: 0;
}

.suggestion-info {
    flex: 1;
    min-width: 0;
}

.suggestion-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.suggestion-name mark {
    background: var(--header-primary);
    color: #000;
    padding: 0 2px;
    border-radius: 2px;
}

.suggestion-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}

.suggestion-category {
    color: #888;
}

.suggestion-price {
    color: #28a745;
    font-weight: 700;
}

.search-view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--header-primary) 0%, #FFD54F 100%);
    color: #000;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: var(--transition-smooth);
    border-radius: 0 0 12px 12px;
}

.search-view-all:hover {
    background: linear-gradient(135deg, var(--header-primary-dark) 0%, var(--header-primary) 100%);
}

.search-no-results {
    padding: 20px 16px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* === Navigation Links Section === */
.top-links {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 13px !important;
    margin-left: auto !important;
    flex-wrap: nowrap !important;
}

.top-links>a,
.top-links>div:not(.user-profile-pill) {
    display: flex !important;
    align-items: center !important;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none !important;
    color: var(--header-text) !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    transition: var(--transition-smooth);
    position: relative;
}

.top-links>a:hover,
.top-links>div:not(.user-profile-pill):hover {
    background: rgba(255, 193, 7, 0.1);
    color: #000 !important;
}

.top-links>a i,
.top-links>div i {
    font-size: 16px;
    color: var(--header-primary-dark);
}

/* Location Selector */
.top-links>div:first-child {
    background: #FFF8E1;
    border: 1px solid #FFE082;
}

.top-links>div:first-child:hover {
    background: #FFECB3;
}

.top-links>div:first-child a {
    color: var(--header-text) !important;
    text-decoration: none;
}

.top-links>div:first-child strong {
    color: var(--header-primary-dark);
    font-weight: 700;
}

/* Cart Badge */
.cart-link {
    position: relative;
}

.cart-count {
    background: var(--header-accent) !important;
    color: #fff !important;
    border-radius: 50% !important;
    padding: 2px 7px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(25%, -25%);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
}

/* User Profile Pill - INLINE FIX */
.user-profile-pill {
    position: relative;
    display: inline-flex !important;
    align-items: center !important;
    flex-shrink: 0;
}

.user-pill-trigger {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px;
    padding: 4px 10px 4px 4px !important;
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    border-radius: 50px;
    text-decoration: none !important;
    color: var(--header-text) !important;
    border: 1px solid #FFE082;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.user-pill-trigger:hover {
    background: linear-gradient(135deg, #FFECB3 0%, #FFE082 100%);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.user-avatar {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    border-radius: 50%;
    overflow: hidden;
    background: var(--header-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.user-name {
    font-weight: 600;
    font-size: 12px !important;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.caret-icon {
    font-size: 10px;
    transition: var(--transition-smooth);
}

.user-profile-pill:hover .caret-icon {
    transform: rotate(180deg);
}

/* User Dropdown */
.user-dropdown {
    min-width: 180px;
    padding: 8px 0;
    border-radius: 12px;
    box-shadow: var(--mega-menu-shadow);
    border: 1px solid #eee;
    margin-top: 8px;
}

.user-dropdown .dropdown-item {
    padding: 10px 20px;
    font-size: 14px;
    color: var(--header-text);
    transition: var(--transition-smooth);
}

.user-dropdown .dropdown-item:hover {
    background: #FFF8E1;
    color: #000;
}

.user-dropdown .dropdown-item i {
    color: var(--header-primary-dark);
}

/* Login Link */
.login-link {
    background: linear-gradient(135deg, var(--header-primary) 0%, var(--header-primary-dark) 100%) !important;
    color: #000 !important;
    font-weight: 600 !important;
    border-radius: 50px !important;
    padding: 8px 16px !important;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
    font-size: 13px !important;
}

.login-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.4) !important;
}

/* === Modern Category Bar === */
.category-bar {
    background: linear-gradient(135deg, var(--header-primary) 0%, #FFD54F 100%);
    position: relative;
    z-index: 100;
    padding: 0;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.2);
}

.category-bar .container {
    max-width: 1400px;
    padding: 0 20px;
}

.category-menu {
    display: flex;
    align-items: center;
    gap: 5px !important;
    list-style: none;
    margin: 0;
    padding: 0 !important;
}

.category-menu>li {
    position: relative;
}

.category-menu>li>a {
    text-decoration: none;
    color: #000;
    font-weight: 600;
    font-size: 13px !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 50px !important;
    display: inline-flex;
    align-items: center;
    padding: 0 16px;
    transition: var(--transition-smooth);
    position: relative;
}

/* Menu item icons */
.category-menu>li>a i {
    font-size: 14px;
    opacity: 0.8;
    transition: var(--transition-smooth);
}

.category-menu>li>a:hover i {
    opacity: 1;
    transform: scale(1.1);
}

.category-menu>li>a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: #000;
    border-radius: 3px 3px 0 0;
    transition: var(--transition-smooth);
    transform: translateX(-50%);
}

.category-menu>li:hover>a::after,
.category-menu>li>a.active::after {
    width: calc(100% - 32px);
}

.category-menu>li>a:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* === All Categories - Modern Mega Menu === */
.allcat {
    position: static !important;
}

.allcat-toggle {
    background: rgba(0, 0, 0, 0.08) !important;
    border-radius: 8px !important;
    margin: 8px 0;
    line-height: 34px !important;
    padding: 0 18px !important;
}

.allcat-toggle:hover {
    background: rgba(0, 0, 0, 0.12) !important;
}

.allcat-toggle .fa-th-large {
    font-size: 14px;
}

.allcat-toggle .fa-angle-down {
    margin-left: 8px;
    font-size: 12px;
    transition: var(--transition-smooth);
}

.allcat:hover .allcat-toggle .fa-angle-down {
    transform: rotate(180deg);
}

/* Mega Menu Container */
.allcat-menu.mega-menu {
    display: none;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    background: #fff;
    border: none;
    border-radius: 0 0 20px 20px;
    box-shadow: var(--mega-menu-shadow);
    padding: 0 !important;
    z-index: 999;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.allcat:hover .allcat-menu.mega-menu {
    display: flex;
}

/* Mega Menu Inner Layout */
.allcat-menu.mega-menu {
    flex-wrap: wrap;
    justify-content: center;
    padding: 30px 40px !important;
    gap: 0;
}

.allcat-menu.mega-menu>li {
    flex: 0 0 25%;
    max-width: 25%;
    padding: 15px 25px;
    list-style: none;
    border-right: 1px solid #f0f0f0;
}

.allcat-menu.mega-menu>li:last-child {
    border-right: none;
}

/* Mega Menu Category Container */
.mega-menu-category {
    height: 100%;
}

/* Category Title with Icon - Enhanced */
.mega-menu-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #000;
    margin-bottom: 18px !important;
    padding-bottom: 12px !important;
    border-bottom: 2px solid var(--header-primary) !important;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mega-menu-title::before {
    display: none;
}

.mega-menu-title i {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--header-primary-dark);
    transition: var(--transition-smooth);
}

.allcat-menu.mega-menu>li:hover .mega-menu-title i {
    background: linear-gradient(135deg, var(--header-primary) 0%, var(--header-primary-dark) 100%);
    color: #000;
    transform: scale(1.1) rotate(5deg);
}

/* Category Links - Enhanced */
.allcat-menu.mega-menu>li>.mega-menu-category>ul,
.allcat-menu.mega-menu>li>ul {
    padding: 0;
    margin: 0;
    list-style: none;
}

.allcat-menu.mega-menu>li>.mega-menu-category>ul li,
.allcat-menu.mega-menu>li>ul li {
    margin-bottom: 2px;
}

.allcat-menu.mega-menu>li>.mega-menu-category>ul a,
.allcat-menu.mega-menu>li>ul a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--header-text-light);
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 8px;
    transition: var(--transition-smooth);
    position: relative;
}

.allcat-menu.mega-menu>li>.mega-menu-category>ul a:hover,
.allcat-menu.mega-menu>li>ul a:hover {
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    color: #000;
    padding-left: 16px;
}

/* View All Link - Enhanced */
.mega-menu-view-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--header-primary) 0%, var(--header-primary-dark) 100%);
    color: #000 !important;
    font-weight: 600;
    font-size: 12px;
    text-decoration: none !important;
    border-radius: 25px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.mega-menu-view-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 193, 7, 0.4);
}

.mega-menu-view-all i {
    font-size: 10px;
    transition: var(--transition-smooth);
}

.mega-menu-view-all:hover i {
    transform: translateX(4px);
}

/* Featured Section in Mega Menu */
.mega-menu-featured {
    background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
    border-radius: 15px;
    padding: 20px;
    margin-top: 10px;
}

.mega-menu-featured-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--header-accent);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mega-menu-featured-title i {
    font-size: 16px;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #000;
    padding: 8px 12px;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.mobile-menu-toggle:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* === Responsive Styles === */
@media (max-width: 1200px) {
    .header-search {
        max-width: 400px !important;
        margin: 0 20px !important;
    }

    .top-links {
        gap: 5px !important;
    }

    .top-links>a,
    .top-links>div {
        padding: 6px 10px;
        font-size: 12px !important;
    }

    .category-menu>li>a {
        padding: 0 12px;
        font-size: 12px !important;
    }

    /* Hide icons on smaller screens */
    .category-menu>li>a i.me-1 {
        display: none;
    }

    .allcat-menu.mega-menu>li {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }

    .allcat-menu.mega-menu>li:nth-child(3) {
        border-right: none;
    }

    .allcat-menu.mega-menu>li:nth-child(4) {
        border-right: 1px solid #f0f0f0;
    }
}

@media (max-width: 991px) {
    body {
        padding-top: 120px !important;
        transition: padding-top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body:has(.header.category-hidden) {
        padding-top: 50px !important;
        /* Match reduced header height */
    }

    .header {
        height: auto !important;
        transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .header.category-hidden {
        height: 50px !important;
    }

    .header-top {
        padding: 10px 0 !important;
    }

    .header-top .container {
        flex-direction: column !important;
        gap: 15px !important;
        align-items: stretch !important;
    }

    /* Logo centered on mobile */
    .header-logo {
        text-align: center !important;
        justify-content: center !important;
    }

    .header-logo img {
        height: 35px !important;
    }

    /* Search full width */
    .header-search {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        order: 2;
        /* Ensure dropdown appears above other header elements */
        z-index: 100000 !important;
    }

    .header-search form {
        display: flex !important;
        width: 100% !important;
    }

    .header-search .form-control {
        height: 48px;
        padding: 10px 20px !important;
        width: auto !important;
        flex: 1 !important;
        min-width: 0 !important;
    }

    .header-search .search-btn {
        flex-shrink: 0 !important;
        width: auto !important;
    }

    /* Links wrap */
    .top-links {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
        order: 3;
        margin-left: 0 !important;
    }

    /* Hide some links on tablet */
    .top-links>a:nth-child(2),
    .top-links>a:nth-child(3) {
        display: none !important;
    }

    /* Category bar */
    .category-bar {
        padding: 8px 0 !important;
        min-height: 50px !important; /* Fixed height for the bar */
        display: flex !important;
        align-items: center !important;
        position: relative !important;
        z-index: 1001 !important; /* Ensure above overlay (998) */
    }

    .category-bar .container {
        position: relative;
        height: 100%;
        min-height: 44px; /* Match button height */
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important; /* Push toggle to right */
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative !important; /* Keep it inside the container flow or absolute relative to container */
        right: auto !important;
        top: auto !important;
        transform: none !important;
        z-index: 101;
        background: rgba(255, 193, 7, 0.9);
        border: 2px solid rgba(255, 193, 7, 1);
        width: 44px;
        height: 44px;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
        margin-left: auto !important; /* Push to right if flex */
    }

    .mobile-menu-toggle:hover {
        background: rgba(255, 193, 7, 1);
        transform: translateY(-50%) scale(1.05);
        box-shadow: 0 6px 16px rgba(255, 193, 7, 0.4);
    }

    .mobile-menu-toggle i {
        font-size: 18px;
        color: #000;
    }

    .category-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: #ffd333;
        flex-direction: column;
        padding: 0 !important;
        z-index: 1000;
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        max-height: calc(100vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 20px !important;
    }

    .category-menu.mobile-open {
        display: flex !important;
    }

    .category-menu::-webkit-scrollbar {
        display: none;
    }

    .category-menu>li {
        width: 100%;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .category-menu>li>a {
        display: block;
        padding: 12px 20px;
        font-size: 14px !important;
        line-height: normal !important;
        color: #000;
        white-space: nowrap;
    }

    .category-menu>li>a i.me-1 {
        display: none;
    }

    /* Mega menu mobile - Accordion Style */
    .allcat-menu.mega-menu {
        position: static !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 0 !important;
        overflow: hidden !important; /* Hide content when collapsed */
        border-radius: 0 !important;
        padding: 0 !important;
        flex-direction: column;
        display: flex !important; /* Keep as flex but hidden via height */
        z-index: 100;
        background: #fdfdfd; /* Slightly off-white to distinguish */
        box-shadow: inset 0 4px 10px rgba(0,0,0,0.05);
        transition: max-height 0.4s ease-in-out, padding 0.3s ease, opacity 0.3s ease;
        visibility: hidden !important;
        opacity: 0 !important;
        margin-top: 0 !important;
        border: none !important;
    }

    .allcat-menu.mega-menu.mobile-open {
        max-height: 80vh !important;
        overflow-y: auto !important;
        padding: 10px 0 !important;
        border-bottom: 2px solid rgba(0,0,0,0.05) !important;
        display: flex !important; /* Ensure it overrides any hiding */
        visibility: visible !important;
        opacity: 1 !important;
        margin-top: 0 !important;
    }
    
    /* Adjust grid items inside accordion */
    .allcat-menu.mega-menu > li {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 10px 20px !important;
        border-bottom: 1px dashed #eee;
    }

    .mega-menu-title {
        font-size: 13px !important;
    }

    .mega-menu-title i {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}

@media (max-width: 575px) {
    body {
        padding-top: 110px !important;
        transition: padding-top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body:has(.header.category-hidden) {
        padding-top: 50px !important;
    }

    .header {
        height: auto !important;
        transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .header.category-hidden {
        height: 50px !important;
    }

    .header-logo img {
        height: 32px !important;
        max-width: 120px !important;
    }

    .header-search .form-control {
        padding: 10px 15px !important;
        font-size: 13px !important;
    }

    .header-search .search-btn {
        padding: 10px 18px !important;
    }

    /* Mobile autocomplete dropdown fixes */
    .search-autocomplete-dropdown {
        min-width: 0 !important;
        max-height: min(400px, calc(100vh - 200px)) !important;
        border-radius: 8px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        top: 100% !important;
        z-index: 2147483647 !important;
    }

    .search-suggestion-item {
        padding: 14px 16px;
        /* Larger tap targets for mobile */
        min-height: 60px;
    }

    .suggestion-image {
        width: 45px;
        height: 45px;
    }

    .suggestion-name {
        font-size: 13px;
        /* Allow wrapping on small screens */
        white-space: normal;
        overflow: visible;
        line-height: 1.3;
        max-height: 2.6em;
        /* 2 lines max */
    }

    .suggestion-meta {
        font-size: 11px;
    }

    .search-view-all {
        padding: 16px;
        font-size: 14px;
        border-radius: 0 0 8px 8px;
        /* Larger tap target */
        min-height: 50px;
    }

    .top-links>div:first-child {
        display: none !important;
    }

    .top-links>a:nth-child(1),
    .top-links>a:nth-child(2),
    .top-links>a:nth-child(3) {
        display: none !important;
    }

    .user-name {
        display: none !important;
    }

    .user-pill-trigger {
        padding: 6px !important;
        border-radius: 50%;
    }

    .category-menu>li>a {
        font-size: 10px !important;
        line-height: 36px !important;
        padding: 0 8px;
    }

    .allcat-toggle {
        padding: 0 12px !important;
        margin: 0 !important;
    }

    .allcat-toggle .fa-th-large {
        display: none;
    }

    .allcat-menu.mega-menu {
        top: 110px !important;
        /* max-height removed to allow scrolling in parent */
        background: #fff;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
    }

    .mobile-menu-toggle {
        width: 40px;
        height: 40px;
        right: 15px;
    }

    .mobile-menu-toggle i {
        font-size: 16px;
    }

    .mega-menu-title {
        font-size: 12px !important;
    }

    .allcat-menu.mega-menu>li>.mega-menu-category>ul a,
    .allcat-menu.mega-menu>li>ul a {
        padding: 8px 10px;
        font-size: 12px;
    }

    .mega-menu-view-all {
        padding: 8px 14px;
        font-size: 11px;
    }
}

/* === Scrollbar Styling for Mega Menu === */
.allcat-menu.mega-menu::-webkit-scrollbar {
    width: 6px;
}

.allcat-menu.mega-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.allcat-menu.mega-menu::-webkit-scrollbar-thumb {
    background: var(--header-primary);
    border-radius: 3px;
}

.allcat-menu.mega-menu::-webkit-scrollbar-thumb:hover {
    background: var(--header-primary-dark);
}

/* === Animations === */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Cart count animation */
.cart-count {
    animation: pulse 2s infinite;
}

/* Shimmer effect for loading */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.mega-menu-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* === Print Styles === */
@media print {
    .header {
        position: relative;
        box-shadow: none;
    }

    .category-bar,
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* === Modern Scroll Behavior === */

/* Smooth scroll transition for category bar */
.category-bar {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
}

/* Hidden state for category bar */
.category-bar.category-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

/* Active scroll state for header */
.header.scroll-active {
    /* Add any additional styles for when scrolling is active */
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.12);
}

/* Ensure header top remains sticky during scroll */
.header-top {
    position: relative;
    z-index: 10;
    background: #ffffff !important;
}

/* Ensure solid background when category bar is hidden */
.header.category-hidden .header-top {
    background: #ffffff !important;
    border-bottom: 1px solid #f0f0f0;
}

/* Performance optimization for scroll */
@media (prefers-reduced-motion: reduce) {
    .category-bar {
        transition: none;
    }

    .category-bar.category-hidden {
        transform: none;
        opacity: 1;
        display: none;
    }
}