/* ============================================================
  NhaDat888 - Mobile Tab Bar: Bản đồ / Danh sách
  Chỉ active trên mobile ≤ 900px
  Desktop (> 900px): không ảnh hưởng gì
  Date: 2026-05-23
  ============================================================ */

/* ─── TAB BAR ─────────────────────────────────────────────── */
.nd-tab-bar {
  display: none; /* ẩn mặc định, chỉ hiện trên mobile */
}

@media (max-width: 900px) {

  /* --- Tab bar container --- */
  .nd-tab-bar {
    display: flex;
    flex: 0 0 auto;
    height: 44px;
    background: #fff;
    border-bottom: 2px solid #e5e7eb;
    z-index: 50;
  }

  .nd-tab-bar__btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s ease, border-color 0.15s ease;
  }

  .nd-tab-bar__btn svg {
    flex-shrink: 0;
  }

  .nd-tab-bar__btn.is-active {
    color: #00b14f;
    border-bottom-color: #00b14f;
    background: rgba(0, 177, 79, 0.04);
  }

  .nd-tab-bar__btn:hover:not(.is-active) {
    color: #111827;
    background: rgba(0, 0, 0, 0.03);
  }

  /* Badge số lượng BĐS trên tab Danh sách */
  .nd-tab-bar__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #00b14f;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
  }

  .nd-tab-bar__btn.is-active .nd-tab-bar__badge {
    background: #00b14f;
  }
  .nd-tab-bar__btn:not(.is-active) .nd-tab-bar__badge {
    background: #9ca3af;
  }

  /* --- Body layout khi có tab --- */
  .nd-map-search__body {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    position: relative;
  }

  /* Map wrap: full height khi active, ẩn khi không active */
  .nd-map-search__map-wrap {
    position: absolute !important;
    inset: 0 !important;
    min-height: 0 !important;
    order: 0 !important;
    flex: none !important;
    transition: opacity 0.2s ease;
  }

  .nd-map-search__map-wrap.nd-tab-hidden {
    opacity: 0;
    pointer-events: none;
    z-index: 1;
  }
  .nd-map-search__map-wrap:not(.nd-tab-hidden) {
    z-index: 2;
  }

  .nd-map-canvas {
    width: 100%;
    height: 100% !important;
    min-height: 0 !important;
  }

  /* List: full height khi active */
  .nd-map-search__list {
    position: absolute !important;
    inset: 0 !important;
    min-height: 0 !important;
    order: 0 !important;
    flex: none !important;
    border-top: none !important;
    transition: opacity 0.2s ease;
    overflow-y: auto;
  }

  .nd-map-search__list.nd-tab-hidden {
    opacity: 0;
    pointer-events: none;
    z-index: 1;
  }
  .nd-map-search__list:not(.nd-tab-hidden) {
    z-index: 2;
  }

  /* Fix: nd-map-results chiếm toàn bộ list panel */
  .nd-map-results {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
  }

  .nd-map-results-head {
    position: sticky !important;
    top: 0 !important;
    background: #fff !important;
    z-index: 10 !important;
    border-bottom: 1px solid #e5e7eb !important;
    border-left: none !important;
    padding: 12px 16px !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
}

/* ─── Fix filter overflow trên màn hình rất nhỏ (< 480px) ─── */
@media (max-width: 480px) {
  .nd-map-search {
    --map-shell-top: 56px;
  }

  #nd-unified-row {
    flex-wrap: wrap !important;
    gap: 4px !important;
    overflow: visible !important;
  }

  #nd-unified-row #listingTypeToggle {
    flex: 0 0 auto;
    border-right: none;
    padding-right: 0;
    margin-right: 0;
    order: 1;
  }

  #nd-unified-row #ownerTypeToggle {
    flex: 0 0 auto;
    border-left: none;
    padding-left: 0;
    margin-left: 0;
    order: 2;
  }

  #nd-unified-row .nd-map-search-input-wrapper {
    flex: 1 1 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 32px !important;
    order: 3;
  }

  #nd-unified-row #mapPropertyType,
  #nd-unified-row #mapPriceRange,
  #nd-unified-row #mapProvince {
    flex: 1 1 calc(33% - 6px) !important;
    max-width: none !important;
    min-width: 70px !important;
    font-size: 10px !important;
    padding: 0 18px 0 5px !important;
    order: 4;
  }

  /* Ẩn results-head khỏi unified row (JS sẽ đưa vào list panel) */
  #nd-unified-row .nd-map-results-head {
    display: none !important;
  }

  /* Card nhỏ hơn */
  .nd-map-card {
    grid-template-columns: 96px minmax(0, 1fr) !important;
    padding: 7px !important;
    gap: 7px !important;
  }
  .nd-map-card__media,
  .nd-map-card__media img {
    min-height: 82px !important;
  }
}
