/* ============================================
   MOBILE HEADER CSS (< 850px)
   ============================================ */

@media (max-width: 849px) {
    /* ============================================
       MOBILE HEADER LAYOUT
       ============================================ */

    /* 1. HAMBURGER MENU (Left Column) */

    /* Hide any stray triggers */
    .fresh-mobile-trigger {
        display: none !important;
    }

    /* Show ONLY the trigger in mobile-nav */
    .show-for-medium.flex-left .mobile-nav .fresh-mobile-trigger {
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        align-items: stretch;
        width: 22px;
        height: 16px;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        border: none !important;
        gap: 5px !important;
        flex-shrink: 0 !important;
    }

    /* Disable pseudo-elements */
    .show-for-medium.flex-left .mobile-nav .fresh-mobile-trigger::before,
    .show-for-medium.flex-left .mobile-nav .fresh-mobile-trigger::after {
        display: none !important;
    }

    /* Style the 3 bars */
    .show-for-medium.flex-left .mobile-nav .fresh-mobile-trigger .fresh-mobile-trigger-bar {
        width: 100% !important;
        height: 2px !important;
        background-color: #004A99 !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 1px !important;
        flex-shrink: 0 !important;
    }

    /* 2. LOGO CENTERING */
    .show-for-medium+#logo {
        text-align: center !important;
        flex-grow: 1 !important;
        order: 2 !important;
        /* Logo ở giữa */
    }

    .show-for-medium+#logo img {
        max-height: 45px !important;
        width: auto !important;
    }

    /* 3. RIGHT ICONS (Search + Cart) */

    /* Container spacing */
    .show-for-medium.flex-right .mobile-nav {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 0 !important;
        /* Don't use gap, use margin instead */
        flex-wrap: nowrap !important;
        padding-right: 0 !important;
    }

    /* Icon list items - FORCE SPACING WITH MARGIN */
    #wrapper .show-for-medium.flex-right .mobile-nav>li {
        margin: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        width: 30px !important;
        /* Fixed width for each icon */
        height: 30px !important;
        /* Fixed height */
        margin-right: 15px !important;
        /* FORCE spacing between icons */
    }

    #wrapper .show-for-medium.flex-right .mobile-nav>li:last-child {
        margin-right: 0 !important;
        /* No margin on last icon */
    }

    /* Search Icon - Use SVG to guarantee visibility */
    .show-for-medium.flex-right .header-search-lightbox {
        flex-shrink: 0 !important;
        width: 30px !important;
        height: 30px !important;
    }

    .show-for-medium.flex-right .header-search-lightbox a {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23004A99' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat center !important;
        background-size: 20px 20px !important;
        /* Adjust icon size */
    }

    /* Hide the old font icon */
    .show-for-medium.flex-right .header-search-lightbox a i.icon-search {
        display: none !important;
    }

    /* Cart Icon */
    .show-for-medium.flex-right .cart-item {
        flex-shrink: 0 !important;
        width: 30px !important;
        /* Match li width */
        height: 30px !important;
        position: relative !important;
    }

    .show-for-medium.flex-right .cart-item .header-cart-link {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
    }

    /* Cart Icon - Use SVG background */
    .show-for-medium.flex-right .cart-item .cart-icon {
        width: 20px !important;
        height: 22px !important;
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='%23004A99'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M15.75 10.5V6a3.75 3.75 0 10-7.5 0v4.5m11.356-1.993l1.263 12c.07.665-.45 1.243-1.119 1.243H4.25a1.125 1.125 0 01-1.12-1.243l1.264-12A1.125 1.125 0 015.513 7.5h12.974c.576 0 1.059.435 1.119 1.007z' /%3E%3C/svg%3E") no-repeat center !important;
        background-size: contain !important;
        border: none !important;
        display: block !important;
        position: relative !important;
    }

    /* Hide Flatsome's default cart icon */
    .show-for-medium.flex-right .cart-item .cart-icon>*:not(strong) {
        display: none !important;
    }

    /* Cart Badge */
    /* Cart Badge - Added white border for separation */
    .show-for-medium.flex-right .cart-item .cart-icon strong {
        display: block !important;
        background-color: #e40712 !important;
        color: #fff !important;
        border-radius: 50% !important;
        font-size: 10px !important;
        /* Slightly larger text */
        width: 16px !important;
        /* Increased size */
        height: 16px !important;
        line-height: 12px !important;
        /* Vertically center */
        top: -5px !important;
        right: -8px !important;
        position: absolute !important;
        text-align: center !important;
        border: 2px solid #fff !important;
        /* KEY FIX: White border cuts the icon line */
        font-weight: bold !important;
        box-sizing: content-box !important;
        /* Ensure size includes content */
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
    }

    /* 4. MOBILE HEADER LAYOUT */
    .show-for-medium .header-inner {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 10px 15px !important;
    }

    .show-for-medium.flex-left {
        order: 1 !important;
        /* Hamburger bên trái */
        flex-shrink: 0 !important;
    }

    .show-for-medium.flex-right {
        order: 3 !important;
        /* Icons bên phải */
        flex-shrink: 0 !important;
    }

}

/* ============================================
   GLOBAL SEARCH POPUP STYLING (Applies to all screens)
   ============================================ */

/* 1. Container & Input */
#search-lightbox .searchform-wrapper {
    max-width: 90% !important;
    margin: 0 auto !important;
}

#search-lightbox input[type="search"] {
    border-radius: 6px !important;
    border: 1px solid #ddd !important;
    padding-left: 15px !important;
    padding-right: 50px !important;
    height: 45px !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05) !important;
    background-color: #fff !important;
    color: #333 !important;
    font-size: 16px !important;
}

#search-lightbox input[type="search"]:focus {
    border-color: #004A99 !important;
    box-shadow: 0 5px 20px rgba(0, 74, 153, 0.15) !important;
}

/* 2. Submit Button */
#search-lightbox button.submit-button {
    background-color: #004A99 !important;
    border-radius: 0 6px 6px 0 !important;
    width: 45px !important;
    height: 45px !important;
    min-width: 0 !important;
    top: 0 !important;
    right: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
}

#search-lightbox button.submit-button:hover {
    background-color: #003366 !important;
}

#search-lightbox button.submit-button i {
    font-size: 18px !important;
}

/* 3. Close Button (GLOBAL FIX - SOLID VISIBLE) */
/* Forced Fixed Position to Viewport Top-Right with High Contrast */
.mfp-wrap .mfp-close,
.mfp-content .mfp-close,
.mfp-close-btn-in .mfp-close {
    position: fixed !important;
    top: 5px !important;
    /* Slight padding from edge */
    right: 5px !important;
    width: 44px !important;
    height: 44px !important;
    background: #004A99 !important;
    /* Navy Background - Always Visible */
    border-radius: 50% !important;
    /* Circle Shape */
    color: #fff !important;
    opacity: 1 !important;
    /* Force fully visible */
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 28px !important;
    line-height: 1 !important;
    font-weight: 300 !important;
    z-index: 10000 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
}

.mfp-wrap .mfp-close:hover,
.mfp-content .mfp-close:hover {
    background: #e40712 !important;
    /* Red on Hover */
    transform: rotate(90deg);
}

/* Background Overlay */
.mfp-bg {
    background: rgba(0, 0, 0, 0.85) !important;
}