/* =============================================
   WooCommerce Ajax Filters — Styles
   Lightweight, zero-dependency, theme-agnostic
   ============================================= */

:root {
    --waf-accent: #2563eb;
    --waf-accent-hover: #1d4ed8;
    --waf-text: #1e293b;
    --waf-text-muted: #64748b;
    --waf-border: #e2e8f0;
    --waf-bg: #ffffff;
    --waf-bg-hover: #f8fafc;
    --waf-radius: 6px;
    --waf-gap: 20px;
    --waf-sidebar-w: 260px;
    --waf-transition: 180ms ease;
}

/* Layout */
.waf-wrapper {
    font-family: inherit;
    color: var(--waf-text);
    line-height: 1.5;
}

/* ── Sidebar ── */
.waf-sidebar {
    padding: 16px;
    border: 1px solid var(--waf-border);
    border-radius: var(--waf-radius);
    background: var(--waf-bg);
}

/* Filter group */
.waf-filter-group {
    margin-bottom: 16px;
}

.waf-filter-group:last-of-type {
    margin-bottom: 12px;
}

.waf-group-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 0;
    margin-bottom: 8px;
    border: none;
    border-bottom: 1px solid var(--waf-border);
    background: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--waf-text);
}

.waf-group-toggle .waf-toggle-icon {
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--waf-text-muted);
    transition: color var(--waf-transition);
}

.waf-group-toggle:hover .waf-toggle-icon {
    color: var(--waf-text);
}

.waf-group-toggle[aria-expanded="false"] + .waf-group-list {
    display: none;
}

/* ── Tree structure ── */
.waf-group-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.waf-tree-node {
    position: relative;
}

/* Indent each depth level */
.waf-tree-node[data-depth="1"] { padding-left: 18px; }
.waf-tree-node[data-depth="2"] { padding-left: 36px; }
.waf-tree-node[data-depth="3"] { padding-left: 54px; }
.waf-tree-node[data-depth="4"] { padding-left: 72px; }

/* Vertical tree lines */
.waf-tree-children {
    position: relative;
}

.waf-tree-children::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10px;
    bottom: 8px;
    width: 1px;
    background: var(--waf-border);
}

/* Row: toggle + checkbox */
.waf-tree-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Branch expand/collapse toggle — solo el símbolo */
.waf-branch-toggle {
    flex-shrink: 0;
    width: auto;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--waf-text);
    padding: 0 4px 0 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.waf-branch-toggle:hover {
    color: var(--waf-accent);
    background: none;
}

.waf-toggle-icon {
    font-size: inherit;
    font-weight: inherit;
    line-height: 1;
}

/* Collapsed children — JS controls display via style.display */

/* Flat list (marcas) — sin árbol, sin toggle de rama */
.waf-flat-list {
    gap: 2px;
}

.waf-flat-list .waf-checkbox {
    flex: none;
}

.waf-branch-spacer {
    flex-shrink: 0;
    width: 12px;
}

/* Checkboxes */
.waf-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background var(--waf-transition);
    user-select: none;
    flex: 1;
    min-width: 0;
}

.waf-checkbox:hover {
    background: var(--waf-bg-hover);
}

.waf-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.waf-check-mark {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--waf-border);
    border-radius: 3px;
    background: var(--waf-bg);
    transition: all var(--waf-transition);
    position: relative;
}

.waf-checkbox input:checked + .waf-check-mark {
    background: var(--waf-accent);
    border-color: var(--waf-accent);
}

.waf-checkbox input:checked + .waf-check-mark::after {
    content: '';
    position: absolute;
    left: 3.5px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.waf-checkbox input:focus-visible + .waf-check-mark {
    outline: 2px solid var(--waf-accent);
    outline-offset: 2px;
}

.waf-label-text {
    flex: 1;
    color: var(--waf-text);
}

.waf-count-badge {
    font-size: 11px;
    color: var(--waf-text-muted);
}

/* Clear button */
.waf-clear-btn {
    display: none; /* se muestra via JS cuando hay filtros */
    width: 100%;
    padding: 8px 12px;
    margin-top: 8px;
    border: 1px solid var(--waf-border);
    border-radius: var(--waf-radius);
    background: none;
    color: var(--waf-text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--waf-transition);
}

.waf-clear-btn.waf-visible {
    display: block;
}

.waf-clear-btn:hover {
    border-color: var(--waf-accent);
    color: var(--waf-accent);
}

/* Transición rápida para el swap de productos */
ul.products {
    transition: opacity 100ms ease;
}

/* ── Paginación Astra — rojo / negro activo / centrada ── */
.ast-pagination,
.woocommerce-pagination,
nav.pagination {
    text-align: center !important;
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
}

.ast-pagination .nav-links,
.woocommerce-pagination .nav-links,
nav.pagination .nav-links {
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
}

.ast-pagination a,
.ast-pagination span,
.woocommerce-pagination a,
.woocommerce-pagination span,
nav.pagination a,
nav.pagination span {
    color: #dc2626 !important;
    border-color: #dc2626 !important;
    background: none !important;
}

.ast-pagination .page-numbers.current,
.woocommerce-pagination .page-numbers.current,
nav.pagination .page-numbers.current {
    color: #fff !important;
    background: #1a1a1a !important;
    border-color: #dc2626 !important;
}

.ast-pagination a:hover,
.woocommerce-pagination a:hover,
nav.pagination a:hover {
    color: #fff !important;
    background: #dc2626 !important;
    border-color: #dc2626 !important;
}

/* ── Responsive ── */
@media (max-width: 991px) {
    .waf-sidebar {
        position: static;
        max-height: none;
    }
}
