/*product header*/

.product__header {
    padding: calc(40 / 1440 * 100vw);

    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;

    box-sizing: border-box;
    border-bottom: 1px solid var(--clr-brown-light);
}

.product__title {
    margin: 0;
}

@media screen and (max-width: 768px) {
    
    .product__header {
        padding: 40px;
    }

}

@media screen and (max-width: 480px) {

    .product__header {
        padding: 40px 20px;
    }

}

/*product category*/

.product__category {
    padding: calc(40 / 1440 * 100vw);

    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 16px;

    box-sizing: border-box;
    border-bottom: 1px solid var(--clr-brown-light);
}

.product__category-title {
    margin: 0;
}

.category__list {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.category__item {
    max-width: max-content;

    padding: 16px 24px 14px;

    display: flex;
    justify-content: center;
    gap: 8px;

    transition: all 0.3s ease-in-out;

    color: var(--clr-brown);
    border: 1px solid var(--clr-brown);
    background-color: transparent;

    cursor: pointer;
    text-decoration: none;
}

.category__item.active {
    color: var(--clr-white);
    background-color: var(--clr-brown);
    border: 1px solid var(--clr-brown);
}

.category__item:hover {
    color: var(--clr-white);
    background-color: var(--clr-brown);
    border: 1px solid var(--clr-brown);
}

@media screen and (max-width: 768px) {
    
    .product__category {
        padding: 40px 0 40px 40px;
    }

    .category__list {
        align-self: stretch;
        flex-wrap: nowrap;
        overflow-x: auto;  /* изменено с scroll на auto */
        -webkit-overflow-scrolling: touch;  /* плавный скролл на iOS */
        scrollbar-width: thin;  /* тонкий скроллбар для Firefox */
        gap: 10px;
        padding-bottom: 10px;  /* место для скроллбара */
    }
    
    /* опционально: стилизация скроллбара для Webkit браузеров */
    .category__list::-webkit-scrollbar {
        height: 4px;
    }
    
    .category__list::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    
    .category__list::-webkit-scrollbar-thumb {
        background: var(--clr-black);
        border-radius: 4px;
    }
    
    .category__item {
        flex-shrink: 0;  /* предотвращает сжатие элементов */
    }

}

@media screen and (max-width: 480px) {

    .product__category {
        padding: 20px 0 40px 20px;
    }

}

/*filter*/

.product__filter {
    padding: calc(40 / 1440 * 100vw);

    display: flex;
    flex-direction: column;
    gap: 20px;

    box-sizing: border-box;
    /* border-bottom: 1px solid var(--clr-brown-light); */
}

.product__filter-header {
    display: none;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
}

.filter__list {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 28px;
}

.filter__item {
    width: 100%;

    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 12px;
}

.filter__item-title {
    margin: 0;
}

.filter__item-select {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    border: 0;
    clip: rect(0 0 0 0);
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select__trigger {
    width: 100%;
    min-height: 56px;
    padding: 16px;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;

    box-sizing: border-box;
    border: 1px solid var(--clr-brown-light);
    background: var(--clr-white);

    color: var(--clr-brown);
    text-align: left;

    cursor: pointer;
}

.custom-select__text {
    flex: 1;
}

.custom-select__arrow {
    width: 24px;
    height: 24px;
    position: relative;
    flex-shrink: 0;
}

.custom-select__arrow::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--clr-brown);
    transform: translate(-50%, -35%);
    transition: transform 0.2s ease;
}

.custom-select.is-open .custom-select__trigger {
    border: 1px solid var(--clr-brown);
}

.custom-select.is-open .custom-select__arrow::before {
    transform: translate(-50%, -60%) rotate(180deg);
}

.custom-select__list {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    z-index: 3;

    margin: 0;
    padding: 0;
    list-style: none;

    box-sizing: border-box;
    border: 1px solid var(--clr-brown);
    background-color: var(--clr-white);

    display: none;
}

.custom-select.is-open .custom-select__list {
    display: block;
}

