/* Existing styles */
.main-content {
    display: flex;
    gap: 1.5rem;
    padding: 0 1.25rem;
    margin: 1.875rem 0;
}

/* Hide close button on desktop */
.filter-close-button {
    display: none;
}

/* Hide WooCommerce default ordering/filtering dropdown (but not inside sidebar) */
.woocommerce-ordering {
    display: none !important;
}

/* Hide WooCommerce filter buttons (we have our own) */
.wc-block-filter-title-button,
button[class*="wc-block"][class*="filter"] {
    display: none !important;
}

/* Show WooCommerce filter blocks inside our sidebar */
.category-filter .wc-block-product-filters,
.category-filter .wp-block-woocommerce-product-filter,
.category-filter .wc-block-components-filter-wrapper {
    display: block !important;
}

/* Disable WooCommerce overlay mode - always show filters inline */
.category-filter :where(.wc-block-product-filters) .wc-block-product-filters__overlay,
.category-filter :where(.wc-block-product-filters) .wc-block-product-filters__overlay-wrapper,
.category-filter :where(.wc-block-product-filters) .wc-block-product-filters__overlay-dialog,
.category-filter :where(.wc-block-product-filters) .wc-block-product-filters__overlay-content {
    position: static !important;
    transform: none !important;
    inset: auto !important;
    background: transparent !important;
    overflow: visible !important;
    padding: 0 !important;
    max-height: none !important;
    display: block !important;
    width: 100% !important;
    pointer-events: auto !important;
    z-index: auto !important;
}

/* Hide WooCommerce overlay header and footer (close button, apply button) */
.category-filter :where(.wc-block-product-filters) .wc-block-product-filters__overlay-header,
.category-filter :where(.wc-block-product-filters) .wc-block-product-filters__overlay-footer {
    display: none !important;
}

/* Ensure WooCommerce filter wrapper doesn't overflow */
.category-filter :where(.wc-block-product-filters) {
    position: relative !important;
    overflow: visible !important;
}

.sidebar {
    width: 21rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1.875rem;
}

.breadcrumbs {
    display: flex;
    gap: 0.4375rem;
    font-size: 1rem;
    color: #000;
    align-items: center;
}

.category-filter {
    border: 0.03125rem solid #2B2B2A;
    border-radius: 0.4375rem;
    padding: 1.562rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.filter-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.filter-title {
    font-weight: bold;
    font-size: 1rem;
}

.reset-filter-btn {
    border: 0.03125rem solid black;
    border-radius: 0.4375rem;
    padding: 0.4375rem;
    font-size: 0.5rem;
    background-color: transparent;
    cursor: pointer;
    align-self: flex-start;
}

.category-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    font-size: 1rem;
    cursor: pointer;
    position: relative;
}

.checkbox-container input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkbox-container input[type="checkbox"]:checked ~ .checkbox-icon-unchecked {
    display: none;
}

.checkbox-container input[type="checkbox"]:not(:checked) ~ .checkbox-icon {
    display: none;
}

.checkbox-container .checkbox-label {
    font-size: 1rem;
    user-select: none;
}

/* Disabled/unavailable filters */
.checkbox-container input[type="checkbox"]:disabled ~ .checkbox-label,
.checkbox-container input[type="checkbox"].filter-unavailable ~ .checkbox-label {
    color: #CCCCCC;
    cursor: not-allowed;
}

.checkbox-container input[type="checkbox"]:disabled ~ .checkbox-icon-unchecked,
.checkbox-container input[type="checkbox"].filter-unavailable ~ .checkbox-icon-unchecked {
    border-color: #CCCCCC;
    opacity: 0.5;
}

.checkbox-container input[type="checkbox"]:disabled,
.checkbox-container input[type="checkbox"].filter-unavailable {
    cursor: not-allowed;
}

/* Стили для блеклых недоступных фильтров WooCommerce */
.category-filter input[type="checkbox"]:disabled,
.category-filter input[type="checkbox"].filter-unavailable {
    cursor: not-allowed;
    opacity: 0.4;
}

.category-filter input[type="checkbox"]:disabled + *,
.category-filter input[type="checkbox"].filter-unavailable + * {
    opacity: 0.4;
    color: #999999 !important;
    cursor: not-allowed;
}

/* Блеклое отображение для элементов списка с disabled чекбоксами */
.category-filter .wc-block-product-filter-checkbox-list__item:has(input:disabled),
.category-filter .wc-block-product-filter-checkbox-list__item:has(input.filter-unavailable) {
    opacity: 0.4;
}

