/* Property search: filters modal, active filter chips and the Filters button badge.
 * Plain CSS on purpose: it does not depend on which Tailwind classes happen to be compiled.
 * Sizes follow the reference design: 650px card, 16px radius, 14px text, 8px control radius,
 * #e7e7e7 borders, #f3f3f3 dividers and idle pills, black for the selected / primary state. */

/* --- Modal -------------------------------------------------------------- */

.ha-filters {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.2s;
}

.ha-filters.is-open {
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.ha-filters__overlay {
  position: absolute;
  inset: 0;
  background: rgba(64, 64, 64, 0.4);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ha-filters.is-open .ha-filters__overlay {
  opacity: 1;
}

.ha-filters__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 650px;
  max-height: calc(100vh - 80px);
  border-radius: 16px;
  background: #fff;
  box-shadow: rgba(153, 153, 153, 0.1) 0 10px 10px 0;
  color: #000;
  font-size: 14px;
  line-height: 20px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  outline: none;
  overflow: hidden;
}

.ha-filters.is-open .ha-filters__panel {
  opacity: 1;
  transform: none;
}

/* Small phones: the modal fills the screen. */
@media (max-width: 640px) {
  .ha-filters {
    padding: 0;
  }

  .ha-filters__panel {
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
}

/* --- Header ------------------------------------------------------------- */

.ha-filters__header {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  height: 57px;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid #e7e7e7;
}

.ha-filters__title {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: -0.008em;
  color: #000;
  transform: translate(-50%, -50%);
}

.ha-filters__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #000;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.ha-filters__close:hover {
  background: #f3f3f3;
}

/* --- Body and collapsible groups ----------------------------------------- */

.ha-filters__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 24px;
}

.ha-filters__top {
  padding: 20px 0 24px;
  border-bottom: 1px solid #f3f3f3;
}

.ha-filters__section {
  padding: 24px 0;
  border-bottom: 1px solid #f3f3f3;
}

.ha-filters__section:last-child {
  border-bottom: 0;
}

.ha-filters__section-head {
  margin: 0;
}

.ha-filters__section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #000;
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
  text-align: left;
  cursor: pointer;
}

.ha-filters__chevron {
  flex: none;
  transition: transform 0.2s ease;
}

.ha-filters__section.is-collapsed .ha-filters__chevron {
  transform: rotate(-90deg);
}

.ha-filters__section-body {
  margin-top: 20px;
}

.ha-filters__section.is-collapsed .ha-filters__section-body {
  display: none;
}

.ha-filters__section-toggle:focus-visible,
.ha-seg__opt:focus-visible,
.ha-pill:focus-visible,
.ha-type-card:focus-visible,
.ha-filters__btn:focus-visible,
.ha-filters__close:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* --- Segmented toggle (property status) ----------------------------------- */

.ha-seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: #f3f3f3;
}

