/**
 * Mobile Filters CSS — Bottom Sheet (<768) / Drawer droit (768–1023) pour catalogue PAC Air/Eau
 * Kadence Child Theme — Mon Énergie
 *
 * Stratégie (variante équilibrée) :
 *  - UNE seule bottom bar (fusion de l'ancienne barre haute + ancienne bottom bar fixe).
 *  - Panneau monté paresseusement via <template> au 1er clic (zéro nœud au chargement).
 *  - <768px : bottom sheet (translateY). 768–1023px : drawer droit (translateX). >=1024 : masqué.
 *  - Animations transform/opacity ONLY. Contrastes AAA visé. Cibles tactiles 44px.
 *
 * @package KadenceChildME
 * @since 1.2.0
 */

/* ============================================================
   BOTTOM BAR UNIQUE (mobile <1024px) — fixed en bas
   Filtres · Tri · Simuler
   ============================================================ */
.me-mobile-bar {
  display: none; /* masquée desktop, affichée <1024 via media query */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  min-height: 56px;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  align-items: center;
  gap: 8px;
}

/* Bouton Filtres (gauche, flex-1) */
.me-filter-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Geist', sans-serif;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #334155; /* slate-700 : contraste AAA */
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.me-filter-trigger:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.me-filter-trigger.has-active {
  border-color: #0058be;
  background: #eff6ff;
  color: #1e40af;
}

/* Compteur badge sur le bouton Filtres */
.me-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #0058be;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 0 6px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.me-filter-count:empty {
  display: none;
}

/* Tri inline (centre) */
.me-sort-inline {
  display: flex;
  align-items: center;
}

.me-sort-inline select {
  min-height: 44px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 30px 8px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Geist', sans-serif;
  background: #ffffff;
  color: #1e293b; /* slate-800 : AAA */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* CTA Simuler (droite) */
.me-bar-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 12px;
  border: none;
  font-size: 12px;
  font-weight: 800;
  font-family: 'Geist', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #d97706; /* amber-600 : contraste AAA sur blanc */
  color: #ffffff;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.me-bar-cta:hover,
.me-bar-cta:active {
  background: #b45309;
}

/* ============================================================
   CHIPS DE FILTRES ACTIFS (scroll horizontal, au-dessus de la grille)
   ============================================================ */
.me-active-chips {
  display: none; /* affiché <1024 via media query */
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 8px 12px 4px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.me-active-chips::-webkit-scrollbar {
  display: none;
}

.me-active-chips:not(:empty) {
  display: flex;
}

.me-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  font-size: 12px;
  font-weight: 600;
  color: #1e40af; /* AAA */
  white-space: nowrap;
  flex-shrink: 0;
  scroll-snap-align: start;
  cursor: default;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.me-chip.is-imm {
  border-color: #93c5fd;
}

.me-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #1d4ed8;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  margin-left: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}

.me-chip-remove:hover,
.me-chip-remove:active {
  background: #dbeafe;
  color: #1e3a8a;
}

/* ============================================================
   OVERLAY
   ============================================================ */
.me-filter-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  will-change: opacity;
}

.me-filter-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* ============================================================
   PANNEAU FILTRE — conteneur unique
   Par défaut (768–1023px) : drawer droit, translateX.
   <768px : bottom sheet, translateY (voir media query).
   ============================================================ */
.me-filter-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 400px;
  z-index: 101;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
  box-shadow: -4px 0 24px rgba(15, 23, 42, 0.12);
  /* inert géré en JS ; quand fermé non monté : pas de nœud. */
}

.me-filter-drawer.open {
  transform: translateX(0);
}

/* Grab handle (bottom sheet <768 uniquement) */
.me-grab {
  display: none;
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: #cbd5e1;
  margin: 8px auto 0;
}

/* Header du panneau */
.me-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.me-drawer-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
}

.me-drawer-title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  font-family: 'Geist', sans-serif;
  letter-spacing: -0.01em;
  margin: 0;
}

.me-drawer-count {
  font-size: 12px;
  font-weight: 600;
  color: #475569; /* slate-600 : AAA */
}

