/* Vertical Category Menu Button */
.btn-category-menu {
    color: white;
    /*background: linear-gradient(135deg, var(--accent, #4285F4) 0%, var(--primary-blue-dark, #1a73e8) 100%);
    padding: 0.75rem 1.5rem;*/
    border: none;
    background: none;

    border-radius: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    min-width: 150px;
    cursor: pointer;
}

.btn-category-menu:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(66, 133, 244, 0.3);
}

.btn-category-menu.active {
    background: var(--primary-blue-dark, #1a73e8);
}

.btn-category-menu i:last-child {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.btn-category-menu.active i:last-child {
    transform: rotate(180deg);
}

/* Vertical Category Wrapper */
.vertical-category-wrapper {
    position: relative;
    z-index: 1100;
}

/* Vertical Dropdown Container */
.vertical-category-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1200;
    /* CRITICAL: Must be visible for mega menu to show outside */
    overflow: visible !important;
}

.vertical-category-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Category List */
.vertical-category-list {
    list-style: none;
    padding: 0.5rem;
    margin: 0;
    /* If you have many items and need scrolling, use this alternative: */
    max-height: 450px;
}

/* Alternative: Scrollable wrapper for many items */
.vertical-category-list.scrollable {
    overflow-y: auto;
    overflow-x: visible;
    /* Note: This won't work properly with mega menu */
    /* Consider pagination or "View More" button instead */
}

/* Category Items */
.vertical-category-item {
    position: relative;
    margin-bottom: 0.25rem;
}

.vertical-category-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-primary, #263238);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.vertical-category-link:hover,
.vertical-category-item.active .vertical-category-link {
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.08) 0%, rgba(66, 133, 244, 0.04) 100%);
    color: var(--accent, #4285F4);
    transform: translateX(4px);
}

