/* =========================================================
   БАЗА
========================================================= */

.cart-drawer {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: stretch;
    justify-content: flex-end;
    font-family: Body, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.cart-drawer.is-open {
    display: flex;
}

.cart-drawer__overlay {
    flex: 1;
    background: #00000099;
}

.cart-drawer__panel {
    width: 460px;
    max-width: 100%;
    height: 100vh;
    background: #FFFFFF;
    box-sizing: border-box;
    padding: 32px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

/* =========================================================
   ХЕДЕР
========================================================= */

.cart-drawer__header {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 48px;
    padding-bottom: 12px;
    box-sizing: border-box;
}

.cart-drawer__title {
    font-size: 24px;
    font-weight: 400;
    text-transform: uppercase;
    font-family: Hint, sans-serif;
    margin: 0;
    line-height: 100%;
    color: #000;
}

.cart-drawer__title-count {
    font-family: Body, sans-serif;
    font-weight: 400;
    font-size: 20px;
}

.cart-drawer__title-count.is-hidden {
    display: none;
}

.cart-drawer__close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-drawer__close-icon {
    width: 18px;
    height: 18px;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}

/* =========================================================
   ДЕЛИТЕЛИ
========================================================= */

.cart-drawer__divider {
    width: 100%;
    border-top: 1px solid #CDCDCD;
}

.cart-drawer__divider--top {
    margin-bottom: 16px;
}

/* между разделителем и футером отступ будет задаваться футером */
.cart-drawer__divider--bottom {
    margin-top: 0;
}

/* =========================================================
   ТЕЛО
========================================================= */

.cart-drawer__body-wrapper {
    flex: 1 1 auto;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    overflow: hidden;
}

.cart-drawer__body {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
    box-sizing: border-box;
}

/* Список товаров */
.cart-drawer__items {
    margin: 0;
    padding: 0;
}

.cart-drawer__item {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.cart-drawer__item:last-child {
    border-bottom: none;
}

.cart-item__image {
    width: 80px;
    height: 80px;
}

.cart-item__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Контент товара */

.cart-item__content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-item__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.cart-item__name {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    color: #000000;
    text-decoration: none;
    flex: 1;
    font-family: Body, sans-serif;
    margin: 0;
}

.cart-item__name a {
    color: #000000;
    text-decoration: none;
    font-family: Body, sans-serif;
}

.cart-item__price {
    font-size: 14px;
    font-weight: 400;
    white-space: nowrap;
    color: #000000;
    font-family: Body, sans-serif;
    margin: 0;
}

.cart-item__meta {
    font-size: 12px;
    color: #666;
    font-family: Body, sans-serif;
    margin: 0;
    text-transform: capitalize;
}

.cart-item__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* =========================================================
   СЧЁТЧИК КОЛИЧЕСТВА
========================================================= */

.cart-item__quantity {
    display: flex;
    align-items: center;
    width: 108px;
    height: 36px;
    border: 1px solid #CDCDCD;
}

.cart-item__quantity-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
    transition: all 0.2s ease;
    font-family: Body, sans-serif;
}

.cart-item__quantity-btn:first-child {
    border-right: 1px solid #CDCDCD;
}

.cart-item__quantity-btn:last-child {
    border-left: 1px solid #CDCDCD;
}

.cart-item__quantity-btn:hover:not(.disabled) {
    background: #333333;
    color: #ffffff;
}

.cart-item__quantity-input {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-family: Body, sans-serif;
    margin: 0;
    text-align: center;
    padding: 0;
    -moz-appearance: textfield;
    appearance: textfield;
}

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

.cart-item__quantity-input:focus {
    outline: none;
    background: #f5f5f5;
}

/* Удаление */

.cart-item__remove {
    font-size: 16px;
    font-weight: 400;
    text-transform: uppercase;
    color: #000000;
    text-decoration: none;
    border: 1px solid #cdcdcd;
    padding: 0 12px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    width: 115px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Body, sans-serif;
    line-height: 100%;
    box-sizing: border-box;
}

.cart-item__remove:hover {
    background: #000000;
    color: #ffffff;
}

/* =========================================================
   ПУСТАЯ КОРЗИНА
========================================================= */

.cart-drawer__empty {
    padding: 24px 0;
    text-align: left;
}

.cart-drawer__empty-title {
    font-family: Hint, sans-serif;
    font-weight: 700;
    font-style: normal;
    font-size: 16px;
    line-height: 100%;
    letter-spacing: 0;
    text-transform: uppercase;
    margin-bottom: 8px;
    color: #000;
}

.cart-drawer__empty-text {
    font-family: Body, sans-serif;
    font-weight: 400;
    font-style: normal;
    font-size: 16px;
    line-height: 140%;
    letter-spacing: 0;
}

/* =========================================================
   ФУТЕР
========================================================= */

.cart-drawer__footer {
    width: 100%;
    max-width: 420px;
    margin: 40px auto 0;
    /* отступ 40px от разделителя сверху */
    padding-top: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Баннер бесплатной доставки */
.cart-drawer__promo {
    display: flex;
    align-items: center;
    width: 420px;
    height: 36px;
    gap: 10px;
    padding: 4px;
    background: #7FFF00;
    font-family: Body, sans-serif;
    font-weight: 400;
    font-style: normal;
    font-size: 14px;
    line-height: 100%;
    letter-spacing: 0;
    box-sizing: border-box;
}

.cart-drawer__promo-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    background-image: url('../img/alert-circle.svg');
    /* иконка слева */
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}

.cart-drawer__promo-text {
    flex: 1;
}

/* Итого + долями в строку */
.cart-drawer__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 420px;
    height: 24px;
    gap: 10px;
    box-sizing: border-box;
}

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

.cart-drawer__total-label {
    font-family: Hint, sans-serif;
    font-weight: 700;
    font-style: normal;
    font-size: 16px;
    line-height: 100%;
    letter-spacing: 0;
    text-transform: uppercase;
    margin: 0;
}

.cart-drawer__subtotal-value {
    font-size: 16px;
    font-weight: 700;
    font-family: Hint, sans-serif;
    line-height: 100%;
    text-transform: uppercase;
    margin: 0;
}

/* Кнопка "Оплата долями" + правый блок */
.cart-drawer__summary-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 273px;
    gap: 10px;
}

