/* ══════════════════════════════════════════════════════════════════
   UNIQUE HAVEN HOMES — Mobile-First Enhancement Layer
   
   Targets: phones (< 480px), small phones (< 380px), tablets (< 768px)
   Goal: Smooth, premium experience for the 90% mobile user base
   ══════════════════════════════════════════════════════════════════ */

/* ── 1. FLOATING BUTTON LAYOUT ───────────────────────────────────
   Desktop:
   Voice agent: bottom-right (24px)
   Chat widget: bottom-left (24px)
   Back to top: bottom-left (88px, above chat, only when .visible)
   
   Mobile (<= 768px):
   Back to top: HIDDEN! (Eliminates ugly mid-screen obstruction)
   Voice agent & Chat widget: Docked together in the bottom-right corner!
   Voice agent: bottom: ~66px, right: 12px
   Chat widget: bottom: ~66px, right: 62px, left: auto!
   Leaving the entire left 75% of the mobile screen 100% UNBLOCKED!
   ─────────────────────────────────────────────────────────────── */
#uhh-voice-widget {
  bottom: 24px !important;
  right: 24px !important;
  z-index: 9998 !important;
}
#uhh-voice-btn {
  position: relative !important;
  bottom: auto !important;
  right: auto !important;
}
#uhh-chat-btn {
  bottom: 24px !important;
  left: 24px !important;
  z-index: 9997 !important;
}
.dir-back-to-top {
  bottom: 88px !important;
  left: 24px !important;
  z-index: 9990 !important;
}

@media (max-width: 768px) {
  /* 1. HIDE BACK TO TOP ON MOBILE (No more floating button covering cards/reviews) */
  .dir-back-to-top {
    display: none !important;
  }

  /* 2. VOICE WIDGET (Compact 44px round button on bottom-right) */
  #uhh-voice-widget {
    bottom: calc(66px + env(safe-area-inset-bottom, 0px)) !important;
    right: 12px !important;
    z-index: 9998 !important;
  }
  #uhh-voice-btn {
    width: 44px !important;
    height: 44px !important;
  }
  #uhh-voice-label {
    display: none !important; /* Hide long pill label on mobile */
  }

  /* 3. CHAT BUTTON (Docks cleanly on bottom-right, leaving center completely free!) */
  #uhh-chat-btn-wrap {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
    right: 14px !important;
    left: auto !important;
    z-index: 9997 !important;
  }
  #uhh-chat-btn {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
    z-index: 9997 !important;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.4) !important;
  }
  .uhh-chat-btn-title,
  .uhh-chat-btn-pill {
    display: none !important;
  }
  .uhh-chat-btn-sparkle {
    font-size: 20px !important;
    margin: 0 !important;
  }

  /* 4. CHAT PANEL BOTTOM SHEET */
  #uhh-chat-panel {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 86vh !important;
    max-height: 86vh !important;
    border-radius: 24px 24px 0 0 !important;
    border: none !important;
    border-top: 1.5px solid rgba(212, 168, 75, 0.4) !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7) !important;
    z-index: 100000 !important;
  }
}

