/* DS Immobilier — inline search bar (800px on desktop) */

.ds-search {
  --ds-search-width: 800px;
  --ds-search-pill-radius: 15px;
  --ds-search-btn-radius: 15px;
  --ds-search-control-h: 46px;
  --ds-search-line: #72c5d3;
  --ds-search-line-focus: #43bfc7;
  --ds-search-btn: #43bfc7;
  --ds-search-btn-hover: #34b3c1;
  --ds-search-fg: #444;
  --ds-search-placeholder: #555;
  width: 100%;
  max-width: var(--ds-search-width);
  margin-inline: auto;
  overflow: visible;
  text-align: left;
}

.ds-search--hero {
  filter: drop-shadow(0 12px 28px rgb(15 40 45 / 18%));
}

.ds-search--panel:not(.ds-search--listing) {
  filter: drop-shadow(0 8px 24px rgb(15 40 45 / 10%));
}

/* Bar — grid on mobile, inline flex on desktop */
.ds-search__bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px;
  background: #fff;
  border-radius: var(--ds-search-pill-radius);
  overflow: visible;
}

.ds-search__field {
  position: relative;
  min-width: 0;
  overflow: visible;
}

.ds-search__actions {
  display: flex;
  align-items: center;
  justify-content: stretch;
}

/* Proportional grid bar (homepage hero + listing search) */
.ds-search--bar-grid .ds-search__bar {
  display: grid;
  grid-template-columns: var(--ds-search-grid, repeat(6, minmax(0, 1fr)));
  gap: 12px 14px;
  align-items: end;
  padding: 16px 22px;
}

.ds-search--bar-grid .ds-search__field--ctypmandat {
  max-width: 172px;
}

.ds-search__bar-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-left: 6px;
  flex-shrink: 0;
}

