/* Top Navigation Z-Index */
.topNav,
.topNavDelivery {
    z-index: 4 !important;
}

/* Desktop: Remove padding from navbar */
nav.shadow-sm {
    padding: 0 !important;
}

/* Main Navigation Link Styling */
.nav-link,
.dropdown-toggle {
    font-size: 15px !important;
    white-space: normal !important;
    line-height: 1.3 !important;
    padding: 8px 10px !important;
}

/* Hide dropdown arrow */
.dropdown-toggle::after {
    display: none !important;
}

/* Custom Nav Item Highlight - applies red text color */
.navbar-light .navbar-nav .nav-link.nav-highlight,
.navbar-light .navbar-nav .dropdown-toggle.nav-highlight,
.navbar-light .navbar-nav a.nav-highlight {
    color: #FF4242 !important;
}

.navbar-light .navbar-nav .nav-link.nav-highlight:hover,
.navbar-light .navbar-nav .dropdown-toggle.nav-highlight:hover,
.navbar-light .navbar-nav a.nav-highlight:hover {
    color: #cc3535 !important;
}

/* Allow navbar to wrap to multiple lines */
.navbar-nav {
    flex-wrap: wrap !important;
}

/* Force nav items to display on 2 lines */
.navbar-nav .nav-item {
    flex: 0 1 auto !important;
    max-width: 115px !important;
    height: 70px !important;
    display: flex !important;
    align-items: center !important;
}

/* Make anchor tags fill the full nav-item space for better hover area */
.navbar-nav .nav-item > a,
.navbar-nav .nav-item > .dropdown-toggle {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Mega Menu Dropdown Styling */
.megamenu .dropdown-menu {
    top: 70px !important;
    border-top: none !important;
    border-radius: 0 0 8px 8px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8) !important;
    background: #ffffff !important;
    padding: 0 !important;
    transition: none !important;
}

/* Three-Panel Mega Menu Layout */
.mega-menu-side-wrapper {
    display: flex !important;
    width: 100% !important;
    min-height: 400px;
    overflow: visible !important;
    position: relative;
    border-bottom: 5px solid #1B8FC1;
    transition: none !important;
}

/* Left Nav: Parent Categories (30%) */
.mega-menu-side-left-nav {
    display: block !important;
    width: 30% !important;
    background: #1b8fc1 !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 600px;
    border-right: 1px solid #e5e7eb;
}

.mega-menu-side-left-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-menu-side-left-nav li {
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background 0.2s ease;
}

.mega-menu-side-left-nav li:hover {
    background: #1C365C !important;
    cursor: pointer;
}

.mega-menu-side-left-nav li a {
    display: flex;
    align-items: center;
    padding: 0;
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
}

.mega-menu-side-left-nav li:hover a {
    color: #ffffff;
}

/* Hide category icons on desktop */
.mega-menu-side-left-nav .category-icon {
    display: none;
}

/* Middle Container: Subcategories (45%) */
.mega-menu-side-middle {
    display: block !important;
    flex: 1 !important;
    width: 45% !important;
    padding: 30px !important;
    background: #ffffff !important;
    overflow-y: auto;
    max-height: 600px;
}

/* Hide middle container when no subcategories exist (JavaScript-controlled) */
.mega-menu-side-middle.hidden-no-subcategories {
    display: none !important;
    width: 0 !important;
    padding: 0 !important;
}

/* Expand right panel when middle is hidden (no subcategories) */
.mega-menu-side-right.expanded-no-subcategories {
    width: 70% !important;
    flex: 1 !important;
}

/* Hide child divs by default, JavaScript will show the active one */
.mega-menu-subcategories {
    display: none !important;
}

.mega-menu-subcategories.active {
    display: block !important;
}

.subcategory-grid {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
}

.subcategory-item {
    display: flex !important;
    align-items: center;
    gap: 15px;
    text-decoration: none !important;
    color: #374151 !important;
    padding: 12px 15px;
    transition: background 0.2s ease;
    background: transparent !important;
    border-bottom: 1px solid #f0f0f0;
}

