/* ── Advanced Filters Frontend by Javier Sanz ── */

/* ─ Reset ─────────────────────────────────────────── */
.afjsanz-widget *,
.afjsanz-widget *::before,
.afjsanz-widget *::after { box-sizing: border-box; }

/* ─ Bar ────────────────────────────────────────────── */
.afjsanz-bar {
    display: flex;
    align-items: stretch;
    position: relative;
    overflow: visible;
    flex: 1;
    min-width: 0;
}

/* ─ Track ──────────────────────────────────────────── */
.afjsanz-track {
    display: flex;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    gap: 8px;
}

/* ─ Layout: horizontal ────────────────────────────── */
.afjsanz-widget--horizontal .afjsanz-track,
.afjsanz-widget.afjsanz-layout-horizontal .afjsanz-track {
    flex-direction: row;
    flex-wrap: wrap;
}

/* ─ Layout: vertical ──────────────────────────────── */
.afjsanz-widget--vertical .afjsanz-track,
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-track {
    flex-direction: column;
    align-items: stretch;
}
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-widget-inner {
    flex-direction: column;
}
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-bar {
    width: 100%;
}
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-filter-item {
    width: 100%;
}
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-filter-trigger,
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-toggle-trigger {
    width: 100%;
}
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-submit,
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-reset {
    width: 100%;
    justify-content: center;
}
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-arrow {
    display: none !important;
}
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-filter-item + .afjsanz-filter-item::before {
    top: 0 !important;
    bottom: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 1px !important;
    display: none !important;
}

.afjsanz-widget.afjsanz-layout-modal .afjsanz-filter-item + .afjsanz-filter-item::before {
    display: none !important;
}

/* ─ Layout: carousel ──────────────────────────────── */
.afjsanz-widget.afjsanz-layout-carousel .afjsanz-track {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    scroll-behavior: auto;
    -webkit-overflow-scrolling: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
}
.afjsanz-widget.afjsanz-layout-carousel .afjsanz-filter-item {
    flex-shrink: 0;
}
.afjsanz-widget.afjsanz-layout-carousel .afjsanz-track:active {
    cursor: grabbing;
}
.afjsanz-widget.afjsanz-layout-carousel .afjsanz-bar {
    overflow: visible;
}
.afjsanz-widget.afjsanz-layout-carousel .afjsanz-track::-webkit-scrollbar { display: none; }

/* ─ Arrows ─────────────────────────────────────────── */
.afjsanz-widget {
    display: flex;
    flex-direction: column;
    position: relative;
}
.afjsanz-widget-inner {
    display: flex;
    align-items: stretch;
    gap: 0;
}
.afjsanz-arrow {
    display: none !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    align-self: stretch;
    border: none;
    cursor: pointer;
    background: transparent;
    border-radius: 50%;
    transition: background-color .15s, color .15s, opacity .15s;
    z-index: 10;
    overflow: hidden;
    padding: 0;
    position: relative;
}
.afjsanz-arrow-prev { }
.afjsanz-arrow-next { }
.afjsanz-arrow > *,
.afjsanz-arrow svg,
.afjsanz-arrow i,
.afjsanz-arrow span {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 14px !important;
    height: 14px !important;
    display: block !important;
    pointer-events: none;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
}
.afjsanz-widget.afjsanz-layout-carousel .afjsanz-arrow { display: flex !important; }
.afjsanz-widget.afjsanz-layout-carousel .afjsanz-arrow:disabled { opacity: .35; cursor: default; }

/* ─ Filter item ────────────────────────────────────── */
.afjsanz-filter-item {
    position: relative;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Separador — el mostrar/ocultar lo decide solo el control responsive de
   Elementor ("Mostrar separador"), que ya pone display:block/none por
   tamaño de pantalla; aquí solo se define su aspecto visual. */
.afjsanz-filter-item + .afjsanz-filter-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: #e5e7eb;
    display: none; /* estado por defecto hasta que Elementor aplique el suyo */
}

/* ─ Trigger ────────────────────────────────────────── */
.afjsanz-filter-trigger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%;
    outline: none;
}

