/**
 * Woo Product Filters - Frontend Styles
 * 
 * @package WooProductFilters
 * @author VictorenStudios
 */

/* CSS Custom Properties */
:root {
    --wpf-primary-color: #6366f1;
    --wpf-primary-hover: #4f46e5;
    --wpf-secondary-color: #64748b;
    --wpf-text-color: #1e293b;
    --wpf-text-muted: #64748b;
    --wpf-border-color: #e2e8f0;
    --wpf-background: #ffffff;
    --wpf-background-hover: #f8fafc;
    --wpf-success-color: #22c55e;
    --wpf-warning-color: #f59e0b;
    --wpf-error-color: #ef4444;
    --wpf-border-radius: 8px;
    --wpf-transition: all 0.3s ease;
    --wpf-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --wpf-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --wpf-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Widget Container */
.wpf-filters-widget {
    background: var(--wpf-background);
    border-radius: var(--wpf-border-radius);
    padding: 24px;
    box-shadow: var(--wpf-shadow);
    position: relative;
}

/* Reset theme list styles */
.wpf-filters-widget ul,
.wpf-filters-widget ol,
.wpf-filters-widget li {
    list-style: none !important;
    list-style-type: none !important;
    margin: 0;
    padding: 0;
}

.wpf-filters-widget li::before,
.wpf-filters-widget li::marker {
    content: none !important;
    display: none !important;
}

.wpf-widget-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--wpf-text-color);
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--wpf-primary-color);
}

/* Filter Sections */
.wpf-filter-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--wpf-border-color);
}

/* Remove border from the last filter section */
.wpf-filter-section:last-of-type,
.wpf-filter-section:last-child,
.wpf-filter-section.wpf-last-section,
.wpf-filter-section:has(+ .wpf-filter-actions) {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none !important;
}

.wpf-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 8px 0;
    user-select: none;
}

.wpf-filter-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--wpf-text-color);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wpf-toggle-icon {
    width: 20px;
    height: 20px;
    position: relative;
    transition: var(--wpf-transition);
}

.wpf-toggle-icon::before,
.wpf-toggle-icon::after {
    content: '';
    position: absolute;
    background: var(--wpf-secondary-color);
    transition: var(--wpf-transition);
}

.wpf-toggle-icon::before {
    width: 12px;
    height: 2px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.wpf-toggle-icon::after {
    width: 2px;
    height: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.wpf-collapsible.collapsed .wpf-toggle-icon::after {
    height: 12px;
}

.wpf-collapsible:not(.collapsed) .wpf-toggle-icon::after {
    height: 0;
}

.wpf-filter-content {
    padding-top: 12px;
    transition: var(--wpf-transition);
}

.wpf-collapsible.collapsed .wpf-filter-content {
    display: none;
}

/* Filter Lists */
.wpf-filter-list,
.wpf-filter-list ul,
.wpf-child-categories {
    list-style: none !important;
    list-style-type: none !important;
    margin: 0;
    padding: 0;
}

.wpf-filter-list li,
.wpf-filter-item {
    list-style: none !important;
    list-style-type: none !important;
}

.wpf-filter-item {
    margin-bottom: 4px;
}

.wpf-filter-item:last-child {
    margin-bottom: 0;
}

/* Category Tree Structure */
.wpf-category-tree {
    --tree-line-color: var(--wpf-border-color);
    --tree-indent: 28px;
}

.wpf-category-tree,
.wpf-category-tree ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.wpf-category-tree li {
    list-style: none !important;
    list-style-type: none !important;
}

.wpf-category-tree li::marker,
.wpf-category-tree li::before {
    content: none !important;
    display: none !important;
}

.wpf-category-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.wpf-category-row .wpf-checkbox-label {
    flex: 1;
}

.wpf-parent-item {
    margin-bottom: 2px;
}

.wpf-parent-item > .wpf-category-row > .wpf-checkbox-label .wpf-filter-name {
    font-weight: 500;
}

.wpf-parent-item.has-children {
    margin-bottom: 0;
}

/* Expand/Collapse Toggle */
.wpf-expand-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    max-width: 20px;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--wpf-transition);
    flex-shrink: 0;
    position: relative;
}