.subcategory-item:hover {
    background: #f8f9fa !important;
    color: #111827 !important;
}

.subcategory-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.subcategory-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.subcategory-name {
    font-size: 14px !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
    transition: color 0.2s ease !important;
    flex: 1;
}

/* Mega Menu Product Grid */
.mega-menu-product-grid {
    max-height: 480px;
    overflow-y: auto;
}

.mega-menu-product-item .subcategory-image {
    width: 60px;
    height: 60px;
}

.mega-menu-view-all {
    text-align: center;
    padding: 12px 15px 5px;
}

.mega-menu-view-all-btn {
    display: inline-block;
    padding: 8px 24px;
    background: #1b8fc1;
    color: #fff !important;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background 0.2s ease;
}

.mega-menu-view-all-btn:hover {
    background: #166f99;
    color: #fff !important;
}

/* Right Container: Promotion (25% normal, 70% when expanded) */
.mega-menu-side-right {
    display: block !important;
    width: 25% !important;
    padding: 30px !important;
    background: #f8f9fa !important;
    overflow-y: auto;
    max-height: 600px;
    flex-shrink: 0;
}

.mega-menu-promotion {
    display: none !important;
}

.mega-menu-promotion.active {
    display: block !important;
}

/* Normal state (25% width): Stack promotions vertically */
.mega-menu-promotion .promotion-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Expanded state (70% width): Flex layout for multiple promotions */
.mega-menu-side-right.expanded-no-subcategories .promotion-content {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 25px;
}

/* Each promo card in expanded state should be flexible but have min/max width */
.mega-menu-side-right.expanded-no-subcategories .mega-menu-promo {
    flex: 1 1 280px;
    max-width: calc(50% - 12.5px); /* 2 columns with gap */
}

.mega-menu-promotion .promotion-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* Promotional Block Styling - Works for both normal and expanded */
.mega-menu-promo {
    max-width: 100%;
    background: #ffffff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mega-menu-promo:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mega-menu-promo .promo-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* Expanded state: Larger thumbnails for better visibility */
.mega-menu-side-right.expanded-no-subcategories .mega-menu-promo .promo-thumbnail {
    height: 220px;
}

.mega-menu-promo .promo-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.3;
}

/* Expanded state: Larger titles */
.mega-menu-side-right.expanded-no-subcategories .mega-menu-promo .promo-title {
    font-size: 18px;
}

