/*==================================================================
  PRODUCTS FILTER v2 — Sidebar + grid filtrable
  Reutiliza variables de home-v2.css (no duplicar)
==================================================================*/

.pf-scope,
.pf-scope * {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Restaurar fuentes de iconos sobre la regla universal */
.pf-scope .fa, .pf-scope .fas, .pf-scope .far, .pf-scope .fab,
.pf-scope i[class*="fa-"] {
  font-family: "Font Awesome 6 Free", "Font Awesome 6 Brands",
               "Font Awesome 5 Free", FontAwesome !important;
}
.pf-scope .material-symbols-outlined {
  font-family: 'Material Symbols Outlined' !important;
}

.pf-scope { color: var(--hv-on-surface); background: var(--hv-surface); }

/*==================================================================
  Layout principal: 2 columnas
==================================================================*/
.pf-container {
  max-width: var(--hv-container-max);
  margin: 0 auto;
  padding: 24px 16px;
}
@media (min-width: 992px) {
  .pf-container { padding: 32px 40px; }
}

.pf-layout {
  display: flex;
  gap: var(--hv-gutter);
  align-items: stretch; /* Permite que el sidebar se estire para que sticky tenga espacio */
}
@media (max-width: 991.98px) {
  .pf-layout {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Breadcrumb */
.pf-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--hv-outline);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.pf-breadcrumb a { color: var(--hv-outline) !important; text-decoration: none !important; }
.pf-breadcrumb a:hover { color: var(--hv-primary) !important; }
.pf-breadcrumb-current { color: var(--hv-on-surface-variant); font-weight: 500; }

/*==================================================================
  Sidebar de Filtros
==================================================================*/
.pf-sidebar {
  width: 280px;
  flex-shrink: 0;
}
@media (max-width: 991.98px) { .pf-sidebar { width: 100%; } }

.pf-sidebar-sticky {
  position: sticky;
  top: 20px;
  /* Si los filtros son más altos que la pantalla, scroll interno */
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  /* Scrollbar discreta */
  scrollbar-width: thin;
  scrollbar-color: rgba(192, 199, 212, .5) transparent;
  padding-right: 4px;
}
.pf-sidebar-sticky::-webkit-scrollbar { width: 5px; }
.pf-sidebar-sticky::-webkit-scrollbar-track { background: transparent; }
.pf-sidebar-sticky::-webkit-scrollbar-thumb {
  background: rgba(192, 199, 212, .5);
  border-radius: 3px;
}
.pf-sidebar-sticky::-webkit-scrollbar-thumb:hover {
  background: rgba(192, 199, 212, .8);
}
@media (max-width: 991.98px) {
  .pf-sidebar-sticky {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

.pf-filters-card {
  background: var(--hv-surface-lowest);
  border: 1px solid var(--hv-outline-variant);
  border-radius: var(--hv-radius-md);
  padding: 20px;
  box-shadow: var(--hv-shadow-sm);
}

.pf-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.pf-filters-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--hv-on-surface);
  letter-spacing: -0.01em;
}
.pf-clear-all {
  background: none;
  border: none;
  color: var(--hv-error);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}
.pf-clear-all:hover { text-decoration: underline; }
.pf-clear-all[disabled] {
  color: var(--hv-outline);
  cursor: not-allowed;
  text-decoration: none;
}

/* Secciones colapsables */
.pf-section {
  border-top: 1px solid var(--hv-outline-variant);
  padding: 16px 0;
}
.pf-section:last-child { padding-bottom: 0; }
.pf-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--hv-on-surface);
  text-transform: uppercase;
  cursor: pointer;
  margin-bottom: 14px;
}
.pf-section-toggle i {
  font-size: 12px;
  color: var(--hv-outline);
  transition: transform var(--hv-trans-fast);
}
.pf-section.is-collapsed .pf-section-body { display: none; }
.pf-section.is-collapsed .pf-section-toggle i { transform: rotate(-90deg); }

/* Buscador interno (marca) */
.pf-search-input-wrap {
  position: relative;
  margin-bottom: 12px;
}
.pf-search-input {
  width: 100%;
  background: var(--hv-surface-low);
  border: 1px solid var(--hv-outline-variant);
  border-radius: var(--hv-radius-sm);
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color var(--hv-trans-fast), box-shadow var(--hv-trans-fast);
}
.pf-search-input:focus {
  border-color: var(--hv-primary);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, .15);
}
.pf-search-input-wrap i {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--hv-outline);
  font-size: 13px;
  pointer-events: none;
}

