/* Filtros de la tienda (modo «avanzados»). Barra lateral fija en la compu y hoja inferior en el celular.
   Tres aspectos según el diseño de la tienda: claro y mínimo (Morpho, Premium: texto sin cajas), paneles redondeados
   oscuros (Feyma) y paneles oscuros rectos (Arena). Todo va bajo .sf-*: no toca el modo de filtros simples. */

body.vidriera {
  --sf-texto: inherit; --sf-suave: #6b6b70; --sf-borde: #e3e3e6; --sf-acento: #1a1a1a; --sf-acento-texto: #fff;
  --sf-panel: transparent; --sf-panel-borde: 0; --sf-panel-pad: 0; --sf-radio: 0; --sf-radio-chico: 999px;
  --sf-caja-ver: none; --sf-hoja: #fff; --sf-campo: #fff; --sf-chip: #f2f2f4; --sf-separa: 1px solid var(--sf-borde);
}
body.vidriera.diseno-premium { --sf-suave: var(--a-suave); --sf-borde: var(--a-linea); --sf-acento: var(--a-azul); --sf-chip: var(--a-gris); }
body.vidriera.diseno-feyma {
  --sf-texto: var(--f-texto); --sf-suave: var(--f-suave); --sf-borde: var(--f-borde-fuerte); --sf-acento: var(--f-lila); --sf-acento-texto: #12101f;
  --sf-panel: var(--f-sup); --sf-panel-borde: 1px solid var(--f-borde); --sf-panel-pad: 14px 16px; --sf-radio: 14px; --sf-radio-chico: 999px;
  --sf-caja-ver: inline-flex; --sf-hoja: var(--f-fondo); --sf-campo: var(--f-fondo-2); --sf-chip: var(--f-sup-2); --sf-separa: 0;
}
body.vidriera.diseno-arena {
  --sf-texto: var(--g-texto); --sf-suave: var(--g-suave); --sf-borde: var(--g-borde-fuerte); --sf-acento: var(--g-verde); --sf-acento-texto: #05070a;
  --sf-panel: var(--g-sup); --sf-panel-borde: 1px solid var(--g-borde); --sf-panel-pad: 14px 16px; --sf-radio: 0; --sf-radio-chico: 0;
  --sf-caja-ver: inline-flex; --sf-hoja: var(--g-fondo); --sf-campo: var(--g-fondo-2); --sf-chip: var(--g-sup-2); --sf-separa: 0;
}

/* Con filtros avanzados, la barra de categorías en píldoras y el contador viejo no se usan. */
.tienda-productos.sf-activo > .tienda-barra, .tienda-productos.sf-activo #v-resultados { display: none !important; }

