/**
 * =============================================================================
 * FILTRES DE PRODUITS - STYLES COMPLETS
 * =============================================================================
 * Organisation:
 * 1. Styles de base des filtres
 * 2. Filtres de marques et promotions
 * 3. Filtre de prix (inputs + sliders)
 * 4. Sidebar desktop sticky
 * 5. Drawer mobile
 * 6. Indicateurs de chargement
 * 7. Encart publicitaire
 * 8. Badge stock faible
 * =============================================================================
 */

/* =============================================================================
   1. STYLES DE BASE DES FILTRES
   ============================================================================= */

.category-filter-sidebar .filter-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 1rem;
  border-bottom: 1px solid var(--wp--preset--color--color-text);
  padding-bottom: 10px;
  margin-bottom: 20px;
  margin-top: 20px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.category-filter-sidebar .filter-title:hover {
  color: var(--wp--preset--color--color-1);
}

.category-filter-sidebar .filter-title .toggle-icon {
  color: var(--wp--preset--color--color-1);
  transition: transform 0.3s ease;
}

.category-filter-sidebar .filter-content ul {
  padding-left: 0;
  list-style-type: none;
  margin-bottom: 25px;
}

.category-filter-sidebar .filter-content ul li {
  margin-bottom: 15px;
}

.category-filter-sidebar .filter-content ul li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
  gap: 10px;
  font-weight: 400;
  transition: all 0.2s ease;
}

.category-filter-sidebar .filter-content ul li a .product-count {
  text-transform: inherit;
  font-size: 0.875rem;
  background-color: #e9ecef;
  padding: 5px 15px;
  border-radius: 25px;
  text-align: center;
}

/* =============================================================================
   2. FILTRES DE MARQUES ET PROMOTIONS
   ============================================================================= */

.brand-list,
.promotion-list {
  padding-left: 0;
  list-style-type: none;
  margin-bottom: 25px;
}

.brand-list li,
.promotion-list li {
  margin-bottom: 15px;
}

.brand-list li a,
.promotion-list li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
  gap: 10px;
  font-weight: 400;
  text-decoration: none;
  color: inherit;
  padding: 5px 12px;
  border-radius: 4px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.promotion-list li a {
  background-color: var(--wp--preset--color--color-6);
  color: var(--wp--preset--color--color-1);
  font-weight: 600 !important;
  justify-content: center !important;
}

.brand-list li a:hover,
.promotion-list li a:hover {
  background-color: #f8f9fa;
  transform: translateX(5px);
}

.brand-list li a.active,
.promotion-list li a.active {
  background-color: var(--wp--preset--color--color-1);
  color: white;
  transform: translateX(5px);
}

.brand-list li a .product-count {
  text-transform: inherit;
  font-size: 0.75rem;
  background-color: #e9ecef;
  padding: 5px 15px;
  border-radius: 25px;
  text-align: center;
}

.brand-list li a.active .product-count {
  background-color: rgba(255, 255, 255, 0.9);
  color: var(--wp--preset--color--color-1);
  font-weight: 600;
}

/* =============================================================================
   3. FILTRE DE PRIX - INPUTS ET SLIDERS
   ============================================================================= */

/* --- Container principal --- */
.price-range-container {
  padding: 20px 0;
}

/* --- Inputs de prix --- */
.price-inputs-modern {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.price-field {
  flex: 1;
  min-width: 120px;
}

.price-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--wp--preset--color--color-1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.price-input-container {
  position: relative;
  display: flex;
  align-items: center;
  background: #fff;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  transition: all 0.3s ease;
  overflow: hidden;
}

.price-input-container:hover {
  border-color: var(--wp--preset--color--color-1);
  box-shadow: 0 0 0 4px rgba(230, 44, 161, 0.1);
}

.price-input-container:focus-within {
  border-color: var(--wp--preset--color--color-1);
  box-shadow: 0 0 0 4px rgba(230, 44, 161, 0.15);
}

.price-currency {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: var(--wp--preset--color--color-1);
  color: white;
  font-weight: 400;
  font-size: 0.875rem;
  height: 40px;
  min-width: 40px;
}

.price-input-container input[type="number"] {
  flex: 1;
  border: none;
  padding: 15px 16px;
  font-size: 1rem;
  font-weight: 600;
  background: transparent;
  color: #333;
  outline: none;
  height: 40px;
  appearance: textfield;
  -moz-appearance: textfield;
}

.price-input-container input[type="number"]::-webkit-outer-spin-button,
.price-input-container input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.price-input-container input[type="number"]::placeholder {
  color: #adb5bd;
  font-weight: 400;
}

.price-separator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px;
  height: 48px;
}

