/* === BDS MOBILE — Single source of truth for mobile ≤991.98px === */

/* 1. Ẩn site-header hoàn toàn trên BDS (BDS dùng bds-topbar riêng) */
@media (max-width: 991.98px) {
    html.aha-bds-theme .site-header { display: none !important; }
    body.aha-bds-shell .page-wrapper {
        margin-top: var(--bds-topbar-height, 72px) !important;
    }
    .bds-topbar-circle {
        width: 46px !important;
        height: 46px !important;
        min-width: 46px !important;
        min-height: 46px !important;
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        color: #0f172a !important;
        box-shadow: 0 2px 8px rgba(15, 23, 42, .08) !important;
    }
}

/* 2. Topbar mobile compact */
@media (max-width: 767.98px) {
    :root { --bds-topbar-height: 64px; }
    .bds-topbar-shortcuts { display: none; }
    .bds-topbar-inner { height: 64px; padding: 0 12px; gap: 8px; }
    .bds-topbar-brand-logo { height: 38px; }
    .bds-topbar-circle {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 20px !important;
    }
    .bds-topbar-account { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
    .bds-topbar-spacer { height: 64px; }
    body.aha-bds-shell .page-wrapper {
        margin-top: 64px !important;
    }
    body.aha-bds-shell .container-xl { padding: 0 12px; }
}

/* 3. Category grid — 2 cột, meta text wrap được */
@media (max-width: 767.98px) {
    .bds-category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bds-category-card { min-height: 72px; gap: 8px; padding: 10px 12px; }
    .bds-category-card__visual { width: 40px; height: 40px; border-radius: 10px; font-size: 1.1rem; }
    .bds-category-card__title { font-size: .86rem; }
    .bds-category-card__meta { font-size: .72rem; white-space: normal; overflow: visible; text-overflow: clip; }
    .bds-category-card:nth-child(2) { border-right: 0; }
    .bds-category-card:nth-child(1),
    .bds-category-card:nth-child(2) { border-bottom: 1px solid #ececec; }
    .bds-category-card:nth-child(3) { border-right: 1px solid #ececec; }
}

/* 4. Search pill — luôn 1 hàng */
@media (max-width: 767.98px) {
    .bds-nhatot-search__pill {
        flex-wrap: nowrap !important;
        border-radius: 999px !important;
        padding: 5px !important;
    }
    .bds-nhatot-search__filter { display: none !important; }
    .bds-nhatot-search__keyword {
        flex: 1 1 auto !important;
        padding: 0 12px !important;
        border-bottom: 0 !important;
    }
    .bds-nhatot-search__btn { min-width: 80px; padding: 0 14px !important; font-size: .88rem !important; }
}

/* 5. Search pill vùng 768-991px — fix flex-wrap */
@media (min-width: 768px) and (max-width: 991.98px) {
    .bds-nhatot-search__pill {
        flex-wrap: nowrap !important;
        border-radius: 999px !important;
        padding: 6px !important;
    }
    .bds-nhatot-search__keyword { flex: 1 1 auto; border-bottom: 0 !important; padding: 0 14px !important; }
    .bds-nhatot-search__filter { flex: 0 0 auto; }
    .bds-nhatot-search__submit { padding: 0 4px 0 8px !important; }
}

/* 6. Intent tabs — scroll ngang */
@media (max-width: 767.98px) {
    .bds-intent-tabs { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; gap: 8px; padding: 0 2px; }
    .bds-intent-tabs::-webkit-scrollbar { display: none; }
    .bds-intent-tabs__primary { min-width: 0; flex: 0 0 auto; order: 1; }
    .bds-intent-tabs__actions { flex: 0 0 auto; order: 2; }
    .bds-intent-tab { min-height: 38px; padding: 0 14px; font-size: .82rem; }
    .bds-intent-post-cta { min-height: 38px; padding: 0 12px; font-size: .82rem; }
    .bds-intent-more-btn { min-height: 38px; padding: 0 10px; font-size: .8rem; }
}

/* 7. Region grid */
@media (max-width: 767.98px) {
    .region-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .region-card { min-height: 100px; padding: 12px; border-radius: 14px; }
    .region-card--hero { grid-column: 1 / -1 !important; min-height: 140px !important; }
}

/* 8. Feed cards scroll ngang */
@media (max-width: 767.98px) {
    .bds-page-hub .bds-feed-section__body > .row-cards {
        display: flex !important; flex-wrap: nowrap !important; overflow-x: auto !important;
        scroll-snap-type: x mandatory; gap: 12px !important;
        margin: 0 !important; padding-bottom: 8px !important; scrollbar-width: none;
    }
    .bds-page-hub .bds-feed-section__body > .row-cards > [class*="col-"] {
        flex: 0 0 78% !important; max-width: 78% !important; scroll-snap-align: start;
        display: flex !important; /* Đảm bảo card con kéo giãn hết chiều cao của hàng */
    }
    .bds-page-hub .bds-feed-section__body > .row-cards > [class*="col-"] > .card {
        width: 100% !important; height: auto !important; min-height: 100%;
        display: flex !important; flex-direction: column;
    }
    .bds-page-hub .bds-feed-section__body > .row-cards::-webkit-scrollbar { display: none !important; }
}

/* 9. Listing/Cho thuê page */
@media (max-width: 767.98px) {
    .bds-list-page .bds-col-preview, 
    .bds-rent-page .bds-col-preview, 
    .bds-col-market { 
        flex: 0 0 100% !important; max-width: 100% !important; 
    }
    .bds-list-price, .bds-rent-price { font-size: 20px !important; }
    .bds-list-card, .bds-rent-card { border-radius: 16px; }
}

/* 10. Detail page */
@media (max-width: 767.98px) {
    .bds-detail-sidebar-sticky { position: static !important; top: auto !important; }
    .bds-detail-title { font-size: 1.2rem; }
    .bds-detail-main-card .card-body,
    .bds-detail-sidebar-card .card-body { padding: 12px; }
    .bds-gallery-main { border-radius: 16px; }
}

/* 11. Filter sticky bar trên listing */
@media (max-width: 767.98px) {
    .bds-list-search.is-sticky-fixed {
        top: 64px !important;
        top: var(--bds-topbar-height, 64px) !important;
        padding: 6px 10px;
    }
    .bds-list-search .bds-results-search-bar {
        flex-wrap: nowrap; gap: 6px; padding: 5px;
        border-radius: 999px;
    }
    .bds-list-search .bds-results-search-input { flex: 1 1 auto; min-height: 40px; }
    .bds-list-search .bds-results-search-submit {
        min-width: 40px; min-height: 40px;
        border-radius: 999px !important; padding: 0 !important;
    }
    .bds-list-search .bds-results-filter-toggle {
        min-height: 40px; border-radius: 999px !important; padding: 0 16px !important; font-size: .82rem !important;
    }
}

/* 12. Neutralize aha-compact-mobile.css interference */
@media (max-width: 767.98px) {
    body.aha-bds-shell .page-wrapper { padding-top: 0 !important; }
    body.aha-bds-shell .page-body { padding-top: 0 !important; }
}
