/* ПОП-АП КОРЗИНЫ (rf) — общий элемент. Пока открывается только с GET-параметром test.
   Контент грузится с route=common/rfcart, изменение количества — cart.update (cart_id),
   удаление — cart.remove. Штатный alert «добавлен в корзину» глушится в footer.tpl.
   После приёмки: убрать проверку gated в JS footer.tpl и вернуть data-toggle
   в cart.tpl (или оставить отключённым, если дропдаун больше не нужен). */

.rf-cart-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
}

.rf-cart-modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.rf-cart-modal__overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 30, 18, .55);
    backdrop-filter: blur(2px);
    animation: rf-cart-fade .2s ease;
}

@keyframes rf-cart-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes rf-cart-rise {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.rf-cart-modal__dialog {
    position: relative;
    width: 580px;
    max-width: 100%;
    max-height: min(90vh, 760px);
    margin: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px; /* --rf-radius */
    box-shadow: 0 4px 8px rgba(15, 30, 18, .06), 0 12px 30px rgba(15, 30, 18, .08);
    animation: rf-cart-rise .25s ease;
    overflow: hidden;
}

.rf-cart-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #e3e8e3; /* --rf-border */
}

.rf-cart-modal__title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: #1a1f1a; /* --rf-text */
}

.rf-cart-modal__count {
    font-size: 14px;
    font-weight: 600;
    color: #5a655a; /* --rf-text-muted */
}

.rf-cart-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: none;
    border: none;
    border-radius: 10px;
    color: #5a655a; /* --rf-text-muted */
    cursor: pointer;
    transition: background .15s, color .15s;
}

.rf-cart-modal__close:hover {
    background: #f1f3f1; /* --rf-neutral-100 */
    color: #1a1f1a;
}

.rf-cart-modal__close svg {
    width: 18px;
    height: 18px;
}

.rf-cart-modal__body {
    overflow-y: auto;
    padding: 6px 20px 20px;
}

.rf-cart-modal__body.is-loading {
    opacity: .5;
}

/* ===== Строки корзины: одна линия (имя | − N + | цены | удалить), фото не используем ===== */
.rf-cart__list {
    padding-top: 8px;
}

.rf-cart__item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #e3e8e3; /* --rf-border */
    transition: opacity .2s;
}

.rf-cart__item:last-child {
    border-bottom: none;
}

.rf-cart__item.is-busy {
    opacity: .45;
}

.rf-cart__item.is-removing {
    opacity: .2;
}

.rf-cart__name-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

.rf-cart__name {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    color: #1a1f1a; /* --rf-text */
    text-decoration: none;
}

.rf-cart__name:hover {
    color: #2d6a3e; /* --rf-accent */
    text-decoration: underline;
}

.rf-cart__options {
    font-size: 12px;
    color: #9aa49a; /* --rf-neutral-400 */
    margin-top: 2px;
}

.rf-cart__options span {
    margin-right: 8px;
}

.rf-cart__unit {
    font-size: 12px;
    color: #5a655a; /* --rf-text-muted */
    white-space: nowrap;
}

.rf-cart__prices {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 110px;
}

.rf-cart__sum {
    font-size: 15px;
    font-weight: 800;
    color: #1a1f1a; /* --rf-text */
    white-space: nowrap;
}

.rf-cart__remove {
    flex: 0 0 auto;
}

.rf-cart__qty {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    border: 1px solid #e3e8e3; /* --rf-border */
    border-radius: 999px;
    overflow: hidden;
}

.rf-cart__qty-btn {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: none;
    font-size: 16px;
    line-height: 1;
    color: #1a1f1a; /* --rf-text */
    cursor: pointer;
    transition: background .15s;
}

.rf-cart__qty-btn:hover {
    background: #e8f3ec; /* --rf-accent-soft */
}

.rf-cart__qty-num {
    min-width: 28px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
}

.rf-cart__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: none;
    border-radius: 8px;
    color: #9aa49a; /* --rf-neutral-400 */
    cursor: pointer;
    transition: color .15s, background .15s;
}

.rf-cart__remove:hover {
    background: #fdecea; /* --rf-danger-soft */
    color: #c8342a; /* --rf-danger */
}

.rf-cart__remove svg {
    width: 15px;
    height: 15px;
}

/* ===== Итоги и кнопки ===== */
.rf-cart__totals {
    border-top: 2px solid #e3e8e3; /* --rf-border */
    padding-top: 12px;
    margin-top: 6px;
}

