/* ============================================================
   Mobile Search Bottom Sheet — Glassmorphism Drawer
   Breakpoint: < 768px mobile, >= 768px desktop inline
   ============================================================ */

/* Hide mobile UI on desktop; hide desktop search on mobile */
.mobile-search-trigger,
.mobile-search-sheet {
  display: none !important;
}

@media (min-width: 768px) {
  .desktop-only {
    display: block;
  }
}

@media (max-width: 767px) {
  .mobile-search-trigger {
    display: flex !important;
  }

  .mobile-search-sheet {
    display: flex !important;
    align-items: flex-end;
  }

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

  /* ── Mobile trigger button (closed state) ── */
  .mobile-search-trigger {
    position: relative;
    width: calc(100% - 32px);
    max-width: 480px;
    margin: 0 auto;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: left;
    display: flex !important;
    align-items: center;
    gap: 12px;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-search-trigger:active {
    transform: scale(0.98);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  }
}

.mobile-search-trigger__icon {
  font-size: 20px;
  flex-shrink: 0;
}

.mobile-search-trigger__text {
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  flex: 1;
}

.mobile-search-trigger__hint {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .mobile-search-trigger__hint {
    display: none;
  }
}

/* ── Bottom sheet container ── */
.mobile-search-sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100vw;
  height: 100%;
  max-height: 100dvh;
  max-height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
  touch-action: none;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

.mobile-search-sheet[aria-hidden="false"] {
  pointer-events: auto;
  touch-action: auto;
}

.mobile-search-sheet[hidden] {
  display: none !important;
}

/* ── Backdrop: full cover, tappable to close ── */
.mobile-search-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mobile-search-sheet[aria-hidden="false"] .mobile-search-backdrop {
  opacity: 1;
}

/* ── Sheet content (glassmorphism) ── */
.mobile-search-sheet__content {
  position: relative;
  width: 100%;
  max-width: 100vw;
  max-height: 85vh;
  max-height: 85dvh;
  min-height: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12), 0 -2px 8px rgba(0, 0, 0, 0.06);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 1;
}

.mobile-search-sheet[aria-hidden="false"] .mobile-search-sheet__content {
  transform: translateY(0);
}

/* ── Handle bar ── */
.mobile-search-sheet__handle {
  width: 40px;
  height: 4px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

/* ── Header ── */
.mobile-search-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.mobile-search-sheet__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text-dark, #0F172A);
  margin: 0;
}