.wpf-expand-toggle::before {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--wpf-text-muted);
    border-bottom: 2px solid var(--wpf-text-muted);
    transform: rotate(-45deg);
    transition: transform 0.2s ease, border-color 0.2s ease;
    margin-left: -2px;
}

.wpf-expand-toggle:hover {
    background: var(--wpf-background-hover);
}

.wpf-expand-toggle:hover::before {
    border-color: var(--wpf-primary-color);
}

.wpf-parent-item.expanded .wpf-expand-toggle::before,
.wpf-parent-item.has-active-child .wpf-expand-toggle::before {
    transform: rotate(45deg);
    margin-left: 0;
    margin-top: -2px;
}

/* Child Categories */
.wpf-child-categories {
    list-style: none !important;
    list-style-type: none !important;
    margin: 0 !important;
    padding: 0 0 0 var(--tree-indent) !important;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
}

.wpf-child-categories li {
    list-style: none !important;
    list-style-type: none !important;
}

.wpf-parent-item.expanded > .wpf-child-categories,
.wpf-parent-item.has-active-child > .wpf-child-categories {
    max-height: 500px;
    opacity: 1;
    padding: 6px 0 8px var(--tree-indent) !important;
}

/* Tree connecting lines */
.wpf-child-categories {
    position: relative;
}

.wpf-child-categories::before {
    content: '' !important;
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 12px;
    width: 1px;
    background: linear-gradient(to bottom, var(--tree-line-color), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.wpf-parent-item.expanded > .wpf-child-categories::before,
.wpf-parent-item.has-active-child > .wpf-child-categories::before {
    opacity: 1;
}

.wpf-child-item {
    position: relative;
    margin-bottom: 2px;
    list-style: none !important;
}

.wpf-child-item::before {
    content: '' !important;
    position: absolute;
    left: -18px;
    top: 50%;
    width: 12px;
    height: 1px;
    background: var(--tree-line-color);
}

.wpf-child-item:last-child::after {
    content: '' !important;
    position: absolute;
    left: -19px;
    top: 50%;
    bottom: 0;
    width: 2px;
    background: var(--wpf-background);
}

/* Child item styling - more subtle */
.wpf-child-item > .wpf-checkbox-label {
    padding: 5px 8px;
    margin-left: 4px;
}

.wpf-child-item > .wpf-checkbox-label .wpf-checkbox-custom {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-width: 1.5px;
    border-radius: 3px;
}

.wpf-child-item > .wpf-checkbox-label .wpf-checkbox-custom::after {
    width: 4px;
    height: 7px;
    border-width: 0 1.5px 1.5px 0;
}

.wpf-child-item > .wpf-checkbox-label .wpf-filter-name {
    font-size: 0.85rem;
    color: var(--wpf-text-muted);
}

.wpf-child-item > .wpf-checkbox-label:hover .wpf-filter-name,
.wpf-child-item > .wpf-checkbox-label:has(input:checked) .wpf-filter-name {
    color: var(--wpf-text-color);
}

.wpf-child-item > .wpf-checkbox-label .wpf-filter-count {
    font-size: 0.75rem;
}

/* Checkbox & Radio Styling */
.wpf-checkbox-label,
.wpf-radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: var(--wpf-transition);
    position: relative;
}

.wpf-checkbox-label:hover,
.wpf-radio-label:hover {
    background: var(--wpf-background-hover);
}

.wpf-checkbox-label:has(input:checked),
.wpf-radio-label:has(input:checked) {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(99, 102, 241, 0.04));
}

.wpf-checkbox-label input,
.wpf-radio-label input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.wpf-checkbox-custom,
.wpf-radio-custom {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--wpf-border-color);
    background: var(--wpf-background);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--wpf-transition);
}

.wpf-checkbox-label:hover .wpf-checkbox-custom,
.wpf-radio-label:hover .wpf-radio-custom {
    border-color: var(--wpf-primary-color);
}