.mega-menu-promo .promo-text {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.mega-menu-promo .promo-link {
    display: inline-block;
    color: #1b8fc1;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s;
}

.mega-menu-promo .promo-link:hover {
    color: #1C365C;
    text-decoration: underline;
}

/* Single promotion in normal state: Full width */
.mega-menu-side-right:not(.expanded-no-subcategories) .mega-menu-promo {
    width: 100%;
    max-width: 100%;
}

/* Standard Menu Promotion Styling */
.standard-menu-with-promotion .mega-menu-promotion-area {
    position: sticky;
    top: 20px;
}

/* Responsive adjustments - Mobile Navigation */
@media (max-width: 991px) {
    /* Mobile: Add padding to navbar */
    nav.shadow-sm {
        padding: 10px !important;
    }

    /* Mobile: Override nav-item max-width to full width */
    .navbar-nav .nav-item {
        max-width: 100% !important;
        height: auto !important;
        display: block !important;
    }

    /* Mobile: Left align nav items and remove centering */
    .navbar-nav .nav-item > a,
    .navbar-nav .nav-item > .dropdown-toggle {
        justify-content: flex-start !important;
        text-align: left !important;
    }

    /* Mobile: Show dropdown arrow */
    .dropdown-toggle::after {
        display: inline-block !important;
        margin-left: auto !important;
    }

    /* Mobile: Remove box shadow from mega menu dropdown */
    .megamenu .dropdown-menu {
        box-shadow: none !important;
        position: static !important;
        transform: none !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
    }

    /* Mobile: Force all dropdown menus to display below */
    .dropdown-menu,
    .normalmenu .dropdown-menu {
        position: static !important;
        transform: none !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
    }

    /* Mobile: Make the collapsible menu white when it opens */
    .navbar-collapse {
        background: #ffffff !important;
        background-color: #ffffff !important;
    }

    /* Mobile: Ensure dropdown content area is white */
    .navbar-collapse .navbar-nav {
        background: #ffffff !important;
    }

    /* Mobile navbar styling */
    .navbar-nav {
        text-align: left;
        padding: 0;
        margin: 0;
    }

    /* Make the navbar collapse scrollable */
    .navbar-collapse,
    .navbar-collapse.show {
        max-height: calc(100vh - 60px) !important;
        height: auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        position: relative !important;
    }

    /* Ensure the navbar content is fully scrollable */
    #navbarContent {
        height: auto !important;
    }

    /* Mobile: Ensure dropdown menus flow within scrollable container */
    .navbar-collapse .dropdown-menu,
    .navbar-collapse .megamenu .dropdown-menu {
        position: static !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* Mobile: Ensure nav items and dropdowns are part of scroll flow */
    .navbar-nav,
    .navbar-nav .nav-item,
    .navbar-nav .dropdown-menu {
        position: static !important;
    }

    .navbar-nav .nav-item {
        width: 100%;
        margin: 0;
    }

    /* Mobile: Fix megamenu alignment */
    .megamenu {
        padding: 0 !important;
    }

    /* Mobile: Override mega menu top-level padding to match other nav items */
    .megamenu > a.dropdown-toggle {
        padding: 0.75rem 1rem !important;
    }

    /* Mobile: For mega menus - hide middle and right panels, keep left nav only */
    .mega-menu-side-middle,
    .mega-menu-side-right {
        display: none !important;
    }

    /* Mobile: Remove min-height from mega menu wrapper */
    .mega-menu-side-wrapper {
        min-height: 0 !important;
    }

    /* Mobile: Make mega menu left navigation full width */
    .mega-menu-side-left-nav {
        width: 100% !important;
        background: #ffffff !important;
        padding: 0 !important;
        border-right: none !important;
        max-height: none !important;
        overflow-y: visible !important;
    }

    /* Mobile: Update mega menu left nav links for white background */
    .mega-menu-side-left-nav li {
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .mega-menu-side-left-nav li a {
        color: #1b8fc1 !important;
        padding: 0.75rem 1rem !important;
    }

    .mega-menu-side-left-nav li:hover {
        background: #f8f9fa !important;
    }

    .mega-menu-side-left-nav li:hover a {
        color: #1C365C !important;
    }

    /* Mobile: Display category icons to the left of titles in mega menu */
    .mega-menu-side-left-nav .category-icon {
        display: inline-block !important;
        width: 32px !important;
        height: 32px !important;
        margin-right: 10px !important;
        vertical-align: middle !important;
        object-fit: contain !important;
    }

    .mega-menu-side-left-nav .category-name {
        display: inline-block !important;
        vertical-align: middle !important;
        font-size: 14px !important;
    }

    .megamenu a {
        display: flex !important;
        align-items: center !important;
    }

    /* Mobile: Dropdown menus hidden by default */
    .dropdown-menu {
        display: none !important;
        position: static !important;
        float: none !important;
        width: 100% !important;
        margin: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: #ffffff !important;
    }

    /* Mobile: Consistent white background for both normal and mega menus */
    .normalmenu .dropdown-menu,
    .megamenu .dropdown-menu {
        background: #ffffff !important;
    }

    .normalmenu .dropdown-menu {
        display: none !important;
    }

    /* Mobile: Override - dropdown menu inside elements without .show class should be hidden */
    .nav-item:not(.show) .dropdown-menu {
        display: none !important;
    }

    /* Mobile: Show dropdown menus when active - override all display rules */
    .nav-item.dropdown.show > .dropdown-menu,
    .nav-item.megamenu.show > .dropdown-menu,
    .dropdown.show .dropdown-menu,
    .megamenu.show .dropdown-menu,
    .dropdown-menu.show {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Mobile: Ensure dropdown stays visible with show class, regardless of hover state */
    .nav-item.show .dropdown-menu,
    .nav-item.show.clicked .dropdown-menu,
    li.show .dropdown-menu,
    li.show.clicked .dropdown-menu {
        display: block !important;
    }

    /* Mobile: Super specific - force display when parent has show class */
    .navbar-nav .nav-item.show > .dropdown-menu,
    .navbar-nav li.show > .dropdown-menu {
        display: block !important;
        visibility: visible !important;
    }

    /* Mobile: Prevent hover from adding show class */
    .dropdown.normalmenu:hover {
        /* Do nothing on hover */
    }

    /* Style all navigation links consistently */
    .nav-link,
    .dropdown-toggle,
    .dropdown > a,
    .dropdown > span {
        padding: 0.75rem 1rem !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        color: #1b8fc1 !important;
    }

    /* Mobile: Navigation link hover state */
    .nav-link:hover,
    .dropdown-toggle:hover,
    .dropdown > a:hover,
    .dropdown > span:hover {
        color: #1C365C !important;
        background-color: #f8f9fa !important;
    }

    /* Mobile: Hide the desktop navbar collapse */
    #navbarContent {
        display: none !important;
    }
}

/* ========================================
   Mobile Drawer Navigation
   ======================================== */

/* Overlay */
.mobile-drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-drawer-overlay.open {
    display: block;
    opacity: 1;
}

/* Drawer */
.mobile-drawer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 80%;
    max-width: 400px;
    height: 100%;
    background: #ffffff;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.mobile-drawer.open {
    transform: translateX(0);
}

/* Prevent body scroll when drawer is open */
body.mobile-drawer-open {
    overflow: hidden;
}

/* Drawer Header */
.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #1b8fc1;
    color: #ffffff;
}

