/**
 * Advanced WooCommerce Filter — Frontend Styles
 *
 * Variables dynamiques injectées depuis l'admin :
 *   --awf-primary, --awf-secondary, --awf-accent
 *
 * @package AdvancedWcFilter
 */

/* ═══════════════════════════════════════════════════════════════════
   Reset & Container
   ═══════════════════════════════════════════════════════════════════ */

.awf-filters {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
    box-sizing: border-box;
}

.awf-filters *,
.awf-filters *::before,
.awf-filters *::after {
    box-sizing: inherit;
}

/* ═══════════════════════════════════════════════════════════════════
   Layout modes
   ═══════════════════════════════════════════════════════════════════ */

/* Vertical (sidebar) */
.awf-vertical .awf-filters-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Horizontal */
.awf-horizontal .awf-filters-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
    padding: 16px 0;
}

.awf-horizontal .awf-filter-group {
    flex: 1 1 200px;
    min-width: 180px;
    max-width: 280px;
}

/* ═══════════════════════════════════════════════════════════════════
   Status bar (product count + active filters + reset)
   ═══════════════════════════════════════════════════════════════════ */

.awf-status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 8px;
    min-height: 40px;
}

.awf-product-count {
    font-weight: 600;
    font-size: 13px;
    color: #4b5563;
    white-space: nowrap;
}

.awf-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.awf-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--awf-primary, #2563eb);
    color: #fff;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background .2s, transform .15s;
    white-space: nowrap;
}

.awf-active-tag:hover {
    background: var(--awf-secondary, #1e40af);
    transform: scale(1.04);
}

.awf-active-tag .awf-tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    font-size: 11px;
    line-height: 1;
}

/* Reset button */
.awf-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}