.sf-marco { display: grid; grid-template-columns: 256px minmax(0, 1fr); gap: 28px; align-items: start; }
.sf-principal { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* Barra lateral fija */
html body.vidriera .sf-lateral {
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  color: var(--sf-texto);
  padding-right: 4px;
}
.sf-paneles { display: flex; flex-direction: column; gap: 10px; }
.sf-hoja-cabeza, .sf-hoja-pie { display: none; }
.sf-nada { margin: 0; color: var(--sf-suave); font-size: 14px; }

html body.vidriera .sf-panel {
  background: var(--sf-panel);
  border: var(--sf-panel-borde);
  border-radius: var(--sf-radio);
  padding: var(--sf-panel-pad);
  border-bottom: var(--sf-separa);
  padding-bottom: 12px;
}
html body.vidriera.diseno-feyma .sf-panel, html body.vidriera.diseno-arena .sf-panel { border-bottom: var(--sf-panel-borde); padding: var(--sf-panel-pad); }
html body.vidriera:not(.diseno-feyma):not(.diseno-arena) .sf-panel:last-child { border-bottom-color: transparent; }
.sf-cabeza { margin: 0; font-size: inherit; }
html body.vidriera .sf-lateral button.sf-plegar {
  all: unset; box-sizing: border-box; display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 32px; cursor: pointer; font: inherit; font-size: 15px; font-weight: 600; color: var(--sf-texto); text-transform: none; letter-spacing: normal;
}
html body.vidriera.diseno-arena .sf-lateral button.sf-plegar {
  font-family: var(--g-condensada);
  font-stretch: condensed;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
html body.vidriera .sf-lateral button.sf-plegar:focus-visible { outline: 2px solid var(--sf-acento); outline-offset: 2px; }
.sf-plegar svg { flex: none; transition: transform 0.2s; color: var(--sf-suave); }
.sf-plegar[aria-expanded="false"] svg { transform: rotate(-90deg); }
.sf-cuerpo { padding-top: 6px; }

.sf-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.sf-lista.larga { max-height: 280px; overflow-y: auto; scrollbar-width: thin; padding-right: 4px; }
.sf-lista li[hidden] { display: none; }

/* Opción con casilla: la casilla real queda invisible (sigue andando con teclado y lectores de pantalla). */
html body.vidriera .sf-op {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 3px 0;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.3;
  color: var(--sf-texto);
  text-transform: none;
  letter-spacing: normal;
}
html body.vidriera .sf-op input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.sf-caja {
  display: var(--sf-caja-ver);
  flex: none;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--sf-borde);
  border-radius: 5px;
  background: var(--sf-campo);
  transition: background 0.15s, border-color 0.15s;
}
html body.vidriera.diseno-arena .sf-caja { border-radius: 0; }
.sf-op input[type="radio"] + .sf-caja { border-radius: 50%; }
.sf-op input:checked + .sf-caja { background: var(--sf-acento); border-color: var(--sf-acento); }
.sf-op input:checked + .sf-caja::after {
  content: '';
  width: 9px;
  height: 5px;
  border: 2px solid var(--sf-acento-texto);
  border-top: 0;
  border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}
.sf-op input:focus-visible + .sf-caja, .sf-op input:focus-visible ~ .sf-txt { outline: 2px solid var(--sf-acento); outline-offset: 2px; }
.sf-txt { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.sf-n { flex: none; color: var(--sf-suave); font-size: 13px; font-variant-numeric: tabular-nums; }
.sf-n::before { content: '('; } .sf-n::after { content: ')'; }
.sf-op:hover .sf-txt { color: var(--sf-acento); }
.sf-op input:checked ~ .sf-txt { font-weight: 600; }
.sf-op.sin { opacity: 0.5; }
/* Estilo claro (sin cajas): la elegida va en negrita con una tilde, como un enlace de texto. */
body.vidriera:not(.diseno-feyma):not(.diseno-arena) .sf-op input:checked ~ .sf-txt::before { content: '✓ '; color: var(--sf-acento); }
body.vidriera:not(.diseno-feyma):not(.diseno-arena) .sf-op:hover .sf-txt { text-decoration: underline; text-underline-offset: 3px; }

/* Tramos de precio o de atributos numéricos: texto que se toca (como Mercado Libre). */
html body.vidriera .sf-lateral button.sf-tramo, html body.vidriera .sf-lateral button.sf-mas {
  all: unset; box-sizing: border-box; display: flex; width: 100%; align-items: center; gap: 8px; min-height: 30px; padding: 3px 0; cursor: pointer; font: inherit; font-size: 14px; color: var(--sf-texto);
}
html body.vidriera .sf-lateral button.sf-tramo:hover .sf-txt { color: var(--sf-acento); }
html body.vidriera .sf-lateral button.sf-tramo.activo .sf-txt { font-weight: 600; color: var(--sf-acento); }
html body.vidriera .sf-lateral button.sf-tramo.activo .sf-txt::before { content: '✓ '; }
html body.vidriera .sf-lateral button.sf-mas { width: auto; min-height: 28px; margin-top: 4px; color: var(--sf-acento); font-size: 13px; font-weight: 600; }
html body.vidriera .sf-lateral button.sf-mas:hover { text-decoration: underline; text-underline-offset: 3px; }
html body.vidriera .sf-lateral button:is(.sf-tramo, .sf-mas):focus-visible { outline: 2px solid var(--sf-acento); outline-offset: 2px; }

/* Buscador de marca */
html body.vidriera .sf-lateral input.sf-buscar {
  box-sizing: border-box;
  width: 100%;
  height: 34px;
  margin: 2px 0 8px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  color: var(--sf-texto);
  background: var(--sf-campo);
  border: 1px solid var(--sf-borde);
  border-radius: var(--sf-radio-chico);
  box-shadow: none;
  clip-path: none;
}

/* Mínimo – Máximo › */
.sf-minmax { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.sf-campo { flex: 1 1 0; min-width: 0; }
html body.vidriera .sf-lateral .sf-campo input {
  box-sizing: border-box;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  color: var(--sf-texto);
  background: var(--sf-campo);
  border: 1px solid var(--sf-borde);
  border-radius: var(--sf-radio-chico);
  box-shadow: none;
  clip-path: none;
  -moz-appearance: textfield;
}
.sf-campo input::-webkit-outer-spin-button, .sf-campo input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sf-guion { color: var(--sf-suave); }
html body.vidriera .sf-lateral button.sf-aplicar {
  all: unset;
  box-sizing: border-box;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  cursor: pointer;
  border-radius: 50%;
  background: var(--sf-acento);
  color: var(--sf-acento-texto);
}
html body.vidriera.diseno-arena .sf-lateral button.sf-aplicar { border-radius: 0; }
html body.vidriera .sf-lateral button.sf-aplicar:focus-visible { outline: 2px solid var(--sf-acento); outline-offset: 2px; }

/* Deslizador doble del precio */
.sf-deslizador { position: relative; height: 28px; margin: 10px 4px 2px; }
.sf-pista { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--sf-borde); }
.sf-relleno { position: absolute; top: 0; bottom: 0; border-radius: 2px; background: var(--sf-acento); }
html body.vidriera .sf-deslizador input[type="range"] {
  position: absolute;
  left: 0;
  top: 4px;
  width: 100%;
  height: 20px;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.sf-deslizador input[type="range"]::-webkit-slider-runnable-track { background: none; border: 0; }
.sf-deslizador input[type="range"]::-moz-range-track { background: none; border: 0; }
.sf-deslizador input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--sf-hoja);
  border: 2px solid var(--sf-acento);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: grab;
}
.sf-deslizador input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sf-hoja);
  border: 2px solid var(--sf-acento);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: grab;
}
.sf-deslizador input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--sf-acento); outline-offset: 2px; }