/* Блеклое отображение текста рядом с disabled чекбоксом */
.category-filter input[type="checkbox"]:disabled ~ label,
.category-filter input[type="checkbox"].filter-unavailable ~ label,
.category-filter input[type="checkbox"]:disabled ~ span,
.category-filter input[type="checkbox"].filter-unavailable ~ span {
    color: #999999 !important;
    cursor: not-allowed;
}

.checkbox-icon {
    width: 1.25rem;
    height: 1.25rem;
}

.checkbox-icon-unchecked {
    width: 1.25rem;
    height: 1.25rem;
    border: 0.03125rem solid #2B2B2A;
    border-radius: 0.4375rem;
    box-sizing: border-box;
}

.price-filter-container {
    position: relative;
    width: 18.31rem;
}

.price-slider {
    width: 100%;
    height: 1rem;
    margin: 2.25rem 0 0.625rem 0;
    position: relative;
}

/* noUiSlider стили */
.price-slider .noUi-base {
    width: 100%;
    height: 0.125rem;
    position: relative;
}

.price-slider .noUi-connects {
    border-radius: 0.1875rem;
}

.price-slider .noUi-connect {
    background: #2B2B2A;
    height: 0.125rem;
}

.price-slider .noUi-handle {
    width: 0.9375rem;
    height: 0.9375rem;
    border-radius: 50%;
    background: #ffffff;
    border: 0.0625rem solid #2B2B2A;
    cursor: pointer;
    box-shadow: none;
}

.price-slider .noUi-handle:before,
.price-slider .noUi-handle:after {
    display: none;
}

.price-slider .noUi-horizontal {
    height: 0.125rem;
}

.price-slider .noUi-horizontal .noUi-handle {
    width: 0.9375rem;
    height: 0.9375rem;
    top: -0.4375rem;
    right: -0.4375rem;
}

.price-inputs {
    display: flex;
    justify-content: space-between;
    margin-top: 0.625rem;
}

.price-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.price-input {
    width: 3.188rem;
    height: 2rem;
    border: 0.03125rem solid #2B2B2A;
    border-radius: 0.4375rem;
    text-align: center;
    font-size: 0.4375rem;
    color: #7F7F7F;
    box-sizing: border-box;
    padding-right: 0.75rem;
}

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

.price-input[type=number] {
    -moz-appearance: textfield;
}

.price-currency {
    position: absolute;
    right: 0.3125rem;
    font-size: 0.4375rem;
    color: #7F7F7F;
    pointer-events: none;
}

