/**
 * FWA Product Filter - Modern UI Styles
 * 
 * Naming: .fwa-pf-* prefix for per-site CSS overrides
 * Override accent: .fwa-pf { --fwa-pf-accent: #your-color; }
 * 
 * @package FWA Add-ons
 * @since 2.2.0
 */

/* ==================== CSS VARIABLES ==================== */
.fwa-pf {
    --fwa-pf-accent: #2563eb;
    --fwa-pf-accent-hover: #1d4ed8;
    --fwa-pf-accent-light: #eff6ff;
    --fwa-pf-accent-bg: #dbeafe;
    --fwa-pf-text: #1e293b;
    --fwa-pf-text-sec: #64748b;
    --fwa-pf-text-muted: #94a3b8;
    --fwa-pf-border: #e2e8f0;
    --fwa-pf-bg: #ffffff;
    --fwa-pf-bg-hover: #f8fafc;
    --fwa-pf-radius: 8px;
    --fwa-pf-radius-sm: 6px;
    --fwa-pf-transition: 0.2s ease;
}
.sidebar > .widget label.fwa-pf-option,
.sidebar > .widget label.fwa-pf-price-range {
    line-height: 24px;
} 
/* ==================== CONTAINER ==================== */
.widget_fwa_product_filter {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--fwa-pf-text);
}

.fwa-pf {
    display: flex;
    flex-direction: column;
    padding: 0 10px 20px;
}

/* ==================== ACTIVE TAGS ==================== */
.fwa-pf-active {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0;
}

.fwa-pf-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--fwa-pf-accent-light);
    color: var(--fwa-pf-accent);
    border: 1px solid var(--fwa-pf-accent-bg);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    transition: background var(--fwa-pf-transition);
}

.fwa-pf-tag:hover { background: var(--fwa-pf-accent-bg); }

.fwa-pf-tag-x {
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    opacity: 0.6;
    line-height: 1;
    transition: opacity var(--fwa-pf-transition);
}

.fwa-pf-tag-x:hover { opacity: 1; }

/* ==================== SECTION ==================== */
.fwa-pf-section {
    border-bottom: 1px solid var(--fwa-pf-border);
}

.fwa-pf-section:last-of-type { border-bottom: none; }

/* Heading */
.fwa-pf-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 10px 0;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fwa-pf-text);
    cursor: pointer;
    user-select: none;
    transition: color var(--fwa-pf-transition);
}

.fwa-pf-heading:hover { color: var(--fwa-pf-accent); }

.fwa-pf-no-collapse > .fwa-pf-heading {
    cursor: default;
    pointer-events: none;
}
.fwa-pf-no-collapse > .fwa-pf-heading:hover { color: var(--fwa-pf-text); }

.fwa-pf-arrow {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.fwa-pf-arrow::after {
    content: '';
    width: 7px;
    height: 7px;
    border-right: 2px solid var(--fwa-pf-text-muted);
    border-bottom: 2px solid var(--fwa-pf-text-muted);
    transform: rotate(45deg);
    margin-top: -3px;
    transition: border-color var(--fwa-pf-transition);
}

.fwa-pf-heading:hover .fwa-pf-arrow::after { border-color: var(--fwa-pf-accent); }
.fwa-pf-section.is-collapsed .fwa-pf-arrow { transform: rotate(-90deg); }
.fwa-pf-section.is-collapsed .fwa-pf-body { display: none; }

/* Body */
.fwa-pf-body { padding: 0 0 10px; }

/* ==================== SEARCH INPUT ==================== */
.fwa-pf-search {
    position: relative;
    margin-bottom: 8px;
}

.fwa-pf-search input {
    width: 100%;
    padding: 6px 10px 6px 30px;
    border: 1px solid var(--fwa-pf-border);
    border-radius: var(--fwa-pf-radius-sm);
    font-size: 13px;
    color: var(--fwa-pf-text);
    background: var(--fwa-pf-bg);
    box-sizing: border-box;
    outline: none;
    transition: border-color var(--fwa-pf-transition), box-shadow var(--fwa-pf-transition);
}

.fwa-pf-search input:focus {
    border-color: var(--fwa-pf-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.fwa-pf-search input::placeholder { color: var(--fwa-pf-text-muted); }

.fwa-pf-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    opacity: 0.35;
    pointer-events: none;
}

.fwa-pf-search-icon svg {
    width: 14px;
    height: 14px;
}

/* ==================== OPTION LIST ==================== */
.fwa-pf-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fwa-pf-list li { margin: 0; padding: 0; }
.fwa-pf-list li.is-hidden { display: none; }

.fwa-pf-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    margin: 0 -6px;
    border-radius: var(--fwa-pf-radius-sm);
    cursor: pointer;
    font-weight: 400;
    transition: background var(--fwa-pf-transition);
}

.fwa-pf-option:hover { background: var(--fwa-pf-bg-hover); }

/* Custom checkbox/radio */
.fwa-pf-option input[type="checkbox"],
.fwa-pf-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.fwa-pf-check {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 2px solid var(--fwa-pf-border);
    border-radius: 4px;
    position: relative;
    transition: all var(--fwa-pf-transition);
    background: var(--fwa-pf-bg);
}

input[type="radio"] ~ .fwa-pf-check { border-radius: 50%; }

input:checked ~ .fwa-pf-check {
    background: var(--fwa-pf-accent);
    border-color: var(--fwa-pf-accent);
}

input:checked ~ .fwa-pf-check::after {
    content: '';
    position: absolute;
    top: 0px;
    left: 4px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="radio"]:checked ~ .fwa-pf-check::after {
    top: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    border: none;
    background: #fff;
    border-radius: 50%;
    transform: none;
}

.fwa-pf-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--fwa-pf-text);
    transition: color var(--fwa-pf-transition);
}

