/**
 * XforWooCommerce 9.1.3 markup. Desktop only, no behavioural overrides.
 * Widget styles do not affect the shortcode above products.
 */
@media (min-width: 1025px) {
    #secondary .prdctfltr-widget {
        background: #fff;
        border: 1px solid #e8e3e5;
        border-radius: 7px;
        box-shadow: 0 2px 7px rgba(0,0,0,.045);
        padding: 18px 16px;
        margin-bottom: 24px;
        box-sizing: border-box;
    }
    #secondary .prdctfltr-widget .prdctfltr_wc {
        margin: 0;
        color: #292629;
    }
    #secondary .prdctfltr-widget .prdctfltr_woocommerce_ordering {
        margin-left: 0;
        margin-right: 0;
    }
    #secondary .prdctfltr-widget .prdctfltr_filter {
        padding-left: 0;
        padding-right: 0;
        padding-bottom: 12px;
    }
    #secondary .prdctfltr-widget .pf-help-title .widget-title {
        margin: 0 0 12px;
        padding: 0;
        background: transparent;
        border: 0;
        color: #292629;
        font-size: 19px;
        font-weight: 600;
        line-height: 1.4;
    }
    #secondary .prdctfltr-widget .prdctfltr_widget_title,
    #secondary .prdctfltr-widget .prdctfltr_regular_title {
        font-size: 19px;
        font-weight: 600;
        line-height: 1.4;
        color: #292629;
        white-space: normal;
    }
    #secondary .prdctfltr-widget .prdctfltr_widget_title i {
        color: var(--sssb-brand-color, #75191b);
    }
    #secondary .prdctfltr-widget .prdctfltr_checkboxes label {
        font-size: 16px;
        line-height: 1.5;
        padding: 7px 5px;
        margin: 0;
        min-height: 38px;
        box-sizing: border-box;
        border-radius: 4px;
        overflow-wrap: anywhere;
    }
    #secondary .prdctfltr-widget .prdctfltr_checkboxes label:hover {
        background: #faf5f7;
    }
    #secondary .prdctfltr-widget .prdctfltr_checkboxes label.prdctfltr_active {
        background: var(--sssb-brand-soft, #f8eeee);
        color: var(--sssb-brand-color, #75191b);
    }
    /* Enlarge the plugin's own checkbox, retaining its icon and event handling. */
    #secondary .prdctfltr-widget .prdctfltr_wc.prdctfltr_checkbox .prdctfltr_filter.prdctfltr_text label > span:before {
        width: 14px;
        height: 14px;
        border: 1px solid #a99da2;
        border-radius: 3px;
        margin: 0 9px 2px 0;
    }
    #secondary .prdctfltr-widget .prdctfltr_wc.prdctfltr_checkbox .prdctfltr_filter.prdctfltr_text label.prdctfltr_active > span:before {
        border-color: var(--sssb-brand-color, #75191b);
    }
    #secondary .prdctfltr-widget .prdctfltr_wc.prdctfltr_checkbox .prdctfltr_filter.prdctfltr_text label.prdctfltr_active > span:after {
        color: var(--sssb-brand-color, #75191b);
        font-size: 15px;
        line-height: 18px;
        left: 1px;
    }
    #secondary .prdctfltr-widget .prdctfltr_count {
        color: #6b6266;
        font-size: 12px;
    }
    #secondary .prdctfltr-widget .prdctfltr_add_scroll {
        scrollbar-width: auto;
        scrollbar-color: #b3a2a9 #f5f1f3;
    }
    #secondary .prdctfltr-widget .prdctfltr_buttons {
        padding-left: 0;
        padding-right: 0;
    }
    #secondary .prdctfltr-widget .prdctfltr_reset {
        font-size: 14px;
        line-height: 1.5;
        color: var(--sssb-brand-color, #75191b);
    }
    /* Same selected-term treatment in sidebar and above products. */
    .prdctfltr_wc .prdctfltr_collector > span,
    .prdctfltr_wc .prdctfltr_title_selected {
        background: var(--sssb-brand-soft, #f8eeee);
        border: 1px solid #eadbe1;
        color: var(--sssb-brand-color, #75191b);
        border-radius: 5px;
        padding: 7px 10px;
        font-size: 14px;
        line-height: 1.5;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .prdctfltr_wc .prdctfltr_collector > span a,
    .prdctfltr_wc .prdctfltr_title_selected .prdctfltr_title_remove {
        color: var(--sssb-brand-color, #75191b);
    }
    .prdctfltr_wc .prdctfltr_collector > span a:focus-visible,
    #secondary .prdctfltr-widget a:focus-visible {
        outline: 2px solid var(--sssb-brand-color, #75191b);
        outline-offset: 3px;
    }
}

/* The template may return early while WP still emits before/after_widget.
 * Check for filter markup, not visibility: collapsed filters must remain usable.
 * CSS updates automatically when XforWooCommerce replaces content through AJAX.
 */
@supports selector(:has(*)) {
    @media (min-width: 1025px) {
        #secondary .prdctfltr-widget:not(:has(.prdctfltr_filter, .prdctfltr_title_selected)) {
            display: none;
        }
    }
}
@media (min-width: 1025px) {
    #secondary .widget_product_categories {
        box-shadow: 0 2px 7px rgba(0,0,0,.045);
        margin-bottom: 24px;
    }
    #secondary .prdctfltr-widget .prdctfltr_checkboxes label {
        cursor: pointer;
    }
    #secondary .prdctfltr-widget .prdctfltr_checkboxes label:focus-within {
        outline: 2px solid var(--sssb-brand-color, #75191b);
        outline-offset: -2px;
    }
    .prdctfltr_wc .prdctfltr_title_selected {
        font-weight: 500;
        vertical-align: middle;
    }
    .prdctfltr_wc .prdctfltr_title_selected .prdctfltr_title_remove {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 24px;
        min-height: 28px;
        vertical-align: middle;
    }
    #primary .prdctfltr_wc .prdctfltr_filter .prdctfltr_regular_title {
        color: #292629;
        font-size: 16px;
        font-weight: 600;
        line-height: 1.5;
    }
}

