/*
 * Мотивация в корзине: прогресс-бар подарков и поп-ап «Рекомендований товар».
 * Разметка — resources/views/partials/header/cart_progress|cart_upsell*.blade.php,
 * логика — public/js/cart-motivation.js, App\Services\Cart\CartMotivation.
 */

/* ---------- корзина: прогресс-бар между товарами и «Сумма / Оформить» ---------- */

#popup-cart .cart-container.has-progress {
    display: flex;
    flex-direction: column;
}
#popup-cart .cart-container.has-progress > .title,
#popup-cart .cart-container.has-progress > .js-cart-progress,
#popup-cart .cart-container.has-progress > .js-popup-summary {
    flex: 0 0 auto;
}
#popup-cart .cart-container.has-progress .cart-item-list {
    flex: 1 1 auto;
    height: auto;
    min-height: 110px;
    margin-bottom: 16px;
}

.cart-progress {
    position: relative;
    margin: 0 0 16px;
    padding: 12px 12px 10px;
    border: 1px solid #e3e7d1;
    border-radius: 12px;
    background: #f7f8f1;
    color: #262626;
    font-family: Museo, sans-serif;
    text-align: center;
    -webkit-font-smoothing: antialiased;
}
.cart-progress.is-complete {
    border-color: #cdd8a3;
    background: #f1f5e2;
}

.cart-progress__head {
    margin-bottom: 8px;
}
.cart-progress__title {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    font-family: Museo700, sans-serif;
    font-size: 15px;
    line-height: 20px;
    color: #262626;
}
.cart-progress__badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-right: 6px;
    color: #8c9f3f;
}
.cart-progress__badge svg {
    width: 20px;
    height: 20px;
}
.cart-progress__badge.is-done {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #8c9f3f;
    color: #fff;
}
.cart-progress__badge.is-done svg {
    width: 11px;
    height: 11px;
}
.cart-progress__text {
    margin-top: 2px;
    font-family: Museo300, sans-serif;
    font-size: 13px;
    line-height: 18px;
    color: #555;
}
.cart-progress__text b {
    font-family: Museo700, sans-serif;
    font-weight: normal;
    color: #7f9233;
    white-space: nowrap;
}