.me-drawer-clear {
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 4px;
  text-decoration: underline;
  -webkit-tap-highlight-color: transparent;
}

.me-drawer-clear:disabled {
  color: #94a3b8;
  text-decoration: none;
  cursor: not-allowed;
}

.me-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  border: none;
  background: #f1f5f9;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  font-size: 18px;
  touch-action: manipulation;
}

.me-drawer-close:hover,
.me-drawer-close:active {
  background: #e2e8f0;
  color: #0f172a;
}

/* Body scrollable */
.me-drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 18px;
  scrollbar-width: thin;
}

.me-drawer-body::-webkit-scrollbar {
  width: 4px;
}

.me-drawer-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Footer sticky (Voir N résultats / Effacer) */
.me-drawer-footer {
  display: flex;
  gap: 10px;
  padding: 12px 18px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  background: #ffffff;
}

.me-drawer-footer .me-btn-apply {
  flex: 2;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 14px;
  border: none;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  background: #0058be;
  color: #ffffff;
  transition: background 0.15s ease;
  touch-action: manipulation;
  font-family: 'Geist', sans-serif;
}

.me-drawer-footer .me-btn-apply:hover,
.me-drawer-footer .me-btn-apply:active {
  background: #003e84;
}

.me-drawer-footer .me-btn-reset {
  flex: 1;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px solid #e2e8f0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: #ffffff;
  color: #475569;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
  font-family: 'Geist', sans-serif;
}

.me-drawer-footer .me-btn-reset:hover:not(:disabled),
.me-drawer-footer .me-btn-reset:active:not(:disabled) {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}

.me-drawer-footer .me-btn-reset:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================================================
   SECTIONS / ACCORDÉONS — hiérarchie headings H2 > H3
   ============================================================ */
.me-filter-section {
  border-bottom: 1px solid #f1f5f9;
  padding: 6px 0;
}

.me-filter-section:last-child {
  border-bottom: none;
}

/* Header = bouton dans un H3 (corrige headings non séquentiels) */
.me-filter-section h3 {
  margin: 0;
}

.me-filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  cursor: pointer;
  padding: 6px 0;
  font-size: 14px;
  font-weight: 700;
  color: #1e293b; /* slate-800 : AAA */
  text-transform: none; /* lisibilité mobile : pas d'uppercase */
  letter-spacing: 0;
  background: none;
  border: none;
  font-family: 'Geist', sans-serif;
  text-align: left;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.me-filter-section-header::after {
  content: '';
  width: 20px;
  height: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.me-filter-section.open .me-filter-section-header::after {
  transform: rotate(180deg);
}

.me-filter-section-header .me-section-count {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 800;
  color: #0058be;
  background: #eff6ff;
  border-radius: 999px;
  padding: 2px 8px;
}

/* Body accordéon : grid-rows (composite-friendly, pas de max-height layout) */
.me-filter-section-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}

.me-filter-section.open .me-filter-section-body {
  grid-template-rows: 1fr;
}

.me-filter-section-body > .me-filter-section-body-inner {
  overflow: hidden;
  min-height: 0;
}

.me-filter-section-body-inner {
  padding: 8px 0 12px;
}

/* ============================================================
   MARQUES — recherche + liste scrollable
   ============================================================ */
.me-brand-search {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  background: #ffffff;
  font-family: 'Geist', sans-serif;
  margin-bottom: 8px;
}

.me-brand-search:focus {
  outline: none;
  border-color: #0058be;
  box-shadow: 0 0 0 3px rgba(0, 88, 190, 0.15);
}

.me-brand-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.me-brand-grid::-webkit-scrollbar {
  width: 4px;
}

.me-brand-grid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.me-brand-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  transition: background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.me-brand-check:hover {
  background: #f8fafc;
}

.me-brand-check input[type="checkbox"] {
  accent-color: #0058be;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin: 0;
}

.me-brand-check.checked {
  background: #eff6ff;
  font-weight: 700;
  color: #1e40af;
}

/* Marque masquée par la recherche */
.me-brand-check.is-hidden {
  display: none;
}