/* Interruptores «Solo en stock» / «En oferta» */
html body.vidriera .sf-llave {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--sf-texto);
  text-transform: none;
  letter-spacing: normal;
}
html body.vidriera .sf-llave input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.sf-interruptor { flex: none; position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--sf-borde); transition: background 0.2s; }
.sf-interruptor::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.sf-llave input:checked + .sf-interruptor { background: var(--sf-acento); }
.sf-llave input:checked + .sf-interruptor::after { transform: translateX(16px); }
.sf-llave input:focus-visible + .sf-interruptor { outline: 2px solid var(--sf-acento); outline-offset: 2px; }
html body.vidriera.diseno-arena .sf-interruptor, html body.vidriera.diseno-arena .sf-interruptor::after { border-radius: 0; }

/* Fila de arriba: cantidad + orden (y «Filtrar» en el celular) */
.sf-barra { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.sf-cuenta { flex: 1 1 auto; margin: 0; font-size: 14px; color: var(--sf-suave); }
.sf-orden { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; color: var(--sf-suave); white-space: nowrap; }
html body.vidriera .sf-orden select { min-height: 38px; max-width: 200px; }
html body.vidriera .sf-barra button.sf-abrir { display: none; }

/* Chips de filtros puestos */
.sf-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sf-chips[hidden] { display: none; }
html body.vidriera button.sf-chip {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--sf-texto);
  background: var(--sf-chip);
  border: 1px solid var(--sf-borde);
  border-radius: var(--sf-radio-chico);
}
html body.vidriera button.sf-chip:hover { border-color: var(--sf-acento); }
html body.vidriera button.sf-chip:focus-visible { outline: 2px solid var(--sf-acento); outline-offset: 2px; }
.sf-chip-x { font-size: 11px; opacity: 0.7; }
html body.vidriera button.sf-limpiar {
  all: unset;
  box-sizing: border-box;
  min-height: 32px;
  padding: 0 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--sf-acento);
}
html body.vidriera button.sf-limpiar:hover { text-decoration: underline; text-underline-offset: 3px; }
html body.vidriera button.sf-limpiar:focus-visible { outline: 2px solid var(--sf-acento); outline-offset: 2px; }

.sf-vacio { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 28px 0; }

