/**
 * PromoSync Pro — Product Filter Frontend CSS
 * Works with Woodmart + WooCommerce product grids.
 * Dark-themed filter panel that sits above or beside the product loop.
 * @package PromoSyncPro
 */

/* ── Design tokens (match Woodmart dark palettes) ───────────────────────── */
.ps-filter-panel {
    --ps-bg:      #0f1117;
    --ps-surface: #1a1d27;
    --ps-border:  #2e3347;
    --ps-accent:  #6366f1;
    --ps-text:    #e2e8f0;
    --ps-muted:   #64748b;
    --ps-success: #22c55e;
    --ps-radius:  8px;
    --ps-font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Filter panel wrapper ───────────────────────────────────────────────── */
.ps-filter-panel {
    background: var(--ps-surface);
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius);
    padding: 0;
    margin-bottom: 24px;
    font-family: var(--ps-font);
    font-size: 13px;
    overflow: hidden;
}

.ps-filter-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--ps-bg);
    border-bottom: 1px solid var(--ps-border);
    cursor: pointer;
}

.ps-filter-panel__title {
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ps-muted);
}

.ps-filter-panel__toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ps-muted);
    padding: 0;
    display: flex;
    align-items: center;
    transition: color .15s ease;
}

.ps-filter-panel__toggle:hover { color: var(--ps-text); }
.ps-filter-panel[data-collapsed="true"] .ps-filter-wrap { display: none; }

/* ── Filter wrap (populated by JS) ─────────────────────────────────────── */
.ps-filter-wrap {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Filter group ──────────────────────────────────────────────────────── */
.ps-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ps-filter-group__title {
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--ps-muted);
}

/* ── Pills ──────────────────────────────────────────────────────────────── */
.ps-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ps-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--ps-border);
    background: transparent;
    color: var(--ps-muted);
    font-family: var(--ps-font);
    transition: all .15s ease;
    white-space: nowrap;
    line-height: 1;
}

.ps-pill:hover {
    border-color: var(--ps-accent);
    color: var(--ps-text);
    background: rgba(99, 102, 241, .08);
}

.ps-pill.is-active {
    background: var(--ps-accent);
    border-color: var(--ps-accent);
    color: #fff;
}

/* ── Sort select ────────────────────────────────────────────────────────── */
.ps-filter-sort { flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; }

.ps-filter-select {
    background: var(--ps-bg);
    border: 1px solid var(--ps-border);
    border-radius: 7px;
    color: var(--ps-text);
    font-size: 12px;
    font-family: var(--ps-font);
    padding: 6px 10px;
    outline: none;
    cursor: pointer;
    min-width: 160px;
    transition: border-color .15s ease;
}

.ps-filter-select:focus { border-color: var(--ps-accent); }
.ps-filter-select option { background: var(--ps-surface); color: var(--ps-text); }

/* ── Slider ─────────────────────────────────────────────────────────────── */
.ps-filter-slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ps-filter-slider {
    flex: 1;
    height: 4px;
    accent-color: var(--ps-accent);
    cursor: pointer;
}

.ps-filter-slider-val {
    font-size: 12px;
    font-weight: 600;
    color: var(--ps-text);
    min-width: 60px;
    text-align: right;
}

/* ── Active filter chips ────────────────────────────────────────────────── */
.ps-filter-summary { padding-top: 4px; }

.ps-active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(99, 102, 241, .06);
    border: 1px solid rgba(99, 102, 241, .15);
    border-radius: var(--ps-radius);
}

.ps-active-label {
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--ps-muted);
}

.ps-active-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    background: rgba(99, 102, 241, .15);
    border: 1px solid rgba(99, 102, 241, .3);
    border-radius: 999px;
    font-size: 11.5px;
    color: #a5b4fc;
}

.ps-active-chip strong { color: #e2e8f0; font-weight: 500; }

.ps-active-chip__remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #6366f1;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: color .15s ease;
}

.ps-active-chip__remove:hover { color: #ef4444; }

.ps-clear-all {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: var(--ps-muted);
    font-family: var(--ps-font);
    text-decoration: underline;
    transition: color .15s ease;
}

.ps-clear-all:hover { color: #ef4444; }

/* ── Product grid loading state ─────────────────────────────────────────── */
.ps-filter-grid {
    position: relative;
    transition: opacity .2s ease;
}

.ps-filter-grid.ps-filter-loading {
    opacity: .45;
    pointer-events: none;
    user-select: none;
}

.ps-filter-grid.ps-filter-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
    cursor: wait;
    z-index: 10;
}

/* Spinner overlay during load */
.ps-filter-grid.ps-filter-loading::before {
    content: '';
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    border: 3px solid rgba(99, 102, 241, .2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: ps-spin .6s linear infinite;
    z-index: 11;
}

@keyframes ps-spin { to { transform: translateX(-50%) rotate(360deg); } }

/* ── Pagination ─────────────────────────────────────────────────────────── */
.ps-filter-pagination { margin-top: 24px; }

.ps-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.ps-pagination__total {
    font-size: 12px;
    color: var(--ps-muted, #64748b);
    margin-right: auto;
}

.ps-page-btn {
    padding: 6px 11px;
    border-radius: 6px;
    background: #1a1d27;
    border: 1px solid #2e3347;
    color: #94a3b8;
    font-size: 12px;
    font-family: var(--ps-font, sans-serif);
    cursor: pointer;
    transition: all .15s ease;
    min-width: 34px;
    text-align: center;
}

.ps-page-btn:hover { border-color: #6366f1; color: #e2e8f0; background: rgba(99,102,241,.08); }
.ps-page-btn.is-active { background: #6366f1; border-color: #6366f1; color: #fff; }

/* ── No results message ─────────────────────────────────────────────────── */
.ps-filter-grid .woocommerce-info {
    width: 100%;
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 14px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ps-filter-wrap { padding: 12px; gap: 14px; }
    .ps-filter-sort { flex-direction: column; align-items: flex-start; }
    .ps-filter-select { min-width: 100%; }
    .ps-pagination { justify-content: center; }
    .ps-pagination__total { width: 100%; text-align: center; margin-right: 0; }
}