.separator-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, #e9ecef, transparent);
  border-radius: 1px;
}

.separator-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--wp--preset--color--color-1);
  background: #f8f9fa;
  padding: 4px 8px;
  border-radius: 8px;
  text-transform: lowercase;
}

/* --- Sliders de prix --- */
.price-range-slider {
  position: relative;
  height: 20px;
  margin: 15px 0 25px 0;
  padding: 0 8px;
}

.range-track {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background-color: var(--wp--preset--color--color-1);
  border-radius: 2px;
  z-index: 2;
}

.price-range-slider input[type="range"] {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  height: 4px;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: none;
  z-index: 3;
}

/* Track du slider */
.price-range-slider input[type="range"]::-webkit-slider-track {
  background: #e9ecef;
  height: 4px;
  border-radius: 2px;
  border: none;
}

.price-range-slider input[type="range"]::-moz-range-track {
  background: #e9ecef;
  height: 4px;
  border-radius: 2px;
  border: none;
}

/* Thumb du slider - Webkit (Chrome, Safari) */
.price-range-slider input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--wp--preset--color--color-1);
  cursor: pointer;
  pointer-events: auto;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.price-range-slider input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
}

/* Thumb du slider - Firefox */
.price-range-slider input[type="range"]::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--wp--preset--color--color-1);
  cursor: pointer;
  pointer-events: auto;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.price-range-slider input[type="range"]::-moz-range-thumb:hover {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
}

/* =============================================================================
   4. SIDEBAR DESKTOP STICKY
   ============================================================================= */

@media screen and (min-width: 992px) {
  .col-lg-3.sticky-lg-top {
    position: sticky;
    top: 120px;
    height: fit-content;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding-bottom: 20px;
  }

  /* Scrollbar discrète */
  .col-lg-3.sticky-lg-top::-webkit-scrollbar {
    width: 4px;
  }

  .col-lg-3.sticky-lg-top::-webkit-scrollbar-track {
    background: transparent;
  }

  .col-lg-3.sticky-lg-top::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
  }
}

/* =============================================================================
   5. DRAWER MOBILE
   ============================================================================= */

