/*
 * Filtrado — estilos base.
 *
 * El marcado usa las clases de FacetWP (facetwp-facet, facetwp-radio, fs-wrap…) porque el CSS de los
 * temas ya está escrito contra ellas. Aquí solo va lo que antes aportaban los CSS de FacetWP, fSelect,
 * noUiSlider y FacetWP Flyout (que se desactivan), el conmutador Nuevos/Seminuevos y los estados de carga.
 *
 * Tipografía: ninguna regla define familia, tamaño ni peso salvo donde el original del tema lo hacía; todo se hereda.
 * Colores: variables del tema (--color1, --neutro1) con un valor de respaldo.
 */

/* Envoltorio de cada faceta: no genera caja, los hijos siguen siendo hijos directos del contenedor. */
.tr-filtrado-facet { display: contents; }

.facetwp-facet { margin-bottom: 40px; }
.facetwp-hidden { display: none; }
.facetwp-display-value { padding-right: 5px; }

/* Radios y casillas (el tema da el aspecto de las que usa; esto es el mínimo para el resto). */
.facetwp-radio, .facetwp-checkbox { margin-bottom: 4px; cursor: pointer; }
.facetwp-radio.disabled, .facetwp-checkbox.disabled { opacity: .4; cursor: default; }
.facetwp-radio:focus-visible, .facetwp-checkbox:focus-visible,
.tr-filtrado-reset:focus-visible, .tr-reset:focus-visible { outline: 2px solid var(--color1, #333); outline-offset: 2px; }

/* Conmutador Nuevos / Seminuevos: solo maqueta (dos pestañas con subrayado). La tipografía es la del tema. */
.facetwp-facet.facetwp-facet-estado { margin-bottom: 22px; }
.facetwp-facet.facetwp-facet-estado .tr-condition { display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 280px; border-bottom: 1px solid #e3e3e6; }
.facetwp-facet.facetwp-facet-estado .facetwp-radio { margin: 0 0 -1px; padding: 10px 4px 9px; background: none; border: 0; border-bottom: 2px solid transparent; text-align: center; white-space: nowrap; cursor: pointer; opacity: .6; transition: opacity .2s ease, border-color .2s ease; }
.facetwp-facet.facetwp-facet-estado .facetwp-radio .facetwp-display-value { display: block; padding: 0; }
.facetwp-facet.facetwp-facet-estado .facetwp-radio:not(.checked):not(.disabled):hover { opacity: 1; }
.facetwp-facet.facetwp-facet-estado .facetwp-radio.checked { opacity: 1; border-bottom-color: var(--color1, #333); cursor: default; }
.facetwp-facet.facetwp-facet-estado .facetwp-radio.disabled { opacity: .35; cursor: not-allowed; }
.facetwp-facet.facetwp-facet-estado .facetwp-counter { display: none; }

/* ------------------------------------------------------------------ desplegable (botón + lista)
   Mismo lenguaje que los botones Automático/Manual del tema: borde 1px --color1, radio pequeño, fondo --neutro1. */
.fs-wrap { position: relative; display: inline-block; width: 220px; max-width: 100%; line-height: 1.2; }
.fs-wrap.tr-select { display: block; width: 100%; }

.fs-wrap .fs-label-wrap {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; min-height: 42px; margin: 0; padding: 8px 12px; box-sizing: border-box;
    background: var(--neutro1, #fff); color: inherit; border: 1px solid var(--color1, #333); border-radius: 5px; box-shadow: none;
    font: inherit; line-height: 1.2; letter-spacing: normal; text-transform: none; text-align: left;
    cursor: pointer; -webkit-appearance: none; appearance: none;
    transition: background-color .15s ease, box-shadow .15s ease;
}
.fs-wrap .fs-label-wrap:hover { background-color: color-mix(in srgb, var(--color1, #333) 6%, var(--neutro1, #fff)); }
.fs-wrap .fs-label-wrap:focus-visible { outline: 2px solid var(--color1, #333); outline-offset: 2px; }
.fs-wrap.fs-open .fs-label-wrap { box-shadow: 0 0 0 1px var(--color1, #333); }
.fs-wrap .fs-label { flex: 1; min-width: 0; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Flecha: chevrón limpio dibujado con bordes */
.fs-wrap .fs-arrow { position: static; flex: none; width: 8px; height: 8px; margin: 0 3px 3px 0; border: 0; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .18s ease; }
.fs-wrap.fs-open .fs-arrow { transform: rotate(-135deg); margin: 3px 3px 0 0; }

.fs-wrap .fs-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 1000; width: auto; box-sizing: border-box;
    background: var(--neutro1, #fff); border: 1px solid var(--color1, #333); border-radius: 5px; box-shadow: 0 10px 28px rgba(0, 0, 0, .14); overflow: hidden;
}
.fs-wrap .fs-dropdown .fs-options { max-height: 280px; padding: 4px; overflow: auto; }
.fs-hidden { display: none; }

.fs-wrap.multiple .fs-option {
    position: relative; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; box-sizing: border-box;
    border-radius: 4px; cursor: pointer; word-break: normal; background: transparent;
}
.fs-wrap.multiple .fs-option:hover, .fs-wrap.multiple .fs-option:focus { background-color: color-mix(in srgb, var(--color1, #333) 8%, transparent); outline: 0; }
.fs-wrap.multiple .fs-option:focus-visible { outline: 2px solid var(--color1, #333); outline-offset: -2px; }
.fs-wrap.multiple .fs-option.selected { background-color: color-mix(in srgb, var(--color1, #333) 6%, transparent); }
.fs-wrap.multiple .fs-checkbox { position: static; display: block; flex: none; width: 18px; height: 18px; }
.fs-wrap.multiple .fs-option .fs-checkbox i { position: static; display: block; width: 18px; height: 18px; margin: 0; box-sizing: border-box; border: 1.5px solid var(--color1, #333); border-radius: 4px; background: var(--neutro1, #fff); transition: background-color .12s ease; }
.fs-wrap.multiple .fs-option.selected .fs-checkbox i { background-color: var(--color1, #333); border-color: var(--color1, #333); }
.fs-wrap.multiple .fs-option.selected .fs-checkbox i::after { content: ""; display: block; width: 5px; height: 9px; margin: 1px 0 0 5px; border: solid var(--neutro1, #fff); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.fs-wrap .fs-option-label { flex: 1; min-width: 0; white-space: normal; }
.fs-wrap .tr-count { flex: none; margin-left: auto; font-size: .8em; opacity: .6; font-variant-numeric: tabular-nums; }
/* El tema oculta el texto de algunas opciones (data-value suv, 4x4, hibridos...) y lo pinta con ::after de sus categorias
   antiguas; en el layout flex ese ::after quedaba a la derecha, detras del contador. Se anula: manda la etiqueta del mapa. */
body .listingProductCategory .filtros .fs-wrap .fs-option > .fs-option-label { display: block !important; }
body .listingProductCategory .filtros .fs-wrap .fs-option::after, .fs-wrap .fs-option::after { content: none !important; display: none !important; }

/* ------------------------------------------------------------------ slider de rango (dos input[type=range]) */
.facetwp-slider-wrap { padding-bottom: 15px; }
.tr-slider { position: relative; height: 20px; margin: 6px 0 4px; }
.tr-slider-track { position: absolute; left: 0; right: 0; top: 3px; height: 14px; box-sizing: border-box; background: #fafafa; border: 1px solid #d3d3d3; border-radius: 4px; }
.tr-slider-range { position: absolute; top: 0; bottom: 0; background: #ddd; border-radius: 3px; }
.tr-slider-input { position: absolute; left: 0; top: 0; width: 100%; height: 20px; margin: 0; padding: 0; background: none; border: 0; pointer-events: none; -webkit-appearance: none; appearance: none; }
.tr-slider-input::-webkit-slider-runnable-track { background: none; border: 0; height: 20px; }
.tr-slider-input::-moz-range-track { background: none; border: 0; height: 20px; }
.tr-slider-input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; cursor: pointer; width: 20px; height: 20px; box-sizing: border-box; border: 1px solid #d9d9d9; border-radius: 3px; background: #fff; box-shadow: inset 0 0 1px #fff, inset 0 1px 7px #ebebeb, 0 3px 6px -3px #bbb; }
.tr-slider-input::-moz-range-thumb { pointer-events: auto; cursor: pointer; width: 20px; height: 20px; box-sizing: border-box; border: 1px solid #d9d9d9; border-radius: 3px; background: #fff; box-shadow: inset 0 0 1px #fff, inset 0 1px 7px #ebebeb, 0 3px 6px -3px #bbb; }
.tr-slider-input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--color1, #333); outline-offset: 2px; }
.tr-slider-input:focus-visible::-moz-range-thumb { outline: 2px solid var(--color1, #333); outline-offset: 2px; }
.facetwp-slider-label { display: block; margin-top: 8px; }

/* ------------------------------------------------------------------ botones «limpiar»: discretos, con ×, solo con filtros activos */
.tr-reset, .tr-filtrado-reset {
    display: inline-flex; align-items: center; gap: 6px; min-height: 32px; margin: 0; padding: 4px 10px;
    background: transparent; color: var(--color1, inherit); border: 0; border-radius: 999px; box-shadow: none;
    font: inherit; font-size: .85rem; line-height: 1; letter-spacing: normal; text-transform: none; text-decoration: none;
    cursor: pointer; opacity: .75; -webkit-appearance: none; appearance: none; transition: opacity .15s ease, background-color .15s ease;
}
.tr-reset:hover, .tr-filtrado-reset:hover { opacity: 1; background-color: color-mix(in srgb, var(--color1, #333) 8%, transparent); }
.tr-reset .tr-x, .tr-filtrado-reset .tr-x { font-size: 1.25em; line-height: 1; }
.tr-reset[hidden], .tr-filtrado-reset[hidden] { display: none; }
.tr-reset.facetwp-hidden { display: none; }   /* sin esto .tr-reset (inline-flex) pisaba a .facetwp-hidden */
.tr-clear[hidden] { display: inline-flex; visibility: hidden; }   /* conserva el hueco: el panel no salta al aparecer */
.tr-clear { margin: 0 0 12px -10px; }

/* Sin resultados */
.tr-filtrado-empty { text-align: center; padding: 40px 10px; }
.tr-filtrado-empty[hidden] { display: none; }
.tr-filtrado-empty .tr-filtrado-reset { min-height: 44px; padding: 10px 20px; border: 1px solid var(--color1, #333); border-radius: 5px; font-size: 1rem; opacity: 1; }

/* ------------------------------------------------------------------ carga: panel atenuado pero usable, esqueleto y fade-in */
body .listingProductCategory .filtros.is-loading { opacity: .65; transition: opacity .15s ease; }

.tr-skel { position: relative; display: flex; flex-direction: column; gap: 14px; box-sizing: border-box; max-width: 100%; min-height: 240px; padding: 20px; overflow: hidden; border-radius: 16px; background: #f3f3f5; }
.tr-skel > i { display: block; flex: none; border-radius: 8px; background: #e4e4e9; }
.tr-skel-title { width: 72%; height: 14px; }
.tr-skel-chip { width: 88px; height: 22px; border-radius: 11px !important; }
.tr-skel-img { flex: 1 1 auto !important; min-height: 90px; margin: 4px 8% 0; border-radius: 12px !important; }
.tr-skel-price { width: 38%; height: 30px; }
.tr-skel-btn { width: 100%; height: 44px; }
.tr-skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent); animation: tr-shimmer 1.3s ease-in-out infinite; }
@keyframes tr-shimmer { to { transform: translateX(100%); } }

.gridProductos.tr-loading { align-content: flex-start; }
.gridProductos.tr-fade-in > * { animation: tr-fade-in .3s ease both; }
@keyframes tr-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .tr-skel::after, .gridProductos.tr-fade-in > * { animation: none; }
    .fs-wrap .fs-arrow, .fs-wrap .fs-label-wrap, body .listingProductCategory .filtros.is-loading { transition: none; }
}

/* ------------------------------------------------------------------ panel lateral en móvil: equivale al flyout de FacetWP */
.tr-filtrado-fog { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9998; background: #000; opacity: .5; }
.tr-filtrado-fog.active { display: block; }
body.tr-filtrado-lock { overflow: hidden; }

@media (max-width: 1023px) {
    body .listingProductCategory .filtros {
        display: block; position: fixed; top: 0; left: 0; width: 300px; max-width: 100%; height: 100%; max-height: none;
        padding: 0; margin: 0; opacity: 1; z-index: 9999; box-sizing: border-box; overflow: hidden;
        background: #fff; border-right: 1px solid #eee; animation: none;
        transform: translateX(-100%); visibility: hidden;
        transition: transform .4s ease-in-out, visibility 0s linear .4s;
    }
    body .listingProductCategory .filtros.tr-open { transform: none; visibility: visible; transition: transform .4s ease-in-out; }
    body .listingProductCategory .filtros > div { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: block; overflow: auto; width: auto; max-height: none; padding: 0 10px 10px; }
    body .listingProductCategory .filtros .close { position: sticky; top: 0; z-index: 1; display: block; height: 40px; margin: 0 -10px; box-sizing: border-box; padding: 10px; text-align: right; line-height: 20px; font-size: 1.5rem; font-weight: 600; cursor: pointer; background: #fff; }
    body .listingProductCategory .filtros .close:before { content: "Cerrar"; position: absolute; right: 37px; top: 11px; font-size: .8rem; }
    body .listingProductCategory .filtros .facetwp-facet { max-width: 100%; }
    /* Mismos estilos que el flyout de FacetWP (h3 de .facetwp-flyout-content + body, que está fuera de .filtros) */
    body .listingProductCategory .filtros { line-height: 1; }
    body .listingProductCategory .filtros .facet-label { color: var(--color1, inherit); font-size: 1rem; font-weight: 500; line-height: 1.2; text-align: left; }
    body .listingProductCategory .filtros .facet-label[data-for="categories"] { display: flex; }
    body .listingProductCategory .filtros .facetwp-display-value { font-size: 1rem; }
    body.admin-bar .listingProductCategory .filtros { top: 46px; height: calc(100% - 46px); }

    /* Táctil: áreas de 44 px o más. La lista se abre en línea (sin posición absoluta) para que no la recorte el panel. */
    body .listingProductCategory .filtros .fs-wrap .fs-label-wrap { min-height: 48px; }
    body .listingProductCategory .filtros .fs-wrap .fs-dropdown { position: static; margin-top: 6px; box-shadow: none; }
    body .listingProductCategory .filtros .fs-wrap.multiple .fs-option { min-height: 48px; }
    body .listingProductCategory .filtros .fs-wrap .fs-dropdown .fs-options { max-height: 240px; }
    body .listingProductCategory .filtros .tr-reset, body .listingProductCategory .filtros .tr-filtrado-reset { min-height: 44px; }
}