/* ============================================================
   RANGE INPUTS (puissance, prix)
   ============================================================ */
.me-range-group {
  margin-bottom: 12px;
}

.me-range-group:last-child {
  margin-bottom: 0;
}

.me-range-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.me-range-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.me-range-inputs input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
  font-family: 'Geist', sans-serif;
  -moz-appearance: textfield;
}

.me-range-inputs input[type="number"]:focus {
  outline: none;
  border-color: #0058be;
  box-shadow: 0 0 0 3px rgba(0, 88, 190, 0.15);
}

.me-range-inputs input[type="number"]::-webkit-outer-spin-button,
.me-range-inputs input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.me-range-inputs .me-range-sep {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 700;
}

/* ============================================================
   SELECTS du panneau
   ============================================================ */
.me-filter-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  background: #ffffff;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  font-family: 'Geist', sans-serif;
  cursor: pointer;
}

.me-filter-select:focus {
  outline: none;
  border-color: #0058be;
  box-shadow: 0 0 0 3px rgba(0, 88, 190, 0.15);
}

/* ============================================================
   TOGGLE BUTTONS (Phase, Courbes, ECS)
   ============================================================ */
.me-toggle-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.me-toggle-btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: #ffffff;
  color: #475569;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Geist', sans-serif;
}

.me-toggle-btn:hover {
  border-color: #cbd5e1;
}

.me-toggle-btn.active {
  background: #0058be;
  border-color: #0058be;
  color: #ffffff;
}

/* ============================================================
   ACCESSIBILITÉ : focus visible + sr-only
   ============================================================ */
.me-filter-trigger:focus-visible,
.me-toggle-btn:focus-visible,
.me-filter-select:focus-visible,
.me-drawer-close:focus-visible,
.me-drawer-clear:focus-visible,
.me-brand-search:focus-visible,
.me-drawer-footer .me-btn-apply:focus-visible,
.me-drawer-footer .me-btn-reset:focus-visible,
.me-brand-check input[type="checkbox"]:focus-visible {
  outline: 2px solid #0058be;
  outline-offset: 2px;
}

.me-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   RESPONSIVE : scission sheet / drawer + affichage bottom bar
   ============================================================ */

/* Bottom bar visible uniquement <1024px */
@media (max-width: 1023px) {
  .me-mobile-bar {
    display: flex;
  }

  /* La liste produit ne doit pas être masquée par la bottom bar */
  .me-content-placeholder {
    padding-bottom: 76px;
  }
}

/* === BOTTOM SHEET <768px === */
@media (max-width: 767px) {
  .me-filter-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.12);
  }

  .me-filter-drawer.open {
    transform: translateY(0);
  }

  .me-grab {
    display: block;
  }

  /* Grille produit 1 colonne sur mobile étroit */
  .me-card-grid {
    grid-template-columns: 1fr !important;
  }
}

/* === DRAWER DROIT 768–1023px : styles par défaut du conteneur === */
/* (déjà défini ci-dessus : max-width 400px, translateX) */

@media (min-width: 640px) and (max-width: 1023px) {
  .me-card-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Très petit mobile (<375px) : CTA Simuler raccourci */
@media (max-width: 374px) {
  .me-bar-cta {
    font-size: 11px;
    padding: 8px 12px;
  }
  .me-filter-trigger {
    font-size: 12px;
    padding: 8px 10px;
  }
}

/* Mode paysage sur mobile : basculer en drawer droit si hauteur < 500px */
@media (max-width: 767px) and (orientation: landscape) and (max-height: 500px) {
  .me-filter-drawer {
    top: 0;
    left: auto;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 400px;
    max-height: none;
    border-radius: 0;
    transform: translateX(100%);
  }
  .me-filter-drawer.open {
    transform: translateX(0);
  }
  .me-grab {
    display: none;
  }
}

/* ============================================================
   PREFERS-REDUCED-MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .me-filter-drawer,
  .me-filter-overlay,
  .me-filter-section-body,
  .me-filter-section-header::after,
  .me-filter-trigger,
  .me-filter-count {
    transition: none !important;
  }
}
