/* Ẩn hoàn toàn Bottom App Bar trên máy tính Desktop */
.m4h-mobile-app-bar {
    display: none !important;
}

@media (max-width: 849px) {

    /* Cart is already available in the fixed bottom app navigation. */
    #header .header-nav .cart-item,
    #header .header-nav .header-cart,
    #header li.html.header-cart,
    #header li.cart-item {
        display: none !important;
    }

    /* 1. Mobile Overscroll & Layout Spacing */
    body {
        overscroll-behavior-y: contain;
        padding-bottom: 72px !important;
        /* Space for Bottom App Navigation Bar */
    }

    /* 2. Fixed Glassmorphism Bottom App Navigation Bar */
    .m4h-mobile-app-bar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 62px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
        align-items: center;
        justify-content: space-around;
        z-index: 99999;
        padding: 4px 6px;
        box-sizing: border-box;
    }

    /* 3. App Bar Tab Items */
    .m4h-app-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none !important;
        color: #64748b;
        font-size: clamp(8px, 2vw, 12px) !important;
        font-weight: 600;
        width: 20%;
        height: 100%;
        position: relative;
        transition: color 0.2s ease, transform 0.15s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .m4h-app-tab:active {
        transform: scale(0.92);
    }

    .m4h-app-tab.active {
        color: #d9261c !important;
        font-weight: 700;
    }

    .m4h-app-tab svg {
        width: 22px;
        height: 22px;
        margin-bottom: 3px;
        stroke: currentColor;
        stroke-width: 2;
        transition: stroke 0.2s ease;
    }

    .m4h-app-tab.active svg {
        stroke: #d9261c !important;
    }

    /* 4. Live Cart Quantity Badge */
    .m4h-cart-count-badge {
        position: absolute;
        top: -5px;
        right: 45%;
        margin-right: -18px;
        background: #d9261c;
        color: #ffffff;
        font-size: 10px;
        font-weight: 800;
        min-width: 17px;
        height: 17px;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        box-shadow: 0 2px 5px rgba(217, 38, 28, 0.4);
        line-height: 1;
    }

    /* 5. Cân đối Thẻ Sản Phẩm Product Card 2 cột chuẩn Mobile App */
    .products.row {
        margin-left: -4px !important;
        margin-right: -4px !important;
    }

    .products.row>.col {
        padding-left: 4px !important;
        padding-right: 4px !important;
        margin-bottom: 8px !important;
    }

    .products .box {
        background: #ffffff !important;
        border-radius: 12px !important;
        overflow: hidden !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
        border: 1px solid #f1f5f9 !important;
    }

    .products .box-text {
        padding: 10px 0px !important;
    }

    .products .product-title a {
        font-size: clamp(11.5px, 3.35vw, 13.5px) !important;
        font-weight: 600 !important;
        line-height: 1.35 !important;
        color: #0f172a !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        height: 35px !important;
    }

    /* Giá bán trên thẻ Mobile */
    .products .price ins .amount,
    .products .price ins bdi,
    .products .price>.amount,
    .products .price>bdi {
        font-size: 12px !important;
        font-weight: 900 !important;
        color: #d9261c !important;
    }

    .products .price del,
    .products .price del .amount,
    .products .price del bdi {
        font-size: 10px !important;
        color: #64748b !important;
        opacity: 1 !important;
    }

    /* Thanh tiến trình Còn X suất trên Mobile */
    .m4h-flashsale-progress-bar {
        height: 16px !important;
        border-radius: 10px !important;
    }

    .m4h-flashsale-progress-text,
    .m4h-fs-progress-text {
        font-size: 10px !important;
        font-weight: 800 !important;
    }

    /* 6. Off-Canvas App Drawer */
    .mfp-content,
    .off-canvas-right,
    .off-canvas-left {
        border-top-left-radius: 18px !important;
        border-top-right-radius: 18px !important;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15) !important;
    }

    /* Nút cuộn lên đầu trang không bị đè app bar */
    .back-to-top {
        bottom: 75px !important;
    }

    .sticky-add-to-cart--active {
        bottom: 62px !important;
    }

    /* Compact header search action: a consistent tap target without wasting header space. */
    #header .header-search,
    #header li.header-search {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    #header .header-search>a,
    #header .header-search .header-search-link {
        width: clamp(34px, 10vw, 40px) !important;
        height: clamp(34px, 10vw, 40px) !important;
        min-width: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 8px !important;
    }

    #header .header-search .icon-search,
    #header .header-search i {
        font-size: clamp(15px, 4.2vw, 18px) !important;
    }

    /* =========================================================
       MOBILE SEARCH DROPDOWN — Full-width below header
       ========================================================= */
    #header {
        position: relative !important;
    }

    #header li.header-search {
        position: static !important;
    }

    /* The dropdown container */
    #header li.header-search>.nav-dropdown,
    #header .header-search>.nav-dropdown,
    #header .header-search .header-search-dropdown {
        /* Anchor to the bottom of the header.  `fixed` + `top:auto` uses a
           browser-dependent static position and was leaving the dropdown a
           few pixels too high on phones. */
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 8px 16px 10px !important;
        background: #ffffff !important;
        border: none !important;
        border-bottom: 1px solid #e2e8f0 !important;
        border-radius: 0 0 16px 16px !important;
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.1) !important;
        box-sizing: border-box !important;
        z-index: 10001 !important;
    }

    /* Flatsome adds a small dropdown arrow above the panel.  It becomes a
       stray chevron over the logo when the panel is expanded full-width. */
    #header li.header-search>.nav-dropdown::before,
    #header li.header-search>.nav-dropdown::after,
    #header .header-search>.nav-dropdown::before,
    #header .header-search>.nav-dropdown::after {
        display: none !important;
        content: none !important;
    }

    /* Search form wrapper & form — stretch full width */
    #header li.header-search>.nav-dropdown>.header-search-form,
    #header li.header-search .header-search-form-wrapper,
    #header li.header-search .searchform-wrapper,
    #header li.header-search form,
    #header .header-search>.nav-dropdown>.header-search-form,
    #header .header-search .header-search-form-wrapper,
    #header .header-search form {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
        box-sizing: border-box !important;
    }

    /* The actual text input */
    #header li.header-search .search-field,
    #header .header-search .search-field,
    #header .header-search input[type="search"],
    #header li.header-search input[type="search"] {
        width: 100% !important;
        max-width: 100% !important;
        height: 46px !important;
        background: #f8fafc !important;
        border: 1.5px solid #cbd5e1 !important;
        border-radius: 12px !important;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02) !important;
        font-size: 15px !important;
        color: #1e293b !important;
        padding: 0 50px 0 16px !important;
        box-sizing: border-box !important;
        -webkit-appearance: none !important;
        appearance: none !important;
    }

    #header li.header-search .search-field:focus,
    #header .header-search .search-field:focus,
    #header .header-search input[type="search"]:focus,
    #header li.header-search input[type="search"]:focus {
        background: #ffffff !important;
        border-color: #f0683a !important;
        box-shadow: 0 0 0 3px rgba(240, 104, 58, 0.15) !important;
        outline: none !important;
    }

    /* Submit button inside search bar */
    #header li.header-search .ux-search-submit,
    #header .header-search .ux-search-submit,
    #header .header-search button[type="submit"],
    #header li.header-search button[type="submit"] {
        position: absolute !important;
        background: transparent !important;
        border: 0 !important;
        color: #1e293b !important;
        height: 46px !important;
        width: 46px !important;
        left: auto !important;
        right: 0 !important;
        top: 0 !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Product cards scale smoothly between compact and large phones. */
    .products .price,
    .products .price .amount,
    .products .price bdi,
    .products .price .woocommerce-Price-amount {
        font-size: clamp(11px, 3.35vw, 13px) !important;
        line-height: 1.2 !important;
    }

    .products .price del,
    .products .price del .amount,
    .products .price del bdi {
        font-size: clamp(9px, 2.65vw, 10.5px) !important;
    }

    /* Keep all product-image labels small enough to reveal the product photo. */
    .products .box-image .badge-container,
    .products .box-image .m4h-gift-badge-in-box,
    .products .box-image .m4h-gift-badge-in-image {
        top: 6px !important;
        left: 6px !important;
        right: 6px !important;
    }

    .products .box-image .badge-container .onsale,
    .products .box-image .badge-container .badge-inner,
    .products .box-image .badge-container .badge,
    .products .box-image .m4h-badge-gift {
        font-size: clamp(8px, 2.45vw, 9.5px) !important;
        line-height: 1.15 !important;
        letter-spacing: 0 !important;
        padding: clamp(2px, 0.8vw, 3px) clamp(4px, 1.6vw, 6px) !important;
        border-radius: 4px !important;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18) !important;
    }
}

