/* ==========================================================================
   HungPhatBDS New — Mobile & tablet responsive layer
   Load sau qvp.css — bổ sung/override cho trải nghiệm mobile trực quan
   ========================================================================== */

/* ── 1. Global mobile foundation ─────────────────────────────────────── */
html {
  overflow-x: clip;
}

body {
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
}

img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* Safe area (notch / home indicator) */
.bk-topbar,
.bk-header,
.bk-nav--pro.is-open,
.bk-plp-sidebar.is-open .bk-filter--sidebar {
  padding-left: max(0px, env(safe-area-inset-left));
  padding-right: max(0px, env(safe-area-inset-right));
}

.bk-social-float,
.bk-back-top {
  right: max(12px, env(safe-area-inset-right));
  bottom: max(72px, calc(72px + env(safe-area-inset-bottom)));
}

/* Khóa scroll khi menu mobile mở */
html:has(body.bk-nav-open) {
  overflow: hidden;
  overscroll-behavior: none;
}

body.bk-nav-open {
  touch-action: none;
}

@media (max-width: 1024px) {
  /* Ghim header + nút X khi menu mobile mở (kể cả sau khi scroll) */
  body.bk-nav-open .bk-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    width: 100%;
    box-shadow: var(--shadow-md);
  }

  body.bk-nav-open .bk-nav--pro.is-open {
    z-index: 1000;
  }
}

