/* ================================================================
   WC Attribute Filter v1.3.0 — Pill/Tag Multi-Select
   Dropdown list uses position:fixed (set by JS) to escape
   any overflow:hidden ancestor (Elementor sections, themes, etc.)
   ================================================================ */

.wcaf-wrapper { position: relative; width: 100%; }

/* ── Filter Bar ─────────────────────────────────────────────── */
.wcaf-filter-bar {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    /* DO NOT set overflow:hidden here — would clip the list */
}

.wcaf-filter-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    flex: 1 1 auto;
    align-items: flex-end;
}

.wcaf-filter-field {
    display: flex;
    flex-direction: column;
    min-width: 160px;
    flex: 1 1 180px;
    max-width: 320px;
    /* NO position:relative, NO overflow — let list escape */
}

.wcaf-filter-field.wcaf-field-multi {
    flex: 2 1 220px;
    max-width: 380px;
}

.wcaf-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #333;
    margin-bottom: 5px;
}

/* ── Dropdown container ─────────────────────────────────────── */
.wcaf-dropdown {
    position: relative;
    user-select: none;
    outline: none;
}

/* ── Trigger box ────────────────────────────────────────────── */
.wcaf-dropdown-trigger {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1.5px solid #c8c8c8;
    border-radius: 6px;
    padding: 6px 10px 6px 8px;
    min-height: 40px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    gap: 4px;
    box-sizing: border-box;
}
.wcaf-dropdown.wcaf-open .wcaf-dropdown-trigger,
.wcaf-dropdown-trigger:hover {
    border-color: #96003b;
    box-shadow: 0 0 0 2px rgba(150,0,59,0.10);
}

/* ── Pills area ─────────────────────────────────────────────── */
.wcaf-pills-area {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    flex: 1;
    align-items: center;
    min-height: 26px;
}

.wcaf-pills-placeholder {
    font-size: 13px;
    color: #aaa;
    line-height: 1;
    padding: 2px 0;
}