.rf-cart__total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    color: #5a655a; /* --rf-text-muted */
    padding: 4px 0;
}

.rf-cart__total b {
    font-weight: 700;
    color: #1a1f1a; /* --rf-text */
}

.rf-cart__total--grand {
    font-size: 17px;
    color: #1a1f1a;
    padding-top: 8px;
}

.rf-cart__total--grand b {
    font-weight: 800;
    color: #2d6a3e; /* --rf-accent */
}

.rf-cart__actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.rf-cart__btn {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 16px;
    border-radius: 10px; /* --rf-radius-sm */
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background .15s, color .15s, border-color .15s;
}

.rf-cart__btn--primary {
    background: #2d6a3e; /* --rf-accent */
    color: #fff;
}

.rf-cart__btn--primary:hover,
.rf-cart__btn--primary:focus {
    background: #1f4a2c; /* --rf-accent-dark */
    color: #fff;
}

.rf-cart__btn--ghost {
    background: #fff;
    border: 1px solid #c8d0c8; /* --rf-neutral-300 */
    color: #1a1f1a; /* --rf-text */
}

.rf-cart__btn--ghost:hover,
.rf-cart__btn--ghost:focus {
    border-color: #2d6a3e; /* --rf-accent */
    color: #1f4a2c; /* --rf-accent-dark */
}

/* ===== Пустая корзина ===== */
.rf-cart__empty {
    padding: 36px 12px 28px;
    text-align: center;
    color: #5a655a; /* --rf-text-muted */
}

.rf-cart__empty svg {
    width: 52px;
    height: 52px;
    color: #c8d0c8; /* --rf-neutral-300 */
    margin-bottom: 12px;
}

.rf-cart__empty-title {
    font-size: 17px;
    font-weight: 800;
    color: #1a1f1a; /* --rf-text */
    margin-bottom: 4px;
}

.rf-cart__empty p {
    font-size: 14px;
    margin: 0 0 18px;
}

.rf-cart__empty .rf-cart__btn {
    flex: none;
    min-width: 220px;
}

/* ===== Мобайл: bottom sheet, строка товара в 2 линии ===== */
@media (max-width: 767px) {
    .rf-cart-modal.open {
        align-items: flex-end;
        padding: 0;
    }

    .rf-cart-modal__dialog {
        width: 100%;
        max-width: none;
        margin: 0;
        max-height: 88vh;
        border-radius: 14px 14px 0 0;
    }

    .rf-cart__item {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 10px 12px;
        padding: 12px 0;
    }

    /* линия 1: имя | цены; линия 2: степпер | удалить */
    .rf-cart__name-wrap {
        grid-column: 1;
        grid-row: 1;
    }

    .rf-cart__prices {
        grid-column: 2;
        grid-row: 1;
    }

    .rf-cart__qty {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
    }

    .rf-cart__remove {
        grid-column: 2;
        grid-row: 2;
        justify-self: end;
        align-self: center;
    }

    .rf-cart-modal__head {
        padding: 16px 16px 12px;
    }

    .rf-cart-modal__body {
        padding: 4px 16px 16px;
    }

    .rf-cart__actions {
        flex-direction: column-reverse;
    }

    .rf-cart__btn {
        width: 100%;
    }
}

/* ===== Плавность поп-апа: открытие с готовым контентом, анимации входа/выхода ===== */
.rf-cart-modal__body {
    transition: height .25s ease, opacity .2s ease;
}

/* Выход: оверлей гаснет, диалог уезжает (мобайл — вниз, ПК — лёгкий sink) */
.rf-cart-modal.closing .rf-cart-modal__overlay {
    animation: rf-cart-fade-out .2s ease forwards;
}

.rf-cart-modal.closing .rf-cart-modal__dialog {
    animation: rf-cart-sink .25s ease forwards;
}

@keyframes rf-cart-sink {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(10px) scale(.98); }
}

@keyframes rf-cart-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes rf-cart-sheet-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes rf-cart-sheet-down {
    from { transform: translateY(0); }
    to { transform: translateY(100%); }
}

/* Мобайл: выезд снизу как bottom-sheet (вход и выход) */
@media (max-width: 767px) {
    .rf-cart-modal__dialog {
        animation: rf-cart-sheet-up .3s cubic-bezier(.22, .61, .36, 1);
    }

    .rf-cart-modal.closing .rf-cart-modal__dialog {
        animation: rf-cart-sheet-down .25s ease forwards;
    }
}
