.favorites-page {
    min-height: 100vh;
    padding: 48px 0 131px;
}

.favorites-page .container {
    max-width: 1440px;
    margin: 0 auto;
}

.back-button {
    display: flex;
    align-items: center;
    gap: 4px;
    border: none;
    font-size: 14px;
    line-height: 18px;
    font-weight: 400;
    color: #81AD4F;
    cursor: pointer;
    transition: color 0.2s;
    letter-spacing: -.02em;
    width: 220px;
    margin-right: 24px;
    background: none;
    margin-bottom: 29px;
}

.back-button:hover {
    color: #6a8f3f;
}

.favorites__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 19px;
    flex-wrap: wrap;
    gap: 16px;
}

.favorites__title {
    font-size: 28px;
    line-height: 120%;
    font-weight: 500;
    color: #20221E;
    letter-spacing: -.02em;
    margin: 0;
}

.favorites__controls {
    display: flex;
    align-items: center;
    gap: 24px;
}

.favorites__count {
    color: #20221E7A;
    font-weight: 400;
    font-size: 14px;
    line-height: 18px;
    letter-spacing: -.03em;
}

.favorites__sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

.favorites__sort-label {
    font-size: 14px;
    line-height: 18px;
    color: #20221E7A;
    font-weight: 400;
}

/* Кастомный селект */
.custom-select {
    position: relative;
    width: 224px;
    user-select: none;
}

.custom-select__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #20221E0F;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    letter-spacing: -.02em;
    line-height: 20px;
    color: #20221E;
    transition: all 0.2s;
}

.custom-select__trigger:hover {
    background: #20221E1F;
}

.custom-select__selected {
    flex: 1;
}

.custom-select__arrow {
    transition: transform 0.2s;
}

.custom-select.open .custom-select__arrow {
    transform: rotate(180deg);
}

.custom-select__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s;
}

.custom-select.open .custom-select__dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select__option {
    padding: 8px 12px;
    font-size: 14px;
    line-height: 18px;
    color: #20221E;
    cursor: pointer;
    transition: background 0.2s;
}

.custom-select__option:hover {
    background: #20221E0F;
}

.custom-select__option.selected {
    background: #81AD4F;
    color: white;
}

.custom-select__option.selected:hover {
    background: #76A14D;
}

.favorites__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}

.favorite-card {
    position: relative;
    background: white;
    border: 1px solid #20221E1A;
    border-radius: 16px;
    overflow: hidden;
}

.favorite-card__link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.favorite-card__image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #F8F9FA;
}

.favorite-card__content {
    padding: 16px;
}

.favorite-card__title {
    font-size: 16px;
    font-weight: 600;
    color: #20221E;
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.favorite-card__brand {
    font-size: 14px;
    color: #20221E7A;
    margin: 0 0 8px 0;
}

.favorite-card__date {
    font-size: 12px;
    color: #20221E52;
}

.favorite-card__remove-form {
    position: absolute;
    top: 12px;
    right: 12px;
    margin: 0;
}

.favorite-card__remove-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #EF4444;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.favorite-card__remove-btn:hover {
    background: #DC2626;
}

.favorites__empty {
    gap: 32px;
    display: flex;
    text-align: center;
    padding: 40px;
    background: #81AD4F14;
    border-radius: 40px;
    flex-direction: column;
    align-items: center;
}

.favorites__empty img {
    width: 144px;
    height: 144px;
}

.favorites__empty-text {
    font-size: 20px;
    color: #20221E;
    font-weight: 500;
    line-height: 27.9px;
    letter-spacing: -.02em;
    max-width: 550px;
}

.favorites__empty-text span {
    font-size: 16px;
    color: #20221EB8;
    font-weight: 400;
    line-height: 120%;
    letter-spacing: -.02em;
}

.favorites__empty-link {
    display: inline-block;
    padding: 12px 16px;
    background: #81AD4F;
    color: white;
    text-decoration: none;
    border-radius: 128px;
    font-size: 16px;
    line-height: 20px;
    font-weight: 500;
    transition: background 0.2s;
}

.favorites__empty-link:hover {
    background: #76A14D;
}

/* Блок "Вам может понравиться" */
.recommended {
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid #20221E14;
}

.recommended__header {
    margin-bottom: 32px;
}

.recommended__title {
    font-size: 24px;
    font-weight: 500;
    color: #20221E;
    margin: 0;
    line-height: 1.2;
}

.recommended__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    justify-content: flex-start;
}

/* Стили для карточек товаров */
.product-card {
    background: white;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 220px;
    min-height: 360px;
    overflow: hidden;
}

.product-card__link {
    display: flex;
    flex-direction: column;
    flex: 1;
    text-decoration: none;
}

.product-card__favorite {
    position: absolute;
    top: 16px;
    right: 16px;
    background: white;
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    z-index: 2;
}

.product-card__image {
    width: 220px;
    height: 220px;
    object-fit: cover;
    margin-bottom: 16px;
    border-radius: 24px;
}

