/* ==========================================================================
   Catalog Filter Panel
   ========================================================================== */

/* 1. Основной контейнер
   ========================================================================== */

.catalog-filter-panel {
    background: #fff;
    padding: 16px 20px;
    margin-bottom: 20px;
}

/* 2. Заголовок
   ========================================================================== */

.filter-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
    margin-bottom: 4px;
}

.filter-panel__title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #333;
}

.filter-panel__reset {
    font-size: 13px;
    color: #ff0083;
    text-decoration: none;
    cursor: pointer;
}

.filter-panel__reset:hover {
    text-decoration: underline;
    color: #ff0083;
}

/* 3. Секции (collapsible)
   ========================================================================== */

.filter-panel__section {
    border-bottom: 1px solid #f0f0f0;
    padding: 0;
}

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

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

.filter-panel__section-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.filter-panel__toggle {
    display: inline-block;
    width: 16px;
    height: 16px;
    position: relative;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.filter-panel__toggle::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 2px;
    width: 8px;
    height: 8px;
    border-right: 2px solid #999;
    border-bottom: 2px solid #999;
    transform: rotate(45deg);
}

.filter-panel__section.collapsed .filter-panel__toggle {
    transform: rotate(-90deg);
}

.filter-panel__section.collapsed .filter-panel__section-body {
    display: none;
}

.filter-panel__section-body {
    padding: 0 0 12px 0;
}

/* 4. Списки фильтров
   ========================================================================== */

.filter-panel__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.filter-panel__list li {
    margin-bottom: 6px;
}

.filter-panel__list.is-truncated li:nth-child(n+9) {
    display: none;
}

.filter-panel__show-more {
    font-size: 13px;
    color: #ff0083;
    cursor: pointer;
    padding: 4px 0;
    background: none;
    border: none;
    display: inline-block;
    margin-top: 2px;
}

.filter-panel__show-more:hover {
    text-decoration: underline;
}

/* Filter search */

.filter-panel__search-wrap {
    position: relative;
    margin-bottom: 6px;
}

.filter-panel__search {
    width: 100%;
    padding: 5px 24px 5px 8px;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
    box-sizing: border-box;
}

.filter-panel__search:focus {
    border-color: #ff0083;
}

.filter-panel__search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: #999;
    width: 16px;
    height: 16px;
    text-align: center;
}

.filter-panel__search-clear:hover {
    color: #333;
}

/* Подкатегории */

.filter-panel__subcat-link {
    font-size: 13px;
    color: #444;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 0;
}

.filter-panel__subcat-link:hover {
    color: #ff0083;
    text-decoration: none;
}

.filter-panel__subcat-link .filter-panel__count {
    color: #999;
    font-size: 12px;
    white-space: nowrap;
    margin-left: 4px;
}

/* 5. Чекбоксы
   ========================================================================== */

.filter-panel__checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 3px 0;
    font-size: 13px;
    gap: 8px;
    margin: 0;
    font-weight: normal;
}

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

.filter-panel__checkmark {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 1.5px solid #ccc;
    border-radius: 3px;
    position: relative;
    transition: background 0.15s, border-color 0.15s;
    display: inline-block;
    background: #fff;
}

.filter-panel__checkbox input[type="checkbox"]:checked + .filter-panel__checkmark {
    background: #ff0083;
    border-color: #ff0083;
}

.filter-panel__checkbox input[type="checkbox"]:checked + .filter-panel__checkmark::after {
    content: '';
    position: absolute;
    left: 4.5px;
    top: 1.5px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.filter-panel__label {
    flex: 1;
    color: #444;
}

.filter-panel__count {
    color: #999;
    font-size: 12px;
    white-space: nowrap;
}

/* 6. Цветные кружки (pa_kleur)
   ========================================================================== */

.filter-panel__list--colors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.filter-panel__list--colors li {
    margin-bottom: 0;
}

.filter-panel__checkbox--color {
    flex-direction: column;
    align-items: center;
    width: auto;
    gap: 4px;
    padding: 4px;
}

.filter-panel__color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    background-size: cover;
    background-position: center;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: inline-block;
}