/* 1.3.3: headings are real template content, not generated CSS text. */
.sssb-filter-heading { display: none; }
@media (min-width: 1025px) {
    #secondary .prdctfltr-widget .sssb-filter-heading--sidebar {
        display: block;
        margin: -18px -16px 16px;
        padding: 12px 16px;
        border-radius: 6px 6px 0 0;
        background: var(--sssb-brand-color, #75191b);
        color: #fff;
        font-size: 17px;
        font-weight: 600;
        line-height: 1.4;
    }
    #secondary .prdctfltr-widget .prdctfltr_filter {
        margin-bottom: 0;
        padding-bottom: 0;
    }
    #secondary .prdctfltr-widget .pf-help-title .widget-title {
        font-size: 16px;
        margin-bottom: 10px;
    }
    #secondary .prdctfltr-widget .prdctfltr_buttons {
        margin-top: 12px;
        margin-bottom: 0;
    }
    #secondary .prdctfltr-widget .prdctfltr_buttons:empty { display: none; }
    #secondary .prdctfltr-widget .prdctfltr_woocommerce_ordering {
        margin-bottom: 0;
        padding-bottom: 0;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular {
        float: none;
        clear: both;
        width: 100%;
        max-width: 100%;
        margin: 18px 0 24px;
        padding: 18px 20px;
        background: #faf4f6;
        border: 1px solid #eadfe3;
        border-radius: 7px;
        box-sizing: border-box;
        text-align: left;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular .sssb-filter-heading--catalog {
        display: block;
        margin: 0 0 12px;
        padding: 0;
        color: var(--sssb-brand-color, #75191b);
        font-size: 18px;
        font-weight: 600;
        line-height: 1.4;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular .prdctfltr_woocommerce_ordering {
        margin: 0;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular .prdctfltr_filter {
        text-align: left;
        padding-left: 0;
        padding-right: 0;
        max-width: 100%;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular .prdctfltr_regular_title {
        border-radius: 5px;
        background: #fff;
        color: #292629;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular .prdctfltr_buttons {
        padding-left: 0;
        text-align: left;
        margin-bottom: 0;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular .prdctfltr_reset {
        color: var(--sssb-brand-color, #75191b);
        font-size: 14px;
    }
}
@supports selector(:has(*)) {
    @media (min-width: 1025px) {
        body.woocommerce.archive #primary .prdctfltr_wc_regular:not(:has(.prdctfltr_filter, .prdctfltr_title_selected)) { display: none; }
    }
}

/* 1.3.4: keep reset clear of the scrollable list, including AJAX updates. */
@media (min-width: 1025px) {
    #secondary .prdctfltr-widget .prdctfltr_wc .prdctfltr_buttons {
        clear: both;
        display: block;
        margin: 18px 0 0;
        padding: 14px 0 0;
        border-top: 1px solid #eee5e9;
    }
    #secondary .prdctfltr-widget .prdctfltr_buttons .prdctfltr_reset {
        display: block;
        margin: 0;
        float: none;
    }
    #secondary .prdctfltr-widget .prdctfltr_reset label {
        display: inline-block;
        padding: 5px 0;
        line-height: 1.5;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular {
        width: 100% !important;
        float: none !important;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular .prdctfltr_woocommerce_ordering {
        width: 100%;
        max-width: none;
        float: none;
        margin: 0;
        text-align: left;
    }
    body.woocommerce.archive #primary .prdctfltr_wc_regular .prdctfltr_buttons {
        clear: both;
        margin-top: 16px;
        padding-top: 12px;
        border-top: 1px solid #eadfe3;
    }
}
@supports selector(:has(*)) {
    @media (min-width: 1025px) {
        body.woocommerce.archive #primary .woocommerce-ordering:has(.prdctfltr_wc_regular),
        body.woocommerce.archive #primary .ast-shop-toolbar-aside-wrap:has(.prdctfltr_wc_regular) {
            float: none;
            width: 100%;
            max-width: none;
            flex-basis: 100%;
        }
        #secondary .prdctfltr-widget .prdctfltr_buttons:not(:has(a, label)) {
            display: none;
        }
    }
}

/* 1.3.7: Removed broad z-index stacking contexts on catalogue/toolbar.
 * Those layers could intercept category-card clicks even when the filter
 * dropdown was closed. XforWooCommerce retains its native dropdown stacking.
 */

/* 1.3.9: The Astra catalogue toolbar must stack above BeRocket product
 * labels while the XforWooCommerce dropdown extends over the product grid.
 * Confirmed on staging at z-index 600 for desktop and mobile.
 * Scope to WooCommerce archives and the main catalogue only.
 */
body.woocommerce.archive #primary .ast-shop-toolbar-container {
    position: relative;
    z-index: 600;
}

/* 1.3.9: Mobile/tablet use the catalogue filter above the products.
 * Hide only the duplicate XforWooCommerce widget in the sidebar;
 * retain the product category navigation and all other sidebar widgets.
 */
@media (max-width: 1024px) {
    body.woocommerce.archive #secondary .prdctfltr-widget {
        display: none !important;
    }
}