/* Category Icons */
.category-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface, #f5f7fa);
    border-radius: 6px;
    margin-right: 0.75rem;
    color: var(--accent, #4285F4);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.vertical-category-link:hover .category-icon,
.vertical-category-item.active .category-icon {
    background: var(--accent, #4285F4);
    color: white;
    transform: scale(1.1);
}

.category-name {
    flex: 1;
}

/* Chevron for items with children */
.vertical-category-link .fa-chevron-right {
    font-size: 0.75rem;
    color: var(--text-muted, #90a4ae);
    margin-left: auto;
    transition: all 0.3s ease;
}

.vertical-category-item:hover .fa-chevron-right,
.vertical-category-item.active .fa-chevron-right {
    transform: translateX(3px);
    color: var(--accent, #4285F4);
}

/* ========================================
   MEGA MENU WRAPPER & CONTAINER
   ======================================== */

/* Mega Menu Wrapper - Dynamic width to fill container */
.mega-menu-wrapper {
    position: absolute;
    left: 100%;
    top: 0;
    min-height: 400px;
    max-height: 85vh; /* Prevent menu from being too tall */
    background: white;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    display: none;
    z-index: 1201;
    border-left: 1px solid var(--border-light, #e1e8ed);
    overflow-y: auto; /* Allow scrolling for tall menus */
    overflow-x: hidden;
    /* Width calculated by JavaScript */

    /* Smooth scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--accent, #4285F4) transparent;
}

.mega-menu-wrapper::-webkit-scrollbar {
    width: 6px;
}

.mega-menu-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.mega-menu-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent, #4285F4);
    border-radius: 3px;
}

/* Individual Mega Menu Content */
.vertical-mega-menu {
    width: 100%;
    padding: 0 1.75rem;
    display: none;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Simple responsive grid - Bootstrap-like */
.vertical-mega-menu > .row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.75rem; /* Negative margin for gutters */
}

/* Mega Menu Columns - Proper spacing */
.mega-column {
    flex: 0 0 auto;
    width: 33.333333%; /* Default: 3 columns */
    padding: 0 0.75rem 1.5rem 0.75rem;
    min-width: 240px; /* Minimum readable width */
}

/* Column count variations */
.vertical-mega-menu[data-columns="1"] .mega-column {
    width: 100%;
    max-width: 400px;
}

.vertical-mega-menu[data-columns="2"] .mega-column {
    width: 50%;
}

.vertical-mega-menu[data-columns="3"] .mega-column {
    width: 33.333333%;
}

.vertical-mega-menu[data-columns="4"] .mega-column {
    width: 25%;
}

/* If menu width is too narrow, stack columns */
@media (max-width: 768px) {
    .mega-column {
        width: 100% !important;
    }
}

/* ========================================
   COLUMN TITLES & HEADERS
   ======================================== */

.mega-column-title {
    color: white;
    background: linear-gradient(135deg, var(--accent, #4285F4) 0%, var(--primary-blue-light, #6ba3f7) 100%);
    font-weight: 600;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem;
    margin-bottom: 0.875rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.15);
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
}

.mega-column-title i {
    font-size: 0.875rem;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

/* ========================================
   MENU LISTS & ITEMS
   ======================================== */

/* Level 2 Menu Items */
.mega-column-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-column-list > li {
    margin-bottom: 0.375rem;
}

.mega-item-level2 {
    color: var(--text-primary, #263238);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.mega-item-level2:hover {
    background: rgba(66, 133, 244, 0.08);
    color: var(--accent, #4285F4);
    transform: translateX(3px);
}

/* Chevron icon for items with submenu */
.mega-item-level2 i.fa-chevron-right {
    color: var(--accent, #4285F4);
    font-size: 0.7rem;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.has-submenu:hover .mega-item-level2 i.fa-chevron-right {
    transform: rotate(90deg);
}

/* ========================================
   LEVEL 3 SUBMENU
   ======================================== */

.mega-submenu-level3 {
    list-style: none;
    padding: 0.25rem 0 0 1.25rem;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    border-left: 2px solid var(--border-light, #e1e8ed);
}

.has-submenu:hover .mega-submenu-level3 {
    max-height: 500px;
    padding: 0.5rem 0 0.5rem 1.25rem;
}

.mega-submenu-level3 li {
    margin-bottom: 0.25rem;
}

.mega-submenu-level3 a {
    color: var(--text-secondary, #546e7a);
    text-decoration: none;
    font-size: 0.8125rem;
    padding: 0.375rem 0.5rem;
    display: block;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.mega-submenu-level3 a:hover {
    background: rgba(244, 180, 0, 0.1);
    color: var(--accent, #4285F4);
    padding-left: 0.75rem;
}

/* Featured Section in Mega Menu */
.mega-menu-featured {
    background: linear-gradient(135deg, var(--surface, #f5f7fa) 0%, white 100%);
    border-radius: 8px;
    padding: 1rem;
    height: 100%;
}

.featured-title {
    color: var(--text-primary, #263238);
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-gold, #F4B400);
    display: flex;
    align-items: center;
}

.featured-title i {
    color: var(--accent-gold, #F4B400);
    margin-right: 0.5rem;
}

.featured-product {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.featured-product:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.featured-product img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    margin-right: 0.75rem;
}

.product-info {
    flex: 1;
}

.product-info a {
    color: var(--text-primary, #263238);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    display: block;
    margin-bottom: 0.25rem;
    transition: color 0.3s ease;
}

.product-info a:hover {
    color: var(--accent, #4285F4);
}

.product-price {
    color: var(--accent-gold, #F4B400);
    font-weight: 700;
    font-size: 0.9rem;
}

/* Scrollbar Styling */
.vertical-category-list::-webkit-scrollbar {
    width: 6px;
}

.vertical-category-list::-webkit-scrollbar-track {
    background: var(--surface, #f5f7fa);
    border-radius: 3px;
}

.vertical-category-list::-webkit-scrollbar-thumb {
    background: var(--accent, #4285F4);
    border-radius: 3px;
}

.vertical-category-list::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover, #1a73e8);
}

/* Responsive Design */
@media (max-width: 991.98px) {
    /* Convert to mobile-friendly layout */
    .vertical-category-wrapper {
        position: static;
    }

    .btn-category-menu {
        width: 100%;
        justify-content: space-between;
        margin-bottom: 1rem;
    }

    .vertical-category-dropdown {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        max-width: 320px;
        height: 100vh;
        background: white;
        z-index: 9999;
        border-radius: 0;
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.3);
        transition: left 0.3s ease;
        overflow-y: auto;
        transform: none;
    }

    .vertical-category-dropdown.show {
        left: 0;
    }

    /* Mobile menu header */
    .vertical-category-dropdown::before {
        content: 'Danh mục sản phẩm';
        display: block;
        padding: 1rem;
        background: linear-gradient(135deg, var(--accent, #4285F4) 0%, var(--primary-blue-dark, #1a73e8) 100%);
        color: white;
        font-weight: 600;
        font-size: 1.1rem;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .vertical-category-list {
        max-height: none;
        padding: 0;
    }

    .vertical-category-item {
        border-bottom: 1px solid var(--border-light, #e1e8ed);
        margin: 0;
    }

    .vertical-category-link {
        padding: 1rem;
        border-radius: 0;
    }

    /* Hide mega menu on mobile, use accordion instead */
    .mega-menu-wrapper {
        display: none !important;
    }

    /* Mobile submenu as accordion */
    .vertical-category-item .mobile-submenu {
        display: block;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        background: var(--surface, #f5f7fa);
    }

    .vertical-category-item.active .mobile-submenu {
        max-height: 1000px;
    }

    .mobile-submenu-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mobile-submenu-item {
        border-top: 1px solid var(--border-light, #e1e8ed);
    }

    .mobile-submenu-link {
        display: block;
        padding: 0.75rem 1rem 0.75rem 3rem;
        color: var(--text-secondary, #546e7a);
        text-decoration: none;
        font-size: 0.9rem;
        position: relative;
    }

    .mobile-submenu-link:hover {
        background: white;
        color: var(--accent, #4285F4);
    }

    .mobile-submenu-link::before {
        content: '›';
        position: absolute;
        left: 2rem;
        font-size: 1.2rem;
        color: var(--text-muted, #90a4ae);
    }

    /* Level 3 items on mobile */
    .mobile-submenu-level3 {
        padding-left: 1rem;
        background: #fff;
    }

    .mobile-submenu-level3 a {
        padding-left: 4rem;
        font-size: 0.85rem;
    }

    .mobile-submenu-level3 a::before {
        left: 3rem;
        content: '•';
    }

    /* Mobile overlay */
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
    }

    .mobile-menu-overlay.show {
        display: block;
    }

    /* Close button for mobile */
    .mobile-menu-close {
        position: absolute;
        top: 1rem;
        right: 1rem;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        z-index: 11;
        background: rgba(255, 255, 255, 0.2);
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
    }

    /* Chevron rotation for active items */
    .vertical-category-item.active .fa-chevron-right {
        transform: rotate(90deg);
    }
}

@media (max-width: 767.98px) {
    .vertical-category-dropdown {
        max-width: 280px;
    }

    .vertical-category-link {
        padding: 0.875rem;
    }

    .category-icon {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .category-name {
        font-size: 0.9rem;
    }
}

@media (max-width: 575.98px) {
    .vertical-category-dropdown {
        max-width: 100%;
        width: 85%;
    }

    .btn-category-menu {
        padding: 0.625rem 1rem;
        font-size: 0.9rem;
        min-width: auto;
    }
}

/* ========================================
   NAVIGATION BAR LAYOUT FIXES
   ======================================== */

/* Fix navigation bar alignment - ensure items are properly aligned */
.navigation-bar .container .d-flex {
    align-items: center !important;
    min-height: auto; /* Let content determine height naturally */
}

/* Fix vertical category wrapper alignment */
.navigation-bar .vertical-category-wrapper {
    display: flex;
    align-items: center;
}

/* Fix navbar-nav alignment and sizing */
.navigation-bar .navbar-nav {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    margin: 0;
}

/* Ensure all nav-items have consistent sizing */
.navigation-bar .navbar-nav .nav-item {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Fix nav-link sizing to be consistent */
.navigation-bar .navbar-nav .nav-link {
    display: flex !important;
    align-items: center !important;
    padding: 0.75rem 1rem !important; /* Consistent padding for all items */
    white-space: nowrap;
    height: auto;
    min-height: 44px; /* Consistent minimum height */
    width: auto; /* Auto width based on content */
    max-width: none; /* Remove any max-width constraints */
}

/* Fix dropdown toggle to not expand width */
.navigation-bar .navbar-nav .dropdown .nav-link {
    padding: 0.75rem 1rem !important; /* Same as other nav-links */
    justify-content: flex-start; /* Align content to start */
    width: auto; /* Auto width based on content only */
}

/* Ensure button category menu maintains proper styling */
.navigation-bar .btn-category-menu {
    align-self: center; /* Center vertically within wrapper */
}

/* ========================================
   NAVBAR DROPDOWN STYLES
   ======================================== */

/* Hide default Bootstrap dropdown arrow - Only for navigation bar */
.navigation-bar .navbar-nav .dropdown-toggle::after {
    display: none;
}

/* Custom chevron icon with rotation animation - Only for navigation bar */
.navigation-bar .navbar-nav .dropdown-toggle i.fa-chevron-down {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    margin-left: 0.25rem; /* Reduced margin to prevent width expansion */
    flex-shrink: 0; /* Prevent icon from shrinking */
    width: 12px; /* Fixed width for consistency */
    text-align: center;
}

.navigation-bar .navbar-nav .dropdown.show .dropdown-toggle i.fa-chevron-down {
    transform: rotate(180deg);
}

/* Navbar dropdown menu styling - Only for navigation bar */
.navigation-bar .navbar-dropdown {
    background: var(--white, #ffffff);
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0;
    min-width: 250px;
    margin-top: 0; /* Remove margin-top to prevent overlap */
    top: 100%; /* Position below the nav-item */
    left: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px); /* Start slightly below, then slide up */
    transition: all 0.3s ease;
    z-index: 1050;
}

/* Show dropdown with smooth animation - Only for navigation bar */
.navigation-bar .navbar-nav .dropdown.show .navbar-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0); /* Slide to final position */
}

/* Dropdown items styling - Only for navigation bar */
.navigation-bar .navbar-dropdown .dropdown-item {
    color: var(--text-primary, #263238);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    border-radius: 8px;
    margin: 0 0.5rem;
    text-decoration: none;
}

/* Dropdown item hover effects - Only for navigation bar */
.navigation-bar .navbar-dropdown .dropdown-item:hover {
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.08) 0%, rgba(66, 133, 244, 0.04) 100%);
    color: var(--accent, #4285F4);
    transform: translateX(4px);
}

/* Icons in dropdown items - Only for navigation bar */
.navigation-bar .navbar-dropdown .dropdown-item i {
    color: var(--accent, #4285F4);
    font-size: 0.85rem;
    width: 20px;
    transition: all 0.3s ease;
}

.navigation-bar .navbar-dropdown .dropdown-item:hover i {
    transform: scale(1.1);
    color: var(--primary-blue-dark, #1a73e8);
}

/* Dropdown divider - Only for navigation bar */
.navigation-bar .navbar-dropdown .dropdown-divider {
    border-color: var(--border-light, #e1e8ed);
    margin: 0.5rem 1rem;
}

/* Special items styling - Fire icon for hot products - Only for navigation bar */
.navigation-bar .navbar-dropdown .dropdown-item .fa-fire {
    color: #ff6b35 !important;
}

/* Special items styling - Percent icon for sales - Only for navigation bar */
.navigation-bar .navbar-dropdown .dropdown-item .fa-percent {
    color: #28a745 !important;
}

/* Pulse animation for special items - Only for navigation bar */
.navigation-bar .navbar-dropdown .dropdown-item:hover .fa-fire,
.navigation-bar .navbar-dropdown .dropdown-item:hover .fa-percent {
    animation: navbarIconPulse 0.6s ease-in-out;
}

@keyframes navbarIconPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Navigation link hover enhancement - Only for navigation bar */
.navigation-bar.navbar-dark .navbar-nav .nav-link:hover,
.navigation-bar.navbar-dark .navbar-nav .nav-link:focus,
.navigation-bar.navbar-dark .navbar-nav .nav-link.active {
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
}

/* Hover trigger for dropdown - Keep hidden but ready to show - Only for navigation bar */
.navigation-bar .navbar-nav .hover-trigger .dropdown-menu.navbar-dropdown {
    display: none; /* Completely hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px); /* Start slightly below */
    position: absolute; /* Ensure it doesn't affect layout */
    top: 100%; /* Position below nav-item */
    left: 0;
}

.navigation-bar .navbar-nav .hover-trigger.show-on-hover:hover .dropdown-menu.navbar-dropdown {
    display: block !important; /* Show on hover */
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important; /* Slide to final position */
}

.navigation-bar .navbar-nav .hover-trigger.show-on-hover:hover .dropdown-toggle i.fa-chevron-down {
    transform: rotate(180deg);
}

/* Keep dropdown open when hovering over the menu itself - Only for navigation bar */
.navigation-bar .navbar-nav .hover-trigger .dropdown-menu.navbar-dropdown:hover {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important; /* Stay at final position */
}

/* Also keep parent link styled when hovering dropdown - Only for navigation bar */
.navigation-bar .navbar-nav .hover-trigger:hover .dropdown-toggle,
.navigation-bar .navbar-nav .hover-trigger .dropdown-menu:hover ~ .dropdown-toggle {
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
}

/* ========================================
   CART DROPDOWN HOVER STYLES
   ======================================== */

/* Cart dropdown hover trigger - Apply to header cart */
.header-icons .cart-items-list.hover-trigger .dropdown-menu {
    display: none; /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.3s ease;
}

.header-icons .cart-items-list.hover-trigger.show-on-hover:hover .dropdown-menu {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* Keep cart dropdown open when hovering over it */
.header-icons .cart-items-list.hover-trigger .dropdown-menu:hover {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* Cart link behavior - allow both hover and click */
.header-icons .cart-items-list.hover-trigger.show-on-hover a[data-bs-toggle="dropdown"] {
    cursor: pointer;
    text-decoration: none;
}

/* Also keep parent cart link styled when hovering dropdown */
.header-icons .cart-items-list.hover-trigger:hover a,
.header-icons .cart-items-list.hover-trigger .dropdown-menu:hover ~ a {
    color: var(--accent, #4285F4);
}

/* ========================================
   END CART DROPDOWN HOVER STYLES
   ======================================== */

/* ========================================
   END NAVBAR DROPDOWN STYLES
   ======================================== */

/* Utility Classes */
.vertical-category-item.view-all .vertical-category-link {
    background: var(--surface, #f5f7fa);
    border: 1px dashed var(--border-light, #e1e8ed);
    color: var(--accent, #4285F4);
    font-weight: 600;
}

.vertical-category-item.view-all .vertical-category-link:hover {
    background: linear-gradient(135deg, var(--accent, #4285F4) 0%, var(--primary-blue-light, #6ba3f7) 100%);
    color: white;
    border-color: transparent;
}