/* ── 2. Container & spacing tokens ─────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --bk-topbar-h: 38px;
    --bk-header-h: 60px;
    --header-offset: calc(var(--bk-topbar-h) + var(--bk-header-h));
    --sp-xl: 32px;
    --sp-2xl: 48px;
    --sp-3xl: 64px;
  }

  .bk-container {
    width: min(100% - 2rem, var(--container-max));
    padding-inline: 16px;
  }
}

@media (max-width: 480px) {
  :root {
    --bk-header-h: 56px;
    --header-offset: calc(var(--bk-topbar-h) + var(--bk-header-h));
  }

  .bk-container {
    width: min(100% - 1.5rem, var(--container-max));
    padding-inline: 12px;
  }
}

/* ── 3. Topbar ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .bk-topbar--pro {
    font-size: 0.75rem;
  }

  .bk-topbar__inner {
    min-height: 36px;
    gap: 8px;
  }

  .bk-topbar--pro .bk-topbar__item--phone {
    font-size: 0.8125rem;
    padding-right: 0;
  }

  .bk-topbar__cta {
    gap: 6px;
  }

  .bk-header-cta {
    padding: 4px 10px;
    font-size: 0.6875rem;
  }
}

@media (max-width: 520px) {
  .bk-topbar__cta .bk-header-cta--outline {
    display: none;
  }

  .bk-topbar__inner {
    flex-wrap: nowrap;
  }

  .bk-topbar__left {
    flex: 1;
    min-width: 0;
  }

  .bk-topbar--pro .bk-topbar__item--phone {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
}

/* ── 4. Header & navigation ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .bk-header__inner {
    flex-wrap: nowrap !important;
    gap: 10px 12px !important;
    min-height: var(--bk-header-h) !important;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  .bk-brand__logo {
    height: 40px;
    max-width: min(160px, 42vw);
  }

  .bk-header__phone--pro {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: var(--bk-accent-light);
    font-size: 0;
    color: var(--bk-accent);
  }

  .bk-header__phone--pro::before {
    content: '';
    width: 18px;
    height: 18px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5'%3E%3Cpath d='M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.5 19.5 0 015.13 12.7 19.79 19.79 0 012.06 4.11 2 2 0 014.05 2h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0122 16.92z'/%3E%3C/svg%3E") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5'%3E%3Cpath d='M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.5 19.5 0 015.13 12.7 19.79 19.79 0 012.06 4.11 2 2 0 014.05 2h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0122 16.92z'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  .bk-nav__toggle {
    display: flex !important;
  }

  .bk-nav--pro .bk-nav__link {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 1rem;
    padding: 12px 16px;
    border-radius: 10px;
  }

  .bk-nav--pro .bk-nav__item:not(.has-children) .bk-nav__link {
    border: 1px solid var(--bk-border-light);
    background: var(--bk-cream);
    margin-bottom: 4px;
  }
}

/* ── 5. Hero (homepage) ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .bk-hero--pro {
    padding: 28px 0 36px;
  }

  .bk-hero__brand-mark {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
  }

  .bk-hero__logo {
    height: 44px;
    max-width: min(180px, 70vw);
  }

  .bk-hero__company-name {
    font-size: clamp(1.25rem, 5vw, 1.625rem);
  }

  .bk-hero__slogan {
    font-size: 0.9375rem;
  }

  .bk-hero__search-panel {
    padding: 18px 16px 20px;
    border-radius: 12px;
  }

  .bk-hero__address {
    font-size: 0.875rem;
  }
}

@media (max-width: 480px) {
  .bk-hero--pro {
    padding: 20px 0 28px;
  }

  .bk-hero__phone-card,
  .bk-hero__phone-card--info {
    padding: 0;
    flex-direction: row;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .bk-hero__phone-num {
    font-size: 0.85rem;
  }
}

/* ── 6. Sections & typography ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .bk-section {
    padding: var(--sp-lg) 0;
  }

  .bk-section--lg {
    padding: var(--sp-xl) 0;
  }

  .bk-section__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: var(--sp-lg);
  }

  .bk-section__head--center {
    align-items: center;
    text-align: center;
  }

  .bk-section__head .bk-btn {
    width: 100%;
    justify-content: center;
  }

  .bk-section__sub {
    max-width: none;
    font-size: 0.875rem;
  }

  .bk-h1,
  .bk-page-hero__title {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }

  .bk-plp-head__title {
    font-size: 1.25rem;
    line-height: 1.3;
  }

  .bk-plp-head {
    padding: var(--sp-md) 0;
  }

  .bk-plp-head__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .bk-breadcrumb {
    font-size: 0.75rem;
    padding: 8px 0;
  }
}

/* ── 7. Buttons & CTA ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .bk-btn {
    white-space: normal;
    text-align: center;
    min-height: 44px;
  }

  .bk-btn--lg,
  .bk-btn--xl {
    padding: 14px 20px;
    font-size: 1rem;
    width: 100%;
  }

  .bk-cta-banner {
    padding: var(--sp-xl) var(--sp-md);
    border-radius: var(--r-lg);
  }

  .bk-cta-banner__actions {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .bk-cta-banner__actions .bk-btn {
    width: 100%;
  }

  .bk-cta-banner--pro,
  .bk-cta-banner--qvp {
    padding: 32px 20px;
  }
}

/* ── 8. Property cards & grids ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .bk-property-grid,
  .bk-property-grid--home,
  [data-filter-grid] > .bds-grid--properties,
  [data-filter-grid] .bds-grid--properties {
    gap: 16px;
  }

  .bk-card__price-overlay,
  .bds-card__price {
    font-size: 1.125rem;
  }

  .bk-card__body {
    padding: 14px;
  }

  .bk-card__title {
    font-size: 0.9375rem;
  }

  .bk-card__tags {
    gap: 4px;
  }

  .bk-card__tags:not(.bk-card__tags--buttons) {
    max-width: 72%;
  }

  .bk-card__tags--buttons {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 3px;
    max-width: calc(100% - 20px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .bk-card__tags--buttons::-webkit-scrollbar {
    display: none;
  }

  .bk-card__tags--buttons .bk-card__tag-btn {
    width: auto;
    flex-shrink: 0;
    justify-content: flex-start;
    white-space: nowrap;
  }

  .bk-card__tag {
    font-size: 0.625rem;
    padding: 4px 8px;
  }

  /* Giảm hover transform trên touch */
  .bk-property-card:hover {
    transform: none;
  }
}

@media (max-width: 480px) {
  .bk-project-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .bk-type-bento {
    gap: 10px;
  }
}

/* ── 9. PLP toolbar & mobile filter drawer ─────────────────────────────── */
.bk-plp-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.bk-plp-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  flex-wrap: wrap;
}

.bk-plp-sort select {
  min-height: 44px;
  flex: 1;
  min-width: 140px;
}