.product-card__title {
    font-size: 16px;
    font-weight: 500;
    color: #20221EB8;
    margin: 0 0 8px 0;
    line-height: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 40px;
}

.product-card__description {
    font-size: 14px;
    color: #20221E7A;
    margin: 0 0 14px 0;
    line-height: 18px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card__footer {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: auto;
}

.product-card__btn {
    background: #81AD4F1F;
    color: #81AD4F;
    padding: 9px 26px;
    border-radius: 128px;
    font-size: 14px;
    line-height: 18px;
    font-weight: 500;
    cursor: pointer;
    border: none;
}

/* ============================================ */
 /* АДАПТИВНАЯ ВЕРСИЯ (НЕ ЛОМАЕТ ДЕСКТОП) */
/* ============================================ */

/* Планшеты и небольшие ноутбуки (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .favorites-page .container {
        padding: 0 32px;
    }

    .favorites__grid {
        gap: 20px;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .recommended__grid {
        gap: 20px;
    }

    .product-card {
        width: 200px;
        min-height: 340px;
    }

    .product-card__image {
        width: 200px;
        height: 200px;
    }
}

/* Мобильные устройства (до 768px) */
@media (max-width: 768px) {
    .favorites-page {
        padding: 24px 0 60px;
    }

    .favorites-page .container {
        padding: 0 20px;
    }

    .back-button {
        width: auto;
        margin-bottom: 20px;
        font-size: 13px;
    }

    .favorites__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 20px;
    }

    .favorites__title {
        font-size: 24px;
    }

    .favorites__controls {
        width: 100%;
        justify-content: space-between;
        gap: 16px;
    }

    .favorites__count {
        font-size: 13px;
    }

    .custom-select {
        width: 180px;
    }

    .custom-select__trigger {
        padding: 10px 12px;
        font-size: 14px;
    }

    .favorites__grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 16px;
    }

    .product-card {
        width: 100%;
        min-width: 160px;
        min-height: 320px;
    }

    .product-card__image {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .product-card__title {
        font-size: 14px;
        min-height: 36px;
        line-height: 18px;
    }

    .product-card__description {
        font-size: 12px;
        line-height: 16px;
    }

    .product-card__btn {
        padding: 6px 16px;
        font-size: 12px;
    }

    .product-card__favorite {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
    }

    .product-card__favorite svg {
        width: 14px;
        height: 14px;
    }

    .recommended {
        margin-top: 48px;
        padding-top: 24px;
    }

    .recommended__title {
        font-size: 20px;
    }

    .recommended__grid {
        gap: 16px;
        justify-content: center;
    }

    .favorites__empty {
        padding: 30px 20px;
        gap: 24px;
    }

    .favorites__empty img {
        width: 100px;
        height: 100px;
    }

    .favorites__empty-text {
        font-size: 18px;
        line-height: 24px;
    }

    .favorites__empty-text span {
        font-size: 14px;
    }

    .favorites__empty-link {
        padding: 10px 14px;
        font-size: 14px;
    }
}

/* Маленькие мобильные устройства (до 576px) */
@media (max-width: 576px) {
    .favorites-page .container {
        padding: 0 16px;
    }

    .favorites__controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
    }

    .favorites__sort {
        width: 100%;
        justify-content: space-between;
    }

    .custom-select {
        width: 100%;
        max-width: 280px;
    }

    .favorites__grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    .product-card {
        min-width: 140px;
        min-height: 300px;
    }

    .product-card__title {
        font-size: 13px;
    }

    .product-card__btn {
        padding: 6px 12px;
    }

    .recommended__grid {
        gap: 12px;
    }
}

/* Очень маленькие устройства (до 480px) */
@media (max-width: 480px) {
    .favorites__title {
        font-size: 22px;
    }

    .favorites__count {
        font-size: 12px;
    }

    .favorites__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .product-card {
        min-width: auto;
    }

    .recommended__grid {
        gap: 12px;
    }
}

/* Экстремально маленькие устройства (до 375px) */
@media (max-width: 375px) {
    .favorites-page .container {
        padding: 0 12px;
    }

    .favorites__grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .product-card {
        max-width: 100%;
        width: 100%;
    }

    .product-card__image {
        max-width: 100%;
    }

    .custom-select {
        max-width: 100%;
    }

    .favorites__sort {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .recommended__grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .product-card {
        min-height: auto;
    }
}

/* Альбомная ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .favorites-page {
        padding: 20px 0 40px;
    }

    .favorites__grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .product-card {
        min-height: 300px;
    }
}

/* Ретина дисплеи */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-card__image {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Улучшения для touch устройств */
@media (hover: none) and (pointer: coarse) {
    .custom-select__trigger {
        min-height: 44px; /* Увеличиваем область касания */
    }

    .product-card__btn,
    .product-card__favorite,
    .back-button,
    .favorites__empty-link {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .product-card__favorite {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}