/* ───────────────────────────────────────────
 * Widget Elementor : Filtres + Grille logements
 * Layout (grille), style de base du panneau filtres,
 * et réconciliation avec les presets du shortcode ayn_filters.
 * Toutes les variables visuelles proviennent de assets/ui/tokens.css.
 * ─────────────────────────────────────────── */

.ayn-elem-filters-grid {
  --ayn-elem-filters-grid-gap: 28px;
  --ayn-elem-filters-grid-sidebar: 320px;
  display: grid;
  gap: var(--ayn-elem-filters-grid-gap);
  align-items: start;
  width: 100%;
  box-sizing: border-box;
}

.ayn-elem-filters-grid__filters,
.ayn-elem-filters-grid__results {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Hauteurs de colonnes : le panneau filtres peut devenir sticky sur desktop. */
.ayn-elem-filters-grid--filters-left .ayn-elem-filters-grid__filters,
.ayn-elem-filters-grid--filters-right .ayn-elem-filters-grid__filters {
  position: sticky;
  top: 24px;
  align-self: start;
}

/* ────── Layout positions ────── */
.ayn-elem-filters-grid--filters-top {
  grid-template-columns: minmax(0, 1fr);
}

.ayn-elem-filters-grid--filters-left {
  grid-template-columns: minmax(240px, var(--ayn-elem-filters-grid-sidebar)) minmax(0, 1fr);
}

.ayn-elem-filters-grid--filters-right {
  grid-template-columns: minmax(0, 1fr) minmax(240px, var(--ayn-elem-filters-grid-sidebar));
  grid-template-areas: "results filters";
}

.ayn-elem-filters-grid--filters-right .ayn-elem-filters-grid__filters {
  grid-area: filters;
}

.ayn-elem-filters-grid--filters-right .ayn-elem-filters-grid__results {
  grid-area: results;
}

/* ────── Reset de l'empilement des champs ────── */
.ayn-elem-filters-grid .ayn-filters__fields,
.ayn-elem-filters-grid .ayn-elem-filters__fields {
  min-width: 0;
}

.ayn-elem-filters-grid .ayn-elem-filters__field input,
.ayn-elem-filters-grid .ayn-elem-filters__field select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Filtres horizontaux en haut : grille fluide multi-colonnes. */
.ayn-elem-filters-grid--filters-top .ayn-filters--horizontal .ayn-filters__fields {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

/* Filtres horizontaux dans une sidebar : forcer l'empilement mono-colonne. */
.ayn-elem-filters-grid--filters-left .ayn-filters--horizontal .ayn-filters__fields,
.ayn-elem-filters-grid--filters-right .ayn-filters--horizontal .ayn-filters__fields {
  grid-template-columns: minmax(0, 1fr);
}

/* ────── Panneau filtres — design par défaut ────── */
/* Donne une carte premium même si l'utilisateur n'a rien configuré dans Elementor.
 * Chaque règle est surchargeable par les contrôles Style du widget. */
.ayn-elem-filters-grid__filters .ayn-elem-filters {
  background: var(--ayn-surface-1, #ffffff);
  border: 1px solid var(--ayn-border-subtle, rgba(15, 23, 42, 0.08));
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 18px 45px -30px rgba(15, 23, 42, 0.35);
}

/* Espacement entre les champs du panneau. */
.ayn-elem-filters-grid__filters .ayn-elem-filters__fields {
  gap: 16px;
}

/* Label + champ : hiérarchie nette. */
.ayn-elem-filters-grid__filters .ayn-elem-filters__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ayn-elem-filters-grid__filters .ayn-elem-filters__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ayn-text-muted, #64748b);
  margin-bottom: 0;
}

.ayn-elem-filters-grid__filters .ayn-elem-filters__field input,
.ayn-elem-filters-grid__filters .ayn-elem-filters__field select {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ayn-text, #0f172a);
  background: var(--ayn-surface-1, #ffffff);
  border: 1px solid var(--ayn-border, rgba(15, 23, 42, 0.14));
  border-radius: 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.ayn-elem-filters-grid__filters .ayn-elem-filters__field input:hover,
.ayn-elem-filters-grid__filters .ayn-elem-filters__field select:hover {
  border-color: var(--ayn-primary-soft, rgba(37, 99, 235, 0.35));
}

.ayn-elem-filters-grid__filters .ayn-elem-filters__field input:focus,
.ayn-elem-filters-grid__filters .ayn-elem-filters__field select:focus {
  outline: none;
  border-color: var(--ayn-primary, #2563eb);
  box-shadow: 0 0 0 3px var(--ayn-primary-softer, rgba(37, 99, 235, 0.18));
}

/* Chips de filtres actifs. */
.ayn-elem-filters-grid__filters .ayn-filters__chips {
  margin-top: 4px;
}

/* Barre d'actions. */
.ayn-elem-filters-grid__filters .ayn-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.ayn-elem-filters-grid__filters .ayn-elem-filters__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 120ms ease;
}

.ayn-elem-filters-grid__filters .ayn-elem-filters__btn:active {
  transform: translateY(1px);
}

.ayn-elem-filters-grid__filters .ayn-btn--primary.ayn-elem-filters__btn {
  background: var(--ayn-primary, #2563eb);
  color: #ffffff;
  box-shadow: 0 10px 24px -16px rgba(37, 99, 235, 0.55);
}

.ayn-elem-filters-grid__filters .ayn-btn--primary.ayn-elem-filters__btn:hover {
  background: var(--ayn-primary-hover, #1d4ed8);
  box-shadow: 0 14px 28px -14px rgba(37, 99, 235, 0.55);
}

.ayn-elem-filters-grid__filters .ayn-btn--ghost.ayn-elem-filters__btn {
  background: transparent;
  color: var(--ayn-text, #0f172a);
  border-color: var(--ayn-border, rgba(15, 23, 42, 0.14));
}

.ayn-elem-filters-grid__filters .ayn-btn--ghost.ayn-elem-filters__btn:hover {
  background: var(--ayn-primary-softer, rgba(37, 99, 235, 0.08));
  color: var(--ayn-primary, #2563eb);
  border-color: var(--ayn-primary-soft, rgba(37, 99, 235, 0.25));
}

/* Grille résultats : harmoniser avec le gap du layout. */
.ayn-elem-filters-grid__results .ayn-elem-listings {
  width: 100%;
}

/* ────── Responsive : empilement tablette/mobile ────── */
@media (max-width: 1024px) {
  .ayn-elem-filters-grid--stack-tablet.ayn-elem-filters-grid--filters-left,
  .ayn-elem-filters-grid--stack-tablet.ayn-elem-filters-grid--filters-right {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: initial;
  }

  .ayn-elem-filters-grid--stack-tablet .ayn-elem-filters-grid__filters,
  .ayn-elem-filters-grid--stack-tablet .ayn-elem-filters-grid__results {
    grid-area: auto;
  }

  .ayn-elem-filters-grid--stack-tablet .ayn-elem-filters-grid__filters {
    position: static;
  }

  .ayn-elem-filters-grid--stack-tablet .ayn-filters--horizontal .ayn-filters__fields {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 640px) {
  .ayn-elem-filters-grid {
    --ayn-elem-filters-grid-gap: 20px;
  }

  .ayn-elem-filters-grid__filters .ayn-elem-filters {
    padding: 18px;
    border-radius: 16px;
  }

  .ayn-elem-filters-grid .ayn-filters--horizontal .ayn-filters__fields {
    grid-template-columns: minmax(0, 1fr);
  }
}
