/* Dropdown Styles */
.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    min-width: 200px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    z-index: 1000;
    flex-direction: column !important;
}

/* Nested Dropdown Support */
.dropdown-menu .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -1px;
}

/* Desktop Hover only - Updated to only apply to top level */
@media (min-width: 969px) {
    #mainNav > ul > li.dropdown:hover > .dropdown-menu {
        display: block;
    }
}

/* Mobile Show Class - Only apply static positioning on mobile */
@media (max-width: 968px) {
    .dropdown-menu {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        display: block !important;
        position: static;
        box-shadow: none;
        border-left: 3px solid var(--primary, #667eea);
        margin-left: 15px;
        background: rgba(255, 255, 255, 0.95);
    }

    .dropdown-menu.show {
        max-height: 500px;
        padding: 5px 0;
    }

    .dropdown-menu li {
        padding: 0;
    }

    .dropdown-menu a {
        padding: 12px 15px !important;
        font-size: 14px !important;
        color: #333 !important;
    }

    /* Nested dropdown menus */
    .dropdown-menu .dropdown-menu {
        margin-left: 10px;
        border-left: 2px solid #ddd;
    }

    .dropdown-toggle-icon {
        transition: transform 0.3s ease;
    }
}

/* Desktop Show Class - Keep absolute positioning */
@media (min-width: 969px) {
    .dropdown-menu.show {
        display: block;
        position: absolute;
    }
}

.dropdown-menu li {
    display: block !important;
    width: 100%;
}

.dropdown-menu a {
    display: block !important;
    padding: 10px 15px !important;
    color: #333;
    border-bottom: 1px solid #eee;
}

.dropdown-menu a:hover {
    background: #f9f9f9;
    color: var(--primary);
}

.dropdown-menu li:last-child a {
    border-bottom: none;
}

/* Mobile Dropdown Toggler */
.dropdown-toggle-btn {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    color: #666;
    margin-left: 5px;
    border-left: 1px solid #eee;
    transition: all 0.3s;
    display: inline-block;
}

.dropdown-toggle-btn:hover {
    color: var(--primary);
    background: #f9f9f9;
}

/* Show on mobile */
@media (max-width: 968px) {
    .dropdown-toggle-btn {
        display: block;
        /* Always show toggle button since interaction is required for nested */
    }

    .dropdown a {
        border-bottom: none !important;
        /* Remove bottom border from link to merge with container */
    }

    .dropdown > div {
        border-bottom: 1px solid #eee;
        /* Apply border to container instead */
    }
}

/* Header Search Styles */
.header-search input:focus {
    border-color: var(--primary) !important;
    background: var(--card-bg, white) !important;
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-shadow, rgba(66, 133, 244, 0.1));
}

.header-search button:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Navigation improvements - Single line */
#mainNav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    /* Allow wrapping on smaller screens if really needed, but try to keep inline */
    flex-wrap: nowrap;
}

/* Allow nav to shrink more aggressively */
#mainNav {
    flex-shrink: 2;
    min-width: 0;
    /* Allow flex item to shrink below content size if needed */
    overflow: visible;
    /* Allow dropdowns to show */
}

#mainNav li {
    display: inline-block;
    flex-shrink: 0;
}

#mainNav a {
    padding: 10px 8px;
    font-size: 16px;
    display: inline-block;
    font-weight: 600;
    text-transform: uppercase;
}

/* Fluid responsiveness before mobile breakpoint */
@media (max-width: 1200px) {
    #mainNav ul {
        gap: 5px !important;
        /* Reduce gap */
    }

    #mainNav a {
        padding: 10px 4px;
    }
}

/* Ensure it wraps if it truly doesn't fit, instead of breaking layout */
/* But usually users prefer it to stay on one line until mobile menu takes over.
   If it overflows, we might need to trigger mobile menu earlier. */

/* Let's try to fit it better first. */
@media (max-width: 968px) {
    .header-main .container {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .logo {
        flex: 1 1 auto;
        max-width: 80%;
    }

    .mobile-menu-toggle {
        flex: 0 0 auto;
        margin-left: auto;
    }

    .header-search {
        order: 3;
        width: 100%;
        max-width: 100% !important;
        margin-top: 0;
        flex: 0 0 100%;
    }

    #mainNav {
        /* Hide nav entirely on mobile until toggled, handled by JS/CSS but ensure it doesn't take space here if needed */
    }

    #mainNav ul {
        flex-direction: column;
        flex-wrap: wrap !important;
    }

    #mainNav li {
        display: block;
        width: 100%;
    }

    #mainNav a {
        display: block;
        padding: 12px 20px;
        font-size: 15px;
    }
}

/* Search Results Scrollbar */
.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: var(--bg-secondary, #f1f1f1);
    border-radius: 0 0 13px 0;
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

.app-banner-font {
    font-family: 'Space Grotesk', sans-serif;
}

.header-main-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: nowrap;
}

.header-logo-img {
    height: 50px;
    width: auto;
}

.header-tagline-nowrap {
    white-space: nowrap;
}

.header-icons-container {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.header-cart-link {
    position: relative;
    color: #333;
    font-size: 20px;
    text-decoration: none;
}

.header-mobile-badge,
.header-notif-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.header-user-menu {
    display: flex;
    align-items: center;
}

.header-user-link {
    color: #333;
    font-size: 20px;
    text-decoration: none;
}

.header-fav-link,
.header-notif-link {
    margin-left: 15px;
}

.header-notif-link {
    position: relative;
}

.header-mobile-toggle {
    line-height: 1;
}

.main-nav-list {
    display: flex;
    gap: 0;
    flex-wrap: nowrap;
    margin: 0;
    padding: 0;
}

.nav-link-nowrap {
    white-space: nowrap;
}

.menu-row-space {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.menu-link-grow {
    white-space: nowrap;
    flex-grow: 1;
}

.menu-link-block-nowrap {
    white-space: nowrap;
    display: block;
    width: 100%;
}

.menu-link-clickable {
    cursor: pointer;
}

.menu-link-featured {
    font-weight: bold;
    color: var(--primary);
}

.nav-search-item {
    margin-left: 20px;
    margin-right: 20px;
    flex-grow: 0;
}

.header-search-inline {
    position: relative;
    display: flex;
    align-items: center;
}

.header-search-input-inline {
    height: 34px;
    padding: 0 35px 0 15px;
    border-radius: 17px;
    border: none;
    font-size: 13px;
    width: 250px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    outline: none;
}

.header-search-btn-inline {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.side-logout-link {
    color: #e53e3e;
}
