/* --- Modern Header Redesign --- */
:root {
    --header-bg-top: #ffffff;
    --header-bg-bottom: var(--MAIN_MENU_BG); 
    --brand-primary: var(--primary_color);
    --brand-secondary: var(--secondary_color);
    --text-dark: #333333;
    --text-white: var(--MAIN_MENU_ul_li_color);
    --search-bg: #F5F5F5;
    --shadow-light: 0 4px 12px rgba(0,0,0,0.08);
}

/* Scroll Lock */
.no-scroll {
    overflow: hidden !important;
    height: 100% !important;
    position: relative !important;
}

/* Header Container */
.modern-header {
    width: 100%;
    z-index: 1000;
    position: relative;
    background: var(--header-bg-top);
}

/* --- TIER 1: TOP BAR --- */
.header-top-tier {
    padding: 5px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.header-top-tier.hidden {
    height: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
}

/* Logo */
.modern-logo img {
    height: 45px;
    width: auto;
}

/* Search Bar */
.modern-search-wrapper {
    flex: 0 0 45%;
    position: relative;
}

.modern-search-form {
    display: flex;
    align-items: center;
    background: var(--search-bg);
    border-radius: 50px;
    padding: 5px 20px;
    width: 100%;
}

.modern-search-form input {
    border: none;
    background: none;
    width: 100%;
    padding: 8px 10px;
    outline: none;
    font-size: 14px;
    color: #666;
}

.modern-search-form button {
    background: none;
    border: none;
    color: #444;
    font-size: 18px;
    cursor: pointer;
}

.search-suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    margin-top: 10px;
    max-height: 500px;
    overflow-y: auto;
    display: none;
    border-top: 3px solid var(--brand-primary);
}

.search-suggestions-dropdown.active {
    display: block;
}

.search-suggestions-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-suggestions-dropdown::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

/* Suggestion Item Styles */
.suggestion-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.suggestion-item:hover {
    background: #fcfcfc;
    text-decoration: none;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-thumbnail {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    margin-right: 15px;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    border: 1px solid #eee;
}

.suggestion-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.suggestion-details {
    flex: 1;
    min-width: 0;
}

.suggestion-title {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-vendor {
    margin: 0 0 4px;
    font-size: 11px;
    color: #888;
}

.suggestion-price {
    display: flex;
    align-items: center;
    gap: 8px;
}

.disc-price {
    color: var(--brand-primary);
    font-weight: 700;
    font-size: 14px;
}

.reg-price {
    color: #bbb;
    font-size: 12px;
    text-decoration: line-through;
}

.suggestion-footer {
    padding: 12px;
    text-align: center;
    background: #f9f9f9;
    border-top: 1px solid #eee;
}

.btn-view-all-search {
    display: inline-block;
    padding: 8px 25px;
    background: #333;
    color: #fff;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.3s;
}

.btn-view-all-search:hover {
    background: var(--brand-primary);
    color: #fff;
    text-decoration: none;
}

.suggestion-empty {
    padding: 25px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* Action Icons */
.header-actions {
    display: flex;
    align-items: center;
    gap: 22px;
}

.action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-dark);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 5px;
    border-radius: 8px;
}

.action-item:hover {
    color: var(--brand-primary);
    text-decoration: none;
    background: rgba(var(--brand-primary-rgb), 0.05);
    transform: translateY(-2px);
}

.action-item i {
    font-size: 24px;
    margin-bottom: 5px;
    transition: transform 0.3s ease;
}

.action-item:hover i {
    transform: scale(1.1);
}

.action-item span {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.cart-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--brand-primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 0;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid #fff;
    transition: all 0.3s ease;
}

.action-item:hover .cart-badge {
    transform: scale(1.1) rotate(10deg);
}

/* --- TIER 2: NAVIGATION BAR --- */
.header-bottom-tier {
    background: var(--header-bg-bottom);
    color: var(--text-white);
    padding: 0;
    width: 100%;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1010; /* Ensure it stays above content */
}

.header-bottom-tier.sticky {
    position: fixed;
    top: 0;
    left: 0;
    box-shadow: var(--shadow-light);
    z-index: 1001;
}

.main-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: start; /* SPREAD ITEMS TO FILL CONTAINER */
    width: 100%;
    gap: 0; /* Remove gap, use space-between */
}

.main-nav-list li {
    position: relative;
}

.main-nav-list li > a {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 100%;
    padding: 12px 12px; /* Slightly reduced padding to fit more items */
    color: var(--text-white);
    text-decoration: none;
    font-size: 13px; /* Slightly smaller font */
    font-weight: 600;
    transition: background 0.3s;
    white-space: nowrap; /* PREVENT 2-LINE TEXT */
}

.main-nav-list li a:hover {
    background: rgba(255,255,255,0.1);
}

.nav-arrow {
    font-size: 10px;
    opacity: 0.8;
}