/* ── 2. HERO SECTION ─────────────────────────────────────────────
   Compact, elegant typography, minimal vertical footprint
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dir-hero {
    padding: 16px 14px 12px !important;
    text-align: center;
  }
  .dir-hero-badge {
    font-size: 10px !important;
    padding: 3px 10px !important;
    margin-bottom: 6px !important;
    letter-spacing: 0.5px !important;
  }
  .dir-hero-title {
    font-size: clamp(22px, 5.5vw, 26px) !important;
    line-height: 1.2 !important;
    margin-bottom: 6px !important;
  }
  .dir-hero-sub {
    font-size: 12.5px !important;
    line-height: 1.4 !important;
    margin-bottom: 10px !important;
    color: #64748b !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }
}

/* ── 3. AIRBNB-GRADE COMPACT SEARCH BAR ──────────────────────────
   Row 1: Search input + Search button
   Row 2: Location (50%) + Sort (50%) side-by-side
   Cuts vertical space by > 60%
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dir-search-wrap {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    padding: 8px 10px !important;
    gap: 6px !important;
    border-radius: 18px !important;
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08) !important;
    max-width: 100% !important;
  }

  .dir-search-input-box {
    flex: 1 1 calc(100% - 46px) !important;
    width: calc(100% - 46px) !important;
    min-height: 38px !important;
    padding-left: 4px !important;
    display: flex !important;
    align-items: center !important;
  }

  .dir-search-input-box input {
    font-size: 14px !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 4px 0 !important;
  }

  .dir-search-btn-icon,
  .dir-search-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    border-radius: 50% !important;
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  .dir-search-divider {
    display: none !important;
  }

  .dir-search-select-box {
    flex: 1 1 calc(50% - 4px) !important;
    width: calc(50% - 4px) !important;
    min-width: 0 !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
    background: #f8fafc !important;
    padding: 0 4px !important;
    margin: 0 !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
  }

  .dir-search-select-box select,
  .dir-search-select {
    font-size: 12px !important;
    min-height: 34px !important;
    height: 34px !important;
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    padding: 0 4px !important;
    color: #1e293b !important;
    font-weight: 600 !important;
  }
}

/* ── 4. CATEGORY FILTER PILLS ────────────────────────────────────
   Horizontal scroll, no text wrap, clear tap targets
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .airnest-cat-scroll,
  .dir-filter-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 8px;
    padding: 4px 0 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    mask-image: linear-gradient(to right, transparent 0, black 16px, black calc(100% - 16px), transparent 100%);
  }
  .airnest-cat-scroll::-webkit-scrollbar,
  .dir-filter-bar::-webkit-scrollbar { display: none; }

  .airnest-cat-btn,
  .dir-filter-btn {
    flex-shrink: 0;
    scroll-snap-align: start;
    min-height: 36px;
    padding: 7px 14px !important;
    font-size: 13px !important;
    white-space: nowrap;
  }
}

/* ── 5. PROPERTY CARDS ───────────────────────────────────────────
   Single column on mobile, full-width tap zone
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .dir-property-grid,
  .dir-cards-grid {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
    padding: 0 2px !important;
  }

  .dir-card {
    border-radius: 16px !important;
  }

  .dir-card-media {
    height: 220px !important; /* Taller image on mobile */
  }

  .dir-card-media img {
    object-position: center 30%; /* Better crop for property photos */
  }

  /* 4-corner non-colliding badge system */
  .dir-card-rating-badge {
    top: 10px !important;
    left: 10px !important;
    bottom: auto !important;
    font-size: 11px !important;
    padding: 3px 8px !important;
  }

  .dir-card-save-badge {
    top: 10px !important;
    right: 10px !important;
    bottom: auto !important;
    font-size: 10.5px !important;
    padding: 3px 8px !important;
  }

  .dir-avail-badge {
    bottom: 10px !important;
    left: 10px !important;
    top: auto !important;
    font-size: 10.5px !important;
    padding: 3px 8px !important;
  }

  .dir-card-photo-count {
    bottom: 10px !important;
    right: 10px !important;
    font-size: 11px !important;
    padding: 3px 8px !important;
  }

  .dir-card-body {
    padding: 14px 14px 12px !important;
  }

  .dir-card-title {
    font-size: 16px !important;
    margin-bottom: 6px !important;
  }

  .dir-card-location {
    font-size: 12px !important;
  }

  .dir-card-specs {
    gap: 6px !important;
    margin: 8px 0 !important;
  }

  .dir-card-spec-item {
    font-size: 11px !important;
    padding: 3px 8px !important;
  }

  .dir-card-price-main {
    font-size: 18px !important;
  }

  .dir-card-price-strike {
    font-size: 12px !important;
  }

  .dir-btn-details {
    font-size: 13px !important;
    padding: 10px 16px !important;
    min-height: 42px;
  }
}

/* ── 6. NAVIGATION HEADER ────────────────────────────────────────
   Compact, no overflow
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .dir-logo-wrap img,
  .luxe-logo img { max-height: 36px !important; }

  .dir-nav-bar,
  .luxe-nav {
    padding: 0 12px !important;
    height: 58px !important;
  }

  /* Hide nav links on small mobile, keep logo + CTA */
  .luxe-nav-links,
  .dir-nav-links { display: none !important; }

  /* Show hamburger or compact nav CTA */
  .dir-nav-cta,
  .luxe-nav-cta {
    font-size: 12px !important;
    padding: 8px 12px !important;
  }
}

/* ── 7. MOBILE STICKY BOTTOM BAR ─────────────────────────────────
   Ensure it doesn't overlap floating buttons
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-sticky-bar {
    padding: 8px 12px 10px !important;
    /* Safe area support for notch phones */
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mobile-bar-btn-wa,
  .mobile-bar-btn-call {
    font-size: 13px !important;
    padding: 11px 10px !important;
    border-radius: 12px !important;
  }
}

