/* WooCommerce AJAX Taxonomy Filter Styles - Enhanced UX Version */

:root {
    /* Primary Colors */
    --primary-burgundy: #573d3d;
    --primary-dark: #1A1A1A;
    --accent-gold: #C5A059;
    --red: #db2920;
    --black: #1f1a17;

    /* Backgrounds & Surfaces */
    --bg-main: #FFFFFF;
    --bg-subtle: #F8F9FA;
    --surface-border: #E0E0E0;
    --hover-bg: #f9f9f9;

    /* Interactive states */
    --focus-color: #0073aa;
    --success-color: #46b450;
    --error-color: #dc3232;
    --info-color: #00a0d2;
}

/* Widget Container */
.wc-ajax-tax-filter-widget {
    position: relative;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease;
}

.wc-ajax-tax-filter-widget.is-loading {
    pointer-events: none;
}

/* Active Filters Badge */
.wc-tax-filter-active-filters {
    background: linear-gradient(135deg, var(--red) 0%, #c02419 100%);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(219, 41, 32, 0.2);
    animation: slideInDown 0.3s ease;
}

.wc-tax-filter-active-count {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Container */
.wc-tax-filter-form {
    margin: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Filter Groups Wrapper */
.wc-tax-filter-groups {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 450px;
    padding-right: 5px;
    margin-bottom: 15px;
}

/* Custom scrollbar for groups */
.wc-tax-filter-groups::-webkit-scrollbar {
    width: 8px;
}

.wc-tax-filter-groups::-webkit-scrollbar-track {
    background: #f8f8f8;
    border-radius: 4px;
    margin: 5px 0;
}

.wc-tax-filter-groups::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #c1c1c1 0%, #a8a8a8 100%);
    border-radius: 4px;
    border: 2px solid #f8f8f8;
}

.wc-tax-filter-groups::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #a1a1a1 0%, #888 100%);
}

/* Firefox scrollbar */
.wc-tax-filter-groups {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f8f8f8;
    scroll-behavior: smooth;
}

/* Individual Filter Group */
.wc-tax-filter-group {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff !important;
}

.wc-tax-filter-group:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

/* Group Title */
.wc-tax-filter-title {
    margin: 0 0 15px 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    position: relative;
    padding-bottom: 8px;
}

.wc-tax-filter-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 30px;
    height: 2px;
    background: var(--red);
    transition: width 0.3s ease;
}

.wc-tax-filter-group:hover .wc-tax-filter-title::after {
    width: 50px;
}

/* Filter List */
.wc-tax-filter-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    max-height: 250px;
}

/* Custom scrollbar for lists */
.wc-tax-filter-list::-webkit-scrollbar {
    width: 6px;
}

.wc-tax-filter-list::-webkit-scrollbar-track {
    background: #f8f8f8;
    border-radius: 3px;
    margin: 5px 0;
}

.wc-tax-filter-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
    border: 1px solid #f8f8f8;
    transition: background 0.2s ease;
}

.wc-tax-filter-list::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.wc-tax-filter-list::-webkit-scrollbar-thumb:active {
    background: #888;
}

/* Firefox scrollbar for lists */
.wc-tax-filter-list {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f8f8f8;
    scroll-behavior: smooth;
}

/* Filter Term Item */
.wc-tax-filter-term {
    margin: 0 0 8px 0;
    padding: 0;
    list-style: none;
    padding-right: 10px;
    position: relative;
    transition: all 0.2s ease;
}

.wc-tax-filter-term.updating {
    opacity: 0.6;
    transform: scale(0.98);
}

.wc-tax-filter-term.resetting {
    animation: fadeOutLeft 0.3s ease;
}

@keyframes fadeOutLeft {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(-10px);
    }
}

/* Term Label */
.wc-tax-filter-term label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 8px 8px 0;
    position: relative;
    transition: all 0.2s ease;
    min-height: 32px;
    border-radius: 4px;
    margin: 0;
}

.wc-tax-filter-term label:hover {
    background-color: var(--hover-bg);
    padding-left: 5px;
}

.wc-tax-filter-term label:hover .wc-tax-filter-label {
    color: var(--red);
}

/* Checkbox Styling */
.wc-tax-filter-checkbox {
    margin: 0 12px 0 0;
    cursor: pointer;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border: 2px solid #ddd;
    border-radius: 3px;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    background: white;
    position: relative;
}

.wc-tax-filter-checkbox:hover {
    border-color: var(--red);
    transform: scale(1.1);
}

.wc-tax-filter-checkbox:checked {
    background: var(--red);
    border-color: var(--red);
}

.wc-tax-filter-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.wc-tax-filter-checkbox:focus {
    outline: 2px solid var(--focus-color);
    outline-offset: 2px;
}

/* Label Text */
.wc-tax-filter-label {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    padding-right: 35px;
    word-break: break-word;
    transition: color 0.2s ease;
    font-weight: 500;
}

.wc-tax-filter-checkbox:checked+.wc-tax-filter-label {
    font-weight: 600;
    color: var(--red);
}

/* Product Count */
.wc-tax-filter-count {
    color: #999;
    font-weight: 400;
    font-size: 13px;
    margin-left: 4px;
}

.wc-tax-filter-checkbox:checked+.wc-tax-filter-label .wc-tax-filter-count {
    color: var(--red);
    font-weight: 600;
}

/* Expand/Collapse Button */
.wc-tax-filter-expand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    color: #666;
    transition: all 0.25s ease;
    flex-shrink: 0;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    text-align: center;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
}

.wc-tax-filter-expand:hover {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 2px 4px rgba(219, 41, 32, 0.3);
}

.wc-tax-filter-expand.expanded {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    transform: translateY(-50%) rotate(180deg);
}

