/* catalog-filters.css - ОПТИМИЗИРОВАННАЯ ВЕРСИЯ */

/* ===== ОСНОВНЫЕ СТИЛИ САЙДБАРА ===== */
.shop-filters-sidebar {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    border: 1px solid #f1f5f9;
    height: auto;
    max-height: none;
    overflow-y: visible;
    position: relative;
    top: auto;
    transition: all 0.3s ease;
    box-sizing: border-box;
    width: 100%;
    overflow-x: hidden;
}

.shop-filters-sidebar * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Состояние когда нужен скролл */
.shop-filters-sidebar.scrollable {
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), inset 0 -2px 4px -1px rgba(0, 0, 0, 0.05);
}

.shop-filters-sidebar.scrollable::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(transparent, rgba(255,255,255,0.9));
    pointer-events: none;
    border-radius: 0 0 16px 16px;
}

/* Отступ сверху только на десктопе */
@media (min-width: 993px) {
    .desktop-sidebar-wrapper {
        margin-top: 30px;
    }

    .shop-filters-sidebar {
        margin-top: 0;
    }

    .sticky-top {
        position: relative !important;
        top: auto !important;
        z-index: auto !important;
    }
}

/* ===== ЗАГОЛОВОК ФИЛЬТРОВ ===== */
.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.filters-title {
    font-weight: 700;
    font-size: 1.25rem;
    color: #1e293b;
    margin: 0;
}

.filters-count {
    background: var(--primary-green);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* ===== СЕКЦИИ ФИЛЬТРОВ ===== */
.filter-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.filter-section:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    cursor: pointer;
}

.filter-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.filter-title i {
    color: var(--primary-green);
    font-size: 1rem;
}

.filter-toggle {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.filter-toggle.collapsed {
    transform: rotate(-90deg);
}

.filter-content {
    margin-top: 0;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== ФИЛЬТР ЦЕНЫ ===== */
.price-filter {
    background: white;
    padding: 1.25rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    width: 100%;
    box-sizing: border-box;
}

.price-inputs-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    width: 100%;
}

.price-input-group {
    position: relative;
    width: 100%;
}

.price-input-group::before {
    content: "₽";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 1rem;
    font-weight: 500;
    z-index: 2;
}

.price-input {
    width: 100%;
    padding: 1rem 1rem 1rem 2.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    background: white;
    transition: all 0.3s ease;
    box-sizing: border-box;
    min-height: 54px;
}

.price-input:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.price-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
    font-size: 0.95rem;
}

.price-separator {
    display: none;
}

/* Ползунок цены */
.price-slider-container {
    margin: 1.5rem 0 0.5rem;
}

.price-slider {
    position: relative;
    height: 20px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
}

.price-slider-track {
    position: absolute;
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
}

.price-slider-progress {
    position: absolute;
    height: 4px;
    background: var(--primary-green);
    border-radius: 2px;
    left: 0%;
    right: 0%;
}

.price-slider-inputs {
    position: relative;
    width: 100%;
}

.price-range-min,
.price-range-max {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0;
}

.price-range-min {
    left: 0;
    z-index: 2;
}

.price-range-max {
    left: 0;
    z-index: 1;
}

.price-range-min::-webkit-slider-thumb,
.price-range-max::-webkit-slider-thumb {
    pointer-events: all;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-green);
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
}

.price-range-min::-moz-range-thumb,
.price-range-max::-moz-range-thumb {
    pointer-events: all;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-green);
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    position: relative;
}

.price-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.5rem;
}

/* ===== ЧЕКБОКСЫ И ОПЦИИ ФИЛЬТРОВ ===== */
.filter-options {
    max-height: 280px;
    overflow-y: auto;
    padding-right: 0.5rem;
    box-sizing: border-box;
    width: 100%;
}

.filter-options::-webkit-scrollbar {
    width: 4px;
}

.filter-options::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 2px;
}