@media screen and (max-width: 991px) {
  /* Masquer la sidebar desktop */
  .category-filter-sidebar-desktop {
    display: none !important;
  }

  /* --- Bouton flottant "Filtrer" --- */
  .mobile-filter-toggle {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--wp--preset--color--color-1);
    color: #fff;
    border: none;
    padding: 14px 28px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(230, 44, 161, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
  }

  .mobile-filter-toggle:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 25px rgba(230, 44, 161, 0.5);
  }

  .mobile-filter-toggle i {
    font-size: 1.1rem;
  }

  /* Badge compteur de filtres actifs */
  .filter-count-badge {
    background-color: #fff;
    color: var(--wp--preset--color--color-1);
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
  }

  .filter-count-badge:empty,
  .filter-count-badge[data-count="0"] {
    display: none;
  }

  /* --- Overlay sombre --- */
  .mobile-filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .mobile-filter-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  /* --- Drawer des filtres --- */
  .mobile-filter-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 85vh;
    background-color: #fff;
    z-index: 1002;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .mobile-filter-drawer.active {
    transform: translateY(0);
  }

  /* --- Header du drawer --- */
  .mobile-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
    flex-shrink: 0;
  }

  .mobile-filter-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--wp--preset--color--color-8);
  }

  .mobile-filter-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: color 0.2s;
  }

  .mobile-filter-close:hover {
    color: var(--wp--preset--color--color-1);
  }

  /* Indicateur de drag */
  .mobile-filter-drag-indicator {
    width: 40px;
    height: 4px;
    background-color: #d1d5db;
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  /* --- Contenu scrollable du drawer --- */
  .mobile-filter-content {
    flex: 1;
    min-height: 0; /* CRITIQUE: Permet au flex child de scroller */
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .mobile-filter-content .filter-section {
    margin-bottom: 20px;
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 15px;
  }

  .mobile-filter-content .filter-section:last-child {
    border-bottom: none;
  }

  .mobile-filter-content .filter-title {
    margin-top: 0;
  }

  /* --- Footer du drawer --- */
  .mobile-filter-footer {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #e5e5e5;
    background-color: #f8f9fa;
    flex-shrink: 0;
  }

  .mobile-filter-reset {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid #e5e5e5;
    background-color: #fff;
    color: #666;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .mobile-filter-reset:hover {
    border-color: var(--wp--preset--color--color-1);
    color: var(--wp--preset--color--color-1);
  }

  .mobile-filter-apply {
    flex: 2;
    padding: 14px 20px;
    border: none;
    background-color: var(--wp--preset--color--color-1);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .mobile-filter-apply:hover {
    background-color: #c4289a;
  }

  /* --- Sliders de prix sur mobile --- */
  .price-range-slider {
    padding: 25px 8px;
    margin: 20px 0;
  }

  /* FIX CRITIQUE: touch-action: pan-x permet le mouvement horizontal du slider
     SANS bloquer le scroll vertical du drawer */
  #range-min,
  #range-max {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto !important;
    cursor: pointer;
    width: 100%;
    touch-action: pan-x !important;
  }

  /* Thumbs plus gros pour mobile */
  #range-min::-webkit-slider-thumb,
  #range-max::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    cursor: grab;
    pointer-events: auto !important;
    border-radius: 50%;
    background: var(--wp--preset--color--color-1);
    border: 3px solid white;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  }

  #range-min:active::-webkit-slider-thumb,
  #range-max:active::-webkit-slider-thumb {
    cursor: grabbing;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  #range-min::-moz-range-thumb,
  #range-max::-moz-range-thumb {
    width: 28px;
    height: 28px;
    cursor: grab;
    pointer-events: auto !important;
    border-radius: 50%;
    background: var(--wp--preset--color--color-1);
    border: 3px solid white;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
  }

  #range-min:active::-moz-range-thumb,
  #range-max:active::-moz-range-thumb {
    cursor: grabbing;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  /* Inputs de prix sur mobile */
  .price-inputs-modern {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }

  .price-field {
    width: 100%;
  }

  .price-separator {
    order: 2;
    flex-direction: row;
    justify-content: center;
    margin: 8px 0;
    height: auto;
  }

  .separator-line {
    display: none;
  }

  .separator-text {
    background: #f8f9fa;
    padding: 4px 12px;
    font-size: 0.75rem;
    color: var(--wp--preset--color--color-1);
    border-radius: 12px;
    border: 1px solid #e9ecef;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .price-input-container {
    border-radius: 10px;
  }

  .price-input-container input[type="number"] {
    font-size: 0.95rem;
    padding: 12px 14px;
    height: 44px;
  }

  .price-currency {
    height: 44px;
    font-size: 0.8rem;
    min-width: 38px;
    padding: 0 10px;
  }

  .price-label {
    font-size: 0.7rem;
    margin-bottom: 6px;
  }
}

/* --- Bloquer le scroll du body quand drawer ouvert --- */
body.drawer-open {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
}

/* =============================================================================
   6. RESPONSIVE - TABLETTES ET PETITS ÉCRANS
   ============================================================================= */