.price-reset {
    font-size: 0.75rem;
    text-decoration: underline;
    color: #2B2B2A;
    display: block;
    text-align: right;
    margin-top: 1.062rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

.product-list-container {
    width: 65rem;
    display: flex;
    flex-direction: column;
    gap: 2.375rem;
}

.product-list-header {
    display: flex;
    align-items: flex-end;
    gap: 0.9375rem;
}

.product-list-title {
    font-size: 2rem;
    margin: 0;
}

.product-list-count {
    font-size: 1rem;
    color: #7F7F7F;
    margin: 0;
    padding-bottom: 0.25rem;
}

.product-list {
    display: flex;
    flex-direction: column;
    gap: 2.25rem;
    align-items: center;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.062rem;
    width: 100%;
}

.load-more-button-container {
    padding: 0.625rem;
}

.load-more-button {
    font-size: 1rem;
    text-decoration: underline;
    color: #2B2B2A;
}

.filter-toggle-button {
    display: none; /* Hidden by default */
}

/* Clear filters button */
.clear-filters-button {
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: transparent;
    color: #2B2B2A;
    border: 0.03125rem solid #2B2B2A;
    border-radius: 0.4375rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 400;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: background 0.2s ease;
}

.clear-filters-button:hover {
    background: #f5f5f5;
}

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

/* Removed body.filter-open overflow hidden for dropdown style */


/* ================================
   RESPONSIVE - TABLET (61.94rem - 75rem)
   ================================ */
@media (min-width: 61.94rem) and (max-width: 75rem) {
    .main-content {
        flex-direction: column;
        gap: 1.875rem;
    }

    .sidebar {
        width: 100%;
        display: block;
    }

    .breadcrumbs {
        justify-content: center;
        margin-bottom: 1.875rem;
    }

    .category-filter {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1.25rem;
        padding: 1.562rem 1.25rem;
    }

    .filter-section {
        flex: 0 1 auto;
        min-width: 11.25rem;
    }

    .filter-section:first-child,
    .filter-section:nth-child(3) {
        flex: 0 1 calc(25% - 0.9375rem);
    }

    .filter-section:nth-child(2),
    .filter-section:nth-child(4) {
        flex: 0 1 calc(25% - 0.9375rem);
    }

    .product-list-container {
        width: 100%;
    }

    .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

/* ================================
   RESPONSIVE - MOBILE (up to 61.88rem)
   ================================ */
@media (max-width: 61.88rem) {
    .main-content {
        flex-direction: column;
        gap: 0;
    }

    .sidebar {
        width: 100%;
        order: 1;
        gap: 1rem;
        display: flex;
        flex-direction: column;
    }

    .breadcrumbs {
        justify-content: center;
        margin-bottom: 0;
        order: 1;
    }

    .filter-toggle-button {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 0.9375rem;
        background: #ffffff;
        color: #333333;
        border: 0.03125rem solid #2B2B2A;
        border-radius: 0.4375rem;
        font-family: 'Inter', sans-serif;
        font-weight: 400;
        font-size: 1rem;
        line-height: 1;
        cursor: pointer;
        order: 2;
        margin-bottom: 1rem;
    }

    .filter-toggle-button::before {
        content: '';
        font-size: 0.75rem;
        color: #333333;
        margin-right: 0.5rem;
    }

    .filter-toggle-button.is-active::before {
        content: 'закрыть';
    }

    .filter-toggle-button::after {
        content: '';
        width: 1.25rem;
        height: 0.875rem;
        background-image: url("data:image/svg+xml,%3Csvg width='20' height='14' viewBox='0 0 20 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cline x1='0' y1='2' x2='20' y2='2' stroke='%232B2B2A' stroke-width='1'/%3E%3Cline x1='0' y1='7' x2='20' y2='7' stroke='%232B2B2A' stroke-width='1'/%3E%3Cline x1='0' y1='12' x2='20' y2='12' stroke='%232B2B2A' stroke-width='1'/%3E%3C/svg%3E");
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
    }

    .product-list-container {
        width: 100%;
        order: 4;
    }

    /* Filter Dropdown Styles */
    .category-filter {
        position: static; /* Changed from fixed */
        width: 100%;
        background: #ffffff;
        overflow: hidden;
        padding: 0;
        max-height: 0; /* Hidden by default */
        opacity: 0;
        pointer-events: none; /* Disable clicks when closed */
        transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out, padding 0.3s ease-in-out;
        border-radius: 0.4375rem;
        border: 0.03125rem solid #2B2B2A;
        margin-bottom: 1rem;
        order: 3;
    }

    .category-filter.is-active {
        max-height: 100vh !important; /* Show filter - full viewport height */
        opacity: 1 !important;
        padding: 1.25rem !important;
        overflow-y: auto !important; /* Add scroll if content is too long */
        pointer-events: auto !important; /* Enable clicks when open */
        display: block !important; /* Force display */
    }

    /* Force WooCommerce overlay to stay visible when our filter is active */
    .category-filter.is-active .wc-block-product-filters__overlay,
    .category-filter.is-active .wc-block-product-filters__overlay-wrapper,
    .category-filter.is-active .wc-block-product-filters__overlay-dialog {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }

    .filter-close-button {
        display: none; /* Hide close button for dropdown */
    }

    /* Mobile sticky filter apply button */
    .mobile-filter-apply-button {
        display: block;
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 1rem 1.25rem;
        background: #2B2B2A;
        color: #ffffff;
        border: none;
        border-radius: 0.4375rem;
        font-family: 'Inter', sans-serif;
        font-size: 1rem;
        font-weight: 500;
        cursor: pointer;
        margin-top: 1.25rem;
        z-index: 10;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    }

    .mobile-filter-apply-button:active {
        background: #1a1a1a;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr); /* Two columns for mobile */
        gap: 1.5rem 1.062rem; /* row-gap column-gap from Figma */
    }

    /* Override WooCommerce filter overlay mode on small screens */
    .category-filter :where(.wc-block-product-filters) .wc-block-product-filters__overlay-dialog {
        position: static !important;
        transform: none !important;
        inset: auto !important;
        background-color: transparent !important;
        max-height: none !important;
    }

    .category-filter :where(.wc-block-product-filters) .wc-block-product-filters__overlay-content {
        background: inherit !important;
        color: inherit !important;
        overflow: visible !important;
        padding: 0 !important;
    }
}