.filter-panel__checkbox--color input[type="checkbox"]:checked ~ .filter-panel__color-swatch {
    border-color: #ff0083;
    box-shadow: 0 0 0 2px #ff0083;
}

.filter-panel__checkbox--color .filter-panel__label {
    font-size: 11px;
    text-align: center;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: none;
}

.filter-panel__checkbox--color .filter-panel__count {
    display: none;
}

/* 7. Ценовые инпуты
   ========================================================================== */

.filter-panel__price-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-panel__price-field {
    position: relative;
    flex: 1;
}

.filter-panel__price-currency {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 13px;
    pointer-events: none;
}

.filter-panel__price-input {
    width: 100%;
    padding: 8px 10px 8px 24px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    -moz-appearance: textfield;
    transition: border-color 0.15s;
}

.filter-panel__price-input:focus {
    border-color: #ff0083;
}

.filter-panel__price-input::-webkit-inner-spin-button,
.filter-panel__price-input::-webkit-outer-spin-button {
    display: none;
    -webkit-appearance: none;
    margin: 0;
}

.filter-panel__price-sep {
    color: #999;
    flex-shrink: 0;
}

.filter-panel__price-range {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* 8 & 9. Мобильная кнопка + Responsive
   ========================================================================== */

.catalog-filter-mobile-btn {
    display: none;
}

@media (max-width: 991px) {
    .catalog-filter-panel {
        display: none;
    }

    .catalog-filter-mobile-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        width: 100%;
        font-size: 14px;
        font-weight: 500;
    }

    .catalog-filter-mobile-btn svg {
        vertical-align: middle;
    }
}

/* 10. Модал (remodal)
   ========================================================================== */

.remodal[data-remodal-id="filteren"] .catalog-filter-panel {
    display: block !important;
    box-shadow: none;
    border-radius: 0;
    margin-bottom: 0;
}

.filteren-container {
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    padding: 10px;
}

.filteren-actions {
    display: flex;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid #eee;
}

.filteren-apply {
    flex: 1;
    background: #ff0083;
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}

.filteren-apply:hover {
    background: #d04828;
}

.filteren-reset {
    padding: 12px 20px;
    border-radius: 6px;
}

/* Mobile filter modal overrides */
.remodal-wrapper:has(.remodal[data-remodal-id="filteren"]) {
    padding: 0;
}

.remodal[data-remodal-id="filteren"] .filteren-container {
    padding: 10px 0;
}

.remodal[data-remodal-id="filteren"] {
    padding: 15px;
    min-height: 100vh;
    height: 100vh;
}

.remodal[data-remodal-id="filteren"] .remodal-close {
    top: 30px;
    right: 15px;
}

.remodal[data-remodal-id="filteren"] .catalog-filter-panel {
    padding: 5px;
}

.remodal[data-remodal-id="filteren"] .filter-panel__title {
    display: none;
}

.remodal[data-remodal-id="filteren"] .filteren-actions {
    padding: 15px 0;
}

.remodal[data-remodal-id="filteren"] .btn {
    height: 40px;
    border-radius: 0;
}

/* 11. Активные теги
   ========================================================================== */

.filter-panel__active-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 12px;
}

.filter-panel__tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f5f5f5;
    border-radius: 16px;
    font-size: 12px;
    color: #444;
}

.filter-panel__tag-remove {
    width: 14px;
    height: 14px;
    cursor: pointer;
    color: #999;
    font-weight: bold;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.filter-panel__tag-remove:hover {
    color: #ff0083;
}

/* 12. Состояние загрузки
   ========================================================================== */

.catalog-filter-panel.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

#catalog-filter-results.is-loading {
    opacity: 0.5;
    min-height: 200px;
    position: relative;
}

#catalog-filter-results.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #eee;
    border-top-color: #ff0083;
    border-radius: 50%;
    animation: catalog-filter-spin 0.8s linear infinite;
}

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

/* 13. Пустые результаты
   ========================================================================== */

.catalog-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

/* 14. Empty filter options (0 results)
   ========================================================================== */

.filter-option--empty {
    opacity: 0.4;
    pointer-events: none;
}

.filter-option--empty .filter-panel__count {
    color: #ccc;
}
