/**
 * MSW Filters — styles complets : facettes, bottom sheet, double range slider,
 * toggle, pagination, états de chargement.
 */

/* =================================================================== */
/* Variables & wrapper                                                  */
/* =================================================================== */

.msw-filters-wrap {
  --msw-filters-bg: var(--msw-modal-bg, #ffffff);
  --msw-filters-text: var(--msw-text, #1a1a1a);
  --msw-filters-text-secondary: var(--msw-text-secondary, #6b7280);
  --msw-filters-border: var(--msw-border, #e5e7eb);
  --msw-filters-accent: var(--msw-accent, #3b82f6);
  --msw-filters-hover-bg: var(--msw-hover-bg, #f3f4f6);
  --msw-filters-overlay: var(--msw-overlay-bg, rgba(0, 0, 0, 0.5));
  --msw-filters-radius: 12px;
  --msw-filters-radius-sm: 6px;

  color: var(--msw-filters-text);
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
}

.msw-filters-wrap *,
.msw-filters-wrap *::before,
.msw-filters-wrap *::after {
  box-sizing: border-box;
}

/* =================================================================== */
/* Bouclier anti-override Elementor / theme                             */
/* Neutralise les styles globaux sur button/select avant que les        */
/* règles spécifiques du plugin (plus précises) ne s'appliquent.        */
/* Spécificité : (0-1-0) + (0-0-1) = 0-1-1 < 0-2-0 des règles ci-bas  */
/* =================================================================== */

.msw-filters-wrap button,
.msw-filters-wrap select,
.msw-loop-header button,
.msw-loop-header select,
.msw-pagination-wrap button {
  box-sizing: border-box;
  font: inherit;
  letter-spacing: inherit;
  text-transform: none;
  text-decoration: none;
  color: inherit;
  background: none;
  background-color: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  box-shadow: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.msw-filters-error {
  padding: 12px 16px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: var(--msw-filters-radius-sm);
}

/* =================================================================== */
/* Toggle button                                                        */
/* =================================================================== */

/* Bouton fixe en bas de l'écran (mode sticky_toggle) */
.msw-filters-wrap--sticky-toggle.msw-filters-wrap--sheet-active .msw-filters-toggle {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9998;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

.msw-filters-wrap .msw-filters-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--msw-filters-bg);
  border: 1px solid var(--msw-filters-border);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  color: inherit;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.msw-filters-wrap .msw-filters-toggle:hover {
  background: var(--msw-filters-hover-bg);
}

.msw-filters-wrap .msw-filters-toggle__icon {
  flex: 0 0 auto;
}

.msw-filters-wrap .msw-filters-toggle__label {
  line-height: 1;
}

.msw-filters-wrap .msw-filters-toggle__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  margin-left: 4px;
  background: var(--msw-filters-accent);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.msw-filters-wrap--bottom_sheet_always .msw-filters-toggle,
.msw-filters-wrap--sheet-active .msw-filters-toggle {
  display: inline-flex;
}

/* =================================================================== */
/* Sheet container                                                      */
/* =================================================================== */

.msw-filters-sheet {
  position: relative;
}

.msw-filters-sheet__backdrop {
  display: none;
}

.msw-filters-sheet__panel {
  background: var(--msw-filters-bg);
  border: 1px solid var(--msw-filters-border);
  border-radius: var(--msw-filters-radius);
  padding: 20px;
}

.msw-filters-sheet__handle,
.msw-filters-sheet__header,
.msw-filters-sheet__footer {
  display: none;
}

/* --- Mode sheet active (mobile or always) --- */

.msw-filters-wrap--sheet-active .msw-filters-sheet {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  display: block;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet--open {
  pointer-events: auto;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet__backdrop {
  display: block;
  position: absolute;
  inset: 0;
  background: var(--msw-filters-overlay);
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet--open .msw-filters-sheet__backdrop {
  opacity: 1;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet__panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: min(85vh, 700px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
}

.msw-filters-wrap--sheet-active .msw-filters-sheet--open .msw-filters-sheet__panel {
  transform: translateY(0);
}

.msw-filters-wrap--sheet-active .msw-filters-sheet__handle {
  display: block;
  width: 40px;
  height: 4px;
  margin: 8px auto 4px;
  background: #d1d5db;
  border-radius: 999px;
  cursor: grab;
  touch-action: none;
  flex: 0 0 auto;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet__handle:active {
  cursor: grabbing;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  /* border-bottom: 1px solid var(--msw-filters-border); */
  flex: 0 0 auto;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet__close {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 6px;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s ease;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet__close:hover {
  background: var(--msw-filters-hover-bg);
}

.msw-filters-wrap--sheet-active .msw-filters {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 0 4px;
  -webkit-overflow-scrolling: touch;
  /* Permet les taps sur les éléments enfants sans conflit avec le scroll iOS */
  touch-action: pan-y;
}

/* Catégories intégrées dans le sheet */
.msw-sheet-cat-section {
  display: none;
}

.msw-filters-wrap--sheet-active .msw-sheet-cat-section {
  display: block;
  padding: 16px 20px 12px;
}

/* Titre : même style que .msw-facet__title */
.msw-filters-wrap--sheet-active .msw-sheet-cat-title {
  margin: 0 0 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Liens catégories : hérite de la couleur du texte parent */
.msw-filters-wrap--sheet-active .msw-sheet-cat-section .msw-cat__link {
  color: inherit;
}

/* Le padding de la liste des facettes passe au niveau de la liste en mode sheet */
.msw-filters-wrap--sheet-active .msw-filters__list {
  padding: 12px 20px 20px;
}

.msw-filters-wrap--sheet-active .msw-filters-sheet__footer {
  display: flex;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--msw-filters-border);
  flex: 0 0 auto;
  background: var(--msw-filters-bg);
}

/* Centered modal style on desktop when bottom_sheet_always */
@media (min-width: 768px) {
  .msw-filters-wrap--bottom_sheet_always .msw-filters-sheet__panel {
    max-width: 480px;
    max-height: min(80vh, 720px);
    margin: auto;
    border-radius: 16px;
    bottom: auto;
    top: 50%;
    left: 50%;
    right: auto;
    transform: translate(-50%, calc(-50% + 100vh));
  }
  .msw-filters-wrap--bottom_sheet_always .msw-filters-sheet--open .msw-filters-sheet__panel {
    transform: translate(-50%, -50%);
  }
}

/* =================================================================== */
/* Inline-only actions                                                  */
/* =================================================================== */

.msw-filters__inline-actions {
  display: flex;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--msw-filters-border);
}

.msw-filters-wrap--sheet-active .msw-filters__inline-actions {
  display: none;
}

/* =================================================================== */
/* Facets                                                               */
/* =================================================================== */

.msw-filters__list {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.msw-facet__title {
  margin: 0 0 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.msw-facet__placeholder {
  margin: 0;
  color: var(--msw-filters-text-secondary);
  font-size: 13px;
  font-style: italic;
}

/* --- Checkbox options --- */

.msw-facet--checkbox .msw-facet__options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

.msw-facet__option.msw-facet__option--collapsed {
  display: none;
}

.msw-facet__options--expanded .msw-facet__option.msw-facet__option--collapsed {
  display: flex;
}

.msw-filters-wrap .msw-facet__options-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  /* Tap target iOS min 44px */
  min-height: 44px;
  padding: 0;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.8125em;
  color: var(--msw-filters-text-secondary);
  cursor: pointer;
  /* iOS fix : évite le délai de 300ms et la capture de scroll */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: color 0.15s ease;
}

.msw-filters-wrap .msw-facet__options-toggle:hover {
  color: var(--msw-filters-text);
}

.msw-filters-wrap .msw-facet__options-toggle:focus-visible {
  outline: 2px solid var(--msw-filters-accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.msw-filters-wrap .msw-facet__options-toggle__icon {
  flex-shrink: 0;
  opacity: 0.6;
  transition: transform 0.2s ease;
}

.msw-facet__option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  margin: 0;
  cursor: pointer;
  border-radius: var(--msw-filters-radius-sm);
  transition: background 0.12s ease;
}

.msw-facet__option:hover {
  background: var(--msw-filters-hover-bg);
}

.msw-facet__option input[type='checkbox'] {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--msw-filters-accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.msw-facet__option-label {
  flex: 1 1 auto;
}

.msw-facet__option-count {
  flex: 0 0 auto;
  font-size: 0.875em;
  color: var(--msw-filters-text-secondary);
  background: var(--msw-filters-hover-bg);
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 28px;
  text-align: center;
}

.msw-facet__option--disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.msw-facet__option--disabled:hover {
  background: transparent;
}

/* --- Range slider (dual thumb) --- */

.msw-facet__range {
  --msw-range-min-pct: 0%;
  --msw-range-max-pct: 100%;
}

.msw-filters-wrap .msw-facet__range-inputs {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.msw-filters-wrap .msw-facet__range-inputs label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--msw-filters-text-secondary);
  font-weight: 500;
}

.msw-filters-wrap .msw-facet__range-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--msw-filters-border);
  border-radius: var(--msw-filters-radius-sm);
  font: inherit;
  font-size: 14px;
  color: var(--msw-filters-text);
  background: var(--msw-filters-bg);
}

.msw-filters-wrap .msw-facet__range-input:focus {
  outline: none;
  border-color: var(--msw-filters-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/*
 * Double range slider — superposition de deux <input type="range"> sur un
 * track visuel commun (pseudo-elements). Le track logique des inputs fait
 * 4px (= track visuel) ; les thumbs sont centrés via margin-top calculé
 * sur Webkit (Firefox centre automatiquement sur ::-moz-range-track).
 */

:root {
  --msw-range-thumb-size: 18px;
  --msw-range-track-h: 4px;
}

.msw-facet__range-sliders {
  position: relative;
  height: var(--msw-range-thumb-size);
}

/* Track de fond — pleine largeur */
.msw-facet__range-sliders::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: var(--msw-range-track-h);
  transform: translateY(-50%);
  background: var(--msw-filters-border);
  border-radius: 999px;
  pointer-events: none;
  z-index: 1;
}

/* Track actif — segment entre les deux thumbs */
.msw-facet__range-sliders::after {
  content: '';
  position: absolute;
  top: 50%;
  left: var(--msw-range-min-pct, 0%);
  right: calc(100% - var(--msw-range-max-pct, 100%));
  height: var(--msw-range-track-h);
  transform: translateY(-50%);
  background: var(--msw-filters-accent);
  border-radius: 999px;
  pointer-events: none;
  z-index: 2;
}

.msw-facet__range-slider {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--msw-range-thumb-size);
  margin: 0;
  padding: 0;
  background: transparent;
  pointer-events: none;
  z-index: 3;
  -webkit-appearance: none;
  appearance: none;
}

/* Tracks logiques invisibles — Webkit + Firefox */
.msw-facet__range-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: var(--msw-range-track-h);
  background: transparent;
  border: 0;
}

.msw-facet__range-slider::-moz-range-track {
  width: 100%;
  height: var(--msw-range-track-h);
  background: transparent;
  border: 0;
}

/* Thumbs — Webkit : margin-top calculé pour centrer sur le track de 4px */
.msw-facet__range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: var(--msw-range-thumb-size);
  height: var(--msw-range-thumb-size);
  border-radius: 50%;
  background: var(--msw-filters-bg);
  border: 2px solid var(--msw-filters-accent);
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  box-sizing: border-box;
  /* (track-h - thumb-h) / 2 = (4 - 18) / 2 = -7px */
  margin-top: calc((var(--msw-range-track-h) - var(--msw-range-thumb-size)) / 2);
}

.msw-facet__range-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
}

/* Thumbs — Firefox : centrage auto sur ::-moz-range-track */
.msw-facet__range-slider::-moz-range-thumb {
  pointer-events: auto;
  width: var(--msw-range-thumb-size);
  height: var(--msw-range-thumb-size);
  border-radius: 50%;
  background: var(--msw-filters-bg);
  border: 2px solid var(--msw-filters-accent);
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  box-sizing: border-box;
}

.msw-facet__range-slider::-moz-range-thumb:active {
  cursor: grabbing;
}

.msw-facet__range-slider:focus {
  outline: none;
}

.msw-facet__range-slider:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.msw-facet__range-slider:focus::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* --- Toggle (interrupteur) --- */

.msw-facet--toggle .msw-facet__title {
  margin-bottom: 6px;
}

.msw-filters-wrap .msw-facet__toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.msw-filters-wrap .msw-facet__toggle input[type='checkbox'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.msw-filters-wrap .msw-facet__toggle-track {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  background: var(--msw-filters-border);
  border-radius: 999px;
  transition: background 0.18s ease;
  flex: 0 0 auto;
}

.msw-filters-wrap .msw-facet__toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.msw-filters-wrap .msw-facet__toggle input[type='checkbox']:checked + .msw-facet__toggle-track {
  background: var(--msw-filters-accent);
}

.msw-filters-wrap
  .msw-facet__toggle
  input[type='checkbox']:checked
  + .msw-facet__toggle-track
  .msw-facet__toggle-thumb {
  transform: translateX(18px);
}

.msw-filters-wrap .msw-facet__toggle input[type='checkbox']:focus-visible + .msw-facet__toggle-track {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* =================================================================== */
/* Desktop collapse (bouton + état réduit)                              */
/* =================================================================== */

/* Header desktop : "Filtres" à gauche, bouton de collapse à droite.
   Visible uniquement sur les widgets --collapsible en desktop. */
.msw-filters-desktop-header {
  display: none;
}

.msw-filters-wrap--collapsible:not(.msw-filters-wrap--sheet-active) .msw-filters-desktop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--msw-filters-border, #e5e7eb);
  transition:
    margin 0.3s ease,
    padding 0.3s ease,
    border-color 0.3s ease;
}

.msw-filters-desktop-header__title {
  font-weight: 600;
  font-size: 15px;
  color: var(--msw-filters-text, #1a1a1a);
  /* Transition opacity+visibility pour un fade-out propre quand on replie. */
  opacity: 1;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}

/* Bouton de collapse : visible uniquement en mode --collapsible desktop. */
.msw-filters-collapse {
  display: none;
}

.msw-filters-wrap--collapsible:not(.msw-filters-wrap--sheet-active) .msw-filters-collapse {
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--msw-filters-radius-sm, 6px);
  color: var(--msw-filters-text, #1a1a1a);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

/* .msw-filters-collapse__icon : l'icône reste identique dans les deux
   états (pas de flip), seule la position du bouton change quand le
   panneau est replié. Pas de règle nécessaire. */

.msw-filters-wrap--collapsible:not(.msw-filters-wrap--sheet-active) .msw-filters-collapse:hover {
  background: var(--msw-filters-hover-bg, #f3f4f6);
  color: var(--msw-filters-accent, #3b82f6);
}

.msw-filters-wrap--collapsible:not(.msw-filters-wrap--sheet-active) .msw-filters-collapse:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--msw-filters-accent, #3b82f6) 25%, transparent);
}

@supports not (box-shadow: 0 0 0 3px color-mix(in srgb, red 25%, transparent)) {
  .msw-filters-wrap--collapsible:not(.msw-filters-wrap--sheet-active) .msw-filters-collapse:focus-visible {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  }
}

/* Transitions de base : on les déclare sur l'état déployé (par défaut)
   pour qu'elles jouent dans les deux sens (déploiement ET repli). Si on
   les met seulement sur --collapsed, l'animation ne joue qu'au repli.
   - opacity + visibility avec delay 0.3s : le wrap réapparaît APRÈS que
     la colonne se soit élargie (cf. theme child : la right-col passe de
     0% à 25% en 0.3s sans delay). Sinon le wrap s'affiche pendant que
     la colonne est encore à 0% et "saute" en place. */
.msw-filters-wrap--collapsible:not(.msw-filters-wrap--sheet-active) {
  opacity: 1;
  visibility: visible;
  transition:
    width 0.3s ease,
    min-width 0.3s ease,
    flex-basis 0.3s ease,
    opacity 0.2s ease 0.3s,
    visibility 0s ease 0.3s;
}

/* Sur le panel : on transitionne padding ET max-height. Le max-height
   sert à éviter que le panel reste à la hauteur de son contenu en mode
   replié — sinon les facettes (en opacity 0 mais toujours dans le flux)
   continueraient de pousser la hauteur, donnant l'impression que la
   bande verticale "prend toute la hauteur".
   - À l'ouverture (default) : pas de delay, max-height passe à 2000px
     en 0.3s, puis le fade-in du contenu démarre (delay 0.3s sur opacity).
   - À la fermeture (collapsed) : on attend 0.2s que le contenu fade-out
     avant de contracter max-height. */
.msw-filters-wrap--collapsible:not(.msw-filters-wrap--sheet-active) .msw-filters-sheet__panel {
  max-height: 2000px;
  overflow: hidden;
  transition:
    padding 0.3s ease 0s,
    max-height 0.3s ease 0s,
    min-height 0.3s ease 0s;
}

/* État replié : le wrap disparaît visuellement (opacity 0) et la colonne
   parente (cf. theme child :has()) shrink à 0%. Le bouton de réouverture
   apparaît ailleurs (dans le loop header, à côté du sélecteur de tri).
   On utilise opacity + visibility + pointer-events plutôt que display:
   none pour autoriser la transition. */
.msw-filters-wrap--collapsed:not(.msw-filters-wrap--sheet-active) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease 0s,
    visibility 0s ease 0.2s;
}

/* Transitions sur le contenu interne du panel pour orchestrer un fade-out
   propre avant la réduction de largeur (et l'inverse à l'ouverture).
   Séquence visée :
   - Fermeture : fade-out 0.2s (sans delay) → la width des colonnes
                  rétrécit ensuite avec un delay 0.2s (cf. theme child)
   - Ouverture : width des colonnes s'élargit sans delay 0.3s → fade-in
                  0.2s avec delay 0.3s

   Important : pas de `display: none` ici, sinon le contenu n'est plus
   transitionnable. On utilise opacity + visibility, en laissant
   `overflow: hidden` du panel masquer ce qui déborde. */
.msw-filters-wrap--collapsible:not(.msw-filters-wrap--sheet-active)
  .msw-filters-sheet__panel > *:not(.msw-filters-desktop-header):not(.msw-filters-sheet__handle) {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 0.2s ease 0.3s,
    visibility 0s ease 0.3s;
}

.msw-filters-wrap--collapsed:not(.msw-filters-wrap--sheet-active)
  .msw-filters-sheet__panel > *:not(.msw-filters-desktop-header):not(.msw-filters-sheet__handle) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease 0s,
    visibility 0s ease 0.2s;
}

/* En mode replié, on garde le header en row + space-between (la même
   structure flex qu'en déployé) : le titre est masqué (width 0) et le
   bouton reste ancré à droite. Pour LE CENTRER dans la bande étroite,
   on ajoute un `padding-right` qui grandit en parallèle du rétrécissement
   de la colonne — le bouton se rapproche progressivement du centre au
   lieu de "snapper" en fin de transition.
   - 18px = moitié de la largeur du bouton (36px) en mode replié, donc
     `calc(50% - 18px)` place le centre du bouton au centre du header. */
.msw-filters-wrap--collapsed:not(.msw-filters-wrap--sheet-active) .msw-filters-desktop-header {
  gap: 0;
  margin: 0;
  padding: 0 calc(50% - 18px) 0 0;
  border-bottom-color: transparent;
  transition:
    margin 0.3s ease 0.2s,
    padding 0.3s ease 0.2s,
    border-color 0.3s ease 0.2s;
}

.msw-filters-wrap--collapsed:not(.msw-filters-wrap--sheet-active) .msw-filters-desktop-header__title {
  opacity: 0;
  visibility: hidden;
  width: 0;
  max-width: 0;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
}

.msw-filters-wrap--collapsed:not(.msw-filters-wrap--sheet-active) .msw-filters-collapse {
  width: 36px;
  height: 36px;
}

/* Si le widget est dans une colonne Elementor qui utilise :has(),
   on tente aussi de forcer la colonne parente à se rétrécir. Les
   navigateurs sans :has() ignorent silencieusement la règle, et le
   user peut alors configurer manuellement sa colonne en width auto. */
@supports selector(:has(*)) {
  .elementor-element:has(> .elementor-widget-container > .msw-filters-wrap--collapsed),
  .elementor-widget:has(> .elementor-widget-container > .msw-filters-wrap--collapsed) {
    width: auto !important;
    flex: 0 0 auto !important;
  }
}

/* =================================================================== */
/* Facette select (dropdown)                                            */
/* =================================================================== */

.msw-facet__select-wrap {
  display: block;
  width: 100%;
}

.msw-filters-wrap .msw-facet__select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--msw-filters-border, #e5e7eb);
  border-radius: var(--msw-filters-radius-sm, 6px);
  background-color: var(--msw-filters-bg, #ffffff);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  font: inherit;
  font-size: 14px;
  color: var(--msw-filters-text, #1a1a1a);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.msw-filters-wrap .msw-facet__select:hover {
  border-color: var(--msw-filters-accent, #3b82f6);
}

.msw-filters-wrap .msw-facet__select:focus-visible {
  outline: none;
  border-color: var(--msw-filters-accent, #3b82f6);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--msw-filters-accent, #3b82f6) 20%, transparent);
}

@supports not (box-shadow: 0 0 0 3px color-mix(in srgb, red 20%, transparent)) {
  .msw-filters-wrap .msw-facet__select:focus-visible {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  }
}

/* Multi-sélection : on retire la flèche custom (la listbox native n'en a
   pas), on agrandit la zone et on contraint la hauteur pour qu'elle reste
   scrollable. */
.msw-facet__select-wrap--multi .msw-facet__select,
.msw-filters-wrap .msw-facet__select[multiple] {
  background-image: none;
  padding: 6px 8px;
  min-height: 140px;
  max-height: 240px;
  cursor: default;
}

.msw-filters-wrap .msw-facet__select[multiple] option {
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.msw-filters-wrap .msw-facet__select[multiple] option:checked {
  background: color-mix(in srgb, var(--msw-filters-accent, #3b82f6) 12%, transparent);
  color: var(--msw-filters-text, #1a1a1a);
  font-weight: 500;
}

.msw-filters-wrap .msw-facet__select option:disabled {
  color: var(--msw-filters-text-secondary, #9ca3af);
}

@supports not (background: color-mix(in srgb, red 12%, transparent)) {
  .msw-filters-wrap .msw-facet__select[multiple] option:checked {
    background: rgba(59, 130, 246, 0.12);
  }
}

/* =================================================================== */
/* Action buttons (Reset / Apply)                                       */
/* =================================================================== */

.msw-filters-wrap .msw-filters__reset,
.msw-filters-wrap .msw-filters__apply {
  flex: 1 1 auto;
  padding: 12px 16px;
  border-radius: var(--msw-filters-radius-sm);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--msw-filters-border);
  background: var(--msw-filters-bg);
  color: inherit;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.msw-filters-wrap .msw-filters__reset:hover {
  background: var(--msw-filters-hover-bg);
}

.msw-filters-wrap .msw-filters__apply {
  background: var(--msw-filters-accent);
  color: #fff;
  border-color: var(--msw-filters-accent);
  font-weight: 600;
}

.msw-filters-wrap .msw-filters__apply:hover {
  filter: brightness(0.95);
}

.msw-filters-wrap .msw-filters__apply-count {
  margin-left: 6px;
  font-weight: 500;
  opacity: 0.85;
}

/* =================================================================== */
/* Loading states                                                       */
/* =================================================================== */

.msw-filters-wrap--loading .msw-filters__list {
  opacity: 0.6;
  pointer-events: none;
}

.msw-loop-loading {
  position: relative;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.2s ease-out;
}

.msw-loop-loading > * {
  pointer-events: none !important;
}

.msw-loop-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
  z-index: 1;
}

@keyframes msw-loop-item-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msw-loop-item--entering {
  animation: msw-loop-item-in 0.32s ease-out both;
}

@media (prefers-reduced-motion: reduce) {
  .msw-loop-item--entering {
    animation: none;
  }
}

.msw-no-results {
  padding: 40px 20px;
  text-align: center;
  color: var(--msw-filters-text-secondary);
  font-size: 15px;
}

/* =================================================================== */
/* Pagination                                                           */
/* =================================================================== */

.msw-pagination-wrap {
  width: 100%;
  margin-top: 32px;
  display: flex;
  justify-content: center;
}

.msw-pagination {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.msw-pagination__page,
.msw-pagination__nav {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--msw-filters-border);
  background: var(--msw-filters-bg);
  color: inherit;
  border-radius: var(--msw-filters-radius-sm);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.msw-pagination__page:hover,
.msw-pagination__nav:hover {
  background: var(--msw-filters-hover-bg);
}

.msw-pagination__page--current {
  background: var(--msw-filters-accent);
  border-color: var(--msw-filters-accent);
  color: #fff;
  font-weight: 600;
  cursor: default;
}

.msw-pagination__page--current:hover {
  background: var(--msw-filters-accent);
}

.msw-pagination__ellipsis {
  padding: 0 4px;
  color: var(--msw-filters-text-secondary);
}

.msw-pagination-wrap .msw-load-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 28px;
  border: 1px solid #07042d !important;
  background: #07042d;
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    opacity 0.15s ease;
  position: relative;
}

.msw-pagination-wrap .msw-load-more:hover:not(:disabled) {
  border: 1px solid #07042d !important;
  background: transparent;
  color: #07042d;
}

.msw-pagination-wrap .msw-load-more:disabled {
  cursor: wait;
}

.msw-pagination-wrap .msw-load-more::before {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  display: none;
  animation: msw-spinner 0.7s linear infinite;
}

.msw-pagination-wrap .msw-load-more--loading {
  opacity: 0.7;
  color: var(--msw-filters-accent);
  background: var(--msw-filters-bg);
}

.msw-pagination-wrap .msw-load-more--loading::before {
  display: inline-block;
}

.msw-pagination-wrap .msw-load-more--loading:hover {
  background: var(--msw-filters-bg);
  color: var(--msw-filters-accent);
}

@keyframes msw-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* =================================================================== */
/* Loop header (badges + sort bar)                                     */
/* =================================================================== */

.msw-loop-header {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 0 14px;
}

/* =================================================================== */
/* Sort bar                                                             */
/* =================================================================== */

.msw-sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Bouton de réouverture du panneau filtres injecté dans la sort bar.
   Caché par défaut, visible seulement quand le wrap MSW correspondant
   est en mode `--collapsed`. On utilise `:has()` (largement supporté en
   2026) pour la détection : la classe est posée sur le wrap quelque part
   dans la page (souvent dans une autre colonne Elementor), donc on
   remonte au body pour faire le matching.
   Trick d'animation : le bouton reste toujours `display: inline-flex`
   mais avec width 0, opacity 0 et padding 0 par défaut → il ne prend
   pas de place visible. À l'apparition, on transitionne ces valeurs
   avec un delay 0.3s pour attendre la fin du fade-out du wrap et du
   rétrécissement de la colonne. */
.msw-loop-header .msw-filters-expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0;
  height: 36px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  border-radius: var(--msw-filters-radius-sm, 6px);
  color: inherit;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease 0s,
    visibility 0s ease 0.2s,
    width 0.2s ease 0s,
    background 0.15s ease,
    color 0.15s ease;
}

body:has(.msw-filters-wrap--collapsed) .msw-loop-header .msw-filters-expand {
  width: 36px;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 0.2s ease 0.3s,
    visibility 0s ease 0.3s,
    width 0.2s ease 0.3s,
    background 0.15s ease,
    color 0.15s ease;
}

.msw-loop-header .msw-filters-expand:hover {
  background: var(--msw-filters-hover-bg, #f3f4f6);
  color: var(--msw-filters-accent, #3b82f6);
}

.msw-loop-header .msw-filters-expand:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--msw-filters-accent, #3b82f6) 25%, transparent);
}

@supports not (box-shadow: 0 0 0 3px color-mix(in srgb, red 25%, transparent)) {
  .msw-loop-header .msw-filters-expand:focus-visible {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
  }
}

.msw-filters-expand__icon {
  display: block;
}

.msw-sort-bar__label {
  font-size: 13px;
  color: var(--msw-filters-text-secondary, #6b7280);
  white-space: nowrap;
}

.msw-loop-header .msw-sort-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 32px 6px 12px;
  border: 1px solid var(--msw-filters-border, #e5e7eb);
  border-radius: 999px;
  background-color: var(--msw-filters-bg, #ffffff);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--msw-filters-text, #1a1a1a);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.msw-loop-header .msw-sort-select:hover {
  border-color: var(--msw-filters-accent, #3b82f6);
}

.msw-loop-header .msw-sort-select:focus-visible {
  outline: none;
  border-color: var(--msw-filters-accent, #3b82f6);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--msw-filters-accent, #3b82f6) 20%, transparent);
}

@supports not (box-shadow: 0 0 0 3px color-mix(in srgb, red 20%, transparent)) {
  .msw-sort-select:focus-visible {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  }
}

/* =================================================================== */
/* Active filter badges                                                 */
/* =================================================================== */

.msw-active-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.msw-active-badges[hidden] {
  display: none;
}

.msw-active-badges .msw-active-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 12px;
  background: #07042d;
  color: #fff;
  border: 1px solid #07042d !important;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.1s ease;
  white-space: nowrap;
}

.msw-active-badges .msw-active-badge:hover {
  background: transparent;
}

/* fallback for browsers without color-mix */
@supports not (background: color-mix(in srgb, red 80%, blue)) {
  .msw-active-badge:hover {
    opacity: 0.85;
  }
}

.msw-active-badges .msw-active-badge:active {
  transform: scale(0.95);
}

.msw-active-badges .msw-active-badge:focus-visible {
  outline: 2px solid var(--msw-filters-accent, #3b82f6);
  outline-offset: 2px;
  background: color-mix(in srgb, var(--msw-filters-accent, #3b82f6) 85%, #000);
}

.msw-active-badges .msw-active-badge__label {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msw-active-badges .msw-active-badge__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.15s ease;
}

.msw-active-badges .msw-active-badge:hover .msw-active-badge__remove {
  background: rgba(255, 255, 255, 0.4);
}

@keyframes msw-badge-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.msw-active-badges .msw-active-badge {
  animation: msw-badge-in 0.15s ease both;
}

.msw-active-badges .msw-active-badges__reset {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--msw-filters-border, #e5e7eb);
  font: inherit;
  font-size: 13px;
  color: #07042d !important;
  cursor: pointer;
  white-space: nowrap;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
  flex-shrink: 0;
}

.msw-active-badges .msw-active-badges__reset:hover {
  border-color: var(--msw-filters-text, #1a1a1a);
  color: white !important;
  background: #07042d;
}

button.msw-facet__options-toggle:focus {
  border: none;
}

/* ----------------------------------------------------------------- */
/*  Recherche textuelle (input dans le panel)                        */
/* ----------------------------------------------------------------- */

.msw-filters-search {
  --msw-search-pad-x: 16px;
  --msw-search-icon-size: 20px;
  --msw-search-icon-gap: 12px; /* gap between icon and text */
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 calc(var(--msw-search-pad-x) + 16px);
  margin-bottom: 12px;
  margin-left: -16px;
}

.msw-filters-wrap--inline .msw-filters-search {
  --msw-search-pad-x: 0px;
  margin-bottom: 16px;
}

/* Icône loupe — positionnée à l'intérieur de la zone visuelle de l'input */
.msw-filters-search__icon,
.msw-filters-search__spinner {
  position: absolute;
  /* Container padding + icon offset relative to the input's visual left edge */
  left: calc(var(--msw-search-pad-x) + 12px);
  top: 50%;
  transform: translateY(-50%);
  width: var(--msw-search-icon-size);
  height: var(--msw-search-icon-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--msw-filters-text-secondary, #6b7280);
  pointer-events: none;
}

/* Specificity bumped (`.msw-filters-wrap` ancestor) to override theme / Elementor
   resets that often target `input[type="search"]` with !important padding. */
.msw-filters-wrap .msw-filters-search .msw-filters-search__input,
.msw-filters-wrap .msw-filters-search input.msw-filters-search__input[type='search'] {
  flex: 1 1 auto;
  min-width: 0;
  box-sizing: border-box;
  /* Left padding = icon offset (12px) + icon size + gap → text never overlaps the icon */
  padding-top: 10px;
  padding-bottom: 10px;
  padding-right: 42px;
  padding-left: calc(12px + var(--msw-search-icon-size) + var(--msw-search-icon-gap));
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--msw-filters-text, #1a1a1a);
  background: var(--msw-input-bg, #fff);
  border: 1px solid var(--msw-filters-border, #e5e7eb);
  border-radius: 8px;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.msw-filters-wrap .msw-filters-search__input::placeholder {
  color: var(--msw-filters-text-secondary, #6b7280);
  opacity: 1;
}

.msw-filters-wrap .msw-filters-search__input:focus {
  border-color: var(--msw-filters-accent, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

/* Hide native clear cross on iOS/WebKit (we have our own) */
.msw-filters-search__input::-webkit-search-cancel-button,
.msw-filters-search__input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

/* Spinner — visible only when the widget is loading */
.msw-filters-search__spinner {
  display: none; /* hidden by default */
  box-sizing: border-box;
  border: 2px solid var(--msw-filters-border, #e5e7eb);
  border-top-color: var(--msw-filters-accent, #3b82f6);
  border-radius: 50%;
  animation: msw-search-spin 0.7s linear infinite;
  /* The width/height already inherit from the shared rule above */
}

.msw-filters-wrap--loading .msw-filters-search__icon {
  visibility: hidden;
}

.msw-filters-wrap--loading .msw-filters-search__spinner {
  display: inline-flex;
}

@keyframes msw-search-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* Respect users' reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .msw-filters-search__spinner {
    animation-duration: 1.6s;
  }
}

/* Bouton clear (×) — à droite de l'input */
.msw-filters-search__clear {
  position: absolute;
  right: calc(var(--msw-search-pad-x) + 8px);
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--msw-filters-border, #e5e7eb);
  color: var(--msw-filters-text, #1a1a1a);
  border-radius: 50%;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.msw-filters-search__clear:hover {
  background: var(--msw-filters-text-secondary, #6b7280);
  color: #fff;
}

.msw-filters-search__clear:focus-visible {
  outline: 2px solid var(--msw-filters-accent, #3b82f6);
  outline-offset: 2px;
}

.msw-filters-search__clear[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .msw-filters-search__input {
    font-size: 16px; /* prevent iOS zoom-on-focus */
  }
}

form.msw-filters {
  margin-top: 30px;
}