.afjsanz-filter-texts {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.afjsanz-filter-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    line-height: 1;
}

.afjsanz-filter-value {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
}
.afjsanz-filter-value.is-placeholder { opacity: .55; }

.afjsanz-filter-chevron {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: transform .2s;
    font-size: 12px;
}
.afjsanz-filter-item.is-open .afjsanz-filter-chevron { transform: rotate(180deg); }

/* ─ Dropdown ────────────────────────────────────────── */
.afjsanz-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    width: max-content;
    max-width: min(320px, 90vw);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 9999;
    overflow: hidden;
}
.afjsanz-dropdown[hidden] { display: none !important; }

/* Search */
.afjsanz-search-wrap { padding: 8px 8px 4px; }
.afjsanz-search {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    background: #f9fafb;
    color: inherit;
    transition: border-color .15s;
}
.afjsanz-search:focus { border-color: #6366f1; background: #fff; }

/* List */
.afjsanz-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.afjsanz-option {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color .1s, color .1s;
}
.afjsanz-option:hover,
.afjsanz-option.is-focused { background: #f3f4f6; }
.afjsanz-option.is-active { font-weight: 600; background: #eff6ff; color: #1d4ed8; }
.afjsanz-option.is-hidden { display: none; }

/* Empty state */
.afjsanz-no-results {
    padding: 10px 12px;
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
    display: none;
}
.afjsanz-no-results.is-visible { display: block; }

/* ─ Submit button ───────────────────────────────────── */
.afjsanz-submit {
    flex-shrink: 0;
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color .15s, color .15s;
    background: #1d4ed8;
    color: #fff;
    border-radius: 8px;
}
.afjsanz-submit:hover { opacity: .9; }



/* ─ Reset button ────────────────────────────────────── */
.afjsanz-reset {
    flex-shrink: 0;
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color .15s, color .15s;
    background: #1d4ed8;
    color: #fff;
    border-radius: 8px;
}
.afjsanz-reset:hover { opacity: .9; }

/* ─ Loading state ───────────────────────────────────── */
.afjsanz-widget.is-loading .afjsanz-submit { opacity: .6; pointer-events: none; }

/* ─ Skeleton / loading options ─────────────────────── */
.afjsanz-option.is-loading {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: afjsanz-skeleton .8s infinite;
    color: transparent;
    border-radius: 4px;
    margin: 4px 8px;
}
@keyframes afjsanz-skeleton {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Visibilidad del dropdown ── */
.afjsanz-dropdown--hidden,
.afjsanz-dropdown[hidden] { display: none !important; }
.afjsanz-filter-item.is-open .afjsanz-dropdown {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: absolute !important;
    z-index: 999999 !important;
}


/* ── Loading pulse ── */
@keyframes afjsanz-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}
.afjsanz-is-loading { animation: afjsanz-pulse 1.4s ease-in-out infinite; pointer-events: none; }

/* ── Contador de resultados ── */
.afjsanz-counter {
    margin-top: 12px;
}
.afjsanz-counter-text {
    font-size: 14px;
}

/* ── Loading pulse ── */
@keyframes afjsanz-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* ─ Toggle filter ───────────────────────────────────── */
.afjsanz-filter-toggle {
    cursor: pointer;
}

.afjsanz-toggle-trigger {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    height: 100%;
    justify-content: center;
    outline: none;
    padding: 0 4px;
}

.afjsanz-toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: #d1d5db;
    border-radius: 999px;
    transition: background-color .2s;
    flex-shrink: 0;
}

.afjsanz-toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.afjsanz-filter-toggle.is-active .afjsanz-toggle-switch {
    background: #1d4ed8;
}

.afjsanz-filter-toggle.is-active .afjsanz-toggle-knob {
    transform: translateX(16px);
}

/* ─ Option count ────────────────────────────────────── */
.afjsanz-option-count {
    margin-left: 5px;
    font-size: 12px;
    opacity: 0.6;
    font-weight: 400;
}
.afjsanz-option:hover .afjsanz-option-count,
.afjsanz-option.is-focused .afjsanz-option-count,
.afjsanz-option.is-active .afjsanz-option-count {
    opacity: 1;
}

/* Ocultar botón cargar más cuando no hay suficientes resultados */
/* ─ Icon Buttons ──────────────────────────────────────────────────────────── */

.afjsanz-icon-group-label {
    display: block;
    margin-bottom: 8px;
}

/* Forzar wrap en las etiquetas del widget SOLO en layout vertical: algunos
   temas/Elementor aplican text-overflow:ellipsis + white-space:nowrap de
   forma global a p/span, lo que corta estas etiquetas con "...". Ganamos
   por especificidad. Restringido a vertical para no afectar horizontal/
   carrusel, donde el diseño depende de una sola línea compacta. */
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-filter-label,
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-icon-group-label,
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-filter-sublabel,
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-icon-btn__label,
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-filter-value,
.afjsanz-widget.afjsanz-layout-vertical .afjsanz-toggle-placeholder {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
}

.afjsanz-icon-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
}

.afjsanz-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background-color: #f5f5f5;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    width: 100%;
    box-sizing: border-box;
}