@media (max-width: 1024px) {
  .bk-plp-filter-mobile {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    font-size: 0.9375rem;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
  }

  .bk-plp-filter-mobile::before {
    content: '';
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M4 6h16M7 12h10M10 18h4'/%3E%3C/svg%3E") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M4 6h16M7 12h10M10 18h4'/%3E%3C/svg%3E") center / contain no-repeat;
  }

  .bk-plp-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    top: auto;
  }

  .bk-plp-sidebar .bk-filter--sidebar {
    display: none;
  }

  /* Filter inline — mở rộng trong luồng trang, không khóa scroll list */
  .bk-plp-sidebar.is-open {
    position: static;
    inset: auto;
    z-index: auto;
    display: block;
    background: transparent;
    backdrop-filter: none;
    padding: 0;
    animation: none;
  }

  .bk-plp-sidebar.is-open .bk-plp-filter-mobile {
    display: flex !important;
    border-color: var(--bk-accent);
    color: var(--bk-accent);
    background: var(--bk-accent-light, #eef4fb);
  }

  .bk-plp-sidebar.is-open .bk-filter--sidebar {
    display: block;
    position: static;
    width: 100%;
    max-height: none;
    overflow: visible;
    margin-top: 12px;
    border-radius: var(--r-lg, 12px);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    animation: bk-slide-down 0.24s ease;
  }

  .bk-plp-sidebar.is-open .bk-filter--sidebar::before {
    display: none;
  }

  .bk-plp-sidebar.is-open .bk-filter__body {
    display: block;
    margin-top: 0;
  }

  .bk-plp-sidebar.is-open .bk-filter__toggle {
    display: none;
  }

  .bk-plp-toolbar {
    justify-content: stretch;
  }

  .bk-plp-sort {
    width: 100%;
    justify-content: space-between;
  }

  .bk-plp-sort select {
    flex: 1;
    max-width: none;
  }
}

@keyframes bk-slide-down {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bk-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bk-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ── 10. PDP (chi tiết BĐS) ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .bk-pdp__layout {
    padding: var(--sp-md) 0 0;
    gap: 16px;
  }

  .bk-pdp__title {
    font-size: 1.125rem;
  }

  .bk-pdp__price {
    font-size: 1.5rem;
  }

  .bk-pdp__info-header {
    padding: 16px;
  }

  .bk-pdp__tags {
    padding: 12px 16px;
  }

  .bk-pdp__ctas {
    padding: 14px 16px;
  }

  .bk-detail-block {
    padding: 18px 14px;
    border-radius: var(--r-md);
  }

  .bk-gallery__main {
    aspect-ratio: 4 / 3;
    border-radius: var(--r-md);
  }

  .bk-gallery__strip {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .bk-gallery__overlay-hint {
    font-size: 0.75rem;
    padding: 6px 10px;
    bottom: 10px;
    right: 10px;
  }

  .bk-map-container,
  .bk-map-container iframe {
    min-height: 240px;
  }

  .bk-tiktok-embed__player iframe {
    min-height: 360px;
    height: min(520px, 65vh);
  }
}

@media (max-width: 768px) {
  .bk-pdp__quick-specs .bk-spec-row {
    grid-template-columns: minmax(96px, 34%) minmax(0, 1fr);
  }
  .bk-spec-row__lbl,
  .bk-spec-row dt.bk-spec-row__lbl {
    padding: 10px 12px;
  }
  .bk-spec-row__val,
  .bk-spec-row dd.bk-spec-row__val {
    padding: 10px 14px;
  }
}

@media (max-width: 480px) {
  .bk-pdp__contact-profile,
  .bk-pdp__contact-actions {
    padding: 14px 16px;
  }

  .bk-pdp__agent-avatar {
    width: 48px;
    height: 48px;
    font-size: 1rem;
  }
}

/* ── 11. Filter forms ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .bk-filter {
    padding: 16px;
    border-radius: var(--r-lg);
  }

  .bk-filter__toggle {
    min-height: 48px;
  }

  .bk-field__input,
  .bk-field__select {
    min-height: 44px;
    font-size: 16px; /* tránh zoom iOS */
  }

  .bk-filter--hero .bk-field__select {
    font-size: 16px;
  }
}

/* ── 12. Stats, features, testimonials ─────────────────────────────────── */
@media (max-width: 768px) {
  .bk-stats-bar {
    padding: var(--sp-lg) 0;
  }

  .bk-stat-item__num {
    font-size: 1.75rem;
  }

  .bk-feature-card {
    padding: 20px 16px;
  }

  .bk-testimonial {
    padding: 20px 16px;
  }
}