.mobile-search-sheet__close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-secondary, rgba(0, 0, 0, 0.06));
  border: none;
  border-radius: 50%;
  color: var(--color-text-dark, #1a1a1a);
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.mobile-search-sheet__close:active {
  background: var(--color-border-light, rgba(0, 0, 0, 0.12));
}

/* ── Form & body (scrollable area) ── */
.mobile-search-sheet__form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.mobile-search-sheet__body {
  padding: 24px 20px 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  flex: 1;
  min-height: 0;
}

/* ── Buy/Rent toggle ── */
.mobile-search-toggle-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.mobile-search-toggle__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mobile-search-toggle__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 12px;
  background: var(--color-bg-secondary, rgba(0, 0, 0, 0.04));
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-search-toggle__input:checked + .mobile-search-toggle__label {
  background: var(--color-primary-soft, rgba(0, 106, 255, 0.12));
  border-color: var(--color-primary, #006AFF);
  box-shadow: 0 4px 12px rgba(0, 106, 255, 0.15);
}

.mobile-search-toggle__icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.mobile-search-toggle__text {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-dark, #1a1a1a);
}

/* ── Input groups ── */
.mobile-search-input-group {
  margin-bottom: 20px;
  position: relative;
}

.mobile-search-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-secondary, #666);
  margin-bottom: 8px;
}

.mobile-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.mobile-search-input-icon {
  position: absolute;
  left: 16px;
  font-size: 20px;
  pointer-events: none;
  z-index: 1;
}

.mobile-search-input {
  width: 100%;
  height: 56px;
  padding: 0 16px 0 48px;
  font-size: 16px;
  color: var(--color-text-dark, #1a1a1a);
  background: var(--color-bg-secondary, rgba(0, 0, 0, 0.04));
  border: 2px solid transparent;
  border-radius: 12px;
  transition: all 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.mobile-search-input:focus {
  outline: none;
  background: var(--color-bg, #fff);
  border-color: var(--color-primary, #006AFF);
  box-shadow: 0 0 0 4px var(--color-primary-soft, rgba(0, 106, 255, 0.1));
}

.mobile-search-input::placeholder {
  color: var(--color-text-muted, #999);
}

.mobile-search-example {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text-secondary, #64748b);
}

/* ── Property type: custom dropdown (mobile-friendly, no native select) ── */
.mobile-search-select-wrapper {
  position: relative;
  width: 100%;
}

.mobile-search-select-trigger {
  width: 100%;
  min-height: 56px;
  padding: 14px 44px 14px 16px;
  font-size: 16px;
  line-height: 1.4;
  text-align: left;
  color: var(--color-text-dark, #1a1a1a);
  background: var(--color-bg-secondary, rgba(0, 0, 0, 0.04));
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mobile-search-select-trigger:active,
.mobile-search-select-trigger[aria-expanded="true"] {
  background: var(--color-bg, #fff);
  border-color: var(--color-primary, #006AFF);
  box-shadow: 0 0 0 4px var(--color-primary-soft, rgba(0, 106, 255, 0.1));
}

.mobile-search-select-trigger__text {
  flex: 1;
}

.mobile-search-select-icon {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--color-text-secondary, #666);
  transition: transform 0.2s ease;
}

.mobile-search-select-trigger[aria-expanded="true"] .mobile-search-select-icon {
  transform: rotate(180deg);
}

/* Dropdown list: below trigger, inside sheet, scrollable */
.mobile-search-select-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  max-height: min(240px, 50vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--color-bg, #fff);
  border: 2px solid var(--color-primary, #006AFF);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 20;
}

.mobile-search-select-dropdown[hidden] {
  display: none !important;
}

.mobile-search-select-option {
  display: block;
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.4;
  text-align: left;
  color: var(--color-text-dark, #1a1a1a);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--color-border-light, rgba(0, 0, 0, 0.06));
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-search-select-option:last-child {
  border-bottom: none;
}

.mobile-search-select-option:hover,
.mobile-search-select-option:active,
.mobile-search-select-option--active {
  background: var(--color-primary-lighter, rgba(0, 106, 255, 0.08));
  color: var(--color-primary, #006AFF);
}

/* ── Submit button ── */
.mobile-search-submit {
  width: 100%;
  min-height: 56px;
  margin-top: 24px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--color-primary, #006AFF);
  border: none;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 106, 255, 0.3);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-search-submit:hover {
  background: var(--color-primary-hover, #0053CC);
}

.mobile-search-submit:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 106, 255, 0.2);
}

.mobile-search-submit__icon {
  font-size: 20px;
}

/* ── Suggestions dropdown ── */
.mobile-search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border-light, rgba(0, 0, 0, 0.08));
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow-y: auto;
  z-index: 10;
}

.mobile-search-suggestions[hidden] {
  display: none !important;
}

.mobile-search-suggestions__item {
  padding: 14px 16px;
  font-size: 15px;
  color: var(--color-text-dark, #1a1a1a);
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid var(--color-border-light, rgba(0, 0, 0, 0.04));
  min-height: 48px;
  display: flex;
  align-items: center;
}

.mobile-search-suggestions__item:last-child {
  border-bottom: none;
}

.mobile-search-suggestions__item:hover,
.mobile-search-suggestions__item[aria-selected="true"] {
  background: var(--color-primary-lighter, rgba(0, 106, 255, 0.08));
}

.mobile-search-suggestions__empty {
  padding: 16px;
  font-size: 14px;
  color: var(--color-text-muted);
  text-align: center;
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
  .mobile-search-sheet__body {
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }
}
