/* Cart / add-to-cart UX: «форма думает» — индикаторы загрузки и блокировка
   кнопок на время дебаунса и запроса к серверу. */

@keyframes cart-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Сводка корзины («Ваш заказ») в состоянии пересчёта --- */
.stats { position: relative; }

/* Вуаль на весь блок: затеняет содержимое и перехватывает клики */
.stats.is-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(245, 247, 253, 0.6);
    border-radius: 20px;
    z-index: 2;
}

/* Спиннер — по центру блока. Центрируем через margin (не transform!),
   чтобы transform остался свободен под анимацию вращения. */
.cart-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    box-sizing: border-box;
    border: 4px solid #D9DCEC;
    border-top-color: #2B6AB6;
    border-radius: 50%;
    animation: cart-spin 0.6s linear infinite;
    z-index: 3;
}

.stats.is-loading .cart-spinner { display: block; }

.stats.is-loading .btn-blue { pointer-events: none; }

/* --- Кнопка «Добавить в корзину» (карточка товара) во время отправки --- */
.btn.is-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn.is-loading > * { visibility: hidden; }

.btn.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    box-sizing: border-box;
    border: 3px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cart-spin 0.6s linear infinite;
}

/* ============================================================
   Редизайн корзины V1 (design_handoff_cart_redesign)
   Все правила scoped под .cart--v1, чтобы не задеть другие страницы.
   Файл подключён в base.html ПОСЛЕ main.css — переопределения выигрывают.
   ============================================================ */