.custom-select__option {
    min-height: 56px;
    padding: 0 16px;

    display: flex;
    align-items: center;

    border-top: 1px solid var(--clr-brown);
    color: var(--clr-brown);

    cursor: pointer;
    user-select: none;
}

.custom-select__option:first-child {
    border-top: 0;
}

.custom-select__option:hover,
.custom-select__option.is-selected {
    background-color: var(--clr-brown);
    color: var(--clr-white);
}

@media screen and (max-width: 1024px) {

    .product__filter {
        padding: 40px;
    }

    .filter__list {
        flex-direction: column;
        gap: 20px;
    }

}

@media screen and (max-width: 480px) {

    .product__filter {
        padding: 0 20px;
    }

    .product__filter-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        cursor: pointer;
    }

    .product__filter .filter__list {
        display: none;
        padding: 20px 0 40px;
    }

    .product__filter.is-open .filter__list {
        display: flex;
    }

    .product__filter-header .custom-select__arrow::before {
        transition: transform 0.2s ease;
    }

    .product__filter.is-open .product__filter-header .custom-select__arrow::before {
        transform: translate(-50%, -60%) rotate(180deg);
    }

}

/*catalog*/

.product__list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* gap: 1px;
    background-color: var(--clr-brown-light); */

    border-top: 1px solid var(--clr-border);
    border-left: 1px solid var(--clr-border);
    border-bottom: 1px solid var(--clr-border);
    position: relative;
    transition: opacity 0.2s ease;
}

.product__list.is-loading {
    opacity: 0.45;
    pointer-events: none;
}

.product__list-empty {
    grid-column: 1 / -1;
    margin: 0;
    padding: calc(40 / 1440 * 100vw);
}

.product__list > * {
    border-right: 1px solid var(--clr-border);
    border-bottom: 1px solid var(--clr-border);
}

/* Remove bottom border only from items in the last row (4 columns) */
.product__list > *:nth-last-child(-n + 4):nth-child(4n + 1),
.product__list > *:nth-last-child(-n + 3):nth-child(4n + 2),
.product__list > *:nth-last-child(-n + 2):nth-child(4n + 3),
.product__list > *:nth-last-child(-n + 1):nth-child(4n + 4) {
    border-bottom: none;
}

.product__list .product__item:nth-child(2n) {
    border-left: none;
}

@media screen and (max-width: 768px) {

    .product__list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    /* Restore borders that the 4-column last-row rules may have removed */
    .product__list > *:nth-last-child(-n + 4):nth-child(4n + 1),
    .product__list > *:nth-last-child(-n + 3):nth-child(4n + 2),
    .product__list > *:nth-last-child(-n + 2):nth-child(4n + 3),
    .product__list > *:nth-last-child(-n + 1):nth-child(4n + 4) {
        border-bottom: 1px solid var(--clr-border);
    }

    /* Remove bottom border only from items in the last row (2 columns) */
    .product__list > *:nth-last-child(-n + 2):nth-child(2n + 1),
    .product__list > *:nth-last-child(-n + 1):nth-child(2n) {
        border-bottom: none;
    }

}

/*pagoination*/

.product__pagination {
    padding: 20px 0px 40px;

    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 16px;

    box-sizing: border-box;
    border-bottom: 1px solid var(--clr-brown-light);
}

.product__pagination-title {
    margin: 0;
}

.product__pagination-list {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
}

.product__pagination-item {
    text-decoration: none;
    color: var(--clr-brown);
    background: transparent;
    cursor: pointer;
    font: inherit;
    padding: 0;
    appearance: none;

    width: calc(44 / 1440 * 100vw);
    height: calc(44 / 1440 * 100vw);

    display: flex;
    justify-content: center;
    align-items: center;

    box-sizing: border-box;
    border: 1px solid var(--clr-brown);
    transition: .3s ease-in-out;
}

.product__pagination-item.active {
    color: var(--clr-white);
    background-color: var(--clr-brown);
}

.product__pagination-item:hover {
    color: var(--clr-white);
    background-color: var(--clr-brown);
}

@media screen and (max-width: 768px) {
    
    .product__pagination-item {
        width: 44px;
        height: 44px;
    }

}