/* =========================================================
   M4H BOTTOM SHEET MODAL TƯ VẤN & DYNAMIC NAVIGATION TABS
   ========================================================= */
.m4h-app-tab {
    flex: 1 1 0 !important;
    width: auto !important;
}

.m4h-cart-empty {
    display: none !important;
}

/* Modal Wrapper */
#m4h-tuvan-modal,
.m4h-tuvan-modal-wrapper {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    align-items: flex-end;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}

#m4h-tuvan-modal.active,
.m4h-tuvan-modal-wrapper.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Backdrop */
.m4h-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Bottom Sheet Drawer Container */
.m4h-tuvan-sheet {
    position: relative;
    width: 100%;
    max-width: 500px;
    background: #ffffff;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 24px 20px 32px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2;
}

@media (min-width: 769px) {
    .m4h-tuvan-modal-wrapper {
        align-items: center !important;
    }

    .m4h-tuvan-sheet {
        border-radius: 24px !important;
        transform: translateY(30px);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    }

    .m4h-tuvan-modal-wrapper.active .m4h-tuvan-sheet {
        transform: translateY(0) !important;
    }
}

.m4h-tuvan-modal-wrapper.active .m4h-tuvan-sheet {
    transform: translateY(0);
}

/* Pull Handle Bar */
.m4h-sheet-handle {
    width: 40px;
    height: 5px;
    background: #cbd5e1;
    border-radius: 10px;
    margin: 0 auto 16px;
}

