/**
 * WooCommerce Sequential Filters - Premium Styling
 */

.woo-seq-filters-container,
.woo-filter-loading-container {
    /* Pulled from the theme's own primary color variable, so the plugin always
       matches the site's configured accent instead of shipping its own palette. */
    --wsq-primary: var(--wd-primary-color, #4f46e5);
    --wsq-primary-hover: color-mix(in srgb, var(--wd-primary-color, #f3ebe5) 85%, black);
    --wsq-accent: var(--wd-primary-color, #f97316);
    --wsq-bg: #ffffff;
    --wsq-border: #e2e8f0;
    --wsq-border-hover: #cbd5e1;
    --wsq-text: #1e293b;
    --wsq-text-muted: #64748b;
    --wsq-disabled-bg: #f8fafc;
    --wsq-disabled-text: #94a3b8;
    --wsq-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --wsq-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --wsq-radius: 8px;
    --wsq-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fallback for browsers without color-mix() support: skip the darkened hover
   shade and just reuse the theme's primary color as-is. */
@supports not (color: color-mix(in srgb, red, blue)) {
    .woo-seq-filters-container,
    .woo-filter-loading-container {
        --wsq-primary-hover: var(--wd-primary-color, #f3ebe5 );
    }
}

/* Container Layout */
.woo-seq-filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
    background: var(--wsq-bg);
    margin-bottom: 30px;
    font-family: inherit;
}

/* Individual Filter Group */
.woo-seq-filter-group {
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.woo-seq-filter-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--wsq-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Styled Select Elements */
.woo-seq-select-wrapper {
    position: relative;
    width: 100%;
}

.woo-seq-filter-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 12px 40px 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--wsq-text);
    background-color: var(--wsq-bg);
    border: 1.5px solid var(--wsq-border);
    border-radius: var(--wsq-radius);
    box-shadow: var(--wsq-shadow);
    cursor: pointer;
    transition: var(--wsq-transition);
}

/* Custom Dropdown Arrow */
.woo-seq-select-wrapper::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--wsq-text-muted);
    pointer-events: none;
    transition: var(--wsq-transition);
}

/* Hover & Focus States */
.woo-seq-filter-select:hover:not(:disabled) {
    border-color: var(--wsq-border-hover);
}

.woo-seq-filter-select:focus {
    outline: none;
    border-color: var(--wsq-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.woo-seq-select-wrapper:has(.woo-seq-filter-select:focus)::after {
    border-top-color: var(--wsq-primary);
    transform: translateY(-50%) rotate(180deg);
}

/* Disabled State */
.woo-seq-filter-select:disabled {
    background-color: var(--wsq-disabled-bg);
    color: var(--wsq-disabled-text);
    border-color: var(--wsq-border);
    cursor: not-allowed;
}

.woo-seq-select-wrapper:has(.woo-seq-filter-select:disabled)::after {
    border-top-color: var(--wsq-disabled-text);
    opacity: 0.5;
}

/* Category Tree - always visible, expandable list */
.woo-seq-filter-group--tree {
    flex-basis: 100%;
}

.woo-seq-tree,
.woo-seq-tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.woo-seq-tree-children {
    display: none;
}

.woo-seq-tree-node.is-expanded > .woo-seq-tree-children {
    display: block;
}

.woo-seq-tree-node {
    margin: 0;
}

.woo-seq-tree-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 6px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.25;
    transition: background-color 0.15s ease;
}

.woo-seq-tree-row:hover {
    background-color: var(--wsq-disabled-bg);
}

.woo-seq-tree-node.is-selected > .woo-seq-tree-row .woo-seq-tree-name {
    color: var(--wsq-primary) !important;
    font-weight: 700;
}

.woo-seq-tree-node.is-selected > .woo-seq-tree-row {
    background-color: #f3ebe554;
}

.woo-seq-tree-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--wsq-text);
    flex: 1 1 auto;
    transition: color 0.15s ease;
}

.woo-seq-tree-name:hover {
    color: var(--wsq-primary);
}

.woo-seq-tree-expand {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    color: var(--wsq-accent);
    user-select: none;
}

.woo-seq-tree-expand--empty {
    visibility: hidden;
}

.woo-seq-tree-node.is-disabled > .woo-seq-tree-row {
    opacity: 0.4;
    pointer-events: none;
}

/* Reset Button */
.woo-seq-filter-reset-wrapper {
    flex: 0 0 auto;
}

.woo-seq-filter-reset-btn {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--wsq-primary);
    background-color: transparent;
    border: 1.5px solid var(--wsq-primary);
    border-radius: var(--wsq-radius);
    cursor: pointer;
    transition: var(--wsq-transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.woo-seq-filter-reset-btn:hover:not(:disabled) {
    color: #fff;
    border-color: var(--wsq-primary-hover);
    background-color: var(--wsq-primary-hover);
}

.woo-seq-filter-reset-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.woo-seq-filter-reset-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--wsq-disabled-text);
    border-color: var(--wsq-border);
    background-color: transparent;
}

/* Loading/Filtering Overlay on Product Grid - ONLY active when is-filtering is set */
.woo-filter-loading-container.is-filtering {
    position: relative !important;
    min-height: 200px;
}

.woo-filter-loading-container.is-filtering::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 50;
    border-radius: var(--wsq-radius);
}

.woo-filter-loading-container.is-filtering::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--wsq-border);
    border-radius: 50%;
    border-top-color: var(--wsq-primary);
    z-index: 51;
    animation: wsq-spin 0.8s linear infinite;
}

@keyframes wsq-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Empty Notice Styling */
.woo-filters-empty-notice-item {
    grid-column: 1 / -1;
    width: 100%;
    list-style: none;
}

.woo-filters-empty-notice {
    padding: 30px;
    text-align: center;
    border: 2px dashed var(--wsq-border);
    border-radius: var(--wsq-radius);
    color: var(--wsq-text-muted);
    font-size: 16px;
    width: 100%;
    box-sizing: border-box;
}

/* Smooth fade-out and disable interactions on products container children ONLY during active filtering */
.woo-filter-loading-container.is-filtering > * {
    transition: opacity 0.3s ease !important;
    opacity: 0.3 !important;
    pointer-events: none !important;
}
