/* Módulo Búsqueda y filtros (Ecomm). Usa los tokens del tema (--b2b-*) si existen. */
.ecomm-facets, .ecomm-instant, .ecomm-chips { --sf-primary: var(--b2b-primary, #1B5585); --sf-line: var(--b2b-line, #E3E8EE); --sf-muted: var(--b2b-muted, #5E6B7A); --sf-subtle: var(--b2b-subtle, #8E9AA7); --sf-text: var(--b2b-text, #0F1B2A); --sf-soft: var(--b2b-soft, #F4F6F9); --sf-ease: var(--b2b-ease, cubic-bezier(.22, 1, .36, 1)); }

/* ---------- Bloque de filtros ---------- */
.ecomm-facets { padding: 1.1rem .9rem .6rem; }
.ecomm-facets__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 0 .45rem .8rem; }
.ecomm-facets__title { display: inline-flex; align-items: center; gap: .45rem; font-size: 1rem; font-weight: 600; letter-spacing: -.015em; color: var(--sf-text); }
.ecomm-facets__icon { width: 18px; height: 18px; color: var(--sf-primary); }
.ecomm-facets__badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--sf-primary); color: #fff; font-size: .7rem; font-weight: 600; }
.ecomm-facets__clear { font-size: .8rem; font-weight: 600; text-decoration: none; color: var(--sf-muted); }
.ecomm-facets__clear:hover { color: #E5484D; }
.ecomm-facets-js .ecomm-facets__apply { display: none; }
.ecomm-facets__apply { margin: .75rem 0 .4rem; }

/* Interruptores (disponibilidad, ofertas) */
.ecomm-facets__toggles { display: flex; flex-direction: column; gap: .15rem; padding: .2rem 0 .7rem; border-top: 1px solid var(--sf-line); padding-top: .7rem; }
.ecomm-switch { position: relative; display: flex; align-items: center; gap: .65rem; padding: .45rem .45rem; border-radius: 10px; cursor: pointer; font-size: .88rem; color: var(--sf-text); transition: background .2s; margin: 0; }
.ecomm-switch:hover { background: var(--sf-soft); }
.ecomm-switch input { position: absolute; opacity: 0; pointer-events: none; }
.ecomm-switch__track { position: relative; flex: none; width: 34px; height: 20px; border-radius: 999px; background: #D5DCE4; transition: background .25s; }
.ecomm-switch__track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 27, 42, .25); transition: transform .35s var(--b2b-spring, cubic-bezier(.34, 1.56, .64, 1)); }
.ecomm-switch input:checked + .ecomm-switch__track { background: var(--sf-primary); }
.ecomm-switch input:checked + .ecomm-switch__track::after { transform: translateX(14px); }
.ecomm-switch input:focus-visible + .ecomm-switch__track { outline: 2px solid var(--b2b-accent, #2FA6CB); outline-offset: 2px; }
.ecomm-switch__label { flex: 1; font-weight: 500; }

/* Grupos plegables */
.ecomm-facet { border-top: 1px solid var(--sf-line); }
.ecomm-facet summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem .45rem; cursor: pointer; font-size: .86rem; font-weight: 600; color: var(--sf-text); border-radius: 8px; }
.ecomm-facet summary::-webkit-details-marker { display: none; }
.ecomm-facet summary:hover { color: var(--sf-primary); }
.ecomm-facet__chev { width: 16px; height: 16px; color: var(--sf-subtle); transition: transform .35s var(--sf-ease); }
.ecomm-facet[open] .ecomm-facet__chev { transform: rotate(180deg); }
.ecomm-facet__dot { display: inline-block; width: 6px; height: 6px; margin-left: .45rem; border-radius: 50%; background: var(--sf-primary); vertical-align: middle; }
.ecomm-facet[open] .ecomm-facet__body { animation: sf-open .35s var(--sf-ease); }
.ecomm-facet__body { display: flex; flex-direction: column; gap: .05rem; padding: 0 0 .7rem; }
.ecomm-facet__body.is-long { max-height: 250px; overflow: auto; scrollbar-width: thin; padding-right: .2rem; }
.ecomm-facet__count { flex: none; min-width: 24px; padding: .05rem .4rem; border-radius: 999px; background: var(--sf-soft); color: var(--sf-muted); font-size: .7rem; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }

/* Casillas */
.ecomm-check { position: relative; display: flex; align-items: center; gap: .6rem; padding: .38rem .45rem; border-radius: 8px; cursor: pointer; font-size: .86rem; color: var(--sf-text); margin: 0; transition: background .15s; }
.ecomm-check:hover { background: var(--sf-soft); }
.ecomm-check input { position: absolute; opacity: 0; pointer-events: none; }
.ecomm-check__box { position: relative; flex: none; width: 18px; height: 18px; border-radius: 6px; background: #fff; box-shadow: inset 0 0 0 1.5px #C4CDD6; transition: background .2s, box-shadow .2s; }
.ecomm-check__box::after { content: ''; position: absolute; left: 6px; top: 2.5px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) scale(0); transition: transform .3s var(--b2b-spring, cubic-bezier(.34, 1.56, .64, 1)); }
.ecomm-check input:checked + .ecomm-check__box { background: var(--sf-primary); box-shadow: none; }
.ecomm-check input:checked + .ecomm-check__box::after { transform: rotate(45deg) scale(1); }
.ecomm-check input:focus-visible + .ecomm-check__box { outline: 2px solid var(--b2b-accent, #2FA6CB); outline-offset: 2px; }
.ecomm-check input:checked ~ .ecomm-check__label { font-weight: 600; }
.ecomm-check__label { flex: 1; min-width: 0; }
.ecomm-check.is-empty, .ecomm-switch.is-empty { opacity: .45; cursor: default; }
.ecomm-check.is-empty:hover, .ecomm-switch.is-empty:hover { background: none; }

/* Rango de precio */
.ecomm-range { flex-direction: row; align-items: flex-end; gap: .5rem; padding: 0 .45rem .8rem; }
.ecomm-range__field { position: relative; flex: 1; display: flex; flex-direction: column; gap: .25rem; margin: 0; }
.ecomm-range__field span { font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--sf-subtle); }
.ecomm-range__field input { width: 100%; height: 40px; padding: 0 1.6rem 0 .7rem; border: 0; border-radius: 10px; background: var(--sf-soft); box-shadow: inset 0 0 0 1px var(--sf-line); font-size: .88rem; font-variant-numeric: tabular-nums; outline: none; -moz-appearance: textfield; transition: box-shadow .2s, background .2s; }
.ecomm-range__field input::-webkit-outer-spin-button, .ecomm-range__field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ecomm-range__field input:focus { background: #fff; box-shadow: inset 0 0 0 1px var(--sf-primary), 0 0 0 4px rgba(27, 85, 133, .1); }
.ecomm-range__field em { position: absolute; right: .65rem; bottom: .62rem; font-style: normal; font-size: .8rem; color: var(--sf-subtle); }
.ecomm-range__sep { width: 10px; height: 2px; margin-bottom: 19px; border-radius: 2px; background: #C4CDD6; }

@media (max-width: 991px) {
    .ecomm-facets > :not(.ecomm-facets__head):not(input) { display: none; }
    .ecomm-facets.is-open > :not(.ecomm-facets__head):not(input) { display: block; }
    .ecomm-facets.is-open > .ecomm-facets__toggles { display: flex; }
    .ecomm-facets__head { padding-bottom: 0; cursor: pointer; }
    .ecomm-facets.is-open .ecomm-facets__head { padding-bottom: .8rem; }
}

/* ---------- Chips de filtros activos ---------- */
.ecomm-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.ecomm-chips:not(:empty) { margin-bottom: 1rem; }
.ecomm-chips:has(.ecomm-fchip) { margin-bottom: 1rem; }
.ecomm-fchip { display: inline-flex; align-items: center; gap: .35rem; padding: .32rem .55rem .32rem .8rem; border-radius: 999px; background: var(--sf-text); color: #fff; font-size: .78rem; font-weight: 500; text-decoration: none; animation: sf-chip .35s var(--b2b-spring, cubic-bezier(.34, 1.56, .64, 1)); transition: background .2s; }
.ecomm-fchip:hover { background: #E5484D; color: #fff; }
.ecomm-fchip__x { width: 14px; height: 14px; opacity: .75; }
.ecomm-chips__clear { margin-left: .25rem; font-size: .8rem; font-weight: 600; color: var(--sf-muted); text-decoration: none; }
.ecomm-chips__clear:hover { color: #E5484D; }

/* ---------- Búsqueda instantánea ---------- */
.ecomm-instant { position: absolute; z-index: 1050; top: calc(100% + 10px); left: 0; width: max(100%, 560px); max-width: calc(100vw - 2rem); max-height: min(70vh, 560px); overflow: auto; background: #fff; border-radius: 18px; box-shadow: 0 30px 70px -20px rgba(15, 27, 42, .35), 0 0 0 1px rgba(15, 27, 42, .06); padding: .5rem; animation: sf-pop .25s var(--sf-ease); scrollbar-width: thin; }
.ecomm-instant[hidden] { display: none; }
.ecomm-instant__label { display: flex; align-items: center; gap: .4rem; padding: .6rem .7rem .35rem; font-size: .68rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--sf-subtle); }
.ecomm-instant__label span { padding: .05rem .4rem; border-radius: 999px; background: var(--sf-soft); letter-spacing: 0; color: var(--sf-muted); }
.ecomm-instant__taxons { display: flex; flex-wrap: wrap; gap: .35rem; padding: 0 .5rem .4rem; }
.ecomm-instant__taxon { display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .75rem .4rem .55rem; border-radius: 999px; background: var(--sf-soft); color: var(--sf-text); font-size: .82rem; font-weight: 500; text-decoration: none; transition: background .2s, color .2s; }
.ecomm-instant__taxon small { margin-left: .35rem; color: var(--sf-subtle); font-size: .72rem; }
.ecomm-instant__taxon-icon { width: 16px; height: 16px; color: var(--sf-primary); }
.ecomm-instant__taxon:hover, .ecomm-instant__taxon.is-active { background: var(--sf-primary); color: #fff; }
.ecomm-instant__taxon:hover small, .ecomm-instant__taxon.is-active small, .ecomm-instant__taxon:hover .ecomm-instant__taxon-icon, .ecomm-instant__taxon.is-active .ecomm-instant__taxon-icon { color: rgba(255, 255, 255, .8); }
.ecomm-instant__product { display: flex; align-items: center; gap: .85rem; padding: .5rem .6rem; border-radius: 12px; color: var(--sf-text); text-decoration: none; transition: background .15s; }
.ecomm-instant__product:hover, .ecomm-instant__product.is-active { background: var(--b2b-primary-50, #EEF4FA); color: var(--sf-text); }
.ecomm-instant__img { flex: none; width: 52px; height: 52px; border-radius: 10px; overflow: hidden; background: linear-gradient(180deg, #F6F8FB, #ECF0F5); }
.ecomm-instant__img img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.ecomm-instant__info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ecomm-instant__name { font-weight: 600; font-size: .88rem; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ecomm-instant__meta { font-size: .74rem; color: var(--sf-muted); }
.ecomm-instant__meta > span { font-family: var(--b2b-mono, ui-monospace, monospace); font-size: .7rem; }
.ecomm-instant mark { padding: 0 .1em; border-radius: 3px; background: #FFE9A8; color: inherit; }
.ecomm-instant__price { flex: none; display: flex; flex-direction: column; align-items: flex-end; font-weight: 700; font-size: .92rem; font-variant-numeric: tabular-nums; }
.ecomm-instant__price small { font-size: .66rem; font-weight: 500; color: var(--sf-subtle); }
.ecomm-instant__all { display: flex; align-items: center; justify-content: center; gap: .4rem; margin: .4rem .2rem .2rem; padding: .7rem; border-radius: 12px; background: var(--sf-soft); color: var(--sf-primary); font-size: .85rem; font-weight: 600; text-decoration: none; transition: background .2s, color .2s; }
.ecomm-instant__all:hover, .ecomm-instant__all.is-active { background: var(--sf-primary); color: #fff; }
.ecomm-instant__empty { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: 1.75rem 1rem; text-align: center; font-size: .84rem; color: var(--sf-muted); }
.ecomm-instant__empty strong { color: var(--sf-text); font-weight: 600; }
.ecomm-instant__empty-icon { width: 36px; height: 36px; color: #B5C0CB; margin-bottom: .3rem; }
/* Indicador de búsqueda en curso sobre el icono de la lupa del tema */
form[role="search"].is-searching .b2b-search__icon svg { animation: sf-pulse .8s ease-in-out infinite alternate; color: var(--b2b-primary, #1B5585); }

@keyframes sf-open { from { opacity: 0; transform: translateY(-4px); } }
@keyframes sf-chip { from { opacity: 0; transform: scale(.85); } }
@keyframes sf-pop { from { opacity: 0; translate: 0 -6px; scale: .98; } }
@keyframes sf-pulse { to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .ecomm-facets *, .ecomm-instant, .ecomm-fchip { animation: none !important; transition: none !important; } }