/* ── 8. REVIEW CARDS (Mobile carousel) ──────────────────────────
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #uhh-reviews-section {
    padding: 48px 0 40px !important;
  }

  .uhh-rev-container {
    padding: 0 12px !important;
  }

  .uhh-rev-title {
    font-size: 24px !important;
  }

  .uhh-rev-card {
    flex: 0 0 88vw !important;
    padding: 20px 18px 16px !important;
  }

  .uhh-rev-text {
    font-size: 13.5px !important;
    -webkit-line-clamp: 4 !important;
  }

  .uhh-rev-nav { display: none !important; }

  .uhh-rev-track-wrapper { gap: 0 !important; }
}

/* ── 9. MAP SECTION ──────────────────────────────────────────────
   Shorter map on phones, don't dominate the screen
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #propertyMap {
    height: 300px !important;
  }

  .dir-map-section-title {
    font-size: 20px !important;
  }
}

/* ── 10. TRUST STRIP ─────────────────────────────────────────────
   2-column grid on mobile
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .airnest-trust-strip {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
    padding: 0 12px !important;
  }

  .airnest-trust-item {
    text-align: center;
    padding: 14px 10px !important;
  }

  .airnest-trust-icon-box {
    font-size: 22px !important;
    margin-bottom: 6px !important;
  }

  .airnest-trust-label {
    font-size: 12px !important;
  }
}

/* ── 11. FOOTER ──────────────────────────────────────────────────
   Stack layout, larger tap targets
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .dir-footer {
    padding: 32px 16px 90px !important; /* bottom padding for sticky bar */
    text-align: center;
  }

  .dir-footer-nav {
    flex-direction: column !important;
    gap: 10px !important;
    align-items: center !important;
  }

  .dir-footer-nav a {
    font-size: 14px !important;
    min-height: 36px;
    display: flex;
    align-items: center;
  }
}

/* ── 12. GRID COUNT / SORT BAR ───────────────────────────────────
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .dir-grid-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    margin-bottom: 14px !important;
  }

  .dir-grid-count {
    font-size: 14px !important;
  }
}


/* ── 14. TOUCH IMPROVEMENTS ──────────────────────────────────────
   Tap targets min 44x44px per Apple HIG / Google Material
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  a, button, [role="button"], input[type="submit"], select {
    -webkit-tap-highlight-color: rgba(212,168,75,0.15);
  }

  /* Ensure all interactive elements have min tap size */
  .dir-filter-btn,
  .dir-btn-details,
  .dir-btn-share-icon,
  .airnest-cat-btn {
    min-height: 40px;
    min-width: 40px;
  }

  /* Remove hover transforms on touch (they cause sticky states) */
  .dir-card:hover {
    transform: none !important;
  }
}

/* ── 15. SCROLL PERFORMANCE ──────────────────────────────────────
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dir-card-media img {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  /* Smooth momentum scroll everywhere */
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* ── 16. TYPOGRAPHY SCALING ──────────────────────────────────────
   Prevent iOS auto-zoom on inputs (font-size < 16px)
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important; /* Prevents iOS auto-zoom */
  }
}

/* ── 17. VOICE CHAT PANEL MOBILE FIXES ───────────────────────────
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #uhh-chat-panel {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: 72vh !important;
    border-radius: 20px 20px 0 0 !important;
    /* Safe area */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .uhh-chat-input-row {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ── 17B. LUXURY FOOTER MOBILE REFINEMENT ────────────────────────
   Safe bottom clearance + clean pill links
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dir-footer {
    padding: 36px 16px calc(96px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .dir-footer-nav {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 14px 0 !important;
  }
  .dir-footer-nav a {
    display: inline-flex !important;
    align-items: center !important;
    padding: 7px 16px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 999px !important;
    font-size: 12.5px !important;
    color: #f1f5f9 !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
  }
  .dir-footer-nav a:hover {
    background: rgba(212, 168, 75, 0.2) !important;
    border-color: #f59e0b !important;
    color: #fbbf24 !important;
  }
  .dir-footer-cin {
    font-size: 11px !important;
    line-height: 1.5 !important;
    color: #94a3b8 !important;
  }
  .dir-footer-copyright {
    font-size: 11.5px !important;
    color: #94a3b8 !important;
  }
}

/* ── 18. PWA / HOME-SCREEN STANDALONE ───────────────────────────
   ─────────────────────────────────────────────────────────────── */
@media (display-mode: standalone) {
  .dir-nav-bar,
  .luxe-nav {
    padding-top: env(safe-area-inset-top, 0px) !important;
  }
  .dir-footer,
  .mobile-sticky-bar {
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
  }
}