.afjsanz-icon-btn:hover:not(.is-active) {
    background-color: #e8e8e8;
}

.afjsanz-icon-btn.is-active {
    background-color: #1a2e3b;
}

.afjsanz-icon-btn__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.afjsanz-icon-btn__icon i {
    font-size: 32px;
    color: #1a2e3b;
}

.afjsanz-icon-btn__icon svg {
    width: 32px;
    height: 32px;
    fill: #1a2e3b;
}

.afjsanz-icon-btn__icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.afjsanz-icon-btn.is-active .afjsanz-icon-btn__icon i,
.afjsanz-icon-btn.is-active .afjsanz-icon-btn__icon svg {
    color: #ffffff;
    fill: #ffffff;
}

.afjsanz-icon-btn__label {
    font-size: 13px;
    line-height: 1.2;
    color: #1a2e3b;
}

.afjsanz-icon-btn.is-active .afjsanz-icon-btn__label {
    color: #ffffff;
}

/* En layout vertical, los icon-buttons ocupan el ancho completo */
.afjsanz-layout-vertical .afjsanz-icon-buttons {
    width: 100%;
}


.afjsanz-filter-input {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: 4px;
}

.afjsanz-filter-input .afjsanz-filter-value {
    flex: 1;
    min-width: 0;
}

/* Toggle placeholder */
.afjsanz-toggle-texts {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.afjsanz-toggle-placeholder {
    font-size: 12px;
    opacity: 0.7;
    line-height: 1.3;
}

/* Subetiqueta del filtro */
.afjsanz-filter-sublabel {
    display: block;
    font-size: 11px;
    opacity: 0.65;
    line-height: 1.3;
}

.afjsanz-filter-label-wrap {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* ─ Range Slider ────────────────────────────────────────────────────────── */

.afjsanz-range-label-top {
    display: block;
    margin-bottom: 6px;
}

.afjsanz-range-slider {
    width: 100%;
    padding: 4px 0 2px;
    user-select: none;
    -webkit-user-select: none;
}

.afjsanz-range-track {
    position: relative;
    height: 34px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    margin: 14px 0 10px;
    box-sizing: border-box;
}

.afjsanz-range-fill {
    position: absolute;
    top: 0;
    height: 100%;
    background: #1a2e3b;
    border-radius: 999px;
    pointer-events: none;
}

.afjsanz-range-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    cursor: grab;
    z-index: 2;
    touch-action: none;
}

.afjsanz-range-thumb:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.06);
}

.afjsanz-range-values {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-top: 4px;
}


.afjsanz-range-markers {
    position: relative;
    height: 28px;
    margin-top: 2px;
}

.afjsanz-range-marker {
    position: absolute;
    transform: translateX(-50%);
    font-size: 10px;
    color: #888;
    white-space: nowrap;
    line-height: 1.2;
    text-align: center;
}

.afjsanz-range-marker::before {
    content: '';
    display: block;
    width: 1px;
    height: 5px;
    background: #ccc;
    margin: 0 auto 2px;
}

.afjsanz-icon-btn.is-active {
    cursor: default;
}


