/**
 * Horex Filtres - Styles CSS optimisés
 * 
 * Version optimisée pour la performance et le chargement
 */

/* 1. Variables et réglages - Centralisés pour une meilleure maintenance */
:root {
  --horex-primary-color: #d02e26;
  --horex-text-color: #333;
  --horex-light-text: #999;
  --horex-border-color: #ccc;
  --horex-bg-color: #fff;
  --horex-hover-bg: #f9f9f9;
  --horex-padding: 12px;
  --horex-border-radius: 15px;
  --horex-font-family: "Lato", sans-serif;
  --horex-transition: 0.2s ease;
  --horex-shadow: 0 0 0 2px rgba(208, 46, 38, 0.1);
}

/* 2. Structure principale - Sélecteurs optimisés */
#horex-filters-form {
  font-family: var(--horex-font-family);
  color: var(--horex-text-color);
  contain: content; /* Amélioration pour l'isolation de contenu */
  width: 100%;
}

.horex-filters-columns {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-top: 10px;
}

/* 3. Éléments d'en-tête - Simplifié */
.horex-filters-header {
  display: flex;
  justify-content: space-between; /* Simplifie la structure */
  align-items: center;
  margin-bottom: 1rem;
}

.horex-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

#horex-reset-filters {
  color: var(--horex-light-text);
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color var(--horex-transition);
}

#horex-reset-filters:hover {
  text-decoration: underline;
}

/* 4. Attributs et dropdowns - Rationalisé */
.horex-filter-attribute + .horex-filter-attribute {
  margin-top: 0; /* Simplifie la gestion des marges */
}

.horex-filter-attribute-label {
  display: block;
  cursor: pointer;
  padding: var(--horex-padding) 0;
  margin: 0;
  border-top: 1px solid var(--horex-border-color);
  font-weight: 600;
  position: relative;
  transition: color var(--horex-transition);
}

/* Arrow indicator - Optimisé avec transform */
.horex-filter-attribute-label::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-top-color: var(--horex-light-text);
  transition: transform var(--horex-transition);
}

.custom-multiple-dropdown.open .horex-filter-attribute-label::after {
  transform: translateY(-50%) rotate(180deg);
}

.horex-filter-attribute:first-of-type .horex-filter-attribute-label {
  border-top: none;
}

/* Dropdown container - Simplifié */
.custom-multiple-dropdown {
  width: 100%;
  position: relative;
}

/* Dropdown list - Optimisé pour la performance */
.custom-dropdown-list {
  display: none;
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  will-change: transform, opacity; /* Améliore les animations */
}

.custom-multiple-dropdown.open .custom-dropdown-list {
  display: block;
  animation: fadeIn 0.15s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Optimisation: Sélecteurs simplifiés */
.custom-dropdown-list li {
  position: relative;
}

/* Checkbox labels - Simplifié */
.custom-dropdown-list label {
  display: flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
  padding: 5px 8px;
  margin: 0;
  width: 100%;
  transition: color var(--horex-transition);
}

.custom-dropdown-list label:hover {
  color: var(--horex-primary-color); 
}

/* Custom checkbox styling - Plus efficace */
.custom-dropdown-list input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--horex-border-color);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  position: relative;
  background-color: var(--horex-bg-color);
  transition: border-color var(--horex-transition), background-color var(--horex-transition);
}

.custom-dropdown-list input[type="checkbox"]:checked {
  background-color: var(--horex-primary-color);
  border-color: var(--horex-primary-color);
}

.custom-dropdown-list input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.custom-dropdown-list input[type="checkbox"]:focus {
  border-color: var(--horex-primary-color);
  box-shadow: var(--horex-shadow);
}

/* 5. Contrôles de formulaire - Optimisé */
.horex-flex-row {
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--horex-border-color);
  padding: var(--horex-padding) 0;
}

.horex-filters-form label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
}

/* Style unique pour les champs de formulaire */
#horex-filters-form input[type="number"] {
  width: 100%;
  border: 1px solid var(--horex-border-color);
  border-radius: var(--horex-border-radius);
  padding: 8px;
  margin-top: 10px;
  box-shadow: none;
  background-color: transparent;
  transition: border-color var(--horex-transition), box-shadow var(--horex-transition);
  -moz-appearance: textfield; /* Firefox */
}

/* Masquer les flèches pour tous les navigateurs */
#horex-filters-form input[type="number"]::-webkit-inner-spin-button,
#horex-filters-form input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#horex-filters-form input[type="number"]:focus {
  outline: none;
  border-color: var(--horex-primary-color);
  box-shadow: var(--horex-shadow);
}

/* 6. Toggle switch - Optimisé et simplifié */
.horex-stock-switch {
  display: flex;
  align-items: center;
  justify-content: space-between; /* Simplifie la structure */
  border-top: 1px solid var(--horex-border-color);
  padding: var(--horex-padding) 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--horex-border-color);
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--horex-bg-color);
  transition: .4s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: var(--horex-primary-color);
}

.switch input:focus + .slider {
  box-shadow: 0 0 1px var(--horex-primary-color);
}

.switch input:checked + .slider:before {
  transform: translateX(26px);
}

/* 7. Styles réactifs - Plus concis */
@media (max-width: 768px) {
  .horex-flex-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .horex-flex-row label {
    width: 100%;
  }
  
  .switch {
    align-self: flex-start;
  }
}

/* 8. État de chargement - Amélioré avec animation */
.horex-loading {
  position: relative;
  opacity: 0.6; /* Augmenté pour meilleure visibilité */
  pointer-events: none;
  transition: opacity 0.3s ease;
}