.wc-tax-filter-expand:focus {
    outline: 2px solid var(--focus-color);
    outline-offset: 2px;
}

/* Loading state for expand button */
.wc-tax-filter-expand.loading {
    background: #f0f0f0;
    border-color: #e0e0e0;
    pointer-events: none;
    padding: 0;
}

/* Blue spinner inside expand button */
.wc-expand-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #e3f2fd;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: expandSpin 0.6s linear infinite;
}

@keyframes expandSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Child Terms */
.wc-tax-filter-children {
    list-style: none;
    margin: 5px 0 0 25px;
    padding: 0 5px 0 15px;
    display: none;
    border-left: 2px solid #e8e8e8;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.wc-tax-filter-children .wc-tax-filter-term {
    margin: 0 0 6px 0;
}

.wc-tax-filter-children .wc-tax-filter-children {
    margin-left: 15px;
    border-left-color: #f0f0f0;
}

/* Nested level styling */
.wc-tax-filter-children .wc-tax-filter-label {
    font-size: 13px;
}

.wc-tax-filter-children .wc-tax-filter-children .wc-tax-filter-label {
    font-size: 12px;
}

/* Action Buttons */
.wc-tax-filter-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid #e0e0e0;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, #fff 90%, rgba(255, 255, 255, 0.9) 100%);
    z-index: 10;
}

.wc-tax-filter-reset {
    flex: 1;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.wc-tax-filter-reset:hover {
    background: var(--red);
    border-color: var(--red);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(219, 41, 32, 0.3);
}

.wc-tax-filter-reset:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(219, 41, 32, 0.2);
}

.wc-tax-filter-reset:focus {
    outline: 2px solid var(--focus-color);
    outline-offset: 2px;
}

.wc-tax-filter-reset-icon {
    font-size: 18px;
    display: inline-block;
    transition: transform 0.3s ease;
}

.wc-tax-filter-reset:hover .wc-tax-filter-reset-icon {
    transform: rotate(180deg);
}

/* Loading Overlay */
.wc-tax-filter-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(2px);
}

.wc-tax-filter-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Notice Messages */
.wc-tax-filter-notice {
    margin-top: 15px;
    padding: 10px;
    background: #f0f8ff;
    border-left: 3px solid var(--info-color);
    border-radius: 3px;
}

.wc-tax-filter-notice p {
    margin: 0;
    color: #666;
    font-size: 12px;
    line-height: 1.4;
}

.wc-tax-filter-notice-message {
    padding: 12px 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-size: 13px;
    animation: slideInDown 0.3s ease;
}

.wc-tax-filter-notice-error {
    background: #fef2f2;
    border-left: 3px solid var(--error-color);
    color: #991b1b;
}

.wc-tax-filter-notice-info {
    background: #f0f8ff;
    border-left: 3px solid var(--info-color);
    color: #0c4a6e;
}

.wc-tax-filter-notice-success {
    background: #f0fdf4;
    border-left: 3px solid var(--success-color);
    color: #166534;
}

/* No Products Message */
.wc-tax-filter-no-products {
    text-align: center;
    padding: 40px 20px;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 20px 0;
}

/* Widget Customization */
.widget.wc_ajax_tax_filter {
    padding: 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    max-height: 700px;
    display: flex;
    flex-direction: column;
}

.widget.wc_ajax_tax_filter .widget-title {
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--red);
    font-size: 18px;
    color: var(--primary-dark);
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wc-tax-filter-buttons {
        flex-direction: column;
    }

    .wc-tax-filter-reset {
        width: 100%;
    }

    .wc-tax-filter-list {
        max-height: 200px;
    }

    .wc-tax-filter-groups {
        max-height: 350px;
    }

    .wc-tax-filter-label {
        font-size: 13px;
    }

    .wc-tax-filter-expand {
        width: 22px;
        height: 22px;
        font-size: 14px;
    }

    .wc-ajax-tax-filter-widget {
        max-height: 500px;
    }
}

@media (max-width: 480px) {
    .wc-tax-filter-title {
        font-size: 14px;
    }

    .wc-tax-filter-label {
        font-size: 12px;
        padding-right: 30px;
    }

    .wc-tax-filter-checkbox {
        width: 16px;
        height: 16px;
    }

    .wc-tax-filter-expand {
        width: 20px;
        height: 20px;
        font-size: 13px;
    }
}

/* Print Styles */
@media print {
    .wc-tax-filter-list {
        max-height: none;
        overflow: visible;
    }

    .wc-tax-filter-buttons {
        display: none;
    }

    .wc-tax-filter-expand {
        display: none;
    }

    .wc-tax-filter-loading-overlay {
        display: none;
    }
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .wc-tax-filter-checkbox {
        border-width: 3px;
    }

    .wc-tax-filter-expand {
        border-width: 2px;
    }
}

/* Dark Mode Support (if theme supports it) */
/* @media (prefers-color-scheme: dark) {
    .widget.wc_ajax_tax_filter {
        background: #1a1a1a;
        border-color: #333;
    }

    .wc-tax-filter-group {
        background: #1a1a1a !important;
        border-bottom-color: #333;
    }

    .wc-tax-filter-title {
        color: #fff;
    }

    .wc-tax-filter-label {
        color: #e0e0e0;
    }

    .wc-tax-filter-checkbox {
        background: #2a2a2a;
        border-color: #444;
    }

    .wc-tax-filter-expand {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }
} */

/* Smooth Scrolling */
.wc-tax-filter-list,
.wc-tax-filter-groups {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Better Focus Visible */
.wc-tax-filter-checkbox:focus-visible,
.wc-tax-filter-expand:focus-visible,
.wc-tax-filter-reset:focus-visible {
    outline: 3px solid var(--focus-color);
    outline-offset: 3px;
}