/* Blinking caret — only visible when open */
.wcaf-cursor {
    display: none;
    width: 1.5px;
    height: 15px;
    background: #555;
    animation: wcaf-blink 1s step-end infinite;
    vertical-align: middle;
    flex-shrink: 0;
}
.wcaf-dropdown.wcaf-open .wcaf-cursor { display: inline-block; }
@keyframes wcaf-blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Pill tag ───────────────────────────────────────────────── */
.wcaf-pill {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border: 1.5px solid #bbb;
    border-radius: 20px;
    padding: 3px 6px 3px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #333;
    gap: 5px;
    white-space: nowrap;
    max-width: 200px;
    line-height: 1.3;
}
.wcaf-pill-text {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}
.wcaf-pill-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ccc;
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.wcaf-pill-remove:hover { background: #96003b; }

/* ── Arrow ──────────────────────────────────────────────────── */
.wcaf-dropdown-arrow {
    flex-shrink: 0;
    font-size: 10px;
    color: #888;
    transition: transform 0.2s;
    margin-left: auto;
    padding-left: 4px;
    line-height: 1;
    pointer-events: none;
}
.wcaf-dropdown.wcaf-open .wcaf-dropdown-arrow { transform: rotate(180deg); }

/* ── Single-select display ──────────────────────────────────── */
.wcaf-single-display {
    flex: 1;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1;
    pointer-events: none;
}
.wcaf-single-display.wcaf-placeholder { color: #aaa; }

.wcaf-dropdown-clear {
    flex-shrink: 0;
    font-size: 20px;
    line-height: 1;
    color: #bbb;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
}
.wcaf-dropdown-clear:hover { color: #96003b; }

/* ── Dropdown list (position set by JS to fixed) ────────────── */
.wcaf-dropdown-list {
    display: none;    /* hidden by default */
    background: #fff;
    border: 1.5px solid #c8c8c8;
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.13);
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 260px;
    overflow-y: auto;
    /* z-index set inline by JS, but also here as fallback */
    z-index: 999999 !important;
    /* Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #ccc #f5f5f5;
    box-sizing: border-box;
}
.wcaf-dropdown-list::-webkit-scrollbar { width: 6px; }
.wcaf-dropdown-list::-webkit-scrollbar-track { background: #f5f5f5; }
.wcaf-dropdown-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.wcaf-dropdown-list::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* Show when open — JS sets position:fixed + coordinates */
.wcaf-dropdown.wcaf-open .wcaf-dropdown-list {
    display: block;
}

/* ── List items ─────────────────────────────────────────────── */
.wcaf-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: background 0.1s;
    list-style: none;
}
.wcaf-dropdown-item:hover { background: #faf0f4; }
.wcaf-dropdown-item.wcaf-selected { background: #f5e8ed; }
.wcaf-dropdown-item.wcaf-selected:hover { background: #eedce4; }

.wcaf-item-label {
    flex: 1;
    font-size: 13px;
    color: #333;
    pointer-events: none;
}
.wcaf-dropdown-item.wcaf-selected .wcaf-item-label { font-weight: 500; }

/* Checkbox for multi */
.wcaf-item-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-radius: 3px;
    flex-shrink: 0;
    background: #fff;
    transition: background 0.15s, border-color 0.15s;
    pointer-events: none;
}
.wcaf-dropdown-item.wcaf-selected .wcaf-item-check {
    background: #96003b;
    border-color: #96003b;
}
.wcaf-dropdown-item.wcaf-selected .wcaf-item-check::after {
    content: '✓';
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
}

/* ── Reset Button ───────────────────────────────────────────── */
.wcaf-filter-actions {
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
}
.wcaf-reset-btn {
    padding: 0 22px;
    height: 40px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid #96003b;
    background: #96003b;
    color: #fff;
    transition: background 0.15s;
    white-space: nowrap;
    line-height: 1;
}
.wcaf-reset-btn:hover { background: #7a0030; border-color: #7a0030; }

/* ── Sort Bar ────────────────────────────────────────────────── */
.wcaf-sort-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.wcaf-sort-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #555;
    white-space: nowrap;
    flex-shrink: 0;
}

.wcaf-sort-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    border: 1.5px solid #c8c8c8;
    border-radius: 6px;
    color: #333;
    cursor: pointer;
    font-size: 13px;
    height: 40px;
    line-height: 1.4;
    padding: 0 36px 0 12px;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 240px;
    max-width: 100%;
    box-sizing: border-box;
}
.wcaf-sort-select:hover,
.wcaf-sort-select:focus {
    border-color: #96003b;
    box-shadow: 0 0 0 2px rgba(150,0,59,0.10);
    outline: none;
}

/* Option active colour in some browsers */
.wcaf-sort-select option:checked { background-color: #96003b; color: #fff; }

@media (max-width: 768px) {
    .wcaf-sort-bar { flex-direction: column; align-items: flex-start; }
    .wcaf-sort-select { width: 100%; }
}

/* ── Loading state on downstream dropdowns ──────────────────── */
.wcaf-dropdown.wcaf-loading .wcaf-dropdown-trigger {
    opacity: 0.55;
    pointer-events: none;
    cursor: default;
}
.wcaf-dropdown.wcaf-loading .wcaf-dropdown-arrow {
    border: 2px solid #e0e0e0;
    border-top-color: #96003b;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    font-size: 0;
    animation: wcaf-spin 0.6s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-left: auto;
    padding: 0;
    flex-shrink: 0;
}

/* ── Term count inside list item ────────────────────────────── */
.wcaf-term-count {
    color: #999;
    font-size: 11px;
    font-weight: 400;
    margin-left: 2px;
}
.wcaf-dropdown-item.wcaf-selected .wcaf-term-count {
    color: #b06;
}
.wcaf-dropdown-item:hover .wcaf-term-count {
    color: #b06;
}
.wcaf-result-count {
    font-size: 13px;
    color: #777;
    margin-bottom: 10px;
}

/* ── Loading ────────────────────────────────────────────────── */
.wcaf-loading-overlay {
    display: none;
    text-align: center;
    padding: 8px 0;
}
.wcaf-spinner {
    display: inline-block;
    width: 26px;
    height: 26px;
    border: 3px solid #e0e0e0;
    border-top-color: #96003b;
    border-radius: 50%;
    animation: wcaf-spin 0.6s linear infinite;
    vertical-align: middle;
}
@keyframes wcaf-spin { to { transform: rotate(360deg); } }

/* ── Products ───────────────────────────────────────────────── */
.wcaf-products-wrapper { position: relative; min-height: 100px; }
.wcaf-no-products { text-align: center; padding: 40px 20px; color: #888; font-size: 15px; width: 100%; }

/* ── Pagination ─────────────────────────────────────────────── */
.wcaf-pagination { margin-top: 24px; text-align: center; }
.wcaf-pagination .woocommerce-pagination ul.page-numbers {
    list-style: none; margin: 0; padding: 0;
    display: inline-flex; flex-wrap: wrap; gap: 4px;
}
.wcaf-pagination .woocommerce-pagination ul.page-numbers li { list-style: none; margin: 0; padding: 0; }
.wcaf-pagination a.page-numbers,
.wcaf-pagination span.page-numbers {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 10px;
    border: 1px solid #ddd; border-radius: 4px; font-size: 13px;
    text-decoration: none; color: #333; background: #fff;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    cursor: pointer;
}
.wcaf-pagination a.page-numbers:hover { background: #96003b; border-color: #96003b; color: #fff; }
.wcaf-pagination span.page-numbers.current { background: #96003b; border-color: #96003b; color: #fff; cursor: default; font-weight: 700; }
.wcaf-pagination span.page-numbers.dots { border: none; background: transparent; color: #aaa; cursor: default; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .wcaf-filter-bar { flex-direction: column; align-items: stretch; }
    .wcaf-filter-fields { flex-direction: column; }
    .wcaf-filter-field,
    .wcaf-filter-field.wcaf-field-multi { max-width: 100%; min-width: 0; flex: none; }
    .wcaf-reset-btn { width: 100%; text-align: center; }
}