.awf-reset-btn:hover {
    border-color: var(--awf-primary, #2563eb);
    color: var(--awf-primary, #2563eb);
    background: #f0f5ff;
}

.awf-reset-btn svg {
    flex-shrink: 0;
}

.awf-reset-inline {
    margin-top: 16px;
    border-color: var(--awf-primary, #2563eb);
    color: var(--awf-primary, #2563eb);
}

/* ═══════════════════════════════════════════════════════════════════
   Filter group (each section)
   ═══════════════════════════════════════════════════════════════════ */

.awf-filter-group {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow .2s;
}

.awf-filter-group:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* ─── Title / Collapsible header ─────────────────────────────────── */

.awf-filter-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
    transition: background .15s;
}

.awf-filter-title:hover {
    background: #f9fafb;
}

.awf-filter-title[aria-expanded="true"] {
    border-bottom-color: #e5e7eb;
}

/* Toggle icon (chevron) */
.awf-toggle-icon {
    position: relative;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.awf-toggle-icon::before,
.awf-toggle-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 8px;
    height: 2px;
    background: #6b7280;
    border-radius: 2px;
    transition: transform .25s;
}

.awf-toggle-icon::before {
    left: 2px;
    transform: translateY(-50%) rotate(45deg);
}

.awf-toggle-icon::after {
    right: 2px;
    transform: translateY(-50%) rotate(-45deg);
}

.awf-filter-title[aria-expanded="false"] .awf-toggle-icon::before {
    transform: translateY(-50%) rotate(-45deg);
}

.awf-filter-title[aria-expanded="false"] .awf-toggle-icon::after {
    transform: translateY(-50%) rotate(45deg);
}

/* ─── Content area ───────────────────────────────────────────────── */

.awf-filter-content {
    padding: 12px 16px 16px;
    transition: max-height .3s ease, opacity .25s ease;
    overflow: hidden;
}

.awf-filter-content.awf-collapsed {
    max-height: 0 !important;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   Checkbox list
   ═══════════════════════════════════════════════════════════════════ */

.awf-checkbox-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.awf-checkbox-list li {
    margin-bottom: 2px;
}

.awf-sub-list {
    list-style: none;
    margin: 0 0 0 20px;
    padding: 0;
}

.awf-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
}

.awf-checkbox-label:hover {
    background: #f3f4f6;
}

/* Hide native checkbox */
.awf-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Custom checkmark */
.awf-checkmark {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    transition: all .15s;
}

.awf-checkmark::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform .15s;
    margin-top: -1px;
}

.awf-checkbox-label input:checked ~ .awf-checkmark {
    background: var(--awf-primary, #2563eb);
    border-color: var(--awf-primary, #2563eb);
}

.awf-checkbox-label input:checked ~ .awf-checkmark::after {
    transform: rotate(45deg) scale(1);
}

.awf-label-text {
    flex: 1;
    font-size: 13px;
    color: #374151;
}

.awf-count {
    font-size: 12px;
    color: #9ca3af;
    margin-left: auto;
}

/* Scrollable list for long taxonomies */
.awf-scrollable {
    max-height: 240px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.awf-scrollable::-webkit-scrollbar {
    width: 5px;
}

.awf-scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.awf-scrollable::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ═══════════════════════════════════════════════════════════════════
   Color swatches
   ═══════════════════════════════════════════════════════════════════ */

.awf-swatch-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.awf-swatch-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

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

.awf-swatch {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    transition: transform .15s, border-color .15s, box-shadow .15s;
}

.awf-swatch-label input:checked ~ .awf-swatch {
    border-color: var(--awf-primary, #2563eb);
    box-shadow: 0 0 0 2px var(--awf-primary, #2563eb);
    transform: scale(1.1);
}

.awf-swatch-label:hover .awf-swatch {
    transform: scale(1.08);
}

.awf-swatch-name {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    max-width: 48px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════
   Price slider
   ═══════════════════════════════════════════════════════════════════ */

.awf-price-inputs {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 16px;
}

.awf-price-field {
    flex: 1;
}

.awf-price-field label {
    display: block;
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.awf-price-input {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    color: #111827;
    background: #fff;
    transition: border-color .2s;
    -moz-appearance: textfield;
}

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

.awf-price-input:focus {
    outline: none;
    border-color: var(--awf-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.awf-price-sep {
    padding-bottom: 10px;
    color: #9ca3af;
    font-weight: 500;
}

/* noUISlider overrides */
.awf-price-slider {
    margin: 0 6px;
}

.awf-price-slider .noUi-target {
    background: #e5e7eb;
    border: none;
    border-radius: 4px;
    box-shadow: none;
    height: 6px;
}

.awf-price-slider .noUi-connect {
    background: var(--awf-primary, #2563eb);
    border-radius: 4px;
}

.awf-price-slider .noUi-handle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--awf-primary, #2563eb);
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
    cursor: grab;
    top: -8px;
    right: -10px;
}

.awf-price-slider .noUi-handle:active {
    cursor: grabbing;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .3);
}

.awf-price-slider .noUi-handle::before,
.awf-price-slider .noUi-handle::after {
    display: none;
}

.awf-price-display {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════
   Toggle switch (Sale filter)
   ═══════════════════════════════════════════════════════════════════ */

.awf-toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 0;
}

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

.awf-slider-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background: #d1d5db;
    border-radius: 24px;
    flex-shrink: 0;
    transition: background .2s;
}

.awf-slider-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
    transition: transform .2s;
}

.awf-toggle-switch input:checked ~ .awf-slider-toggle {
    background: var(--awf-primary, #2563eb);
}

.awf-toggle-switch input:checked ~ .awf-slider-toggle::after {
    transform: translateX(20px);
}

/* ═══════════════════════════════════════════════════════════════════
   Search input for long term lists
   ═══════════════════════════════════════════════════════════════════ */

.awf-search-input-wrap {
    margin-bottom: 10px;
}

.awf-term-search {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    color: #111827;
    background: #f9fafb;
    transition: border-color .2s;
}

.awf-term-search:focus {
    outline: none;
    border-color: var(--awf-primary, #2563eb);
    background: #fff;
}

/* ═══════════════════════════════════════════════════════════════════
   Loading overlay
   ═══════════════════════════════════════════════════════════════════ */

.awf-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, .6);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    pointer-events: all;
}

.awf-spinner {
    display: flex;
    gap: 6px;
    align-items: center;
}

.awf-bounce1,
.awf-bounce2,
.awf-bounce3 {
    width: 12px;
    height: 12px;
    background: var(--awf-primary, #2563eb);
    border-radius: 50%;
    animation: awf-bounce 1.4s infinite ease-in-out both;
}

.awf-bounce1 { animation-delay: -0.32s; }
.awf-bounce2 { animation-delay: -0.16s; }
.awf-bounce3 { animation-delay: 0s; }

@keyframes awf-bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: .5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.awf-loading-text {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════
   No products found
   ═══════════════════════════════════════════════════════════════════ */

.awf-no-products {
    text-align: center;
    padding: 48px 20px;
    color: #6b7280;
}

.awf-no-products svg {
    margin-bottom: 12px;
    opacity: .5;
}

.awf-no-products p {
    font-size: 15px;
    margin: 0 0 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   Pagination
   ═══════════════════════════════════════════════════════════════════ */

.awf-pagination {
    display: flex;
    justify-content: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
}

.awf-page-numbers {
    list-style: none;
    display: flex;
    gap: 4px;
    margin: 0;
    padding: 0;
}

.awf-page-numbers li a,
.awf-page-numbers li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    color: #374151;
    background: #fff;
    border: 1px solid #e5e7eb;
    transition: all .2s;
    cursor: pointer;
}

.awf-page-numbers li a:hover {
    border-color: var(--awf-primary, #2563eb);
    color: var(--awf-primary, #2563eb);
    background: #f0f5ff;
}

.awf-page-numbers li span.current {
    background: var(--awf-primary, #2563eb);
    border-color: var(--awf-primary, #2563eb);
    color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════
   Product grid transition
   ═══════════════════════════════════════════════════════════════════ */

.awf-products-container {
    transition: opacity .3s;
}

.awf-products-container.awf-fading {
    opacity: .3;
}

/* ═══════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

    .awf-horizontal .awf-filters-inner {
        flex-direction: column;
    }

    .awf-horizontal .awf-filter-group {
        max-width: 100%;
    }

    /* Mobile toggle button */
    .awf-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 12px;
        background: var(--awf-primary, #2563eb);
        color: #fff;
        border: none;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        margin-bottom: 12px;
    }

    .awf-mobile-toggle svg {
        width: 18px;
        height: 18px;
    }

    .awf-filters-inner.awf-mobile-hidden {
        display: none;
    }
}

@media (min-width: 769px) {
    .awf-mobile-toggle {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   Depth styling for subcategories
   ═══════════════════════════════════════════════════════════════════ */

.awf-depth-1 {
    padding-left: 8px;
}

.awf-depth-2 {
    padding-left: 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   Disabled state for terms with 0 results
   ═══════════════════════════════════════════════════════════════════ */

.awf-checkbox-label.awf-disabled {
    opacity: .4;
    pointer-events: none;
}