.filter-options::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.filter-option {
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin: 0.25rem 0;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.filter-option:hover {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.filter-option.active {
    background: rgba(46, 125, 50, 0.05);
    border-color: var(--primary-green);
}

.filter-option[data-filter="category"].active {
    background: rgba(46, 125, 50, 0.08);
    border: 1.5px solid var(--primary-green);
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.15);
}

.modern-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    margin-right: 0.75rem;
    position: relative;
    transition: all 0.3s ease;
    flex-shrink: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modern-checkbox.checked {
    background: var(--primary-green);
    border-color: var(--primary-green);
}

.modern-checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
}

.filter-label {
    flex: 1;
    font-size: 0.9rem;
    color: #475569;
    font-weight: 500;
    line-height: 1.4;
}

.filter-count {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 500;
    background: #f1f5f9;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    min-width: 32px;
    text-align: center;
}

/* Звезды рейтинга */
.rating-stars {
    display: flex;
    gap: 2px;
    margin-right: 0.5rem;
}

.rating-stars .fas {
    font-size: 0.75rem;
    color: #fbbf24;
}

/* ===== КНОПКИ ФИЛЬТРОВ ===== */
.filter-actions {
    padding-top: 1.5rem;
    margin-top: 1rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.filter-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    font-size: 1rem;
    border: 2px solid transparent;
    box-sizing: border-box;
}

.filter-btn:first-child {
    background: var(--primary-green);
    border-color: var(--primary-green);
    color: white;
}

.filter-btn:first-child:hover {
    background: var(--dark-green);
    border-color: var(--dark-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.filter-btn:last-child {
    background: white;
    border-color: #e2e8f0;
    color: #64748b;
}

.filter-btn:last-child:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
    transform: translateY(-2px);
}

/* ===== АКТИВНЫЕ ФИЛЬТРЫ ===== */
.active-filters {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.5rem;
    margin: 2rem 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}

.active-filters-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.active-filters-title {
    font-weight: 700;
    color: #1e293b;
    font-size: 1.1rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f1f5f9;
}

.active-filters-title i {
    color: var(--primary-green);
    font-size: 1.2rem;
}

.active-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    min-height: 3rem;
}

.active-filter-tag {
    background: white;
    color: #334155;
    padding: 0.625rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1.5px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.active-filter-tag::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--primary-green);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.active-filter-tag:hover {
    border-color: var(--primary-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.05);
}

.active-filter-tag:hover::before {
    opacity: 1;
}

.active-filter-tag .remove-filter {
    background: #fef2f2;
    border: none;
    color: #dc2626;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.25rem;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.active-filter-tag .remove-filter:hover {
    background: #dc2626;
    color: white;
    transform: scale(1.1);
}

.clear-all-filters {
    background: var(--primary-green);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    align-self: flex-start;
    margin-top: 0.5rem;
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.2);
}

.clear-all-filters:hover {
    background: var(--dark-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3), 0 2px 4px rgba(46, 125, 50, 0.1);
}

.clear-all-filters:active {
    transform: translateY(0);
}

/* Состояние когда нет активных фильтров */
.active-filters:empty {
    display: none;
}

/* Специфические стили для разных типов фильтров */
.active-filter-tag[data-filter-type="price"] {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: #bbf7d0;
    color: #166534;
}

.active-filter-tag[data-filter-type="category"] {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-color: #bae6fd;
    color: #075985;
}