.mobile-drawer-title {
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-drawer-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 28px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

/* Drawer Body */
.mobile-drawer-body {
    position: relative;
    height: calc(100% - 56px);
    overflow: hidden;
}

/* Panels */
.mobile-drawer-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

.mobile-drawer-panel.active {
    transform: translateX(0);
}

/* Back Button */
.mobile-drawer-back {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    background: #f0f4f8;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    color: #1b8fc1;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.mobile-drawer-back:hover {
    background: #e2e8f0;
}

/* Panel Title (link to parent category) */
.mobile-drawer-panel-title {
    display: block;
    padding: 14px 20px;
    background: #1b8fc1;
    color: #ffffff !important;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none !important;
    text-transform: uppercase;
}

.mobile-drawer-panel-title:hover {
    background: #166f99;
    color: #ffffff !important;
}

/* Menu List */
.mobile-drawer-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Menu Item */
.mobile-drawer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    color: #333333 !important;
    text-decoration: none !important;
    font-size: 15px;
    font-weight: 500;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s ease;
}

.mobile-drawer-item:hover {
    background: #f8f9fa;
    color: #1b8fc1 !important;
}

.mobile-drawer-item.has-children {
    cursor: pointer;
}

.mobile-drawer-item i {
    font-size: 12px;
    color: #999;
}

/* View All link */
.mobile-drawer-view-all {
    color: #1b8fc1 !important;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.mobile-drawer-view-all:hover {
    background: #1b8fc1;
    color: #ffffff !important;
}

/* Drawer Contact Info */
.mobile-drawer-contact {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    margin-top: auto;
    text-align: center;
}

.mobile-drawer-phone {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #1b8fc1 !important;
    text-decoration: none !important;
    margin-bottom: 15px;
}

.mobile-drawer-phone:hover {
    color: #166f99 !important;
}

.mobile-drawer-contact-heading {
    display: block;
    font-size: 15px;
    color: #333;
    margin-bottom: 5px;
}

.mobile-drawer-hours-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #666;
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
}

.mobile-drawer-hours-row:last-child {
    border-bottom: none;
}

.mobile-drawer-closed {
    font-weight: 700;
    color: #cc3535;
    text-align: right;
}

/* Only show drawer elements on mobile */
@media (min-width: 992px) {
    .mobile-drawer,
    .mobile-drawer-overlay {
        display: none !important;
    }
}

@media (max-width: 991px) {
    .mobile-drawer {
        display: block;
    }
}