/* assets/css/header.css */

:root {
    /* Palette */
    --nav-bg-dark: #131921;
    --nav-bg-light: #232f3e;
    --nav-hover-border: #ffffff;
    --primary-orange: #febd69;
    --primary-orange-hover: #f3a847;
    --focus-ring: #ff9900;
    --text-white: #ffffff;
    --text-gray: #cccccc;
    --text-dark: #111111;
    --text-link: #007185;
    
    /* Dimensions */
    --header-height: 60px;
    --nav-height: 39px;
    --max-width: 1500px;
    --z-index-dropdown: 2000;
    --z-index-modal: 3000;
}

/* Reset & Base */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Poppins', sans-serif; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }

/* =========================================
   MAIN HEADER CONTAINER
   ========================================= */
#main-header {
    background-color: var(--nav-bg-dark);
    color: var(--text-white);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header__main {
    display: flex;
    align-items: center;
    height: var(--header-height);
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 15px;
    gap: 10px;
}

/* Mobile Menu Trigger (Hidden by default) */
.mobile-menu-trigger {
    display: none;
    color: white;
    font-size: 22px;
    padding: 5px 10px 5px 0;
    cursor: pointer;
}

/* 1. Logo */
.header__logo {
    padding: 1px 0;
    margin-right: 5px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.header__logo a {
    display: flex;
    align-items: center;
    padding: 5px 8px 0 8px;
    border: 1px solid transparent;
    border-radius: 2px;
}
.header__logo a:hover { border-color: var(--nav-hover-border); }

/* =========================================
   2. LOCATION SELECTOR
   ========================================= */
.header__location {
    display: flex;
    align-items: center;
    padding: 6px 9px;
    border: 1px solid transparent;
    border-radius: 2px;
    cursor: pointer;
    min-width: 135px;
    margin-right: 5px;
}

.header__location:hover { border-color: var(--nav-hover-border); }

.header__location i {
    align-self: flex-end;
    margin-bottom: 3px;
    margin-right: 6px;
    color: var(--text-white);
    font-size: 18px;
}

.location__address {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.1;
}

.location__address span {
    font-size: 12px;
    color: var(--text-gray);
    margin-bottom: 1px;
}

.location__address strong {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* =========================================
   3. SEARCH BAR
   ========================================= */
.search__container {
    flex: 1;
    display: flex;
    height: 40px;
    border-radius: 4px;
    position: relative;
    background: white;
    transition: all 0.2s ease;
}

.search__container:focus-within {
    box-shadow: 0 0 0 2px var(--focus-ring), 0 0 0 3px rgba(255, 153, 0, 0.5);
    z-index: 1002;
}

/* Scope Dropdown (The Gray Box) */
.search__scope {
    background-color: #f3f3f3;
    border-right: 1px solid #cdcdcd;
    border-radius: 4px 0 0 4px;
    position: relative;
    width: auto;
    display: flex;
    align-items: center;
}

/* Dropdown Arrow Fix */
.search__dropdown {
    height: 100%;
    max-width: 140px;
    padding: 0 22px 0 10px;
    border: none;
    background-color: transparent;
    font-size: 12px;
    color: #555;
    cursor: pointer;
    outline: none;
    border-radius: 4px 0 0 4px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23555555'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 16px;
}
.search__dropdown:hover { background-color: #dadada; color: #111; }

/* Input */
.search__input-wrap { flex: 1; }
.search__input {
    width: 100%;
    height: 100%;
    border: none;
    padding: 0 10px;
    font-size: 15px;
    color: #111;
    outline: none;
    background: transparent;
}

/* Submit Button */
.search__submit-wrap { width: 45px; }
.search__button {
    width: 100%;
    height: 100%;
    background-color: var(--primary-orange);
    border: none;
    border-radius: 0 4px 4px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.search__button:hover { background-color: var(--primary-orange-hover); }
.search__button i { font-size: 20px; color: #333; }

/* --- SEARCH SUGGESTIONS UI (FIXED) --- */
.search-suggestions {
    display: none;
    position: absolute;
    top: 41px;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #bbb;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    z-index: 1005;
    overflow: hidden;
}

/* Generic suggestion row */
.suggestion-row {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #111;
    font-weight: 500;
}
.suggestion-row:hover { background-color: #f1f1f1; }

/* Product suggestion row */
.suggestion-product {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    border-top: 1px solid #f0f0f0;
}
.suggestion-product:hover { background-color: #f0f8ff; }

/* --- IMAGE SIZE FIX --- */
.s-img-container {
    width: 40px;
    height: 40px;
    flex-shrink: 0; /* Prevents squishing */
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    overflow: hidden; /* Crops overlap */
}

/* Force image to fit 40x40 box */
.s-img-container img,
.suggestion-product img {
    width: 100% !important;
    height: 100% !important;
    max-width: 40px !important;
    max-height: 40px !important;
    object-fit: contain; /* Keeps aspect ratio */
}

/* Suggestion Text Info */
.s-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}
.s-title {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.s-price { color: #B12704; font-size: 12px; font-weight: 700; }

/* =========================================
   4. RIGHT NAV LINKS
   ========================================= */
.header__nav-links {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 10px;
}

.header__nav-item {
    display: flex;
    flex-direction: column;
    padding: 8px 9px;
    border: 1px solid transparent;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    color: white;
}
.header__nav-item:hover { border-color: var(--nav-hover-border); }

/* Desktop Text Styles */
.nav-text-block small { font-size: 12px; line-height: 14px; color: var(--text-gray); display: block; }
.nav-text-block strong { font-size: 14px; line-height: 15px; font-weight: 700; display: flex; align-items: center; color: white; }
.header__nav-item small { font-size: 12px; line-height: 14px; color: var(--text-gray); }
.header__nav-item strong { font-size: 14px; line-height: 15px; font-weight: 700; display: flex; align-items: center; }

/* Mobile Icons Hidden on Desktop */
.nav-icon-mobile { display: none; }

/* =========================================
   CART & ACCOUNT
   ========================================= */
.account-dropdown-container { position: relative; }
.account-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: -5px;
    width: 380px;
    background: white;
    border: 1px solid #bbb;
    border-radius: 3px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    z-index: var(--z-index-dropdown);
    color: #111;
    cursor: auto;
}
.account-dropdown-container:hover .account-dropdown { display: block; }

/* Cart */
.header__cart {
    display: flex;
    align-items: flex-end;
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 2px;
    position: relative;
    color: white;
}
.header__cart:hover { border-color: var(--nav-hover-border); }
.cart-icon-wrapper { position: relative; }
.cart-icon-wrapper i { font-size: 26px; }
.cart__count {
    position: absolute;
    top: -5px;
    left: 12px;
    color: #f08804;
    font-weight: 700;
    font-size: 14px;
    background: transparent;
}
.header__cart strong { margin-left: 5px; font-size: 14px; align-self: flex-end; }


/* =========================================
   SECONDARY NAV & SIDEBAR
   ========================================= */
#secondary-navigation {
    background-color: var(--nav-bg-light);
    height: var(--nav-height);
    display: flex;
    align-items: center;
}
.secondary-nav__list {
    display: flex;
    align-items: center;
    padding: 0 15px;
    gap: 6px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.secondary-nav__list::-webkit-scrollbar { display: none; }
.secondary-nav__list a {
    color: white;
    padding: 5px 8px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: 2px;
}
.secondary-nav__list a:hover { border-color: var(--nav-hover-border); }
.secondary-nav__all { font-weight: 700 !important; display: flex; align-items: center; gap: 5px; }

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -365px;
    width: 365px;
    height: 100%;
    background: white;
    z-index: 3001;
    transition: transform 0.3s ease-in-out;
    box-shadow: 4px 0 10px rgba(0,0,0,0.2);
}
.sidebar.active { transform: translateX(365px); }
.sidebar__header {
    background-color: var(--nav-bg-light);
    color: white;
    padding: 15px 20px 15px 35px;
    font-size: 19px;
    font-weight: 700;
}
.sidebar__close-btn {
    position: absolute;
    top: 10px;
    right: -45px;
    background: none;
    border: none;
    color: white;
    font-size: 30px;
}
.sidebar__content { height: calc(100% - 60px); overflow-y: auto; }
.sidebar__section { border-bottom: 1px solid #ddd; padding: 10px 0; }
.sidebar__section h4 { padding: 10px 20px; font-size: 16px; font-weight: 700; color: #333; }
.sidebar__item { display: block; padding: 12px 20px; color: #111; font-size: 14px; }
.sidebar__item:hover { background-color: #eaeded; }
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 3000;
}
.sidebar-overlay.active { display: block; }

/* =========================================
   LOCATION MODAL & LANGUAGE
   ========================================= */
.location-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    z-index: 3000;
}
.location-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    width: 375px;
    border-radius: 8px;
    box-shadow: 0 4px 25px rgba(0,0,0,0.25);
    overflow: hidden;
    max-width: 90%;
}
.location-modal__header { background: #f0f2f2; padding: 16px 24px; border-bottom: 1px solid #d5d9d9; display: flex; justify-content: space-between; align-items: center; }
.location-modal__header h3 { font-size: 16px; font-weight: 700; margin: 0; }
.location-modal__close { background: none; border: none; font-size: 24px; cursor: pointer; color: #555; }
.location-modal__content { padding: 20px 24px; }
.location-modal__text { font-size: 13px; color: #565959; margin-bottom: 20px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.custom-select-wrapper { position: relative; background: #f0f2f2; border: 1px solid #D5D9D9; border-radius: 8px; box-shadow: 0 1px 2px rgba(15,17,17,0.15) inset; }
.modal-select { width: 100%; padding: 10px 30px 10px 12px; border: none; background: transparent; font-size: 14px; appearance: none; outline: none; }
.select-arrow { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: #555; pointer-events: none; }
.btn-modal-submit { width: 100%; padding: 8px; background: #FFD814; border: 1px solid #FCD200; border-radius: 20px; color: #111; font-size: 13px; font-weight: 500; cursor: pointer; margin-top: 5px; }

/* Language Dropdown CSS */
.header__country-selector { position: relative; display: flex; align-items: center; gap: 4px; padding: 10px 8px; }
.flag-icon { width: 20px; height: 14px; background-size: cover; border: 1px solid #555; }
.lang-code { font-weight: 700; font-size: 13px; color: #fff; margin-top: 2px; }
.country-selector__dropdown { display: none; position: absolute; top: 100%; right: 0; width: 240px; background: white; border: 1px solid #ccc; box-shadow: 0 5px 15px rgba(0,0,0,0.2); z-index: 2000; padding: 14px 0; }
.header__country-selector:hover .country-selector__dropdown { display: block; }
.dropdown__section { padding: 0 14px; }
.dropdown__header { font-size: 13px; color: #111; margin-bottom: 8px; }
.dropdown__radio-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; color: #444; }
.radio-circle { width: 16px; height: 16px; border: 1px solid #888; border-radius: 50%; }
.dropdown__radio-item.selected .radio-circle { border-color: #e47911; background: #fff; border-width: 5px; }
.dropdown__divider { height: 1px; background: #eee; margin: 10px 0; }


/* =========================================
   MOBILE RESPONSIVENESS (APP VIEW)
   ========================================= */
@media (max-width: 991px) {
    /* 1. Header Container Logic */
    .header__main {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 15px;
        position: relative;
        justify-content: space-between;
    }

    /* 2. Element Ordering for Mobile (Row 1) */
    .mobile-menu-trigger {
        display: block; /* Show Hamburger */
        order: 1;
        font-size: 24px;
        margin-right: 15px;
    }

    .header__logo {
        order: 2;
        margin-right: auto; /* Pushes everything else to right */
    }

    .header__nav-links {
        order: 3;
        margin-left: 0;
        gap: 15px;
    }

    /* 3. Account & Cart (Icon Only Mode) */
    .mobile-hidden { display: none !important; }
    
    .nav-text-block { display: none; }
    
    .nav-icon-mobile { 
        display: flex; 
        align-items: center; 
        color: white; 
        gap: 5px;
    }
    .nav-icon-mobile i { font-size: 24px; }
    .nav-icon-mobile .mobile-name { font-size: 13px; font-weight: 500; }

    .header__cart .cart-text { display: none; }
    .header__cart { padding: 0; border: none; }
    .cart-icon-wrapper i { font-size: 26px; }
    .cart__count { 
        font-size: 12px; 
        top: -8px; 
        left: 14px; 
        background: transparent;
        color: #f08804;
    }

    /* 4. Search Bar (Row 2 - Full Width) */
    .search__container {
        order: 4;
        flex-basis: 100%;
        margin-top: 10px;
        height: 45px; /* Taller touch target */
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    .search__scope { display: none; /* Hide category dropdown on mobile to save space */ }
    .search__dropdown { display: none; }
    .search__input { border-radius: 4px; padding-left: 15px; }

    /* 5. Location Strip (Row 3 - App Style) */
    .header__location {
        order: 5;
        flex-basis: 100%;
        width: 100vw;
        margin: 10px -15px -10px -15px; /* Negative margins to stretch full width */
        background: #232f3e; /* Lighter dark */
        padding: 10px 15px;
        display: flex !important;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    .header__location i { font-size: 16px; margin-bottom: 0; align-self: center; }
    .location__address { flex-direction: row; gap: 5px; align-items: center; }
    .location__address span { display: inline; font-size: 13px; color: #fff; }
    .location__address strong { font-size: 13px; color: #fff; max-width: 200px; }

    /* 6. Hide Desktop Secondary Nav */
    #secondary-navigation {
        display: none; /* We use the Sidebar for nav now */
    }

    /* Sidebar Mobile Adjustments */
    .sidebar { width: 85%; left: -85%; }
    .sidebar.active { transform: translateX(100%); }
    .sidebar__close-btn { right: 15px; top: 15px; font-size: 36px; }

    /* Disable hover dropdowns on mobile */
    .account-dropdown-container:hover .account-dropdown { display: none; }
}