/* «Comprar por marca» */
.sf-marcas[hidden] { display: none; }
.sf-marcas { display: flex; flex-direction: column; gap: 10px; }
.sf-marcas-titulo { margin: 0; font-size: 16px; font-weight: 600; }
.sf-marcas-fila { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; scroll-snap-type: x proximity; }
html body.vidriera button.sf-marca {
  all: unset;
  box-sizing: border-box;
  flex: none;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  height: 56px;
  padding: 0 18px;
  cursor: pointer;
  background: var(--sf-panel, transparent);
  border: 1px solid var(--sf-borde);
  border-radius: var(--sf-radio, 0);
  color: var(--sf-texto);
  font-weight: 600;
  font-size: 14px;
  transition: border-color 0.15s;
}
html body.vidriera:not(.diseno-feyma):not(.diseno-arena) button.sf-marca { border-radius: 12px; background: #fff; }
html body.vidriera button.sf-marca:hover, html body.vidriera button.sf-marca[aria-pressed="true"] { border-color: var(--sf-acento); }
html body.vidriera button.sf-marca[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--sf-acento); }
html body.vidriera button.sf-marca:focus-visible { outline: 2px solid var(--sf-acento); outline-offset: 2px; }
.sf-marca img { display: block; max-width: 100px; max-height: 32px; width: auto; height: auto; object-fit: contain; }

.sf-fondo { display: none; }

/* ---------- Celular: botón «Filtrar (n)» y hoja inferior ---------- */
@media (max-width: 700px) {
  .sf-marco { display: block; }
  .sf-barra { flex-wrap: wrap; gap: 8px; }
  .sf-cuenta { order: 3; flex-basis: 100%; font-size: 13px; }
  html body.vidriera .sf-barra button.sf-abrir {
    all: unset; box-sizing: border-box; flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 14px; cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--sf-texto); background: var(--sf-chip); border: 1px solid var(--sf-borde); border-radius: var(--sf-radio-chico);
  }
  html body.vidriera .sf-barra button.sf-abrir:focus-visible { outline: 2px solid var(--sf-acento); outline-offset: 2px; }
  .sf-orden { flex: 1 1 0; min-width: 0; }
  .sf-orden-texto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  html body.vidriera .sf-orden select { width: 100%; max-width: none; min-height: 42px; }

  html body.vidriera .sf-lateral {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 86vh; max-height: 86dvh; padding: 0;
    display: flex; flex-direction: column; overflow: hidden; background: var(--sf-hoja); color: var(--sf-texto);
    border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.3);
    transform: translateY(100%); visibility: hidden; transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.28s;
  }
  html body.vidriera.diseno-arena .sf-lateral { border-radius: 0; border-top: 1px solid var(--g-borde-fuerte); }
  html body.vidriera .sf-lateral.abierta { transform: none; visibility: visible; }
  .sf-hoja-cabeza {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--sf-borde);
  }
  .sf-hoja-cabeza h2 { margin: 0; font-size: 18px; }
  html body.vidriera .sf-lateral button.sf-cerrar {
    all: unset;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 18px;
    color: var(--sf-texto);
    border-radius: 50%;
  }
  html body.vidriera .sf-lateral button.sf-cerrar:focus-visible { outline: 2px solid var(--sf-acento); }
  .sf-paneles { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px; }
  .sf-hoja-pie {
    display: flex;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--sf-borde);
    background: var(--sf-hoja);
  }
  html body.vidriera .sf-hoja-pie button.sf-limpiar-hoja { flex: none; min-height: 46px; padding: 0 16px; }
  html body.vidriera .sf-hoja-pie button.sf-ver { flex: 1 1 auto; min-height: 46px; }
  .sf-fondo {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s, visibility 0.28s;
  }
  .sf-fondo.visible { opacity: 1; visibility: visible; }
  html.sf-hoja-abierta, html.sf-hoja-abierta body { overflow: hidden; }
  html body.vidriera .sf-op, html body.vidriera .sf-lateral button.sf-tramo { min-height: 40px; }
  .sf-marcas-titulo { font-size: 15px; }
  html body.vidriera button.sf-marca { min-width: 96px; height: 48px; padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  html body.vidriera .sf-lateral, .sf-fondo, .sf-plegar svg, .sf-interruptor, .sf-interruptor::after { transition: none; }
}