.wpf-checkbox-custom {
    border-radius: 5px;
}

.wpf-radio-custom {
    border-radius: 50%;
}

.wpf-checkbox-label input:checked ~ .wpf-checkbox-custom,
.wpf-radio-label input:checked ~ .wpf-radio-custom {
    background: var(--wpf-primary-color);
    border-color: var(--wpf-primary-color);
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

.wpf-checkbox-custom::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: var(--wpf-transition);
    margin-top: -1px;
}

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

.wpf-radio-custom::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
    transform: scale(0);
    transition: var(--wpf-transition);
}

.wpf-radio-label input:checked ~ .wpf-radio-custom::after {
    transform: scale(1);
}

.wpf-filter-name {
    flex: 1;
    color: var(--wpf-text-color);
    font-size: 0.9rem;
}

.wpf-filter-count {
    color: var(--wpf-text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--wpf-background-hover);
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.wpf-checkbox-label:hover .wpf-filter-count {
    background: var(--wpf-border-color);
}

.wpf-checkbox-label:has(input:checked) .wpf-filter-count {
    background: rgba(99, 102, 241, 0.15);
    color: var(--wpf-primary-color);
}

/* Price Slider */
.wpf-price-slider-wrapper {
    padding: 10px 0;
}

.wpf-price-slider-track {
    position: relative;
    height: 6px;
    background: var(--wpf-border-color);
    border-radius: 3px;
    margin: 20px 0;
}

.wpf-price-slider-range {
    position: absolute;
    height: 100%;
    background: linear-gradient(90deg, var(--wpf-primary-color), var(--wpf-primary-hover));
    border-radius: 3px;
}

.wpf-price-slider-track input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    top: 0;
    left: 0;
}

.wpf-price-slider-track input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--wpf-primary-color);
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: var(--wpf-shadow);
    transition: var(--wpf-transition);
}

.wpf-price-slider-track input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--wpf-primary-hover);
}

.wpf-price-slider-track input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--wpf-primary-color);
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: var(--wpf-shadow);
}

.wpf-price-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.wpf-price-input-group {
    display: flex;
    align-items: center;
    background: var(--wpf-background-hover);
    border: 1px solid var(--wpf-border-color);
    border-radius: 6px;
    padding: 8px 12px;
    flex: 1;
}

.wpf-currency-symbol {
    color: var(--wpf-text-muted);
    font-weight: 500;
    margin-right: 6px;
}

.wpf-price-input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--wpf-text-color);
    outline: none;
}

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

.wpf-price-input[type=number] {
    -moz-appearance: textfield;
}

.wpf-price-separator {
    color: var(--wpf-text-muted);
    font-weight: 500;
}

/* Tag Cloud */
.wpf-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wpf-tag-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--wpf-background-hover);
    border: 1px solid var(--wpf-border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--wpf-transition);
    font-size: 0.85rem;
}

.wpf-tag-item input {
    display: none;
}

.wpf-tag-item:hover {
    border-color: var(--wpf-primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.wpf-tag-item.active,
.wpf-tag-item:has(input:checked) {
    background: var(--wpf-primary-color);
    border-color: var(--wpf-primary-color);
    color: white;
}

.wpf-tag-name {
    color: inherit;
}

.wpf-tag-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.wpf-tag-item.active .wpf-tag-count,
.wpf-tag-item:has(input:checked) .wpf-tag-count {
    background: rgba(255, 255, 255, 0.2);
}

/* Color Swatches */
.wpf-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.wpf-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
    transition: var(--wpf-transition);
    box-shadow: var(--wpf-shadow-sm);
}

.wpf-color-swatch input {
    display: none;
}

.wpf-color-swatch:hover {
    transform: scale(1.1);
}

.wpf-color-swatch.active,
.wpf-color-swatch:has(input:checked) {
    border-color: var(--wpf-primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.wpf-color-swatch::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    color: white;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: var(--wpf-transition);
}

.wpf-color-swatch.active::after,
.wpf-color-swatch:has(input:checked)::after {
    transform: translate(-50%, -50%) scale(1);
}

/* Rating Stars */
.wpf-rating-list {
    margin: 0;
    padding: 0;
}

.wpf-rating-stars {
    display: inline-flex;
    gap: 2px;
}

.wpf-star {
    font-size: 1rem;
    line-height: 1;
}

.wpf-star.filled {
    color: #fbbf24;
}

.wpf-star.empty {
    color: #d1d5db;
}

.wpf-rating-text {
    color: var(--wpf-text-muted);
    font-size: 0.85rem;
    margin-left: 8px;
}

/* Filter Actions */
.wpf-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--wpf-border-color);
}