@media (max-width: 480px) {
  .bk-stats-bar__inner {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .bk-stat-item {
    padding: 10px 8px;
  }

  .bk-stat-item__num {
    font-size: 1.5rem;
  }

  .bk-stat-item__lbl {
    font-size: 0.75rem;
  }
}

/* ── 13. Footer ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .bk-footer__main {
    padding: var(--sp-xl) 0 var(--sp-lg);
  }

  .bk-footer .bk-footer__top,
  .bk-footer--pro .bk-footer__top {
    grid-template-columns: 1fr;
    gap: var(--sp-lg);
  }

  .bk-footer__top > div {
    padding-left: 0 !important;
    border-left: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: var(--sp-md);
  }

  .bk-footer__top > div:first-child {
    border-top: none;
    padding-top: 0;
  }

  .bk-footer__tagline {
    max-width: none;
    font-size: 0.875rem;
  }

  .bk-footer__hotline {
    max-width: 100%;
    width: 100%;
  }

  .bk-footer__price-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .bk-footer__bar {
    flex-direction: column;
    text-align: center;
    gap: 12px;
    padding: var(--sp-md) 0 max(var(--sp-md), env(safe-area-inset-bottom));
  }

  .bk-footer .bk-back-top {
    position: static;
    margin: 0 auto;
    opacity: 1;
    pointer-events: all;
  }
}

@media (max-width: 400px) {
  .bk-footer__price-links {
    grid-template-columns: 1fr;
  }
}

/* ── 14. Static pages (contact, news) ──────────────────────────────────── */
@media (max-width: 768px) {
  .bk-page-hero {
    padding: var(--sp-xl) 0 var(--sp-lg);
  }

  .bk-page-hero__sub {
    font-size: 0.9375rem;
  }

  .bk-contact-page__form {
    padding: var(--sp-lg);
  }

  .bk-directors-grid {
    grid-template-columns: 1fr;
  }

  .bk-director-card {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }

  .bk-director-card__actions {
    justify-content: center;
    width: 100%;
  }

  .bk-director-card__actions .bk-btn {
    flex: 1;
    min-width: 0;
  }
}

/* ── 15. Floating widgets ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .bk-social-float {
    bottom: max(16px, calc(16px + env(safe-area-inset-bottom)));
    right: max(10px, env(safe-area-inset-right));
    gap: 8px;
  }

  .bk-social-float__btn {
    width: 44px;
    height: 44px;
  }

  .bk-sticky-contact {
    bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
    right: max(10px, env(safe-area-inset-right));
  }

  .bk-sticky-contact__btn {
    width: 52px;
    min-height: 52px;
  }

  /* PDP mobile: gom phone/Zalo vào nút collapse */
  .bk-sticky-contact--pdp {
    flex-direction: column-reverse;
    bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
  }

  .bk-sticky-contact--pdp .bk-sticky-contact__toggle {
    display: flex;
  }

  .bk-sticky-contact--pdp:not(.is-open) .bk-sticky-contact__actions {
    display: none;
  }

  .bk-sticky-contact--pdp.is-open .bk-sticky-contact__actions {
    display: flex;
    animation: bk-sticky-actions-in 0.2s ease;
  }
}

@keyframes bk-sticky-actions-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── 16. Lightbox mobile ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .bk-lightbox__prev,
  .bk-lightbox__next {
    width: 40px;
    height: 40px;
  }

  .bk-lightbox__prev { left: 8px; }
  .bk-lightbox__next { right: 8px; }

  .bk-lightbox__close {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
  }

  .bk-lightbox__thumbs {
    bottom: max(48px, calc(48px + env(safe-area-inset-bottom)));
    max-width: 96vw;
  }

  .bk-lightbox__thumb-item {
    width: 44px;
    height: 34px;
  }
}

/* ── 17. Pagination ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .bk-pagination a,
  .bk-pagination span {
    width: 36px;
    height: 36px;
    font-size: 0.8125rem;
  }
}

/* ── 18. 404 & misc ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .bk-404__inner {
    padding: 40px 0;
  }

  .bk-404__actions {
    flex-direction: column;
    width: 100%;
    padding-inline: 16px;
  }

  .bk-404__actions .bk-btn {
    width: 100%;
  }
}