input:checked ~ .fwa-pf-name {
    color: var(--fwa-pf-accent);
    font-weight: 600;
}

.fwa-pf-count {
    color: var(--fwa-pf-text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

/* Scrollable */
.fwa-pf-scroll {
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--fwa-pf-border) transparent;
}

.fwa-pf-scroll::-webkit-scrollbar { width: 5px; }
.fwa-pf-scroll::-webkit-scrollbar-track { background: transparent; }
.fwa-pf-scroll::-webkit-scrollbar-thumb { background: var(--fwa-pf-border); border-radius: 3px; }
.fwa-pf-scroll::-webkit-scrollbar-thumb:hover { background: var(--fwa-pf-text-muted); }

/* ==================== SHOW MORE ==================== */
.fwa-pf-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 0;
    margin-top: 2px;
    border: none;
    background: none;
    color: var(--fwa-pf-accent);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--fwa-pf-transition);
}

.fwa-pf-more:hover {
    color: var(--fwa-pf-accent-hover);
    text-decoration: underline;
}

.fwa-pf-more-icon {
    transition: transform 0.25s ease;
    font-size: 10px;
    line-height: 1;
}

.fwa-pf-more.is-expanded .fwa-pf-more-icon {
    transform: rotate(180deg);
}

/* ==================== PRICE RANGES ==================== */
.fwa-pf-price-ranges {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--fwa-pf-border);
    border-radius: var(--fwa-pf-radius);
    overflow: hidden;
}

.fwa-pf-price-range {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--fwa-pf-border);
    border-radius: 0;
    cursor: pointer;
    transition: all var(--fwa-pf-transition);
    background: var(--fwa-pf-bg);
}

.fwa-pf-price-range:last-child { border-bottom: none; }

.fwa-pf-price-range:hover {
    background: var(--fwa-pf-accent-light);
}

.fwa-pf-price-range input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.fwa-pf-price-range-dot {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 2px solid var(--fwa-pf-border);
    border-radius: 50%;
    position: relative;
    transition: all var(--fwa-pf-transition);
    background: var(--fwa-pf-bg);
}

input:checked ~ .fwa-pf-price-range-dot {
    border-color: var(--fwa-pf-accent);
}

input:checked ~ .fwa-pf-price-range-dot::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    background: var(--fwa-pf-accent);
    border-radius: 50%;
}

.fwa-pf-price-range-label {
    font-size: 13px;
    color: var(--fwa-pf-text);
    font-weight: 400;
}

input:checked ~ .fwa-pf-price-range-label {
    color: var(--fwa-pf-accent);
    font-weight: 600;
}

/* Custom price inputs */
.fwa-pf-price-custom-wrap {
    margin-top: 10px;
}

.fwa-pf-price-custom-label {
    margin: 10px 0 6px;
    font-size: 12px;
    color: var(--fwa-pf-text-sec);
}

.fwa-pf-price-custom {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.fwa-pf-price-input {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--fwa-pf-border);
    border-radius: var(--fwa-pf-radius-sm);
    background: var(--fwa-pf-bg);
    overflow: hidden;
    transition: border-color var(--fwa-pf-transition), box-shadow var(--fwa-pf-transition);
}