.cart-progress__steps {
    position: relative;
    display: flex;
    align-items: flex-start;
}
/* Центр точки: сумма (18px) + отступ (2px) + половина точки (9px) = 29px, линия 4px. */
.cart-progress__track,
.cart-progress__fill {
    position: absolute;
    top: 27px;
    left: 0;
    height: 4px;
    border-radius: 2px;
}
.cart-progress__track {
    background: #e1e2d8;
}
.cart-progress__fill {
    background: #8c9f3f;
    -webkit-transition: width .45s ease;
    transition: width .45s ease;
}
.cart-progress__step {
    position: relative;
    z-index: 1;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.cart-progress__amount {
    box-sizing: border-box;
    height: 18px;
    margin-bottom: 2px;
    padding: 0 6px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-family: Museo700, sans-serif;
    font-size: 12px;
    line-height: 16px;
    color: #9a9a90;
    white-space: nowrap;
}
.cart-progress__step.is-reached .cart-progress__amount {
    color: #7f9233;
}
.cart-progress__step.is-next .cart-progress__amount {
    border-color: #8c9f3f;
    background: #fff;
    color: #7f9233;
}
.cart-progress__dot {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 2px solid #d2d3c8;
    border-radius: 50%;
    background: #fff;
    color: #fff;
    -webkit-transition: background-color .3s ease, border-color .3s ease;
    transition: background-color .3s ease, border-color .3s ease;
}
.cart-progress__dot svg {
    width: 10px;
    height: 10px;
}
.cart-progress__step.is-next .cart-progress__dot {
    border-color: #8c9f3f;
}
.cart-progress__step.is-reached .cart-progress__dot {
    border-color: #8c9f3f;
    background: #8c9f3f;
}
.cart-progress__label {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    margin-top: 4px;
    font-family: Museo300, sans-serif;
    font-size: 12px;
    line-height: 14px;
    color: #6b6b63;
}
.cart-progress__label > span {
    max-width: 100%;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cart-progress__label .cm-icon {
    width: 20px;
    height: 20px;
    color: #a4a59a;
}
.cart-progress__step.is-reached .cart-progress__label {
    color: #4d5721;
}
.cart-progress__step.is-reached .cm-icon,
.cart-progress__step.is-next .cm-icon {
    color: #8c9f3f;
}

/* «Оформить» ждёт ответа поп-апа */
#popup-cart .cart-container .btn-checkout.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}
#popup-cart .cart-container .btn-checkout.is-loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    -webkit-animation: cart-motivation-spin .7s linear infinite;
    animation: cart-motivation-spin .7s linear infinite;
}
@-webkit-keyframes cart-motivation-spin {
    to { -webkit-transform: rotate(360deg); }
}
@keyframes cart-motivation-spin {
    to { transform: rotate(360deg); }
}

/* ---------- поп-ап «Рекомендований товар» ---------- */

.cart-upsell {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.cart-upsell[hidden] {
    display: none !important;
}
.cart-upsell__backdrop {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(17, 17, 17, .55);
    opacity: 0;
    -webkit-transition: opacity .2s ease;
    transition: opacity .2s ease;
}
.cart-upsell.is-open .cart-upsell__backdrop {
    opacity: 1;
}
.cart-upsell__dialog {
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    padding: 26px 28px 24px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
    color: #1f1f1f;
    font-family: Museo, sans-serif;
    outline: none;
    opacity: 0;
    -webkit-transform: translateY(16px) scale(.98);
    transform: translateY(16px) scale(.98);
    -webkit-transition: opacity .22s ease, -webkit-transform .22s ease;
    transition: opacity .22s ease, transform .22s ease;
    -webkit-font-smoothing: antialiased;
}
.cart-upsell.is-open .cart-upsell__dialog {
    opacity: 1;
    -webkit-transform: none;
    transform: none;
}
.cart-upsell__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    padding: 7px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #8a8a83;
    cursor: pointer;
}
.cart-upsell__close svg {
    display: block;
    width: 22px;
    height: 22px;
}
.cart-upsell__close:hover,
.cart-upsell__close:focus {
    background: #f2f2ec;
    color: #1f1f1f;
    outline: none;
}
.cart-upsell__title {
    flex: 0 0 auto;
    margin: 4px 0 16px;
    padding: 0 40px;
    font-family: Museo700, sans-serif;
    font-size: 22px;
    line-height: 28px;
    text-align: center;
    color: #1f1f1f;
}
.cart-upsell__progress {
    flex: 0 0 auto;
}
.cart-upsell__list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0 -8px;
    padding: 0 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.cart-upsell__footer {
    flex: 0 0 auto;
    padding-top: 14px;
}

.cart-upsell__item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #ebeae3;
    border-radius: 12px;
    background: #fff;
    -webkit-transition: border-color .2s ease, background-color .2s ease;
    transition: border-color .2s ease, background-color .2s ease;
}
.cart-upsell__item:last-child {
    margin-bottom: 0;
}
.cart-upsell__item.is-added {
    border-color: #c8d498;
    background: #fafcf2;
}
.cart-upsell__img {
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    margin-right: 12px;
    overflow: hidden;
    border-radius: 10px;
    background: #f4f3ee;
}
.cart-upsell__img img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cart-upsell__info {
    flex: 1 1 auto;
    min-width: 0;
}
.cart-upsell__name {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 15px;
    line-height: 19px;
    color: #1f1f1f;
}
.cart-upsell__price {
    margin-top: 6px;
    white-space: nowrap;
}
.cart-upsell__price-now {
    font-family: Museo700, sans-serif;
    font-size: 16px;
    line-height: 20px;
    color: #1f1f1f;
}
.cart-upsell__price-old {
    margin-left: 6px;
    font-family: Museo300, sans-serif;
    font-size: 13px;
    color: #9b9b95;
}
.cart-upsell__action {
    flex: 0 0 auto;
    margin-left: 12px;
    -webkit-transition: opacity .15s ease;
    transition: opacity .15s ease;
}
.cart-upsell__item.is-busy .cart-upsell__action {
    opacity: .5;
    pointer-events: none;
}
.cart-upsell__add {
    display: inline-flex;
    align-items: center;
    height: 38px;
    padding: 0 14px 0 10px;
    border: 1.5px solid #8c9f3f;
    border-radius: 19px;
    background: #fff;
    color: #7f9233;
    font-family: Museo700, sans-serif;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    -webkit-transition: background-color .15s ease, color .15s ease;
    transition: background-color .15s ease, color .15s ease;
}
.cart-upsell__add svg {
    width: 16px;
    height: 16px;
    margin-right: 5px;
}
.cart-upsell__add:hover,
.cart-upsell__add:focus {
    background: #8c9f3f;
    color: #fff;
    outline: none;
}
.cart-upsell__add[hidden],
.cart-upsell__stepper[hidden] {
    display: none;
}
.cart-upsell__stepper {
    display: inline-flex;
    align-items: center;
    height: 38px;
    border-radius: 19px;
    background: #8c9f3f;
    color: #fff;
}
.cart-upsell__step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
}
.cart-upsell__step svg {
    width: 16px;
    height: 16px;
}
.cart-upsell__step:hover,
.cart-upsell__step:focus {
    background: rgba(255, 255, 255, .16);
    outline: none;
}
.cart-upsell__qty {
    min-width: 16px;
    font-family: Museo700, sans-serif;
    font-size: 15px;
    text-align: center;
}
.cart-upsell__checkout {
    display: block;
    height: 52px;
    border-radius: 10px;
    background: #8c9f3f;
    color: #fff;
    font-family: Museo700, sans-serif;
    font-size: 16px;
    line-height: 52px;
    text-align: center;
    text-decoration: none;
    -webkit-transition: background-color .15s ease;
    transition: background-color .15s ease;
}
.cart-upsell__checkout:hover,
.cart-upsell__checkout:focus {
    background: #91b306;
    color: #fff;
    text-decoration: none;
}