/* --- Шапка корзины --- */
.cart--v1 .cart-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 4px 18px;
    margin: 0;
    border: none;
}
.cart--v1 .cart-header__selectall {
    display: flex;
    align-items: center;
    gap: 10px;
}
.cart--v1 .cart-header__selectall label {
    font-size: 14px;
    font-weight: 500;
    color: #0e1230;
    cursor: pointer;
    margin: 0;
}
.cart--v1 .cart-header__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    color: #4d5469;
    font-size: 13px;
}
.cart--v1 .cart-header__dot { color: #c2c8de; }
.cart--v1 .cart-header__clear {
    margin-left: auto;
    background: none;
    border: none;
    color: #4d5469;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color .15s;
    padding: 0;
}
.cart--v1 .cart-header__clear svg { width: 16px; height: 16px; }
.cart--v1 .cart-header__clear:hover { color: #ff153f; }

/* --- Карточка товара --- */
.cart--v1 .cart-item {
    display: grid;
    grid-template-columns: auto 156px minmax(0, 1fr) 196px;
    gap: 22px;
    align-items: center;
    background: #fff;
    border: 1.5px solid #d7ddf2;
    border-radius: 16px;
    padding: 12px 24px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(20, 24, 60, .04);
    transition: box-shadow .28s ease, border-color .28s ease, transform .28s ease;
}
.cart--v1 .cart-item:hover {
    box-shadow: 0 10px 24px -16px rgba(43, 44, 124, .3);
    border-color: #2b2c7c;
    transform: translateY(-1px);
}
.cart--v1 .cart-item__checkbox { margin: 0; }

.cart--v1 .cart-item__img {
    width: 156px;
    height: 156px;
    border-radius: 12px;
    overflow: hidden;
    background: #f5f7fd;
    flex-shrink: 0;
}
.cart--v1 .cart-item__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cart--v1 .cart-item__content { min-width: 0; }
.cart--v1 .cart-item__status {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 8px;
}
.cart--v1 .cart-item__status--in { background: #e6f4ed; color: #1f8a5b; }
.cart--v1 .cart-item__status--out { background: #fdeecf; color: #9a6b08; }
.cart--v1 .cart-item__content p { margin: 0; }
.cart--v1 .cart-item__content p a {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
    color: #0e1230;
    text-decoration: none;
    display: inline-block;
    max-width: 34ch;
    transition: color .15s;
}
.cart--v1 .cart-item__content p a:hover { color: #2b2c7c; }
.cart--v1 .cart-item__articul {
    font-size: 12px;
    color: #4d5469;
    margin-top: 8px;
}
.cart--v1 .cart-item__nav {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}
.cart--v1 .cart-item__button {
    width: 38px;
    height: 38px;
    border: 1px solid #e6e9f5;
    border-radius: 10px;
    background: #fff;
    color: #4d5469;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all .15s;
}
.cart--v1 .cart-item__button svg { width: 18px; height: 18px; }
/* main.css задаёт глобально svg path{fill:#1a1a2e} — гасим заливку,
   иконки должны быть только контурными (stroke=currentColor). */
.cart--v1 .cart-item__button svg,
.cart--v1 .cart-item__button svg path { fill: none; }
.cart--v1 .cart-item__button:hover {
    background: #f5f7fd;
    border-color: #dde4fb;
    color: #2b2c7c;
}
.cart--v1 .cart-item__button--danger:hover {
    color: #ff153f;
    border-color: #f6c6cf;
    background: #fff5f6;
}

/* --- Правая колонка карточки: цена + степпер --- */
.cart--v1 .cart-item__info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 18px;
}
.cart--v1 .cart-item__info .card__price { text-align: right; }
.cart--v1 .cart-item__info .card__price-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.cart--v1 .card__price-old {
    font-size: 14px;
    color: #4d5469;
    text-decoration: line-through;
}
.cart--v1 .card__price-sale {
    background: #ff153f;
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    border-radius: 6px;
    padding: 2px 6px;
    line-height: 1.4;
}
.cart--v1 .card__price-new {
    font-size: 24px;
    font-weight: 800;
    color: #0e1230;
    font-family: 'Nunito Sans', sans-serif;
}
.cart--v1 .cart-item__unit {
    font-size: 12px;
    color: #4d5469;
    margin-top: 4px;
    text-align: right;
}

.cart--v1 .cart-item__info .quantity {
    display: flex;
    align-items: center;
    border: 1px solid #e6e9f5;
    border-radius: 12px;
    height: 46px;
    overflow: hidden;
    width: fit-content;
    background: #fff;
}
.cart--v1 .quantity-row {
    display: flex;
    align-items: center;
}
.cart--v1 .quantity-arrow {
    width: 34px;
    height: 34px;
    margin: 0 6px;
    border: none;
    background: none;
    color: #2b2c7c;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 9px;
    padding: 0;
    transition: background .15s;
}
.cart--v1 .quantity-arrow svg { width: 18px; height: 18px; }
.cart--v1 .quantity-arrow:hover { background: #f5f7fd; }
.cart--v1 .quantity-input {
    width: 44px;
    border: none;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    font-family: 'Nunito Sans', sans-serif;
    color: #0e1230;
    background: none;
    outline: none;
    padding: 0;
}

/* --- Блок «Ваш заказ» --- */
.cart--v1 .stats {
    background: #f5f7fd;
    border-radius: 20px;
    padding: 32px 30px;
}
.cart--v1 .stats-header { margin-bottom: 22px; }
.cart--v1 .stats-header__head {
    font-size: 22px;
    font-weight: 800;
    font-family: 'Nunito Sans', sans-serif;
    color: #0e1230;
}
.cart--v1 .stats-header__labels {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #4d5469;
    margin-top: 6px;
}
.cart--v1 .stats-header__dot { color: #c2c8de; }

/* Прогресс-бар до бесплатной доставки */
.cart--v1 .ship-progress {
    background: #fff;
    border: 1.5px solid #ebeffc;
    border-radius: 14px;
    padding: 15px 16px;
    margin-bottom: 22px;
}
.cart--v1 .ship-progress__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.cart--v1 .ship-progress__label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #4d5469;
}
.cart--v1 .ship-progress__label svg { width: 17px; height: 17px; color: #2b2c7c; }
.cart--v1 .ship-progress__amount {
    font-size: 13px;
    font-weight: 700;
    color: #2b2c7c;
    font-family: 'Nunito Sans', sans-serif;
    white-space: nowrap;
}
.cart--v1 .ship-progress__bar {
    height: 8px;
    border-radius: 8px;
    background: #ebeffc;
    overflow: hidden;
}
.cart--v1 .ship-progress__bar span {
    display: block;
    height: 100%;
    background: #2b2c7c;
    border-radius: 8px;
    transition: width .4s;
}
.cart--v1 .ship-progress.is-reached .ship-progress__label svg,
.cart--v1 .ship-progress.is-reached .ship-progress__amount { color: #2b2c7c; }
.cart--v1 .ship-progress.is-reached .ship-progress__bar span { background: #2b2c7c; }

/* Строки сумм */
.cart--v1 .stats-body {
    display: flex;
    flex-direction: column;
    gap: 13px;
    margin-bottom: 20px;
}
.cart--v1 .stats-body__row {
    /* main.css задаёт для .stats-body__row column-раскладку + margin/padding-bottom 24px
       и нижнюю границу (для блоков ЛК) — гасим, тут строки горизонтальные, отступ держит gap. */
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #4d5469;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: none;
}
.cart--v1 .stats-body__text { color: #4d5469; }
.cart--v1 .stats-body__value {
    font-weight: 700;
    color: #0e1230;
    font-family: 'Nunito Sans', sans-serif;
    white-space: nowrap;
}
.cart--v1 .stats-body__value.red { color: #ff153f; }
.cart--v1 .stats-body__value--muted {
    color: #9aa0b4;
    font-weight: 400;
    font-size: 13px;
}

/* Промокод (визуальная заглушка) */
.cart--v1 .promo {
    display: flex;
    gap: 9px;
    margin-bottom: 13px;
}
.cart--v1 .promo__input {
    flex: 1;
    min-width: 0;
    border: 1px solid #e6e9f5;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: 'Onest', sans-serif;
    outline: none;
    background: #fff;
    transition: border-color .15s;
}
.cart--v1 .promo__input:focus { border-color: #2b2c7c; }
.cart--v1 .promo__btn {
    background: #ebeffc;
    color: #2b2c7c;
    border: none;
    border-radius: 12px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Onest', sans-serif;
    transition: background .15s;
}
.cart--v1 .promo__btn:hover { background: #dde4fb; }
.cart--v1 .promo__state {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 13px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 13px;
}
.cart--v1 .promo__state[hidden] { display: none; }
.cart--v1 .promo__state svg { width: 16px; height: 16px; flex-shrink: 0; }
.cart--v1 .promo__state--ok { background: #e6f4ed; color: #1f8a5b; }
.cart--v1 .promo__state--err { background: #fdebed; color: #d61f3f; }

/* Итого + кнопка */
.cart--v1 .stats-footer {
    border-top: 1px solid #e6e9f5;
    padding-top: 24px;
    margin-top: 4px;
}
.cart--v1 .stats-footer__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 20px;
}
.cart--v1 .stats-footer__text {
    font-size: 22px;
    font-weight: 800;
    font-family: 'Nunito Sans', sans-serif;
    color: #0e1230;
}
.cart--v1 #fullprice-total { font-size: 26px; white-space: nowrap; }
.cart--v1 .cart-checkout {
    width: 100%;
    border-radius: 14px;
    padding: 18px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.cart--v1 .cart-checkout svg { width: 20px; height: 20px; }
.cart--v1 .form-policy {
    font-size: 12px;
    color: #4d5469;
    text-align: center;
    margin-top: 14px;
    line-height: 1.5;
}

/* --- Блок «Документы по заказу» --- */
.cart--v1 .cart-docs {
    margin-top: 28px;
    background: #fff;
    border: 1.5px solid #d7ddf2;
    border-radius: 18px;
    padding: 26px 28px;
    box-shadow: 0 1px 2px rgba(20, 24, 60, .04);
}
.cart--v1 .cart-docs__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}
.cart--v1 .cart-docs__title {
    font-size: 20px;
    font-weight: 800;
    font-family: 'Nunito Sans', sans-serif;
    color: #0e1230;
    margin: 0;
}
.cart--v1 .cart-docs__desc {
    font-size: 13.5px;
    color: #4d5469;
    margin: 5px 0 0;
    max-width: 60ch;
    line-height: 1.5;
}
.cart--v1 .cart-docs__count {
    flex-shrink: 0;
    background: #f5f7fd;
    color: #4d5469;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    white-space: nowrap;
}
.cart--v1 .cart-docs__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.cart--v1 .cart-docrow {
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1.5px solid #e6e9f5;
    border-radius: 14px;
    padding: 16px 18px;
    background: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: all .2s;
}
.cart--v1 .cart-docrow:hover {
    border-color: #2b2c7c;
    background: #f5f7fd;
    box-shadow: 0 8px 18px -14px rgba(43, 44, 124, .32);
    transform: translateY(-1px);
}
.cart--v1 .cart-docrow__icon {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    font-family: 'Nunito Sans', sans-serif;
}
.cart--v1 .cart-docrow__icon--word { background: #2b579a; }
.cart--v1 .cart-docrow__icon--excel { background: #217346; }
.cart--v1 .cart-docrow__main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.cart--v1 .cart-docrow__name {
    font-size: 15px;
    font-weight: 600;
    color: #0e1230;
}
.cart--v1 .cart-docrow__sub {
    font-size: 12px;
    color: #4d5469;
    margin-top: 2px;
}
.cart--v1 .cart-docrow__dl {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: #f5f7fd;
    color: #2b2c7c;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .2s;
}
.cart--v1 .cart-docrow__dl svg { width: 18px; height: 18px; }
.cart--v1 .cart-docrow:hover .cart-docrow__dl { background: #2b2c7c; color: #fff; }

/* --- Адаптив --- */
@media (max-width: 991.98px) {
    .cart--v1 .stats { position: static; }
}
@media (max-width: 767.98px) {
    .cart--v1 .cart-item {
        grid-template-columns: auto 96px minmax(0, 1fr);
        gap: 14px;
        padding: 16px;
    }
    .cart--v1 .cart-item__img { width: 96px; height: 96px; }
    .cart--v1 .cart-item__info {
        grid-column: 2 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    .cart--v1 .cart-docs__grid { grid-template-columns: 1fr; }
    .cart--v1 .stats { padding: 24px 20px; }
}