.ds-search__bar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
  height: 46px;
  padding: 0 22px;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--ds-font-sans, "Jost", sans-serif);
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.ds-search__bar-btn--submit {
  color: #fff;
  background: var(--ds-brand, #43bfc7);
  border: 0;
}

.ds-search__bar-btn--submit:hover {
  background: var(--ds-brand-dark, #34b3c1);
}

.ds-search__bar-btn--submit:active {
  transform: scale(0.97);
}

.ds-search__bar-btn--reset {
  color: var(--ds-ink, #1a2b32);
  background: #fff;
  border: 1px solid #c9d6da;
}

.ds-search__bar-btn--reset:hover {
  border-color: var(--ds-brand, #43bfc7);
  color: var(--ds-brand-dark, #34b3c1);
}

.ds-search__bar-btn:focus-visible {
  outline: 2px solid var(--ds-brand, #43bfc7);
  outline-offset: 2px;
}

.ds-search__bar-btn-icon {
  display: block;
  flex-shrink: 0;
}

.ds-search__bar-btn-text {
  white-space: nowrap;
}

/* Search button (legacy icon-only — kept for backwards compatibility) */
.ds-search__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  padding: 0;
  color: #fff;
  background: var(--ds-search-btn);
  border: 0;
  border-radius: var(--ds-search-btn-radius);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
}

/* Underline inputs (price fields) */
.ds-search__input {
  display: block;
  width: 100%;
  height: var(--ds-search-control-h);
  padding: 10px 0 8px;
  color: var(--ds-search-fg);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--ds-search-line);
  border-radius: 0;
  font-family: var(--ds-font-sans, "Jost", sans-serif);
  font-size: 0.95rem;
  font-weight: 400;
  text-align: left;
  transition: border-color 0.18s ease;
}

.ds-search__input::placeholder {
  color: var(--ds-search-placeholder);
  opacity: 1;
}

.ds-search__input:hover {
  border-bottom-color: var(--ds-search-line-focus);
}

.ds-search__input:focus {
  outline: none;
  border-bottom-color: var(--ds-search-line-focus);
}

/* Native select fallback (before Select2 init) */
.ds-search__select {
  display: block;
  width: 100%;
  height: var(--ds-search-control-h);
  padding: 10px 24px 8px 0;
  color: var(--ds-search-fg);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--ds-search-line);
  border-radius: 0;
  font-family: var(--ds-font-sans, "Jost", sans-serif);
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2372c5d3' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
}

.ds-search__select:focus {
  outline: none;
  border-bottom-color: var(--ds-search-line-focus);
}

.ds-search__select.select2-hidden-accessible {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
}

.ds-search__submit:hover {
  background: var(--ds-search-btn-hover);
}

.ds-search__submit:active {
  transform: scale(0.97);
}

.ds-search__submit-icon {
  display: block;
  flex-shrink: 0;
}

/* -------------------------------------------------------------------------
   Select2 — underline + teal chevron
--------------------------------------------------------------------------- */

.ds-search .select2-container {
  width: 100% !important;
  font-family: var(--ds-font-sans, "Jost", sans-serif);
}

.ds-search .select2-container--default .select2-selection--single {
  display: flex;
  align-items: center;
  height: var(--ds-search-control-h);
  padding: 10px 28px 8px 0;
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--ds-search-line);
  border-radius: 0;
  transition: border-color 0.18s ease;
}

.ds-search .select2-container--default .select2-selection--single:hover {
  border-bottom-color: var(--ds-search-line-focus);
}

.ds-search .select2-container--default.select2-container--open .select2-selection--single,
.ds-search .select2-container--default.select2-container--focus .select2-selection--single {
  border-bottom-color: var(--ds-search-line-focus);
  outline: none;
  box-shadow: none;
}

.ds-search .select2-container--default .select2-selection--single .select2-selection__rendered {
  padding: 0;
  padding-right: 4px;
  color: var(--ds-search-fg);
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-search .select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: var(--ds-search-placeholder);
}

.ds-search .select2-container--default .select2-selection--single .select2-selection__arrow {
  top: auto;
  bottom: 14px;
  right: 0;
  width: 16px;
  height: 16px;
}

.ds-search .select2-container--default .select2-selection--single .select2-selection__arrow b {
  display: none;
}

.ds-search .select2-container--default .select2-selection--single .select2-selection__arrow::after {
  content: "";
  display: block;
  width: 12px;
  height: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2372c5d3' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
}

.ds-search .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow::after {
  transform: rotate(180deg);
}

.ds-search .select2-container--default .select2-selection--single .select2-selection__clear {
  margin-right: 6px;
  color: var(--ds-search-line-focus);
  font-weight: 500;
}

/* Dropdown panel — at least as wide as field; can grow for long labels */
.ds-search__field .select2-dropdown.ds-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: auto;
  width: auto !important;
  min-width: 100% !important;
  max-width: min(480px, 92vw) !important;
  margin-top: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgb(114 197 211 / 35%);
  border-top: 2px solid var(--ds-search-line-focus);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 14px 36px rgb(15 40 45 / 14%);
  z-index: 80;
}

.ds-search__field--open {
  z-index: 50;
  overflow: visible;
}

.ds-search__field--ctyp .select2-dropdown.ds-search-dropdown {
  min-width: max(100%, 320px) !important;
}

.select2-dropdown.ds-search-dropdown {
  overflow: hidden;
  background: #fff;
  border: 1px solid rgb(114 197 211 / 35%);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgb(15 40 45 / 14%);
}

.select2-dropdown.ds-search-dropdown .select2-search--dropdown {
  padding: 10px 10px 6px;
}

.select2-dropdown.ds-search-dropdown .select2-search--dropdown .select2-search__field {
  min-height: 38px;
  padding: 8px 12px;
  border: 0 !important;
  border-bottom: 2px solid var(--ds-search-line, #72c5d3) !important;
  border-radius: 0 !important;
  font-family: var(--ds-font-sans, "Jost", sans-serif);
  font-size: 0.9rem;
}

.select2-dropdown.ds-search-dropdown .select2-search--dropdown .select2-search__field:focus {
  border-bottom-color: var(--ds-search-line-focus, #43bfc7) !important;
  outline: none;
  box-shadow: none;
}

.select2-dropdown.ds-search-dropdown .select2-results__options {
  max-height: 260px;
  padding: 4px 0 8px;
}

.select2-dropdown.ds-search-dropdown .select2-results__option {
  margin: 0;
  padding: 9px 14px;
  border-radius: 0;
  font-family: var(--ds-font-sans, "Jost", sans-serif);
  font-size: 0.92rem;
  text-align: left;
  white-space: nowrap;
  word-break: normal;
  line-height: 1.4;
}

/* Remove Select2’s default indent for nested type (optgroup) options */
.select2-dropdown.ds-search-dropdown .select2-results__option .select2-results__option,
.select2-container--default .select2-dropdown.ds-search-dropdown .select2-results__option .select2-results__option {
  padding-left: 12px !important;
  margin-left: 0 !important;
}

.select2-dropdown.ds-search-dropdown .select2-results__option--selectable {
  color: var(--ds-ink, #444);
}

.select2-dropdown.ds-search-dropdown .select2-results__option--highlighted.select2-results__option--selectable {
  color: #fff;
  background: var(--ds-search-btn, #43bfc7);
}

.select2-dropdown.ds-search-dropdown .select2-results__group {
  padding: 10px 12px 4px;
  color: #888;
  font-family: var(--ds-font-sans, "Jost", sans-serif);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

/* Hero placement */
.ds-hero-search-wrap {
  width: 100%;
  max-width: var(--ds-search-width, 800px);
  margin: 28px auto 0;
  padding-inline: 12px;
  overflow: visible;
}

.ds-hero-search-wrap .ds-search {
  width: 100%;
}

/* -------------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------------- */

/* Mobile + tablet — full width of hero/container */
@media (max-width: 900px) {
  .ds-hero-search-wrap {
    align-self: stretch;
    width: 100%;
    max-width: none;
    margin-top: 28px;
    margin-inline: 0;
    padding-inline: 0;
    box-sizing: border-box;
  }

  /* Cancel .ds-hero__body horizontal padding so the bar spans the shell */
  .ds-hero__body > .ds-hero-search-wrap {
    width: auto;
    margin-inline: calc(-1 * clamp(18px, 4vw, 48px));
  }

  .ds-hero-search-wrap .ds-search,
  .ds-hero__body .ds-search,
  .elementor-widget-ds-search,
  .elementor-widget-ds-search .ds-search {
    width: 100% !important;
    max-width: none !important;
    min-width: 0;
    margin-inline: 0;
    box-sizing: border-box;
  }

  .ds-search__bar {
    width: 100%;
    box-sizing: border-box;
  }
}

/* Mobile — stacked grid, larger tap targets (all selects same size) */
@media (max-width: 560px) {
  .ds-search {
    --ds-search-control-h: 56px;
  }

  .ds-search__bar {
    gap: 20px;
    padding: 22px 18px;
  }

  .ds-search__input,
  .ds-search__select,
  .ds-search .select2-container--default .select2-selection--single .select2-selection__rendered,
  .ds-search--bar-grid .ds-search__field--ctypmandat .ds-search__select,
  .ds-search--bar-grid .ds-search__field--ctypmandat .select2-container--default .select2-selection--single .select2-selection__rendered,
  .ds-search--hero.ds-search--bar-grid .ds-search__input,
  .ds-search--hero.ds-search--bar-grid .ds-search__select,
  .ds-search--hero.ds-search--bar-grid .select2-container--default .select2-selection--single .select2-selection__rendered,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__input,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__select,
  .ds-hero-search-wrap .ds-search--bar-grid .select2-container--default .select2-selection--single .select2-selection__rendered {
    font-size: 1.125rem;
  }

  .ds-search__submit {
    width: 100%;
    height: 56px;
  }

  .ds-search .select2-container--default .select2-selection--single .select2-selection__arrow {
    bottom: 18px;
  }
}

/* Tablet — 2-column grid (non bar-grid search only) */
@media (min-width: 561px) and (max-width: 900px) {
  .ds-search:not(.ds-search--listing):not(.ds-search--bar-grid) {
    --ds-search-control-h: 54px;
  }

  .ds-search:not(.ds-search--listing):not(.ds-search--bar-grid) .ds-search__bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 28px;
    padding: 28px 24px;
  }

  .ds-search:not(.ds-search--listing):not(.ds-search--bar-grid) .ds-search__input,
  .ds-search:not(.ds-search--listing):not(.ds-search--bar-grid) .ds-search__select,
  .ds-search:not(.ds-search--listing):not(.ds-search--bar-grid) .select2-container--default .select2-selection--single .select2-selection__rendered {
    font-size: 1.1rem;
  }

  .ds-search:not(.ds-search--listing):not(.ds-search--bar-grid) .ds-search__actions {
    grid-column: 1 / -1;
  }

  .ds-search:not(.ds-search--listing):not(.ds-search--bar-grid) .ds-search__submit {
    width: 100%;
    max-width: none;
    height: 56px;
  }

  .ds-search:not(.ds-search--listing):not(.ds-search--bar-grid) .select2-container--default .select2-selection--single .select2-selection__arrow {
    bottom: 16px;
  }

  /* Listing bar-grid only — homepage hero stacks (see below). */
  .ds-search--bar-grid:not(.ds-search--hero) .ds-search__bar {
    grid-template-columns: minmax(108px, 0.64fr) minmax(0, 1fr) minmax(0, 1fr);
    padding: 14px 18px;
  }

  .ds-search--bar-grid:not(.ds-search--hero) .ds-search__field--ctypmandat {
    max-width: none;
  }
}

/* Desktop — inline row for legacy search; bar-grid keeps proportional columns */
@media (min-width: 901px) {
  .ds-search:not(.ds-search--bar-grid):not(.ds-search--listing),
  .ds-hero-search-wrap {
    width: var(--ds-search-width);
    min-width: var(--ds-search-width);
    max-width: var(--ds-search-width);
  }

  /* Compact transaction column only in the inline desktop bar */
  .ds-search--bar-grid .ds-search__field--ctypmandat .select2-container--default .select2-selection--single .select2-selection__rendered,
  .ds-search--bar-grid .ds-search__field--ctypmandat .ds-search__select {
    font-size: 0.9rem;
  }

  .ds-search:not(.ds-search--bar-grid):not(.ds-search--listing) .ds-search__bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0;
    min-height: 72px;
    padding: 12px 14px 12px 24px;
    overflow: visible;
  }

  .ds-search:not(.ds-search--bar-grid):not(.ds-search--listing) .ds-search__field {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 12px;
  }

  .ds-search:not(.ds-search--bar-grid):not(.ds-search--listing) .ds-search__field:first-child {
    padding-left: 0;
  }

  .ds-search:not(.ds-search--bar-grid):not(.ds-search--listing) .ds-search__field--open {
    z-index: 40;
  }

  .ds-search:not(.ds-search--bar-grid):not(.ds-search--listing) .ds-search__actions {
    flex: 0 0 auto;
    justify-content: center;
    padding-left: 8px;
  }

  .ds-search:not(.ds-search--bar-grid):not(.ds-search--listing) .ds-search__submit {
    width: 52px;
    height: 52px;
  }
}

@media (max-width: 980px) {
  .ds-search--bar-grid:not(.ds-search--hero) .ds-search__bar {
    grid-template-columns: minmax(108px, 0.64fr) minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .ds-search--bar-grid:not(.ds-search--hero) .ds-search__bar {
    grid-template-columns: 1fr 1fr;
    padding: 14px 16px;
  }

  .ds-search--bar-grid:not(.ds-search--hero) .ds-search__field--ctyp,
  .ds-search--bar-grid:not(.ds-search--hero) .ds-search__field--localite {
    grid-column: 1 / -1;
  }

  .ds-search--bar-grid:not(.ds-search--hero) .ds-search__bar-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-left: 0;
    padding-top: 2px;
  }

  .ds-search--bar-grid:not(.ds-search--hero) .ds-search__bar-btn {
    padding: 0 18px;
  }
}

/* Homepage hero search — desktop stays inline columns; mobile = stacked 100% */
@media (max-width: 900px) {
  .ds-search--hero.ds-search--bar-grid .ds-search__bar,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: stretch;
    padding: 18px 16px;
  }

  .ds-search--hero.ds-search--bar-grid .ds-search__field,
  .ds-search--hero.ds-search--bar-grid .ds-search__field--ctypmandat,
  .ds-search--hero.ds-search--bar-grid .ds-search__field--ctyp,
  .ds-search--hero.ds-search--bar-grid .ds-search__field--localite,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__field,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__field--ctypmandat,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__field--ctyp,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__field--localite {
    grid-column: 1 / -1;
    width: 100%;
    max-width: none;
  }

  .ds-search--hero.ds-search--bar-grid .select2-container,
  .ds-hero-search-wrap .ds-search--bar-grid .select2-container {
    width: 100% !important;
  }

  .ds-search--hero.ds-search--bar-grid .ds-search__bar-actions,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__bar-actions {
    grid-column: 1 / -1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: stretch;
    padding: 0;
    gap: 10px;
  }

  .ds-search--hero.ds-search--bar-grid .ds-search__bar-btn,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__bar-btn {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    justify-content: center;
  }

  /* Same type size for every field while stacked (incl. transaction) */
  .ds-search--hero.ds-search--bar-grid .ds-search__input,
  .ds-search--hero.ds-search--bar-grid .ds-search__select,
  .ds-search--hero.ds-search--bar-grid .select2-container--default .select2-selection--single .select2-selection__rendered,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__input,
  .ds-hero-search-wrap .ds-search--bar-grid .ds-search__select,
  .ds-hero-search-wrap .ds-search--bar-grid .select2-container--default .select2-selection--single .select2-selection__rendered {
    font-size: 1rem;
  }
}