@media (min-width: 769px) and (max-width: 991px) {
  .price-inputs-modern {
    gap: 10px;
  }

  .price-separator {
    margin: 0 2px;
  }

  .separator-text {
    font-size: 0.8rem;
    padding: 3px 6px;
  }

  .price-input-container input[type="number"] {
    padding: 12px 14px;
    font-size: 0.95rem;
  }

  .price-currency {
    min-width: 38px;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .price-range-container {
    padding: 16px 0;
  }

  .price-inputs-modern {
    gap: 12px;
  }

  .price-input-container input[type="number"] {
    font-size: 0.9rem;
    padding: 10px 12px;
    height: 40px;
  }

  .price-currency {
    height: 40px;
    font-size: 0.75rem;
    min-width: 34px;
    padding: 0 8px;
  }

  .price-label {
    font-size: 0.65rem;
    margin-bottom: 4px;
  }

  .separator-text {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  .price-field {
    min-width: 100px;
  }
}

@media (max-width: 360px) {
  .price-range-container {
    padding: 12px 0;
  }

  .price-inputs-modern {
    gap: 10px;
  }

  .price-input-container input[type="number"] {
    font-size: 0.85rem;
    padding: 8px 10px;
    height: 36px;
  }

  .price-currency {
    height: 36px;
    font-size: 0.7rem;
    min-width: 30px;
    padding: 0 6px;
  }

  .price-label {
    font-size: 0.6rem;
    margin-bottom: 3px;
  }

  .separator-text {
    font-size: 0.65rem;
    padding: 2px 6px;
  }

  .price-field {
    min-width: 90px;
  }
}

/* =============================================================================
   7. INDICATEURS DE CHARGEMENT ET MESSAGES
   ============================================================================= */

.products-loading {
  text-align: center;
  padding: 40px 20px;
  background-color: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 20px;
}

.products-loading .spinner-border {
  color: var(--wp--preset--color--color-1);
  margin-bottom: 15px;
}

.products-loading p {
  margin: 0;
  color: #666;
  font-style: italic;
}

.no-products-message {
  text-align: center;
  padding: 60px 20px;
  background-color: #f8f9fa;
  border-radius: 12px;
  margin: 40px 0;
  border: 2px dashed #e9ecef;
}

.no-products-message h3 {
  color: var(--wp--preset--color--color-1);
  font-size: 1.5rem;
  margin-bottom: 15px;
  font-weight: 600;
}

.no-products-message p {
  color: #666;
  font-size: 1rem;
  margin: 0;
  line-height: 1.5;
}

/* =============================================================================
   8. ENCART PUBLICITAIRE SIDEBAR
   ============================================================================= */

.sidebar-ad-container {
  margin-top: 30px;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.sidebar-ad-container:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.sidebar-ad-link {
  display: block;
  position: relative;
  text-decoration: none;
  overflow: hidden;
}

.sidebar-ad-image {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  object-fit: cover;
}

.sidebar-ad-container:hover .sidebar-ad-image {
  transform: scale(1.03);
}

.sidebar-ad-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 5px 10px;
  border-radius: 20px;
  opacity: 0.85;
  transition: opacity 0.3s ease;
}

.sidebar-ad-container:hover .sidebar-ad-badge {
  opacity: 1;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sidebar-ad-container {
  animation: fadeInUp 0.5s ease forwards;
}

@media (max-width: 991px) {
  .sidebar-ad-container {
    margin-top: 20px;
    border-radius: 12px;
  }

  .sidebar-ad-badge {
    font-size: 0.6rem;
    padding: 4px 8px;
    top: 10px;
    left: 10px;
  }
}

@media (max-width: 767px) {
  .sidebar-ad-container {
    margin-top: 25px;
    margin-bottom: 15px;
    max-width: 100%;
  }
}

/* =============================================================================
   9. BADGE STOCK FAIBLE
   ============================================================================= */

.badge-low-stock {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 3;
  background-color: #ff6b35;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  animation: pulse-stock 2s infinite;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-low-stock i {
  font-size: 0.75rem;
}

@keyframes pulse-stock {
  0%,
  100% {
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
  }
  50% {
    box-shadow: 0 2px 15px rgba(255, 107, 53, 0.6);
  }
}

.badge-low-stock.critical {
  background-color: #dc3545;
  animation: pulse-stock-critical 1.5s infinite;
}

@keyframes pulse-stock-critical {
  0%,
  100% {
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 2px 15px rgba(220, 53, 69, 0.6);
    transform: scale(1.02);
  }
}

@media screen and (max-width: 767px) {
  .badge-low-stock {
    font-size: 0.65rem;
    padding: 4px 8px;
    bottom: 8px;
    right: 8px;
  }
}