/* Сообщения об ошибках корзины ($.notify) — поверх поп-апа. */
html.cart-upsell-open .notifyjs-corner {
    z-index: 100002 !important;
}

/* Телефон: поп-ап — нижняя шторка */
@media (max-width: 600px) {
    .cart-progress {
        padding: 10px 8px 8px;
        border-radius: 10px;
    }
    .cart-progress__title {
        font-size: 14px;
        line-height: 18px;
    }
    .cart-progress__text {
        font-size: 12px;
        line-height: 16px;
    }
    .cart-progress__label {
        font-size: 11px;
    }

    .cart-upsell {
        align-items: flex-end;
        padding: 0;
    }
    .cart-upsell__dialog {
        max-width: none;
        max-height: 88vh;
        padding: 20px 16px 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        border-radius: 18px 18px 0 0;
        -webkit-transform: translateY(100%);
        transform: translateY(100%);
    }
    .cart-upsell.is-open .cart-upsell__dialog {
        -webkit-transform: none;
        transform: none;
    }
    .cart-upsell__close {
        top: 10px;
        right: 8px;
    }
    .cart-upsell__title {
        margin-bottom: 14px;
        padding: 0 36px;
        font-size: 19px;
        line-height: 24px;
    }
    .cart-upsell__img {
        flex-basis: 60px;
        width: 60px;
        height: 60px;
        margin-right: 10px;
    }
    .cart-upsell__name {
        font-size: 14px;
        line-height: 18px;
    }
    .cart-upsell__action {
        margin-left: 8px;
    }
    .cart-upsell__add {
        padding: 0 12px 0 9px;
    }
}