.ha-seg__opt {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #000;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.ha-seg__opt--active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* --- Inputs ------------------------------------------------------------- */

.ha-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid #e7e7e7;
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

.ha-input::placeholder {
  color: #8a8a8a;
}

.ha-input:hover {
  border-color: #b8b8b8;
}

.ha-input:focus {
  border-color: #000;
}

.ha-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ha-price-to {
  flex: none;
  padding: 0 4px;
  color: #000;
  font-size: 14px;
}

/* Price slider: thin black track, round handles with a grip. */
.ha-slider {
  margin-top: 24px;
  padding: 0 11px;
}

.ha-filters .noUi-target,
.ha-dropdown .noUi-target {
  height: 2px;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
}

.ha-filters .noUi-horizontal,
.ha-dropdown .noUi-horizontal {
  height: 2px;
}

.ha-filters .noUi-connect,
.ha-dropdown .noUi-connect {
  background: #000;
}

.ha-filters .noUi-horizontal .noUi-handle,
.ha-dropdown .noUi-horizontal .noUi-handle {
  top: -10px;
  right: -11px;
  width: 22px;
  height: 22px;
  border: 1px solid #000;
  border-radius: 50%;
  background: #fff;
  box-shadow: none;
  cursor: grab;
}

.ha-filters .noUi-handle:before,
.ha-dropdown .noUi-handle:before {
  display: none;
}

.ha-filters .noUi-handle:after,
.ha-dropdown .noUi-handle:after {
  /* The theme hides the vendor handle lines; show this one as the grip. */
  display: block;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 12px;
  background-color: transparent;
  /* Six dots (2 x 3) as a grip. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3E%3Cg fill='%23000'%3E%3Ccircle cx='2' cy='2' r='1.2'/%3E%3Ccircle cx='6' cy='2' r='1.2'/%3E%3Ccircle cx='2' cy='6' r='1.2'/%3E%3Ccircle cx='6' cy='6' r='1.2'/%3E%3Ccircle cx='2' cy='10' r='1.2'/%3E%3Ccircle cx='6' cy='10' r='1.2'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 8px 12px;
  transform: translate(-50%, -50%);
}

/* --- Pills (bedrooms, bathrooms) ----------------------------------------- */

.ha-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ha-pill {
  min-width: 44px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: #f3f3f3;
  color: #000;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ha-pill:hover {
  background: #e8e8e8;
}

.ha-pill--active,
.ha-pill--active:hover {
  background: #000;
  color: #fff;
}

/* --- Property type cards --------------------------------------------------- */

.ha-type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ha-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 82px;
  padding: 8px;
  border: 1px solid #e7e7e7;
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-size: 14px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ha-type-card:hover {
  border-color: #b8b8b8;
}

.ha-type-card--active,
.ha-type-card--active:hover {
  border-color: #000;
  box-shadow: 0 0 0 1px #000;
}

.ha-type-card__icon {
  flex: none;
  width: 20px;
  height: 20px;
  color: #000;
}

.ha-type-card__label {
  font-size: 14px;
  font-weight: 400;
}

/* --- Footer ------------------------------------------------------------- */

.ha-filters__footer {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid #f3f3f3;
  background: #fff;
}

.ha-filters__btn {
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ha-filters__btn:hover {
  background: #f7f7f7;
}

.ha-filters__btn--primary {
  height: 40px;
  padding: 0 16px;
  border-color: #000;
  background: #000;
  color: #fff;
}

.ha-filters__footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Save search inside the filters modal: the soft grey button of the reference. */
.ha-filters__btn--soft {
  border-color: #f4f4f4;
  background: #f4f4f4;
}

.ha-filters__btn--soft:hover {
  background: #ebebeb;
}

.ha-filters__btn--primary:hover {
  background: #262626;
}

/* The live count changes width; keep the button steady, and dim it while it recounts. */
.ha-filters__btn--primary {
  min-width: 170px;
}

.ha-filters__btn--primary.is-loading {
  opacity: 0.65;
}

/* --- Active filter chips ------------------------------------------------- */

.ha-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ha-chips[hidden] {
  display: none;
}

.ha-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 0.75rem;
  line-height: 1.25rem;
}

.ha-chip button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #6b7280;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.ha-chip button:hover {
  background: #f3f4f6;
  color: #111827;
}

/* --- Search bar ----------------------------------------------------------- */
/* Follows the reference: a light strip with hairline borders, white 40px fields with a faint border, a grey
 * fill on hover / while open, and a 1.5px black border with weight 500 once a field has a selection. */

.ha-bar {
  padding: 16px 0;
  border-top: 1px solid #e7e7e7;
  border-bottom: 1px solid #e7e7e7;
  background: #f7f7f7;
}

.ha-bar .ha-filters-open {
  margin-left: auto;
}

/* Search field with a magnifier. */
.ha-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 420px;
  max-width: 100%;
  height: 40px;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 3px 11px rgba(0, 0, 0, 0.02);
  transition: border-color 0.15s ease;
}

.ha-search:hover {
  border-color: rgba(0, 0, 0, 0.2);
}

.ha-search:focus-within {
  border-color: #000;
}

.ha-search__icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: #000;
  pointer-events: none;
}

.ha-search__input {
  width: 100%;
  height: 100%;
  padding: 0 36px 0 38px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #000;
  font-size: 14px;
}

.ha-search__input::placeholder {
  color: #848484;
}

.ha-search__clear {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.ha-search__clear.hidden {
  display: none;
}

.ha-search__clear:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #000;
}

/* Dropdown triggers (Price, Type, Beds, Baths) and the Filters button. */
.ha-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: #fff;
  color: #000;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ha-trigger:hover,
.ha-trigger[aria-expanded='true'] {
  background: rgba(0, 0, 0, 0.04);
}

/* Has a selection: black border, medium weight (the padding shrinks by the extra border so nothing jumps). */
.ha-trigger--active {
  padding: 7.5px 11.5px;
  border: 1.5px solid #000;
  background: #fff;
  font-weight: 500;
}

.ha-trigger--active:hover,
.ha-trigger--active[aria-expanded='true'] {
  background: rgba(0, 0, 0, 0.04);
}

.ha-trigger:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* Dropdown panels under the triggers (and the location suggestions). */
.ha-dropdown {
  padding: 12px;
  border: 1px solid #e7e7e7;
  border-radius: 8px 8px 16px 16px;
  background: #fff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
  color: #000;
  font-size: 14px;
}

.ha-dropdown--flush {
  padding: 0;
}

/* --- Filters button badge ------------------------------------------------ */

.ha-filters-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #000;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

.ha-filters-badge[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .ha-filters,
  .ha-filters__overlay,
  .ha-filters__panel,
  .ha-filters__chevron {
    transition: none;
  }
}