/* Lista de checkboxes con scroll */
.pf-check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.pf-check-list::-webkit-scrollbar { width: 5px; }
.pf-check-list::-webkit-scrollbar-thumb {
  background: rgba(192, 199, 212, .5);
  border-radius: 3px;
}

.pf-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 2px 0;
}
.pf-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--hv-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.pf-check span {
  font-size: 13px;
  color: var(--hv-on-surface-variant);
  user-select: none;
  flex: 1;
}
.pf-check:hover span { color: var(--hv-primary); }
.pf-check.is-hidden { display: none; }

/* Range de precio */
.pf-price-slider {
  width: 100%;
  height: 4px;
  background: var(--hv-outline-variant);
  border-radius: 4px;
  outline: none;
  margin: 8px 0 14px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.pf-price-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--hv-primary);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.pf-price-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--hv-primary);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
}

.pf-price-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--hv-on-surface-variant);
  margin-bottom: 12px;
  padding: 0 2px;
}
.pf-price-display strong {
  color: var(--hv-primary);
  font-weight: 700;
  font-size: 14px;
}
.pf-price-display small {
  font-size: 11px;
  color: var(--hv-outline);
}

.pf-price-inputs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.pf-price-inputs > div { flex: 1; }
.pf-price-inputs label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--hv-outline);
  margin-bottom: 4px;
  letter-spacing: .04em;
}
.pf-price-inputs input {
  width: 100%;
  background: var(--hv-surface-lowest);
  border: 1px solid var(--hv-outline-variant);
  border-radius: var(--hv-radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}
.pf-price-inputs input:focus {
  border-color: var(--hv-primary);
}

.pf-btn-apply {
  width: 100%;
  padding: 8px 12px;
  background: rgba(30, 136, 229, .1);
  color: var(--hv-primary);
  border: none;
  border-radius: var(--hv-radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .03em;
  transition: all var(--hv-trans-fast);
}
.pf-btn-apply:hover {
  background: var(--hv-primary);
  color: #fff;
}

/* Switch en una línea (solo en stock) */
.pf-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 4px 0;
}
.pf-switch-row span {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--hv-on-surface);
  text-transform: uppercase;
}
.pf-switch-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--hv-primary);
  cursor: pointer;
}

/*==================================================================
  Listing (columna derecha)
==================================================================*/
.pf-listing { flex: 1; min-width: 0; }

/* Toolbar superior: conteo + sort + grid/list */
.pf-toolbar {
  background: var(--hv-surface-lowest);
  border: 1px solid var(--hv-outline-variant);
  border-radius: var(--hv-radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.pf-toolbar-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--hv-on-surface-variant);
}
.pf-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.pf-sort {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pf-sort-label {
  font-size: 12px;
  color: var(--hv-outline);
  font-weight: 500;
}
.pf-sort select {
  background: var(--hv-surface-low);
  border: 1px solid var(--hv-outline-variant);
  border-radius: var(--hv-radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  color: var(--hv-on-surface);
}
.pf-sort select:focus {
  border-color: var(--hv-primary);
}

/* Toggle Grid/List */
.pf-view-toggle {
  display: inline-flex;
  background: var(--hv-surface-lowest);
  border: 1px solid var(--hv-outline-variant);
  border-radius: var(--hv-radius-sm);
  overflow: hidden;
}
.pf-view-btn {
  width: 34px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--hv-on-surface-variant);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--hv-trans-fast);
}
.pf-view-btn:hover { color: var(--hv-primary); }
.pf-view-btn.is-active {
  background: var(--hv-primary);
  color: #fff;
}

/* Chips de filtros activos */
.pf-active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.pf-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--hv-surface-container);
  border: 1px solid var(--hv-outline-variant);
  border-radius: var(--hv-radius-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--hv-on-surface-variant);
  cursor: pointer;
  transition: all var(--hv-trans-fast);
}
.pf-chip:hover {
  border-color: var(--hv-primary);
  color: var(--hv-primary);
}
.pf-chip i { font-size: 10px; }
.pf-chip-clear {
  background: transparent;
  border: none;
  color: var(--hv-error);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 4px;
}
.pf-chip-clear:hover { text-decoration: underline; }