.wpf-apply-filters,
.wpf-reset-filters {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--wpf-transition);
    text-align: center;
}

.wpf-apply-filters {
    background: linear-gradient(135deg, var(--wpf-primary-color), var(--wpf-primary-hover));
    color: white;
}

.wpf-apply-filters:hover {
    transform: translateY(-2px);
    box-shadow: var(--wpf-shadow-lg);
}

.wpf-reset-filters {
    background: transparent;
    border: 2px solid var(--wpf-border-color);
    color: var(--wpf-text-muted);
}

.wpf-reset-filters:hover {
    border-color: var(--wpf-error-color);
    color: var(--wpf-error-color);
    background: rgba(239, 68, 68, 0.05);
}

/* Active Filters */
.wpf-active-filters {
    margin-top: 20px;
    padding: 16px;
    background: var(--wpf-background-hover);
    border-radius: 8px;
}

.wpf-active-filters-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--wpf-text-muted);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wpf-active-filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wpf-active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--wpf-primary-color);
    color: white;
    border-radius: 4px;
    font-size: 0.8rem;
}

.wpf-remove-filter {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    transition: var(--wpf-transition);
}

.wpf-remove-filter:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Loading Overlay */
.wpf-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--wpf-border-radius);
    z-index: 100;
}

.wpf-loading-overlay.active {
    display: flex;
}

.wpf-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--wpf-border-color);
    border-top-color: var(--wpf-primary-color);
    border-radius: 50%;
    animation: wpf-spin 0.8s linear infinite;
}

@keyframes wpf-spin {
    to {
        transform: rotate(360deg);
    }
}

/* No Products */
.wpf-no-products {
    text-align: center;
    padding: 60px 20px;
    color: var(--wpf-text-muted);
}

.wpf-no-products p {
    margin: 0;
    font-size: 1rem;
}

/* Product Grid Loading State */
.wpf-products-loading {
    opacity: 0.5;
    pointer-events: none;
}

.wpf-products-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 3px solid var(--wpf-border-color);
    border-top-color: var(--wpf-primary-color);
    border-radius: 50%;
    animation: wpf-spin 0.8s linear infinite;
}

/* Elementor Preview */
.wpf-elementor-preview {
    padding: 40px;
    text-align: center;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border-radius: var(--wpf-border-radius);
    border: 2px dashed var(--wpf-border-color);
}

.wpf-preview-placeholder .eicon-filter {
    font-size: 48px;
    color: var(--wpf-primary-color);
    margin-bottom: 16px;
}

.wpf-preview-placeholder h3 {
    margin: 0 0 8px 0;
    color: var(--wpf-text-color);
}

.wpf-preview-placeholder p {
    margin: 0;
    color: var(--wpf-text-muted);
    font-size: 0.9rem;
}

/* ==========================================================================
   MOBILE RESPONSIVE DESIGN
   ========================================================================== */

/* Mobile Filter Toggle Button (Floating) */
.wpf-mobile-toggle {
    display: none;
    position: fixed;
    z-index: 999;
    padding: 14px 28px;
    background: linear-gradient(135deg, var(--wpf-primary-color), var(--wpf-primary-hover));
    color: white !important;
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: var(--wpf-transition);
    align-items: center;
    gap: 8px;
}

