/* ==================== MOBILE HEADER ==================== */
/* Chỉ hiện trên mobile (<=768px), PC dùng header riêng */

/* ===== Ẩn toàn bộ trên PC (>768px) ===== */
.qh-mobile-header-bar,
.qh-mobile-drawer-overlay,
.qh-mobile-drawer,
.qh-mobile-search-panel {
    display: none;
}

/* ==================== MOBILE ONLY ==================== */
@media (max-width: 768px) {

    /* Ẩn PC header, điều chỉnh body padding */
    .qh-header-container {
        display: none;
    }

    body {
        padding-top: 60px;
    }

    /* ===== THANH HEADER MOBILE ===== */
    .qh-mobile-header-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 60px;
        padding: 0 12px;
    }

    .qh-mhb-btn {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        border-radius: 50%;
        color: var(--qh-text);
        font-size: 22px;
        flex-shrink: 0;
        transition: background 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .qh-mhb-btn:active {
        background: var(--qh-bg);
    }

    .qh-mhb-logo {
        flex: 1;
        display: flex;
        justify-content: center;
    }

    .qh-mhb-logo img {
        height: 36px;
        width: auto;
        object-fit: contain;
    }

    /* ===== DRAWER OVERLAY ===== */
    .qh-mobile-drawer-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 19998;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .qh-mobile-drawer-overlay.qh-mob-active {
        opacity: 1;
        pointer-events: auto;
    }

    /* ===== DRAWER MENU (trượt từ trái) ===== */
    .qh-mobile-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 82%;
        max-width: 300px;
        background: var(--qh-white);
        z-index: 19999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .qh-mobile-drawer.qh-mob-active {
        transform: translateX(0);
    }

    /* Đầu drawer: nền đỏ, logo bên trái + nút đóng bên phải */
    .qh-drawer-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 12px;
        height: 60px;
        background: var(--qh-primary);
        color: #fff;
        flex-shrink: 0;
    }

    .qh-drawer-head-logo {
        display: flex;
        align-items: center;
    }

    .qh-drawer-head-logo img {
        height: 36px;
        width: auto;
        border-radius: 4px;
    }

    /* Row chào người dùng nằm giữa header và nav */
    .qh-drawer-greeting-row {
        padding: 14px 20px 12px;
        border-bottom: 1px solid var(--qh-border);
        background: var(--qh-white);
    }

    .qh-drawer-greeting-name {
        font-size: 16px;
        font-weight: 700;
        color: var(--qh-text);
        line-height: 1.3;
    }

    .qh-drawer-greeting-sub {
        font-size: 12px;
        color: var(--qh-text-light);
        margin-top: 2px;
    }

    .qh-drawer-head-close {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.18);
        border: none;
        border-radius: 50%;
        cursor: pointer;
        color: #fff;
        font-size: 20px;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }

    /* Danh sách menu */
    .qh-drawer-nav {
        flex: 1;
        display: flex;
        flex-direction: column;
        padding: 4px 0;
    }

    .qh-drawer-nav-item {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 15px 20px;
        color: var(--qh-text);
        font-size: 15px;
        font-weight: 500;
        border-bottom: 1px solid var(--qh-border);
        text-decoration: none;
        transition: background 0.15s;
        -webkit-tap-highlight-color: transparent;
    }

    .qh-drawer-nav-item:last-child {
        border-bottom: none;
    }

    .qh-drawer-nav-item:active {
        background: var(--qh-bg);
    }

    .qh-drawer-nav-item i {
        font-size: 20px;
        color: var(--qh-primary);
        width: 24px;
        text-align: center;
        flex-shrink: 0;
    }

    .qh-drawer-nav-item.qh-drawer-logout {
        color: var(--qh-primary);
        margin-top: 4px;
    }

    /* ===== SEARCH PANEL (trượt từ phải) ===== */
    .qh-mobile-search-panel {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 0;
        background: var(--qh-white);
        z-index: 20000;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
    }

    .qh-mobile-search-panel.qh-mob-active {
        transform: translateX(0);
    }

    /* Header của search panel */
    .qh-msp-head {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--qh-border);
        background: var(--qh-white);
        flex-shrink: 0;
    }

    .qh-msp-back {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--qh-primary);
        font-size: 22px;
        flex-shrink: 0;
        -webkit-tap-highlight-color: transparent;
    }

    .qh-msp-form {
        flex: 1;
        display: flex;
        align-items: center;
        border: 2px solid var(--qh-primary);
        border-radius: 999px;
        overflow: hidden;
        background: #fff;
    }

    .qh-msp-input {
        flex: 1;
        height: 40px;
        padding: 0 14px;
        border: none;
        font-family: 'Signika', sans-serif;
        font-size: 14px;
        background: transparent;
        min-width: 0;
    }

    .qh-msp-input:focus {
        outline: none;
    }

    .qh-msp-submit {
        height: 40px;
        padding: 0 14px;
        background: var(--qh-primary);
        border: none;
        color: #fff;
        cursor: pointer;
        font-size: 17px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    /* Phần thân search panel (cuộn được) */
    .qh-msp-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
    }

    .qh-msp-section {
        margin-bottom: 22px;
    }

    .qh-msp-section-title {
        font-size: 12px;
        font-weight: 700;
        color: var(--qh-text-light);
        text-transform: uppercase;
        letter-spacing: 0.6px;
        margin-bottom: 10px;
    }

    /* Chips xu hướng */
    .qh-msp-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .qh-msp-chip {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 6px 12px;
        background: var(--qh-bg);
        border: 1px solid var(--qh-border);
        border-radius: 999px;
        font-size: 13px;
        color: var(--qh-text);
        cursor: pointer;
        transition: background 0.15s, border-color 0.15s, color 0.15s;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }

    .qh-msp-chip:active {
        background: var(--qh-primary-light);
        border-color: var(--qh-primary);
        color: var(--qh-primary);
    }

    .qh-msp-chip i {
        font-size: 13px;
        color: var(--qh-primary);
    }

    /* Tìm kiếm gần đây */
    .qh-msp-recent-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .qh-msp-recent-empty {
        color: var(--qh-text-light);
        font-size: 13px;
        font-style: italic;
    }

    .qh-msp-recent-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 0;
        border-bottom: 1px solid var(--qh-border);
        cursor: pointer;
        color: var(--qh-text);
        font-size: 14px;
        -webkit-tap-highlight-color: transparent;
    }

    .qh-msp-recent-item:last-child {
        border-bottom: none;
    }

    .qh-msp-recent-item i.ri-history-line {
        color: var(--qh-text-light);
        font-size: 16px;
        flex-shrink: 0;
    }

    .qh-msp-recent-text {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .qh-msp-recent-remove {
        width: 26px;
        height: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        color: #bbb;
        font-size: 16px;
        flex-shrink: 0;
    }

    /* Gợi ý sản phẩm (grid 2 cột) */
    .qh-msp-products {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .qh-msp-product-card {
        display: flex;
        flex-direction: column;
        border: 1px solid var(--qh-border);
        border-radius: var(--qh-radius-sm);
        overflow: hidden;
        text-decoration: none;
        color: var(--qh-text);
        transition: box-shadow 0.2s;
        background: var(--qh-white);
    }

    .qh-msp-product-img {
        width: 100%;
        aspect-ratio: 1;
        object-fit: cover;
        background: var(--qh-bg);
        display: block;
    }

    .qh-msp-product-img-ph {
        width: 100%;
        aspect-ratio: 1;
        background: linear-gradient(135deg, #e8e8e8, #f5f5f5);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ccc;
        font-size: 28px;
    }

    .qh-msp-product-info {
        padding: 8px;
        flex: 1;
    }

    .qh-msp-product-name {
        font-size: 12px;
        font-weight: 500;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: 4px;
        line-height: 1.4;
    }

    .qh-msp-product-price {
        font-size: 12px;
        font-weight: 700;
        color: var(--qh-primary);
    }

    /* Kết quả tìm kiếm real-time (khi đang gõ) */
    .qh-msp-live-results {
        display: none;
    }

    .qh-msp-live-results.qh-mob-active {
        display: block;
    }

    .qh-msp-default-view.qh-mob-hidden {
        display: none;
    }

    .qh-msp-result-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 11px 0;
        border-bottom: 1px solid var(--qh-border);
        text-decoration: none;
        color: var(--qh-text);
    }

    .qh-msp-result-item:last-child {
        border-bottom: none;
    }

    .qh-msp-result-img {
        width: 50px;
        height: 50px;
        object-fit: cover;
        border-radius: 6px;
        flex-shrink: 0;
        background: var(--qh-bg);
    }

    .qh-msp-result-img-ph {
        width: 50px;
        height: 50px;
        border-radius: 6px;
        flex-shrink: 0;
        background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ccc;
        font-size: 20px;
    }

    .qh-msp-result-info {
        flex: 1;
        min-width: 0;
    }

    .qh-msp-result-name {
        font-size: 14px;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .qh-msp-result-name strong {
        color: var(--qh-primary);
    }

    .qh-msp-result-brand {
        font-size: 12px;
        color: #888;
        margin-top: 2px;
    }

    .qh-msp-result-price {
        font-size: 13px;
        font-weight: 700;
        color: var(--qh-primary);
        flex-shrink: 0;
        margin-left: 4px;
    }

    .qh-msp-result-kw {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 11px 0;
        border-bottom: 1px solid var(--qh-border);
        text-decoration: none;
        color: var(--qh-text);
        font-size: 14px;
    }

    .qh-msp-result-kw i {
        color: var(--qh-text-light);
        font-size: 17px;
        flex-shrink: 0;
    }

    .qh-msp-result-kw-text strong {
        color: var(--qh-primary);
    }

    .qh-msp-no-result {
        text-align: center;
        padding: 24px 0;
        color: var(--qh-text-light);
        font-size: 14px;
    }

    .qh-msp-loading {
        text-align: center;
        padding: 20px 0;
        color: var(--qh-text-light);
        font-size: 14px;
    }

    .qh-msp-loading i {
        font-size: 24px;
        animation: qh-spin 0.8s linear infinite;
        display: block;
        margin-bottom: 6px;
        color: var(--qh-primary);
    }

    @keyframes qh-spin {
        to { transform: rotate(360deg); }
    }
}