.fwa-pf-price-input:focus-within {
    border-color: var(--fwa-pf-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.fwa-pf-price-input input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 6px 8px;
    font-size: 13px;
    color: var(--fwa-pf-text);
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
    box-sizing: border-box;
}

.fwa-pf-price-input input::-webkit-inner-spin-button,
.fwa-pf-price-input input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fwa-pf-price-input input::placeholder { color: var(--fwa-pf-text-muted); }

.fwa-pf-price-unit {
    padding: 0 10px 0 0;
    font-size: 13px;
    color: var(--fwa-pf-text-muted);
    flex-shrink: 0;
    pointer-events: none;
}

/* ==================== RATING ==================== */
.fwa-pf-stars {
    display: inline-flex;
    gap: 1px;
}

.fwa-pf-star {
    font-size: 15px;
    line-height: 1;
    color: #facc15;
}

.fwa-pf-star.is-empty { color: #e2e8f0; }

.fwa-pf-rating-label {
    font-size: 12px;
    color: var(--fwa-pf-text-sec);
}

/* ==================== COLOR SWATCHES ==================== */
.fwa-pf-swatches .fwa-pf-check { display: none; }

.fwa-pf-swatch {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--fwa-pf-border);
    flex-shrink: 0;
    transition: all var(--fwa-pf-transition);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

input:checked ~ .fwa-pf-swatch {
    border-color: var(--fwa-pf-accent);
    box-shadow: 0 0 0 2px var(--fwa-pf-bg), 0 0 0 4px var(--fwa-pf-accent);
}

/* ==================== HEADER ==================== */
.fwa-pf-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 4px 0;
}

.fwa-pf-header .fwa-pf-active {
    flex: 1;
    padding: 0;
    min-height: 0;
}

/* ==================== ACTIONS ==================== */
.fwa-pf-btn-apply {
    display: block;
    width: 100%;
    padding: 8px 14px;
    background: var(--fwa-pf-accent);
    color: #fff;
    border: none;
    border-radius: var(--fwa-pf-radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--fwa-pf-transition), transform 0.1s;
    text-align: center;
}

.fwa-pf-btn-apply:hover { background: var(--fwa-pf-accent-hover); }
.fwa-pf-btn-apply:active { transform: scale(0.98); }

/* ==================== DROPDOWN AUTOCOMPLETE ==================== */
.fwa-pf-dropdown {
    position: relative;
}

.fwa-pf-dd-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-height: 36px;
    padding: 4px 30px 4px 8px;
    border: 1px solid var(--fwa-pf-border);
    border-radius: var(--fwa-pf-radius-sm);
    background: var(--fwa-pf-bg);
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    transition: border-color var(--fwa-pf-transition), box-shadow var(--fwa-pf-transition);
}

.fwa-pf-dropdown.is-open .fwa-pf-dd-box {
    border-color: var(--fwa-pf-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Chips live inline with the search input */
.fwa-pf-dd-chips { display: contents; }

.fwa-pf-dd-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 4px 2px 8px;
    background: var(--fwa-pf-accent-light);
    color: var(--fwa-pf-accent);
    border: 1px solid var(--fwa-pf-accent-bg);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 130px;
}

.fwa-pf-dd-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.fwa-pf-dd-chip-x {
    flex-shrink: 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    opacity: 0.55;
    line-height: 1;
    transition: opacity var(--fwa-pf-transition);
}
.fwa-pf-dd-chip-x:hover { opacity: 1; }

.fwa-pf-dd-search {
    flex: 1;
    min-width: 50px;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: var(--fwa-pf-text);
    padding: 2px 0;
    cursor: pointer;
}
.fwa-pf-dd-search::placeholder { color: var(--fwa-pf-text-muted); }
.fwa-pf-dd-search:focus { cursor: text; }

.fwa-pf-dd-caret {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fwa-pf-text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    transition: transform 0.2s ease;
}
.fwa-pf-dropdown.is-open .fwa-pf-dd-caret {
    transform: translateY(-50%) rotate(180deg);
}

.fwa-pf-dd-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--fwa-pf-bg);
    border: 1px solid var(--fwa-pf-accent);
    border-top: none;
    border-bottom-left-radius: var(--fwa-pf-radius-sm);
    border-bottom-right-radius: var(--fwa-pf-radius-sm);
    box-shadow: 0 6px 16px rgba(0,0,0,0.10);
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--fwa-pf-border) transparent;
}
.fwa-pf-dropdown.is-open .fwa-pf-dd-menu { display: block; }

