/**
 * WC Dynamic Filters Styles
 *
 * @package WC_Dynamic_Filters
 */

/* Base styles */
.wcdf-container {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.wcdf-container *,
.wcdf-container *::before,
.wcdf-container *::after {
    box-sizing: border-box;
}

/* Loading state */
.wcdf-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    gap: 10px;
}

.wcdf-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top-color: #333;
    border-radius: 50%;
    animation: wcdf-spin 0.8s linear infinite;
}

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

.wcdf-loading-text {
    color: #666;
}

/* Filters wrapper */
.wcdf-filters-wrapper {
    padding: 0;
}

/* Selected filters */
.wcdf-selected-filters {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.wcdf-selected-title {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.wcdf-selected-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.wcdf-selected-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background-color: #f0f0f0;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
}

.wcdf-remove-filter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: background-color 0.2s, color 0.2s;
}

.wcdf-remove-filter:hover {
    background-color: #333;
    color: #fff;
}

.wcdf-clear-all {
    padding: 6px 12px;
    background: none;
    border: 1px solid #999;
    border-radius: 4px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.wcdf-clear-all:hover {
    background-color: #333;
    border-color: #333;
    color: #fff;
}

/* Filter groups */
.wcdf-filter-groups {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.wcdf-filter-group {
    border-bottom: 1px solid #e0e0e0;
}

.wcdf-filter-group:last-child {
    border-bottom: none;
}

.wcdf-filter-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    padding: 15px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.wcdf-toggle-icon {
    position: relative;
    width: 12px;
    height: 12px;
}

.wcdf-toggle-icon::before,
.wcdf-toggle-icon::after {
    content: '';
    position: absolute;
    background-color: #666;
    transition: transform 0.2s;
}

.wcdf-toggle-icon::before {
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
}

.wcdf-toggle-icon::after {
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
}

.wcdf-filter-group.wcdf-collapsed .wcdf-toggle-icon::after {
    transform: translateX(-50%) rotate(90deg);
}

.wcdf-filter-group.wcdf-collapsed .wcdf-filter-options {
    display: none;
}

/* Filter options */
.wcdf-filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 15px;
    max-height: 250px;
    overflow-y: auto;
}

.wcdf-filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin: 0;
    background-color: transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.wcdf-filter-option:hover {
    background-color: #f5f5f5;
}

.wcdf-filter-option.wcdf-selected {
    background-color: #f0f7ff;
}

.wcdf-filter-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.wcdf-checkbox-custom {
    position: relative;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background-color: #fff;
    border: 2px solid #ccc;
    border-radius: 3px;
    transition: border-color 0.2s, background-color 0.2s;
}

.wcdf-filter-option:hover .wcdf-checkbox-custom {
    border-color: #999;
}

.wcdf-filter-option input[type="checkbox"]:checked + .wcdf-checkbox-custom {
    background-color: #333;
    border-color: #333;
}

.wcdf-checkbox-custom::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.2s;
}

.wcdf-filter-option input[type="checkbox"]:checked + .wcdf-checkbox-custom::after {
    opacity: 1;
}

.wcdf-option-label {
    flex: 1;
    color: #333;
}

.wcdf-option-count {
    color: #999;
    font-size: 12px;
}

/* Mobile toggle button - hidden on desktop */
.wcdf-mobile-toggle {
    display: none;
}

/* Mobile overlay - hidden on desktop */
.wcdf-overlay {
    display: none;
}

/* Panel header - hidden on desktop */
.wcdf-panel-header {
    display: none;
}

/* Panel footer - hidden on desktop */
.wcdf-panel-footer {
    display: none;
}

/* Filters panel - default (desktop) */
.wcdf-filters-panel {
    background-color: #fff;
}

.wcdf-panel-content {
    padding: 0;
}

/* ========================================
   Mobile styles (max-width: 992px)
   ======================================== */
@media screen and (max-width: 992px) {
    /* Mobile toggle button */
    .wcdf-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 12px 20px;
        background-color: #fff;
        border: 1px solid #e0e0e0;
        border-radius: 4px;
        font-size: 14px;
        font-weight: 500;
        color: #333;
        cursor: pointer;
        transition: background-color 0.2s, border-color 0.2s;
    }

    .wcdf-mobile-toggle:hover {
        background-color: #f5f5f5;
        border-color: #ccc;
    }

    .wcdf-toggle-text {
        flex: 1;
        text-align: left;
    }

    .wcdf-mobile-toggle .wcdf-toggle-icon {
        width: 20px;
        height: 20px;
    }

    .wcdf-mobile-toggle .wcdf-toggle-icon svg {
        display: block;
        width: 100%;
        height: 100%;
    }

    .wcdf-active-count {
        display: none;
        min-width: 20px;
        height: 20px;
        padding: 0 6px;
        background-color: #333;
        border-radius: 10px;
        font-size: 12px;
        font-weight: 600;
        color: #fff;
        line-height: 20px;
        text-align: center;
    }

    .wcdf-active-count.wcdf-has-count {
        display: inline-block;
    }

    /* Mobile overlay */
    .wcdf-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 9998;
        opacity: 0;
        transition: opacity 0.3s;
    }

    .wcdf-overlay.wcdf-visible {
        display: block;
        opacity: 1;
    }

    /* Filters panel - mobile popup */
    .wcdf-filters-panel {
        position: fixed;
        top: 0;
        right: -100%;
        width: 90%;
        max-width: 400px;
        height: 100%;
        background-color: #fff;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        transition: right 0.3s ease;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .wcdf-filters-panel.wcdf-open {
        right: 0;
    }

    /* Panel header */
    .wcdf-panel-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px 20px;
        border-bottom: 1px solid #e0e0e0;
        flex-shrink: 0;
    }

    .wcdf-panel-title {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #333;
    }

    .wcdf-panel-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        background: none;
        border: none;
        border-radius: 50%;
        font-size: 24px;
        color: #666;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .wcdf-panel-close:hover {
        background-color: #f0f0f0;
    }

    /* Panel content */
    .wcdf-panel-content {
        flex: 1;
        overflow-y: auto;
        padding: 15px 20px;
        -webkit-overflow-scrolling: touch;
    }

    /* Panel footer */
    .wcdf-panel-footer {
        display: flex;
        padding: 15px 20px;
        border-top: 1px solid #e0e0e0;
        flex-shrink: 0;
        background-color: #fff;
    }

    .wcdf-apply-filters {
        flex: 1;
        padding: 14px 20px;
        background-color: #333;
        border: none;
        border-radius: 4px;
        font-size: 16px;
        font-weight: 500;
        color: #fff;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .wcdf-apply-filters:hover {
        background-color: #444;
    }

    /* Prevent body scroll when panel is open */
    body.wcdf-panel-open {
        overflow: hidden;
    }
}

/* Accessibility - focus styles */
.wcdf-mobile-toggle:focus,
.wcdf-panel-close:focus,
.wcdf-remove-filter:focus,
.wcdf-clear-all:focus,
.wcdf-apply-filters:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}

.wcdf-filter-option:focus-within {
    outline: 2px solid #005fcc;
    outline-offset: -2px;
}

/* No filters message */
.wcdf-no-filters {
    padding: 30px 20px;
    text-align: center;
    color: #666;
}

/* Error message */
.wcdf-error {
    padding: 20px;
    background-color: #fff5f5;
    border: 1px solid #ffccc7;
    border-radius: 4px;
    color: #cf1322;
    text-align: center;
}
