/* ═══════════════════════════════════════════════
   Alma Publications Filter v2 — filter.css
   Filtre URL → Loop Grid Elementor
   ═══════════════════════════════════════════════ */

:root {
  --apf-accent:       #1a6b8a;
  --apf-accent-light: #e8f4f8;
  --apf-accent-dark:  #134f69;
  --apf-border:       #e2e8f0;
  --apf-bg:           #f8fafc;
  --apf-text:         #1e293b;
  --apf-muted:        #64748b;
  --apf-radius:       8px;
  --apf-shadow:       0 1px 4px rgba(0,0,0,.08);
  --apf-transition:   .2s ease;
}

/* ── LAYOUT GLOBAL ───────────────────────────── */
/* Le filtre est placé AU-DESSUS du Loop Grid.
   Le wrapper est juste le panneau + overlay. */
.apf-wrapper {
  margin-bottom: 32px;
  position: relative;
  font-family: inherit;
  color: var(--apf-text);
}

/* ── PANNEAU FILTRES ─────────────────────────── */
.apf-panel {
  background: #fff;
  border: 1px solid var(--apf-border);
  border-radius: var(--apf-radius);
  box-shadow: var(--apf-shadow);
  overflow: visible;
}

/* Header */
.apf-panel__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  background: var(--apf-accent);
  color: #fff;
  font-weight: 600;
  font-size: .93rem;
  border-radius: var(--apf-radius) var(--apf-radius) 0 0;
  flex-wrap: wrap;
}
.apf-panel__header > span:first-of-type { flex: 1; }

/* Badge filtres actifs */
.apf-active-badge {
  background: #fff;
  color: var(--apf-accent);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Bouton reset */
.apf-reset {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .75rem;
  cursor: pointer;
  transition: background var(--apf-transition);
  white-space: nowrap;
}
.apf-reset:hover { background: rgba(255,255,255,.28); }

/* Corps du panneau : disposition horizontale */
.apf-panel__body {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-top: none;
}

/* ── GROUPES DE FILTRE ───────────────────────── */
/* Horizontaux dans le panneau */
.apf-filter-group {
  flex: 1;
  min-width: 200px;
  border-right: 1px solid var(--apf-border);
  border-bottom: 1px solid var(--apf-border);
}
.apf-filter-group:last-child { border-right: none; }

.apf-filter-group__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 18px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--apf-border);
  font-size: .82rem;
  font-weight: 600;
  color: var(--apf-text);
  cursor: pointer;
  text-align: left;
  transition: background var(--apf-transition);
}
.apf-filter-group__toggle:hover { background: var(--apf-bg); }

.apf-chevron {
  flex-shrink: 0;
  color: var(--apf-muted);
  transition: transform var(--apf-transition);
}
.apf-filter-group__toggle[aria-expanded="false"] .apf-chevron {
  transform: rotate(-90deg);
}

/* Contenu rétractable */
.apf-filter-group [id] {
  overflow: hidden;
  transition: max-height .28s ease, opacity .28s ease;
  max-height: 400px; /* valeur de départ ouverte */
  opacity: 1;
}
.apf-filter-group [id].apf-collapsed {
  max-height: 0 !important;
  opacity: 0;
  border-bottom: none;
}

/* ── CHECKLIST CATÉGORIES ────────────────────── */
.apf-checklist {
  list-style: none;
  margin: 0;
  padding: 10px 16px 14px;
  max-height: 230px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.apf-checklist li { margin: 0; }

.apf-check-label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 2px;
  cursor: pointer;
  font-size: .81rem;
  border-radius: 4px;
  transition: background var(--apf-transition);
  user-select: none;
}
.apf-check-label:hover { background: var(--apf-bg); padding-left: 4px; }

.apf-category-cb { display: none; }

.apf-checkmark {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border: 2px solid var(--apf-border);
  border-radius: 3px;
  position: relative;
  transition: border-color var(--apf-transition), background var(--apf-transition);
}
.apf-category-cb:checked + .apf-checkmark {
  background: var(--apf-accent);
  border-color: var(--apf-accent);
}
.apf-category-cb:checked + .apf-checkmark::after {
  content: '';
  position: absolute;
  left: 2px; top: 0;
  width: 5px; height: 8px;
  border: 2px solid #fff;
  border-top: none; border-left: none;
  transform: rotate(45deg);
}

.apf-check-text { flex: 1; color: var(--apf-text); }
.apf-count {
  font-size: .7rem;
  color: var(--apf-muted);
  background: var(--apf-bg);
  border: 1px solid var(--apf-border);
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
}

/* ── SLIDER ANNÉE ────────────────────────────── */
#apf-year-wrap {
  padding: 16px 20px 20px;
}

.apf-year-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: .95rem;
  font-weight: 700;
  color: var(--apf-accent);
  margin-bottom: 16px;
}
.apf-year-sep { color: var(--apf-muted); font-weight: 400; }

/* noUiSlider overrides */
#apf-year-slider.noUi-target {
  border: none;
  box-shadow: none;
  background: var(--apf-border);
  height: 4px;
  border-radius: 2px;
}
#apf-year-slider .noUi-connect {
  background: var(--apf-accent);
}
#apf-year-slider .noUi-handle {
  width: 18px;
  height: 18px;
  top: -7px;
  right: -9px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--apf-accent);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  cursor: grab;
}
#apf-year-slider .noUi-handle:active { cursor: grabbing; }
#apf-year-slider .noUi-handle::before,
#apf-year-slider .noUi-handle::after { display: none; }

/* ── LANGUE PILLS ────────────────────────────── */
.apf-lang-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 16px;
}

.apf-lang-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--apf-border);
  border-radius: 20px;
  background: #fff;
  font-size: .8rem;
  font-weight: 500;
  color: var(--apf-muted);
  cursor: pointer;
  transition: all var(--apf-transition);
}
.apf-lang-pill:hover {
  border-color: var(--apf-accent);
  color: var(--apf-accent);
}
.apf-lang-pill[aria-pressed="true"] {
  border-color: var(--apf-accent);
  background: var(--apf-accent);
  color: #fff;
}
.apf-lang-code {
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .04em;
  opacity: .75;
}
.apf-lang-pill[aria-pressed="true"] .apf-lang-code { opacity: .9; }

/* ── OVERLAY CHARGEMENT ──────────────────────── */
/* Positionné sur le Loop Grid, pas le panneau */
.apf-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99;
  border-radius: var(--apf-radius);
  pointer-events: none;
}
.apf-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--apf-border);
  border-top-color: var(--apf-accent);
  border-radius: 50%;
  animation: apf-spin .7s linear infinite;
}
@keyframes apf-spin { to { transform: rotate(360deg); } }

/* ── CLASSE SUR LE LOOP GRID ─────────────────── */
/* Ajouter « apf-loop-grid » au widget Loop Grid dans Elementor */
.apf-loop-grid {
  position: relative;
  transition: opacity .25s ease;
}
.apf-loop-grid.is-loading {
  opacity: .4;
  pointer-events: none;
}

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 768px) {
  .apf-filter-group {
    flex: 1 1 100%;
    border-right: none;
  }
}
