/**
 * Gerrards Shop Filter - Styles
 * Matches the category menu sidebar design
 *
 * @package Gerrards_Utilities
 */

/* Filter Container */
.gerrards-shop-filter {
    margin-bottom: 1.5rem;
    font-family: inherit;
}

.gerrards-shop-filter.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Filter Header */
.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 20px;
    background: var(--gb-navy, #16284f);
    border-bottom: 1px solid #e5e5e5;
}

.filter-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

/* Toggle button — visible at all sizes */
.filter-toggle {
    display: block;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: #fff;
}

.toggle-icon {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    position: relative;
}

.toggle-icon::before,
.toggle-icon::after {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    position: absolute;
    left: 0;
    transition: transform 0.2s ease;
}

.toggle-icon::before {
    top: -6px;
}

.toggle-icon::after {
    top: 6px;
}

.gerrards-shop-filter.is-open .toggle-icon {
    background: transparent;
}

.gerrards-shop-filter.is-open .toggle-icon::before {
    transform: rotate(45deg);
    top: 0;
}

.gerrards-shop-filter.is-open .toggle-icon::after {
    transform: rotate(-45deg);
    top: 0;
}

/* Filter Content */
.filter-content {
    padding: 0;
}

/* Active Filters */
.active-filters {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
}

.active-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.active-filters-label {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.clear-all-filters {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
}

.clear-all-filters:hover {
    text-decoration: underline;
}

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

.active-filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f0f0f0;
    border: 1px solid #d3d3d3;
    padding: 3px 8px;
    font-size: 13px;
    color: #333;
}

.active-filter-remove {
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.active-filter-remove:hover {
    color: #dc2626;
}

/* Filter Groups — match category menu style */
.filter-group {
    border-bottom: 1px solid #e5e5e5;
}

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

.filter-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: #fff;
    border: none;
    padding: 5px 20px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s ease;
}

.filter-group-header:hover {
    background: #f5f5f5;
}

.filter-group.is-open .filter-group-header {
    background: #f5f5f5;
}

.filter-group-title {
    font-weight: 400;
    font-size: 15px;
    color: #333;
}

/* Chevron — matches category menu */
.filter-group-toggle {
    display: block;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-top: -2px;
    color: #333;
}

.filter-group-header[aria-expanded="true"] .filter-group-toggle {
    transform: rotate(-135deg);
    margin-top: 2px;
}

.filter-group-content {
    display: none;
    padding: 6px 20px 10px;
    background: #fff;
}

/* Filter Options */
.filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    cursor: pointer;
}

.filter-option:hover {
    background: none;
}

.filter-option:hover .filter-option-label {
    color: #000;
}

.filter-option input[type="checkbox"],
.filter-option input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--gb-navy, #16284f);
    flex-shrink: 0;
}

.filter-option-label {
    font-size: 15px;
    color: #333;
    font-weight: 400;
}

.filter-option-count {
    color: #999;
    font-size: 14px;
}

/* Price Filter */
.price-inputs {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.price-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.price-input-group label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.price-input-group input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #d3d3d3;
    font-size: 14px;
}

.price-input-group input:focus {
    outline: none;
    border-color: var(--gb-navy, #16284f);
}

.price-separator {
    margin-bottom: 6px;
    color: #999;
    font-weight: 500;
}

/* Loading State */
.gerrards-shop-filter.is-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
}

/* Products Loading State */
ul.products.is-loading {
    position: relative;
    opacity: 0.5;
    transition: opacity 0.2s;
}

/* Scrollbar for long filter lists */
.filter-group-content {
    max-height: 250px;
    overflow-y: auto;
}

.filter-group-content::-webkit-scrollbar {
    width: 6px;
}

.filter-group-content::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.filter-group-content::-webkit-scrollbar-thumb {
    background: #ccc;
}

.filter-group-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive — tablet and below: collapsed by default */
@media (max-width: 992px) {
    .filter-content {
        display: none;
    }

    .gerrards-shop-filter.is-open .filter-content {
        display: block;
    }
}

@media (max-width: 768px) {
    .filter-header {
        padding: 8px 15px;
    }

    .filter-group-header {
        padding: 8px 15px;
    }

    .filter-group-content {
        padding: 6px 15px 10px;
    }

    .price-inputs {
        flex-direction: column;
        align-items: stretch;
    }

    .price-separator {
        text-align: center;
        margin: 0;
    }

    .active-filters-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

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

    .filter-option-label {
        font-size: 14px;
    }
}

/* Inline error message shown when the filter AJAX fails */
.gerrards-filter-error {
    background: #fff4f4;
    border: 1px solid #e8b4b4;
    color: #8a1f1f;
    padding: 12px 16px;
    border-radius: 4px;
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.4;
}