/* Default position: bottom center */
.wpf-mobile-toggle {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.wpf-mobile-toggle:hover {
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5);
}

.wpf-mobile-toggle:active {
    transform: translateX(-50%) scale(0.98);
}

/* Position: Bottom Left */
.wpf-mobile-toggle.wpf-position-bottom-left {
    bottom: 20px;
    left: 20px;
    right: auto;
    transform: none;
}

.wpf-mobile-toggle.wpf-position-bottom-left:hover {
    transform: translateY(-2px);
}

.wpf-mobile-toggle.wpf-position-bottom-left:active {
    transform: translateY(0) scale(0.98);
}

/* Position: Bottom Center (default) */
.wpf-mobile-toggle.wpf-position-bottom-center {
    bottom: 20px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

.wpf-mobile-toggle.wpf-position-bottom-center:hover {
    transform: translateX(-50%) translateY(-2px);
}

.wpf-mobile-toggle.wpf-position-bottom-center:active {
    transform: translateX(-50%) scale(0.98);
}

/* Position: Bottom Right */
.wpf-mobile-toggle.wpf-position-bottom-right {
    bottom: 20px;
    right: 20px;
    left: auto;
    transform: none;
}

.wpf-mobile-toggle.wpf-position-bottom-right:hover {
    transform: translateY(-2px);
}

.wpf-mobile-toggle.wpf-position-bottom-right:active {
    transform: translateY(0) scale(0.98);
}

/* Position: Top Left */
.wpf-mobile-toggle.wpf-position-top-left {
    top: 20px;
    bottom: auto;
    left: 20px;
    right: auto;
    transform: none;
}

.wpf-mobile-toggle.wpf-position-top-left:hover {
    transform: translateY(2px);
}

.wpf-mobile-toggle.wpf-position-top-left:active {
    transform: translateY(0) scale(0.98);
}

/* Position: Top Center */
.wpf-mobile-toggle.wpf-position-top-center {
    top: 20px;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

.wpf-mobile-toggle.wpf-position-top-center:hover {
    transform: translateX(-50%) translateY(2px);
}

.wpf-mobile-toggle.wpf-position-top-center:active {
    transform: translateX(-50%) scale(0.98);
}

/* Position: Top Right */
.wpf-mobile-toggle.wpf-position-top-right {
    top: 20px;
    bottom: auto;
    right: 20px;
    left: auto;
    transform: none;
}

.wpf-mobile-toggle.wpf-position-top-right:hover {
    transform: translateY(2px);
}

.wpf-mobile-toggle.wpf-position-top-right:active {
    transform: translateY(0) scale(0.98);
}

.wpf-mobile-toggle-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
}

.wpf-mobile-toggle-count {
    background-color: rgba(255, 255, 255, 0.25);
    color: inherit;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-left: 4px;
}

/* Mobile Button Style: Icon Only */
.wpf-mobile-toggle.wpf-style-icon-only {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    align-items: center;
}

.wpf-mobile-toggle.wpf-style-icon-only .wpf-mobile-toggle-icon {
    width: 24px;
    height: 24px;
}

.wpf-mobile-toggle.wpf-style-icon-only .wpf-mobile-toggle-text {
    display: none;
}

.wpf-mobile-toggle.wpf-style-icon-only .wpf-mobile-toggle-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 0.7rem;
    line-height: 20px;
    margin: 0;
    background-color: #ef4444;
    color: white;
    border-radius: 10px;
    text-align: center;
}

/* Mobile Button Style: Text Only */
.wpf-mobile-toggle.wpf-style-text-only .wpf-mobile-toggle-icon {
    display: none;
}

.wpf-mobile-toggle.wpf-style-text-only {
    padding: 14px 24px;
}

/* Mobile Button Style: Icon + Text (default - no changes needed) */
.wpf-mobile-toggle.wpf-style-icon-text {
    /* Default styles apply */
}

/* Mobile Backdrop Overlay */
.wpf-mobile-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.wpf-mobile-backdrop.active {
    opacity: 1;
}