/* ══════════════════ Diseño "modal" ══════════════════ */

/* Por defecto (cualquier layout que no sea "modal"): el botón oculto del
   todo, y la ventana oculta y fuera de flujo (no solo invisible, para
   que nunca pueda tapar nada por accidente). */
.afjsanz-modal-trigger {
    display: none !important;
}

.afjsanz-modal-backdrop {
    display: none !important;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.55);
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    box-sizing: border-box;
}

.afjsanz-widget.afjsanz-layout-modal .afjsanz-widget-inner {
    display: none;
}

.afjsanz-widget.afjsanz-layout-modal .afjsanz-modal-trigger {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    border: 0;
    background: var(--afjsanz-btn-bg, #1d4ed8);
    color: var(--afjsanz-btn-color, #fff);
    padding: 10px 20px;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    line-height: 1;
}

/* Tamaño del icono dentro del botón — sin esto, un SVG/icono de fuente
   puede salir a su tamaño nativo (a veces enorme). */
.afjsanz-modal-trigger i,
.afjsanz-modal-trigger svg {
    width: 16px;
    height: 16px;
    font-size: 16px;
    flex-shrink: 0;
}

/* Ventana modal — solo se vuelve visible con la clase .is-open */
.afjsanz-modal-backdrop.is-open {
    display: flex !important;
}

.afjsanz-modal-panel {
    background: #fff;
    width: 100%;
    max-width: 640px;
    max-height: 82vh;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    transform: scale(0.97);
    transition: transform .22s ease;
    overflow: hidden;
}

.afjsanz-modal-backdrop.is-open .afjsanz-modal-panel {
    transform: scale(1);
}

.afjsanz-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #ececec;
    flex-shrink: 0;
}

.afjsanz-modal-title {
    font-weight: 700;
    font-size: 17px;
}

.afjsanz-modal-close {
    position: relative;
    width: 32px;
    height: 32px;
    display: inline-block;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    color: #444;
}

.afjsanz-modal-close svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: block;
}

.afjsanz-modal-body {
    overflow-y: auto;
    padding: 16px 20px;
    flex: 1 1 auto;
}

.afjsanz-modal-footer {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid #ececec;
    flex-shrink: 0;
}

.afjsanz-modal-footer .afjsanz-submit,
.afjsanz-modal-footer .afjsanz-reset {
    margin-top: 0 !important;
    flex: 1;
    justify-content: center;
}

/* Grupos dentro del modal */
.afjsanz-modal-group {
    margin-bottom: 18px;
}

.afjsanz-modal-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 6px 0;
    font-weight: 700;
    font-size: 14px;
    border-bottom: 1px solid #eee;
    margin-bottom: 12px;
}

.afjsanz-modal-group-header svg,
.afjsanz-modal-group-header i {
    width: 14px;
    height: 14px;
    font-size: 14px;
    line-height: 1;
    display: inline-block;
    transition: transform .25s ease;
}

.afjsanz-modal-group.is-closed .afjsanz-modal-group-header svg,
.afjsanz-modal-group.is-closed .afjsanz-modal-group-header i {
    transform: rotate(-90deg);
}

/* Envoltorio que anima suavemente el alto al abrir/cerrar (truco de
   grid-template-rows 1fr↔0fr) — separado de la cuadrícula de columnas
   de abajo, para que ambas cosas no choquen entre sí. */
.afjsanz-modal-group-collapse {
    display: grid;
    grid-template-rows: 1fr;
    opacity: 1;
    transition: grid-template-rows .28s ease, opacity .22s ease;
}

.afjsanz-modal-group.is-closed .afjsanz-modal-group-collapse {
    grid-template-rows: 0fr;
    opacity: 0;
}

.afjsanz-modal-group-body {
    display: grid;
    gap: 12px;
    overflow: hidden;
    min-height: 0;
}

/* Dentro del modal, cada filtro ocupa toda su celda de la cuadrícula
   (anula el ancho/posicionamiento propio de los otros diseños) */
.afjsanz-modal-group-body .afjsanz-filter-item {
    width: 100% !important;
    flex: none !important;
}
