/**
 * Belbaza UX polish — layered on current look (no redesign).
 * Scope: hero readability, search CTA, home hierarchy, cards, mobile trust.
 */

/* ── Hero readability (keep photo / atmosphere) ── */
body:not(.bb-dash-active) section[class*="h-screen"]::before,
body:not(.bb-dash-active) section.relative.min-h-\[100dvh\]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(10, 22, 40, 0.55) 0%, rgba(10, 22, 40, 0.35) 42%, rgba(10, 22, 40, 0.72) 100%);
}

body:not(.bb-dash-active) section[class*="h-screen"] > .relative.z-10,
body:not(.bb-dash-active) section.relative.min-h-\[100dvh\] > .relative.z-10 {
  position: relative;
  z-index: 2;
}

body:not(.bb-dash-active) section[class*="h-screen"] h1,
body:not(.bb-dash-active) section.relative.min-h-\[100dvh\] h1 {
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.4);
  letter-spacing: -0.02em;
}

body:not(.bb-dash-active) section[class*="h-screen"] h1 + p,
body:not(.bb-dash-active) section.relative.min-h-\[100dvh\] h1 + p {
  color: rgba(248, 250, 252, 0.92) !important;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

/* Primary search CTA «Искать» */
body:not(.bb-dash-active) section[class*="h-screen"] button.rounded-xl,
body:not(.bb-dash-active) section.relative.min-h-\[100dvh\] button.rounded-xl {
  min-height: 48px;
  padding-left: 1.35rem !important;
  padding-right: 1.35rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 28px rgba(0, 212, 170, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

body:not(.bb-dash-active) section[class*="h-screen"] button.rounded-xl:hover,
body:not(.bb-dash-active) section.relative.min-h-\[100dvh\] button.rounded-xl:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 32px rgba(0, 212, 170, 0.45);
  filter: brightness(1.04);
}

body:not(.bb-dash-active) section[class*="h-screen"] button.rounded-xl:active,
body:not(.bb-dash-active) section.relative.min-h-\[100dvh\] button.rounded-xl:active {
  transform: translateY(0);
  filter: brightness(0.96);
}

body:not(.bb-dash-active) section[class*="h-screen"] button.rounded-xl:focus-visible,
body:not(.bb-dash-active) section.relative.min-h-\[100dvh\] button.rounded-xl:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* Injected guests field */
.bb-hero-guests {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  font-size: 14px;
}

.bb-hero-guests select {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  min-width: 4.5rem;
  padding-right: 4px;
  cursor: pointer;
}

.bb-hero-guests select:focus-visible {
  outline: 2px solid #00d4aa;
  outline-offset: 2px;
  border-radius: 8px;
}

/* Mobile: collapse suggestion chips so CTA stays in first viewport */
@media (max-width: 767px) {
  body:not(.bb-dash-active) section[class*="h-screen"] .flex.flex-wrap.justify-center.gap-2,
  body:not(.bb-dash-active) section.relative.min-h-\[100dvh\] .flex.flex-wrap.justify-center.gap-2 {
    display: none !important;
  }

  body:not(.bb-dash-active) section[class*="h-screen"] button.rounded-xl,
  body:not(.bb-dash-active) section.relative.min-h-\[100dvh\] button.rounded-xl {
    width: 100%;
    justify-content: center;
  }

  .bb-hero-guests {
    width: 100%;
    justify-content: space-between;
  }
}

/* ── Home hierarchy: rest primary, realty secondary ── */
#bb-home-featured .bb-hf-section[data-bb-kind="cabins"] h2,
#bb-home-featured-host .bb-hf-section[data-bb-kind="cabins"] h2 {
  font-size: clamp(1.4rem, 3.2vw, 1.9rem);
}

#bb-home-featured .bb-hf-section[data-bb-kind="sale"],
#bb-home-featured .bb-hf-section[data-bb-kind="rent"],
#bb-home-featured-host .bb-hf-section[data-bb-kind="sale"],
#bb-home-featured-host .bb-hf-section[data-bb-kind="rent"] {
  opacity: 0.92;
  margin-top: 8px;
  padding-top: 28px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#bb-home-featured .bb-hf-section[data-bb-kind="sale"] h2,
#bb-home-featured .bb-hf-section[data-bb-kind="rent"] h2,
#bb-home-featured-host .bb-hf-section[data-bb-kind="sale"] h2,
#bb-home-featured-host .bb-hf-section[data-bb-kind="rent"] h2 {
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  font-weight: 700;
  color: #cbd5e1;
}