/* Mobile Header for Filter Panel */
.wpf-mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--wpf-border-color);
    background: var(--wpf-background);
    position: sticky;
    top: 0;
    z-index: 10;
}

.wpf-mobile-header-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--wpf-text-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wpf-mobile-result-count {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--wpf-text-muted);
    background: var(--wpf-background-hover);
    padding: 4px 10px;
    border-radius: 12px;
}

.wpf-mobile-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wpf-background-hover);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--wpf-transition);
    color: var(--wpf-text-color);
    font-size: 1.5rem;
    line-height: 1;
}

.wpf-mobile-close:hover {
    background: var(--wpf-border-color);
}

.wpf-mobile-close:active {
    transform: scale(0.95);
}

/* Tablet Breakpoint (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .wpf-filters-widget {
        padding: 20px;
    }

    .wpf-filter-title {
        font-size: 0.9rem;
    }

    .wpf-checkbox-label,
    .wpf-radio-label {
        padding: 10px;
    }

    .wpf-filter-name {
        font-size: 0.85rem;
    }
}

/* Mobile Breakpoint (768px and below) */
@media (max-width: 768px) {
    /* Show mobile toggle button */
    .wpf-mobile-toggle {
        display: flex;
    }

    /* Show backdrop when needed */
    body.wpf-filters-open .wpf-mobile-backdrop {
        display: block;
    }

    /* Transform widget into off-canvas drawer */
    .wpf-filters-widget {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 320px;
        height: 100%;
        max-height: 100vh;
        padding: 0;
        margin: 0;
        border-radius: 0;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
        z-index: 9999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* Open state */
    body.wpf-filters-open .wpf-filters-widget {
        transform: translateX(0);
    }

    /* Prevent body scroll when filters open */
    body.wpf-filters-open {
        overflow: hidden;
    }

    /* Show mobile header */
    .wpf-mobile-header {
        display: flex;
        flex-shrink: 0;
    }

    /* Hide regular widget title on mobile (replaced by mobile header) */
    .wpf-filters-widget .wpf-widget-title {
        display: none;
    }

    /* Scrollable form area */
    .wpf-filters-form {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 16px;
        -webkit-overflow-scrolling: touch;
    }

    /* Filter sections */
    .wpf-filter-section {
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    .wpf-filter-header {
        padding: 10px 0;
    }

    .wpf-filter-title {
        font-size: 0.9rem;
    }

    /* Larger touch targets for checkboxes and radios */
    .wpf-checkbox-label,
    .wpf-radio-label {
        padding: 12px 14px;
        min-height: 48px;
        gap: 12px;
    }

    .wpf-checkbox-custom,
    .wpf-radio-custom {
        width: 22px;
        height: 22px;
        min-width: 22px;
    }

    .wpf-checkbox-custom::after {
        width: 5px;
        height: 10px;
    }

    .wpf-radio-custom::after {
        width: 8px;
        height: 8px;
    }

    .wpf-filter-name {
        font-size: 0.95rem;
    }

    .wpf-filter-count {
        font-size: 0.75rem;
        padding: 3px 8px;
    }

    /* Price inputs stack vertically */
    .wpf-price-inputs {
        flex-direction: column;
        gap: 10px;
    }

    .wpf-price-input-group {
        width: 100%;
    }

    .wpf-price-separator {
        display: none;
    }

    /* Larger slider thumbs for touch */
    .wpf-price-slider-track {
        height: 8px;
        margin: 24px 0;
    }

    .wpf-price-slider-track input[type="range"]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
        border-width: 4px;
    }

    .wpf-price-slider-track input[type="range"]::-moz-range-thumb {
        width: 28px;
        height: 28px;
        border-width: 4px;
    }

    /* Tag cloud adjustments */
    .wpf-tag-cloud {
        gap: 10px;
    }

    .wpf-tag-item {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    /* Color swatches larger */
    .wpf-color-swatch {
        width: 40px;
        height: 40px;
    }

    /* Category tree adjustments */
    .wpf-category-tree {
        --tree-indent: 24px;
    }

    .wpf-expand-toggle {
        width: 28px;
        height: 28px;
        min-width: 28px;
        max-width: 28px;
    }

    .wpf-child-item > .wpf-checkbox-label {
        padding: 10px 12px;
    }

    /* Rating stars larger */
    .wpf-star {
        font-size: 1.2rem;
    }

    .wpf-rating-text {
        font-size: 0.9rem;
    }

    /* Sticky filter actions at bottom */
    .wpf-filter-actions {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--wpf-background);
        margin: 0;
        padding: 16px;
        border-top: 1px solid var(--wpf-border-color);
        flex-direction: column;
        gap: 10px;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
        z-index: 5;
    }

    /* All action buttons - consistent styling */
    .wpf-apply-filters,
    .wpf-reset-filters,
    .wpf-view-results {
        width: 100%;
        padding: 14px 20px;
        font-size: 1rem;
        font-weight: 600;
        min-height: 50px;
        border-radius: 6px;
        cursor: pointer;
        transition: var(--wpf-transition);
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    /* View Results button - matches Apply Filters styling */
    .wpf-view-results {
        background: linear-gradient(135deg, var(--wpf-primary-color), var(--wpf-primary-hover));
        color: white !important;
        border: none;
        order: -1; /* Show first in the button group */
    }

    .wpf-view-results:hover {
        transform: translateY(-2px);
        box-shadow: var(--wpf-shadow-lg);
    }

    .wpf-view-results:active {
        transform: translateY(0);
    }

    .wpf-view-results-count {
        background-color: rgba(255, 255, 255, 0.2);
        color: inherit;
        padding: 2px 8px;
        border-radius: 10px;
        font-size: 0.85rem;
        margin-left: 6px;
    }

    /* When custom colors are applied via inline style, they take precedence */
    .wpf-view-results-count[style*="background-color"] {
        /* Custom background applied */
    }

    .wpf-view-results-count[style*="color"] {
        /* Custom text color applied */
    }

    /* Apply button styling */
    .wpf-apply-filters {
        background: linear-gradient(135deg, var(--wpf-primary-color), var(--wpf-primary-hover));
        color: white !important;
        border: none;
    }

    .wpf-apply-filters:hover {
        transform: translateY(-2px);
        box-shadow: var(--wpf-shadow-lg);
    }

    /* Reset button styling */
    .wpf-reset-filters {
        background: transparent;
        border: 2px solid var(--wpf-border-color);
        color: var(--wpf-text-muted);
    }

    .wpf-reset-filters:hover {
        border-color: var(--wpf-error-color);
        color: var(--wpf-error-color);
        background: rgba(239, 68, 68, 0.05);
    }

    /* Active filters */
    .wpf-active-filters {
        margin-top: 16px;
        padding: 14px;
    }

    .wpf-active-filter-tag {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .wpf-remove-filter {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }

    /* Loading overlay */
    .wpf-loading-overlay {
        border-radius: 0;
    }

    .wpf-spinner {
        width: 36px;
        height: 36px;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    .wpf-filters-widget {
        max-width: 100%;
    }

    .wpf-mobile-toggle {
        bottom: 16px;
        padding: 12px 24px;
        font-size: 0.9rem;
    }

    /* Icon only button - smaller on small screens */
    .wpf-mobile-toggle.wpf-style-icon-only {
        width: 50px;
        height: 50px;
        padding: 0;
    }

    .wpf-mobile-toggle.wpf-style-icon-only .wpf-mobile-toggle-icon {
        width: 22px;
        height: 22px;
    }

    .wpf-mobile-header {
        padding: 14px 16px;
    }

    .wpf-mobile-header-title {
        font-size: 1rem;
    }

    .wpf-filters-form {
        padding: 14px;
    }

    .wpf-filter-section {
        margin-bottom: 14px;
        padding-bottom: 14px;
    }

    .wpf-checkbox-label,
    .wpf-radio-label {
        padding: 10px 12px;
    }

    .wpf-filter-actions {
        padding: 14px;
    }

    .wpf-apply-filters,
    .wpf-reset-filters {
        padding: 12px 18px;
        min-height: 46px;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .wpf-filters-widget {
        max-width: 50%;
    }

    .wpf-mobile-toggle {
        bottom: 12px;
        padding: 10px 20px;
    }
}

/* Right-to-Left (RTL) Support for Mobile */
[dir="rtl"] .wpf-filters-widget {
    left: auto;
    right: 0;
    transform: translateX(100%);
}

[dir="rtl"] body.wpf-filters-open .wpf-filters-widget {
    transform: translateX(0);
}

@media (max-width: 768px) {
    [dir="rtl"] .wpf-filters-widget {
        box-shadow: -4px 0 25px rgba(0, 0, 0, 0.15);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --wpf-text-color: #f1f5f9;
        --wpf-text-muted: #94a3b8;
        --wpf-border-color: #334155;
        --wpf-background: #1e293b;
        --wpf-background-hover: #334155;
    }

    .wpf-loading-overlay {
        background: rgba(30, 41, 59, 0.9);
    }
}

/* Accessibility */
.wpf-checkbox-label:focus-within,
.wpf-radio-label:focus-within {
    outline: 2px solid var(--wpf-primary-color);
    outline-offset: 2px;
}

.wpf-apply-filters:focus,
.wpf-reset-filters:focus {
    outline: 2px solid var(--wpf-primary-color);
    outline-offset: 2px;
}

/* Hidden filter items (contextual filtering) */
.wpf-filter-item.wpf-hidden,
.wpf-tag-item.wpf-hidden,
.wpf-filter-item.wpf-hidden-smart,
.wpf-tag-item.wpf-hidden-smart {
    display: none !important;
}

/* Zero count styling */
.wpf-filter-item.wpf-zero-count .wpf-filter-count {
    opacity: 0.4;
}

.wpf-filter-item.wpf-zero-count .wpf-filter-name {
    opacity: 0.6;
}

/* Print Styles */
@media print {
    .wpf-filters-widget {
        display: none;
    }
}

/* Hide mobile elements on desktop */
@media (min-width: 769px) {
    .wpf-mobile-toggle,
    .wpf-mobile-backdrop,
    .wpf-mobile-header,
    .wpf-view-results {
        display: none !important;
    }
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
    .wpf-filters-widget {
        will-change: transform;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }

    .wpf-mobile-backdrop {
        will-change: opacity;
    }

    /* Smooth scrolling for filter content */
    .wpf-filters-form {
        scroll-behavior: smooth;
        overscroll-behavior: contain;
    }

    /* Reduce motion for users who prefer it */
    @media (prefers-reduced-motion: reduce) {
        .wpf-filters-widget,
        .wpf-mobile-backdrop,
        .wpf-mobile-toggle {
            transition: none;
        }
    }
}

/* Safe area padding for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .wpf-filter-actions {
            padding-bottom: calc(16px + env(safe-area-inset-bottom));
        }

        /* Bottom positions - add bottom safe area */
        .wpf-mobile-toggle.wpf-position-bottom-left,
        .wpf-mobile-toggle.wpf-position-bottom-center,
        .wpf-mobile-toggle.wpf-position-bottom-right {
            bottom: calc(20px + env(safe-area-inset-bottom));
        }

        /* Top positions - add top safe area */
        .wpf-mobile-toggle.wpf-position-top-left,
        .wpf-mobile-toggle.wpf-position-top-center,
        .wpf-mobile-toggle.wpf-position-top-right {
            top: calc(20px + env(safe-area-inset-top));
        }

        /* Left positions - add left safe area */
        .wpf-mobile-toggle.wpf-position-bottom-left,
        .wpf-mobile-toggle.wpf-position-top-left {
            left: calc(20px + env(safe-area-inset-left));
        }

        /* Right positions - add right safe area */
        .wpf-mobile-toggle.wpf-position-bottom-right,
        .wpf-mobile-toggle.wpf-position-top-right {
            right: calc(20px + env(safe-area-inset-right));
        }
    }
}