.cart-drawer__dolyame-btn {
    width: 222px;
    height: 29px;
    border: 1px solid #cdcdcd;
    background: transparent;
    padding: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 14px;
    font-family: Body, sans-serif;
    font-weight: 400;
    font-style: normal;
    line-height: 100%;
    letter-spacing: 0;
    box-sizing: border-box;
}

.cart-drawer__dolyame-label {
    opacity: 0.8;
}

.cart-drawer__installment-amount {
    font-weight: 500;
    color: #303030;

}

/* Нижние кнопки */
.cart-drawer__buttons {
    display: flex;
    width: 420px;
    height: 48px;
    gap: 10px;
    box-sizing: border-box;
}

/* Общий стиль кнопок */
.cart-drawer__btn {
    height: 48px;
    border: 1px solid #cdcdcd;
    font-size: 16px;
    text-transform: uppercase;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    color: #000000;
    padding: 16px 32px;
    font-family: Body, sans-serif;
    line-height: 100%;
    box-sizing: border-box;
}

.cart-drawer__btn--primary {
    background: #000000;
    color: #FFFFFF;
}

.cart-drawer__btn:hover {
    background: #333333;
    color: #FFFFFF;
    border-color: #333333;
}

/* Левая кнопка "Продовжить охоту" */
.cart-drawer__buttons .cart-drawer__continue {
    width: 231px;
    flex: 0 0 231px;
}

/* Правая кнопка "Купить" */
.cart-drawer__buttons .cart-drawer__btn--primary {
    width: 179px;
    flex: 0 0 179px;
}

/* Кнопка "В каталог" (пустая корзина) */
.cart-drawer__btn--catalog {
    align-self: stretch;
    width: 420px;
    max-width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Логика пустой/непустой корзины по data-empty */
.cart-drawer__footer[data-empty="1"] .cart-drawer__promo,
.cart-drawer__footer[data-empty="1"] .cart-drawer__summary,
.cart-drawer__footer[data-empty="1"] .cart-drawer__buttons {
    display: none;
}

.cart-drawer__footer[data-empty="0"] .cart-drawer__btn--catalog {
    display: none;
}

/* =========================================================
   СОСТОЯНИЯ
========================================================= */

body.cart-drawer-open {
    overflow: hidden;
}

.cart-item__quantity-btn.loading,
.cart-item__quantity-input.loading {
    opacity: 0.6;
    pointer-events: none;
}

.cart-drawer__item.removing {
    opacity: 0.6;
    pointer-events: none;
}

.cart-item__quantity-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.cart-item__quantity-btn.disabled:hover {
    background: transparent;
    color: inherit;
}

/* =========================================================
   МОБИЛЬНАЯ ВЕРСИЯ
========================================================= */

@media (max-width: 768px) {
    .cart-drawer {
        align-items: flex-end;
        justify-content: center;
    }

    .cart-drawer__overlay {
        display: block;
        background: #00000099;
    }

    .cart-drawer__panel {
        width: 100%;
        height: 85vh;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.25);
        padding: 20px 16px;
    }

    .cart-drawer__header,
    .cart-drawer__body-wrapper,
    .cart-drawer__footer {
        max-width: 100%;
        width: 100%;
    }

    .cart-drawer__body {
        padding-right: 0;
    }

    .cart-drawer__item {
        grid-template-columns: 60px 1fr;
        gap: 10px;
    }

    .cart-item__image {
        width: 60px;
        height: 60px;
    }

    .cart-drawer__promo,
    .cart-drawer__summary,
    .cart-drawer__buttons {
        width: 100%;
    }

    .cart-drawer__promo {
        font-size: 12px;
    }

    .cart-drawer__buttons .cart-drawer__continue,
    .cart-drawer__buttons .cart-drawer__btn--primary {
        flex: 1 1 auto;
        width: auto;
    }

    .cart-drawer__btn {
        height: 40px;
        font-size: 14px;
        padding: 0 20px;
    }

    .cart-drawer__promo {
        font-size: 12px;
    }

    .cart-item__quantity {
        width: 100px;
    }

    .cart-item__quantity-btn {
        width: 32px;
        height: 32px;
    }

    .cart-item__quantity-input {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }

    .cart-item__remove {
        width: 100px;
        font-size: 14px;
        height: 32px;
    }

    .cart-drawer__btn--catalog {
        width: 100%;
    }
}