/**
 * mobile.css — Mobile-first UX (customer pages)
 * Safe areas, bottom nav, sticky actions, touch targets
 */

:root {
  --mobile-nav-h: 4.25rem;
  --mobile-action-h: 3.75rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ─── App shell ─── */
@media (max-width: 991px) {
  body.page-shell.has-mobile-nav {
    padding-bottom: max(1rem, var(--safe-bottom));
  }

  body.page-shell.has-mobile-action {
    padding-bottom: calc(var(--mobile-action-h) + var(--safe-bottom) + 0.75rem);
  }

  .container.page-content,
  .listing-section .container {
    padding-left: max(0.85rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.85rem, env(safe-area-inset-right, 0px));
  }

  /* Navbar lebih ringkas */
  .navbar {
    padding-top: max(0.5rem, var(--safe-top));
    padding-bottom: 0.5rem;
  }

  .navbar .navbar-collapse {
    max-height: min(70vh, 420px);
    overflow-y: auto;
  }

  /* Header landing lebih pendek */
  .page-header--landing {
    padding-top: 1.25rem !important;
    padding-bottom: 1rem !important;
  }

  .page-header--landing .page-header__title {
    font-size: 1.45rem !important;
    line-height: 1.15;
  }

  .page-header--landing .page-header__sub {
    font-size: 0.86rem !important;
    line-height: 1.45;
  }

  .page-header--compact {
    padding: 1rem 0 0.75rem !important;
  }

  .page-header--compact .page-header__title {
    font-size: 1.2rem !important;
  }

  .page-header--compact .page-header__sub {
    display: none;
  }

  .page-header--compact .page-header__kicker {
    margin-bottom: 0.25rem;
  }
}

/* ─── Bottom tab navigation ─── */
.mobile-tabbar {
  display: none;
}

@media (max-width: 991px) {
  .mobile-tabbar {
    display: none !important;
  }
}

/* ─── Rekomendasi: hasil dulu, filter collapsible ─── */
@media (max-width: 991px) {
  .rec-layout__results {
    order: 1;
  }

  .rec-layout__filters {
    order: 2;
  }

  .filter-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 18px);
    background: var(--surface);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--ink);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .filter-mobile-toggle__hint {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
  }

  .filter-mobile-toggle i.bi-chevron-down {
    transition: transform 0.2s;
    color: var(--primary);
  }

  .filter-mobile-toggle[aria-expanded="true"] i.bi-chevron-down {
    transform: rotate(180deg);
  }

  #filterCollapse:not(.show) .filter-card {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: -0.65rem;
    border-top: none;
  }

  .filter-card .form-control,
  .filter-card .form-select {
    min-height: 48px;
    font-size: 16px; /* cegah zoom iOS */
  }

  .btn-rekomendasi,
  .btn-reset {
    min-height: 48px;
    font-size: 0.95rem;
  }

  .filter-actions--mobile-only {
    display: flex !important;
  }

  .filter-actions--desktop-only {
    display: none !important;
  }
}

@media (min-width: 992px) {
  .filter-mobile-toggle {
    display: none !important;
  }

  .filter-actions--mobile-only {
    display: none !important;
  }

  #filterCollapse.collapse {
    display: block !important;
    height: auto !important;
    visibility: visible !important;
  }
}

/* Sticky action bar rekomendasi */
.mobile-action-bar {
  display: none;
}

@media (max-width: 991px) {
  .mobile-action-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--safe-bottom);
    z-index: 1035;
    gap: 0.5rem;
    padding: 0.55rem max(0.85rem, env(safe-area-inset-left, 0px)) 0.55rem max(0.85rem, env(safe-area-inset-right, 0px));
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.05);
  }

  .mobile-action-bar__btn {
    flex: 1;
    min-height: 46px;
    border-radius: var(--radius-md, 14px);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.88rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-action-bar__btn--primary {
    flex: 1.4;
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(224, 134, 0, 0.28);
  }

  .mobile-action-bar__btn:active {
    transform: scale(0.98);
  }
}

/* ─── Kartu rekomendasi mobile ─── */
@media (max-width: 991px) {
  .rec-card {
    border-radius: var(--radius-lg, 18px);
  }

  .rec-card:hover {
    transform: none;
  }

  .rec-card img {
    height: 200px !important;
  }

  .rec-card .card-inner {
    padding: 1rem 1.05rem 1.05rem;
  }

  .btn-property-detail {
    min-height: 46px;
    font-size: 0.9rem;
  }

  .score-row {
    gap: 6px;
  }

  .score-label {
    width: 52px;
    font-size: 0.68rem;
  }

  /* Feedback — touch target lebih besar */
  .feedback-section {
    margin-top: 0.75rem;
  }

  .btn-feedback {
    width: 2.75rem !important;
    height: 2.75rem !important;
    font-size: 1.1rem !important;
  }

  .feedback-star {
    font-size: 1.15rem !important;
    padding: 0.35rem !important;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .results-meta {
    background: var(--surface);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    width: 100%;
  }

  .empty-state {
    padding: 2rem 1rem !important;
  }

  .empty-state p {
    font-size: 0.88rem;
    line-height: 1.5;
  }
}

/* ─── Daftar rumah (index) ─── */
@media (max-width: 991px) {
  .page-header--landing .search-panel {
    padding: 1rem !important;
    border-radius: var(--radius-lg, 18px) !important;
  }

  .search-panel .form-control,
  .search-panel .form-select {
    min-height: 48px;
    font-size: 16px;
  }

  .search-panel__actions .btn-search,
  .search-panel__actions .btn-search-ghost {
    min-height: 48px;
    width: 100%;
  }

  .house-card img {
    height: 195px !important;
  }

  .house-card:hover {
    transform: none;
  }

  .page-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ─── Modal fullscreen feel ─── */
@media (max-width: 991px) {
  .modal-fullscreen-md-down {
    margin: 0 !important;
    max-width: 100% !important;
    height: 100%;
  }

  .modal-fullscreen-md-down .modal-content {
    border-radius: 0;
    min-height: 100%;
  }

  #profileModal .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border-soft);
    padding-bottom: max(1rem, var(--safe-bottom));
  }

  #profileModal .modal-footer .btn {
    min-height: 48px;
  }
}

/* ─── Auth pages ─── */
@media (max-width: 576px) {
  body.auth-page {
    min-height: 100dvh;
    padding-bottom: max(1rem, var(--safe-bottom));
  }

  .auth-container .card-body {
    padding: 1.35rem !important;
  }

  .auth-container .form-control {
    min-height: 48px;
    font-size: 16px;
  }

  .auth-container .btn-primary {
    min-height: 48px;
  }
}