/* 1.4.0 – Mobile catalogue filter: match desktop visual identity.
 * Presentation only: preserve XforWooCommerce's native controls and AJAX.
 * The duplicate sidebar filter stays hidden by the 1.3.9 rule.
 */
@media (max-width: 1024px) {
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular {
        display: block;
        float: none;
        clear: both;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin: 16px 0 22px;
        padding: 16px;
        background: #faf4f6;
        border: 1px solid #eadfe3;
        border-radius: 7px;
        text-align: left;
    }
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .sssb-filter-heading--catalog {
        display: block !important;
        visibility: visible;
        color: var(--sssb-brand-color, #75191b);
        font-size: 17px;
        font-weight: 600;
        line-height: 1.4;
        margin: 0 0 12px;
        padding: 0;
        border: 0;
        background: transparent;
    }
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_woocommerce_ordering,
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_filter_wrapper,
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_filter {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
        text-align: left;
    }
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_regular_title {
        background: #fff;
        color: #292629;
        border: 1px solid #e4dce0;
        border-radius: 5px;
        font-size: 15px;
        font-weight: 600;
        line-height: 1.5;
        box-sizing: border-box;
    }
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_buttons {
        clear: both;
        margin: 12px 0 0;
        padding: 10px 0 0;
        border-top: 1px solid #eadfe3;
    }
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_reset {
        color: var(--sssb-brand-color, #75191b);
        font-size: 14px;
    }
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_title_selected,
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_collector > span {
        background: var(--sssb-brand-soft, #f8eeee);
        border: 1px solid #eadbe1;
        border-radius: 5px;
        color: var(--sssb-brand-color, #75191b);
        padding: 6px 9px;
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

/* Astra shop toolbar: full-width filter on mobile and tablet.
   Verified in responsive view at 412px and 633px. */
@media (max-width: 1024px) {
    body.woocommerce.archive #primary .ast-shop-toolbar-container {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    body.woocommerce.archive #primary .ast-shop-toolbar-container > .ast-shop-toolbar-aside-wrap {
        display: block !important;
        float: none !important;
        flex: 0 0 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }
}

/* 1.4.2 – Keep XforWooCommerce selector inside the pink mobile panel.
   The Astra toolbar fix above alone does not constrain plugin child widths. */
@media (max-width: 1024px) {
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular,
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_filter_inner,
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_filter_wrapper,
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_filter,
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_regular_title,
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_add_scroll {
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_regular_title {
        display: block;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* 1.4.3 – Limit only the model list in the mobile catalogue filter.
 * Keep native opening/closing and AJAX; do not set display or widths.
 */
@media (max-width: 767px) {
    body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular .prdctfltr_pa_passer-til .prdctfltr_add_scroll {
        max-height: 300px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* 1.5.1 – Hide the empty mobile/tablet panel, including its heading and frame.
 * Match structure rather than visibility: collapsed filters must stay available.
 * CSS is recalculated automatically when XforWooCommerce replaces content via AJAX.
 */
@supports selector(:has(*)) {
    @media (max-width: 1024px) {
        body.woocommerce.archive #primary .ast-shop-toolbar-container .prdctfltr_wc_regular:not(:has(.prdctfltr_filter, .prdctfltr_title_selected, .prdctfltr_collector > span)) {
            display: none !important;
        }
    }
}