.fwa-pf-dd-menu::-webkit-scrollbar { width: 4px; }
.fwa-pf-dd-menu::-webkit-scrollbar-track { background: transparent; }
.fwa-pf-dd-menu::-webkit-scrollbar-thumb { background: var(--fwa-pf-border); border-radius: 3px; }

.fwa-pf-dd-menu .fwa-pf-list { padding: 4px 0; }
.fwa-pf-dd-menu .fwa-pf-option {
    border-radius: 0;
    margin: 0;
    padding: 7px 12px;
}

.fwa-pf-dd-empty {
    margin: 0;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--fwa-pf-text-muted);
    text-align: center;
}

.fwa-pf-dd-loading {
    display: none; /* shown by JS while the AJAX call is in-flight */
    margin: 0;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--fwa-pf-text-muted);
    text-align: center;
}

/* Smaller swatch inside dropdown options */
.fwa-pf-swatch-sm {
    width: 16px;
    height: 16px;
}

.fwa-pf-btn-reset {
    display: none;
    flex-shrink: 0;
    padding: 0;
    background: none;
    border: none;
    color: var(--fwa-pf-accent);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--fwa-pf-transition);
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.fwa-pf-btn-reset:hover {
    color: var(--fwa-pf-accent-hover);
}

.fwa-pf-btn-reset svg {
    display: block;
}

/* ==================== LOADING ==================== */
.fwa-pf-loading {
    position: relative;
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.fwa-pf-loading::after {
    content: '';
    position: absolute;
    top: 60px;
    left: 50%;
    width: 32px;
    height: 32px;
    margin-left: -16px;
    border: 3px solid var(--fwa-pf-border);
    border-top-color: var(--fwa-pf-accent);
    border-radius: 50%;
    animation: fwa-pf-spin 0.6s linear infinite;
    z-index: 10;
}

@keyframes fwa-pf-spin { to { transform: rotate(360deg); } }

/* ==================== NO RESULTS ==================== */
.fwa-pf-no-results {
    text-align: center;
    padding: 48px 20px;
    color: var(--fwa-pf-text-sec);
}

.fwa-pf-no-results p { margin: 0; font-size: 14px; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .fwa-pf-heading { padding: 12px 0; }
}

/* Chặn click khi đang load bộ lọc */
.fwa-pf.is-loading-filters {
    pointer-events: none;
    position: relative;
}

/* Hiệu ứng mờ khi load */
.fwa-pf.is-loading-filters .fwa-pf-section {
    opacity: 0.6;
    transition: opacity 0.2s;
}

.fwa-pf.is-loading-filters::after {
    content: "";
    position: absolute;
    top: 100px;
    left: 50%;
    width: 32px;
    height: 32px;
    margin-left: -16px;
    border: 3px solid var(--fwa-pf-border);
    border-top-color: var(--fwa-pf-accent);
    border-radius: 50%;
    animation: fwa-pf-spin 0.6s linear infinite;
    z-index: 100;
}

.woocommerce-pagination {
    margin: 24px 0;
    text-align: center;
}
.woocommerce-pagination ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: inline-flex;
    gap: 4px;
    border: none;
}
.woocommerce-pagination ul li {
    list-style: none;
    margin: 0;
    padding: 0;
    border: none;
}
.woocommerce-pagination ul li a,
.woocommerce-pagination ul li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--fwa-pf-border, #e2e8f0);
    border-radius: 6px;
    background: var(--fwa-pf-bg, #fff);
    color: var(--fwa-pf-text, #1e293b);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}
.woocommerce-pagination ul li a:hover {
    background: var(--fwa-pf-accent-light, #eff6ff);
    border-color: var(--fwa-pf-accent, #2563eb);
    color: var(--fwa-pf-accent, #2563eb);
}
.woocommerce-pagination ul li span.current {
    background: var(--fwa-pf-accent, #2563eb);
    border-color: var(--fwa-pf-accent, #2563eb);
    color: #fff;
    cursor: default;
}
.woocommerce-pagination ul li .dots {
    border-color: transparent;
    background: transparent;
    cursor: default;
    color: var(--fwa-pf-text-muted, #94a3b8);
}
.woocommerce-pagination ul li .prev,
.woocommerce-pagination ul li .next {
    font-size: 16px;
}