/* Grid de productos: reutiliza .hv-card del home v2 */
.pf-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 16px;
}
@media (min-width: 576px) { .pf-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; } }
@media (min-width: 992px) { .pf-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px){ .pf-grid { grid-template-columns: repeat(4, 1fr); } }

/* Estado vacío */
.pf-empty {
  background: var(--hv-surface-lowest);
  border: 1px solid var(--hv-outline-variant);
  border-radius: var(--hv-radius-md);
  padding: 60px 24px;
  text-align: center;
  color: var(--hv-on-surface-variant);
}
.pf-empty i {
  font-size: 48px;
  color: var(--hv-outline);
  margin-bottom: 16px;
}
.pf-empty h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--hv-on-surface);
  margin: 0 0 8px;
}
.pf-empty p { margin: 0 0 20px; font-size: 14px; }

/*==================================================================
  Paginación
==================================================================*/
.pf-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
  flex-wrap: wrap;
}
.pf-page-btn {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--hv-surface-lowest);
  border: 1px solid var(--hv-outline-variant);
  border-radius: var(--hv-radius-sm);
  color: var(--hv-on-surface) !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  padding: 0 10px;
  transition: all var(--hv-trans-fast);
  cursor: pointer;
}
.pf-page-btn:hover {
  background: var(--hv-surface-container);
  border-color: var(--hv-primary);
}
.pf-page-btn.is-active {
  background: var(--hv-primary);
  border-color: var(--hv-primary);
  color: #fff !important;
}
.pf-page-btn[disabled],
.pf-page-btn.is-disabled {
  opacity: .4;
  pointer-events: none;
}
.pf-page-dots { padding: 0 6px; color: var(--hv-outline); }

/*==================================================================
  RESPONSIVE MÓVIL: drawer lateral
==================================================================*/
.pf-mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--hv-surface);
  padding: 8px 0;
  margin-bottom: 12px;
  gap: 8px;
}
.pf-btn-filter-mobile {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--hv-primary);
  color: #fff;
  border: none;
  border-radius: var(--hv-radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(30, 136, 229, .25);
}
.pf-btn-filter-mobile .badge {
  background: #fff;
  color: var(--hv-primary);
  border-radius: var(--hv-radius-pill);
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}

@media (max-width: 991.98px) {
  .pf-sidebar { display: none; } /* Drawer en vez de columna */
  .pf-mobile-bar { display: flex; }

  /* Drawer overlay */
  .pf-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1090;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility 0s linear .3s;
  }
  .pf-drawer-backdrop.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity .3s ease;
  }
  .pf-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 360px;
    background: var(--hv-surface);
    z-index: 1100;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.22,1,.36,1);
    box-shadow: 4px 0 20px rgba(0,0,0,.2);
    display: block !important;
  }
  .pf-drawer.is-open { transform: translateX(0); }
  .pf-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hv-outline-variant);
    background: var(--hv-surface-lowest);
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .pf-drawer-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
  }
  .pf-drawer-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--hv-on-surface-variant);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
  }
  .pf-drawer-close:hover { background: var(--hv-surface-low); }
  .pf-drawer-body { padding: 16px; }
  .pf-drawer-foot {
    position: sticky;
    bottom: 0;
    background: var(--hv-surface-lowest);
    border-top: 1px solid var(--hv-outline-variant);
    padding: 12px 20px;
    display: flex;
    gap: 10px;
  }
  .pf-drawer-foot .pf-btn-secondary {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--hv-outline-variant);
    border-radius: var(--hv-radius-sm);
    color: var(--hv-on-surface-variant);
    font-weight: 600;
    cursor: pointer;
  }
  .pf-drawer-foot .pf-btn-primary {
    flex: 2;
    padding: 10px;
    background: var(--hv-primary);
    border: none;
    border-radius: var(--hv-radius-sm);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
  }
}

/* En desktop: drawer y backdrop ocultos */
@media (min-width: 992px) {
  .pf-drawer, .pf-drawer-backdrop { display: none !important; }
}