#bb-home-featured .bb-hf-section[data-bb-kind="sale"] .bb-hf-grid,
#bb-home-featured .bb-hf-section[data-bb-kind="rent"] .bb-hf-grid,
#bb-home-featured-host .bb-hf-section[data-bb-kind="sale"] .bb-hf-grid,
#bb-home-featured-host .bb-hf-section[data-bb-kind="rent"] .bb-hf-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 1024px) {
  #bb-home-featured .bb-hf-section[data-bb-kind="sale"] .bb-hf-grid,
  #bb-home-featured .bb-hf-section[data-bb-kind="rent"] .bb-hf-grid,
  #bb-home-featured-host .bb-hf-section[data-bb-kind="sale"] .bb-hf-grid,
  #bb-home-featured-host .bb-hf-section[data-bb-kind="rent"] .bb-hf-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  #bb-home-featured .bb-hf-section[data-bb-kind="sale"] .bb-hf-grid,
  #bb-home-featured .bb-hf-section[data-bb-kind="rent"] .bb-hf-grid,
  #bb-home-featured-host .bb-hf-section[data-bb-kind="sale"] .bb-hf-grid,
  #bb-home-featured-host .bb-hf-section[data-bb-kind="rent"] .bb-hf-grid {
    grid-template-columns: 1fr;
  }
}

/* Hide empty home blocks */
#bb-home-featured:empty,
#bb-home-featured-host:empty,
.bb-hf-section:empty {
  display: none !important;
}

/* ── Cards polish ── */
.bb-hf-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.bb-hf-card:hover {
  border-color: rgba(0, 212, 170, 0.35);
}

.bb-hf-card:focus-visible {
  outline: 2px solid #00d4aa;
  outline-offset: 3px;
}

.bb-hf-card:active {
  transform: translateY(0) scale(0.995);
}

.bb-hf-card .price {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.bb-hf-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0 0 8px;
  font-size: 12px;
  color: #94a3b8;
}

.bb-hf-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.bb-hf-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.bb-hf-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: rgba(0, 212, 170, 0.14);
  color: #5eead4;
  border: 1px solid rgba(0, 212, 170, 0.28);
}

.bb-hf-badge--muted {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.25);
}

.bb-hf-amenities {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 10px;
}

.bb-hf-amenity {
  font-size: 11px;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  padding: 2px 6px;
}

/* React cabin cards on /cabins — light density/price tweaks only */
body.bb-cabins-active #root a[href^="/cabin/"] {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

body.bb-cabins-active #root a[href^="/cabin/"]:hover {
  transform: translateY(-2px);
}

body.bb-cabins-active #root a[href^="/cabin/"]:focus-visible {
  outline: 2px solid #00d4aa;
  outline-offset: 3px;
  border-radius: 16px;
}

/* ── Cabin detail sticky CTA (mobile) ── */
.bb-sticky-book {
  display: none;
}

@media (max-width: 767px) {
  .bb-sticky-book {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(10, 22, 40, 0.96);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  }

  .bb-sticky-book__price {
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    line-height: 1.2;
  }

  .bb-sticky-book__hint {
    display: block;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 500;
  }

  .bb-sticky-book__btn {
    flex: 0 0 auto;
    min-height: 48px;
    min-width: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: #00d4aa;
    color: #0a1628;
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
    touch-action: manipulation;
  }

  .bb-sticky-book__btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
  }

  body.bb-cabin-page-active {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Filters bottom sheet (cabins / realty) ── */
.bb-filters-sheet-backdrop {
  display: none;
}

@media (max-width: 767px) {
  .bb-filters-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(2, 8, 20, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .bb-filters-sheet-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .bb-filters-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 81;
    max-height: min(86vh, 720px);
    transform: translateY(110%);
    transition: transform 0.25s ease;
    background: #0f172a;
    border-radius: 18px 18px 0 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .bb-filters-sheet.is-open {
    transform: translateY(0);
  }

  .bb-filters-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .bb-filters-sheet__head strong {
    color: #fff;
    font-size: 16px;
  }

  .bb-filters-sheet__close {
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .bb-filters-sheet__body {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 20px;
  }

  .bb-filters-open-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 23, 42, 0.9);
    color: #f8fafc;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
  }
}

@media (min-width: 768px) {
  .bb-filters-open-btn,
  .bb-filters-sheet,
  .bb-filters-sheet-backdrop {
    display: none !important;
  }
}

/* Trust strip under home cabins */
.bb-trust-strip {
  max-width: 1280px;
  margin: -8px auto 28px;
  padding: 0 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: #94a3b8;
  font-size: 13px;
}

.bb-trust-strip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bb-trust-strip b {
  color: #e2e8f0;
  font-weight: 700;
}

/* Prevent accidental horizontal scroll */
html, body {
  overflow-x: clip;
}

#root {
  overflow-x: clip;
}

/* Keep Bel FAB clear of hero CTA / sticky book on mobile */
@media (max-width: 767px) {
  .bb-bel-fab {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.bb-cabin-page-active .bb-bel-fab {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