/* Close Button */
.m4h-modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    background: #f1f5f9 !important;
    border: none !important;
    color: #64748b !important;
    font-size: 24px !important;
    line-height: 1 !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    padding: 0 !important;
    transition: background 0.2s ease, color 0.2s ease;
}

.m4h-modal-close:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

/* Sheet Header */
.m4h-sheet-header {
    text-align: center;
    margin-bottom: 20px;
    padding-right: 20px;
    padding-left: 20px;
}

.m4h-sheet-header h3 {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin: 0 0 6px !important;
}

.m4h-sheet-header p {
    font-size: 13px !important;
    color: #64748b !important;
    margin: 0 !important;
    line-height: 1.4 !important;
}

/* Channels List */
.m4h-sheet-channels {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Contact Button Item */
.m4h-contact-channel-btn {
    display: flex !important;
    align-items: center !important;
    padding: 12px 16px !important;
    background: #f8fafc !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 14px !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    -webkit-tap-highlight-color: transparent;
}

.m4h-contact-channel-btn:active {
    transform: scale(0.98) !important;
    background: #f1f5f9 !important;
}

.m4h-channel-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--channel-color, #d9261c);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.m4h-channel-icon svg {
    width: 22px;
    height: 22px;
}

.m4h-channel-info {
    flex: 1;
}

.m4h-channel-title {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    margin-bottom: 3px;
}

.m4h-channel-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.3;
}

.m4h-channel-arrow {
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
}