.active-filter-tag[data-filter-type="brand"] {
    background: linear-gradient(135deg, #faf5ff, #f3e8ff);
    border-color: #e9d5ff;
    color: #7c3aed;
}

.active-filter-tag[data-filter-type="rating"] {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border-color: #fde68a;
    color: #d97706;
}

/* ===== АНИМАЦИИ ===== */
@keyframes slideInFilters {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.active-filters[style*="display: block"] {
    animation: slideInFilters 0.3s ease-out;
}

@keyframes smoothHeightChange {
    from {
        opacity: 0.95;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.shop-filters-sidebar:not(.scrollable) {
    animation: smoothHeightChange 0.4s ease-out;
}

/* ===== МОБИЛЬНАЯ ВЕРСИЯ ===== */
@media (max-width: 992px) {
    .shop-filters-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 90%;
        max-width: 380px;
        height: 100vh !important;
        max-height: 100vh !important;
        z-index: 1060;
        transition: left 0.3s ease;
        border-radius: 0;
        margin: 0;
        overflow-y: auto;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
        padding: 1.5rem;
    }

    .shop-filters-sidebar.active {
        left: 0;
    }

    .filters-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        padding: 1rem 0;
        margin: -1.5rem -1.5rem 1.5rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    .filter-actions {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1.5rem 0 0;
        margin: 0 -1.5rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
    }

    .filters-header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        margin: -1.5rem -1.5rem 1.5rem;
        padding: 1.5rem;
        border-radius: 0;
    }

    .filters-title {
        color: white;
        font-size: 1.3rem;
    }

    .filters-count {
        background: rgba(255, 255, 255, 0.2);
        backdrop-filter: blur(10px);
    }

    .shop-filters-sidebar::after {
        display: none;
    }
}

/* ===== МОБИЛЬНЫЙ ПЕРЕКЛЮЧАТЕЛЬ ФИЛЬТРОВ ===== */
.mobile-filters-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: var(--primary-green);
    color: white;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
    width: 100%;
    text-align: center;
}

.mobile-filters-toggle:hover {
    background: var(--dark-green);
    transform: translateY(-2px);
}

/* Показываем только на мобильных */
@media (min-width: 993px) {
    .mobile-filters-toggle {
        display: none !important;
    }
}

/* Стили для бейджа на мобильной кнопке */
.filters-count-badge {
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-green);
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    display: none;
}

/* ===== OVERLAY ДЛЯ МОБИЛЬНЫХ ===== */
.filters-overlay {
    display: none;
}

@media (max-width: 992px) {
    .filters-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1059;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .filters-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

/* ===== АДАПТАЦИЯ ДЛЯ МАЛЕНЬКИХ ЭКРАНОВ ===== */
@media (max-width: 768px) {
    .active-filters {
        padding: 1.25rem;
        margin: 1.5rem 0;
        border-radius: 12px;
    }

    .active-filters-title {
        font-size: 1rem;
        gap: 0.5rem;
    }

    .active-filter-tags {
        gap: 0.5rem;
    }

    .active-filter-tag {
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
        gap: 0.5rem;
    }

    .active-filter-tag .remove-filter {
        width: 18px;
        height: 18px;
        font-size: 0.9rem;
    }

    .clear-all-filters {
        padding: 0.625rem 1.25rem;
        font-size: 0.85rem;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .price-inputs-wrapper {
        flex-direction: column;
        gap: 0.5rem;
    }

    .price-separator {
        display: none;
    }

    .filter-actions {
        flex-direction: column;
    }

    .mobile-filters-toggle {
        padding: 0.875rem 1.25rem;
        font-size: 0.9rem;
    }

    .mobile-filters-toggle span:not(.filters-count-badge) {
        display: none;
    }

    .mobile-filters-toggle i {
        margin-right: 0;
    }
}

@media (max-width: 360px) {
    .filter-btn {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }

    .price-input {
        padding: 0.875rem 0.875rem 0.875rem 2.25rem;
        font-size: 0.95rem;
        min-height: 50px;
    }
}

/* ===== СКРОЛЛБАРЫ ===== */
.shop-filters-sidebar {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.shop-filters-sidebar::-webkit-scrollbar {
    width: 6px;
}

.shop-filters-sidebar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
    margin: 5px 0;
}

.shop-filters-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.shop-filters-sidebar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Для очень коротких страниц */
@media (max-height: 600px) {
    .shop-filters-sidebar {
        max-height: calc(100vh - 120px);
    }
}

/* Десктоп улучшения */
@media (min-width: 768px) {
    .filter-actions {
        flex-direction: column;
    }

    .filter-btn {
        padding: 1.125rem 1.5rem;
        font-size: 1.05rem;
    }

    .price-inputs-wrapper {
        flex-direction: column;
        gap: 1rem;
    }

    .price-input {
        padding: 1.125rem 1.125rem 1.125rem 2.75rem;
        font-size: 1.05rem;
        min-height: 58px;
    }

    .price-input-group::before {
        left: 1.125rem;
        font-size: 1.05rem;
    }
}