/* --- DROPDOWN HOVER EFFECTS --- */
.modern-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 230px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    list-style: none;
    padding: 10px 0;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    border-top: 3px solid var(--brand-primary);
    display: none; /* Binary show/hide for reliability */
}

.main-nav-list li:hover > .modern-dropdown {
    opacity: 1;
    visibility: visible;
    display: block;
    transform: translateY(0);
}

.modern-dropdown li {
    padding: 0;
    width: 100%;
}

.modern-dropdown li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    color: #333 !important;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    background: none !important;
}

.modern-dropdown li a:hover {
    background: #f8f8f8 !important;
    color: var(--brand-primary) !important;
    padding-left: 25px;
}

/* Nested Dropdown */
.modern-nested-dropdown {
    position: absolute;
    top: -10px;
    left: 100%;
    width: 220px;
    background: #fff;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    list-style: none;
    padding: 10px 0;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(15px);
    transition: all 0.3s ease;
    z-index: 2001;
    border-left: 2px solid var(--brand-primary);
}

.modern-dropdown li:hover .modern-nested-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* --- MOBILE DRAWER UI --- */
.mobile-header {
    display: none;
    background: #fff;
    border-bottom: 1px solid #eee;
    z-index: 1002;
    position: relative;
    padding: 10px 15px;
       align-items: center;
    justify-content: space-between;
}

.mobile-hamburger i {
    color: #333;
    font-size: 28px;
    display: block;
}

.mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px); /* Modern Glassmorphism */
    z-index: 999998; /* High enough to be above everything */
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-drawer-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: #fff;
    z-index: 999999; /* Higher than overlay */
    box-shadow: 10px 0 30px rgba(0,0,0,0.2);
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.mobile-drawer.active {
    left: 0;
}

.drawer-user-header {
    background: var(--brand-primary);
    padding: 25px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #fff;
}

.drawer-user-header .user-icon {
    width: 45px;
    height: 45px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 24px;
}

.drawer-user-header .user-info h6 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.drawer-user-header .user-info p {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

.drawer-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.drawer-menu-list li {
    padding: 0;
    border-bottom: 1px solid #eee;
}

.drawer-menu-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

/* Mobile Accordion */
.drawer-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #f9f9f9;
    display: none;
}

.drawer-submenu li a {
    padding-left: 40px;
    font-size: 13px;
    font-weight: 400;
}

.drawer-menu-item-with-child.active .drawer-submenu {
    display: block;
}

.drawer-menu-item-with-child.active .icofont-rounded-right {
    transform: rotate(90deg);
}

.drawer-menu-item-with-child .icofont-rounded-right {
    transition: transform 0.2s ease;
}

.drawer-menu-section-title {
    padding: 15px 20px 5px;
    font-size: 16px;
    font-weight: 700;
    color: #333;
    border-left: 3px solid var(--brand-primary);
    margin: 10px 0;
}

.quick-links-card {
    margin: 15px;
    background: #fdfdfd;
    border-radius: 8px;
    border: 1px solid #eeeeee;
}

/* RESPONSIVENESS */
@media (max-width: 991px) {
    .modern-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 2000;
        background: #fff;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }
    body {
        padding-top: 60px; /* Height of the mobile header */
    }
    .header-top-tier, .header-bottom-tier {
        display: none !important;
    }
    .mobile-header {
        display: flex;
        position: relative;
        padding: 10px 15px;
        box-shadow: none;
        border-bottom: none;
        height: 60px;
    }
}

/* --- Search Modal Overlay --- */
.search-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 10000;
    display: none; /* Hidden by default */
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-modal-overlay.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.search-modal-container {
    padding: 15px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.search-modal-logo img {
    height: 30px;
}

.search-modal-close {
    background: #f5f5f5;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
}

.search-modal-close:hover {
    background: #eeeeee;
}

.search-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-input-wrapper {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.search-modal-form {
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--brand-primary);
    padding-bottom: 10px;
}

.search-modal-form input {
    flex: 1;
    border: none;
    background: none;
    font-size: 24px;
    font-weight: 600;
    color: #333;
    outline: none;
    padding: 10px 0;
}

.search-modal-form input::placeholder {
    color: #ccc;
    font-weight: 400;
}

.search-submit-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--brand-primary);
    cursor: pointer;
    padding: 0 10px;
}

.search-results-container {
    flex: 1;
    overflow-y: auto;
    margin-top: 5px;
    padding-bottom: 20px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling for iOS Safari */
}

.search-placeholder-msg {
    text-align: center;
    padding-top: 50px;
}

/* Hide body scroll when modal is active */
body.search-modal-open {
    overflow: hidden !important;
}

@media (max-width: 480px) {
    .search-modal-form input {
        font-size: 18px;
    }
    .search-modal-logo img {
        height: 28px;
    }
}
