/* =====================================================================
   Добавление в корзину — обновлённый UI (v1)
   Подключается после style.css и аккуратно его дополняет.
   ===================================================================== */

/* ---------- степпер количества ---------- */
.qty-stepper {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    user-select: none;
}

.qty-stepper .qty-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: inherit;
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    transition: background .18s ease, transform .12s ease, opacity .18s ease;
}

.qty-stepper .qty-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
.qty-stepper .qty-btn:active:not(:disabled) { transform: scale(0.92); }
.qty-stepper .qty-btn:disabled { opacity: .3; cursor: not-allowed; }

.qty-stepper input[type="number"] {
    width: 52px;
    height: 34px;
    text-align: center;
    border: 0;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 15px;
    font-weight: 800;
    appearance: textfield;
    -moz-appearance: textfield;
}

.qty-stepper input[type="number"]::-webkit-outer-spin-button,
.qty-stepper input[type="number"]::-webkit-inner-spin-button {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
}

.qty-stepper input[type="number"]:focus { outline: none; }

.qty-stepper--compact { padding: 3px; border-radius: 12px; }
.qty-stepper--compact .qty-btn { width: 28px; height: 28px; font-size: 16px; border-radius: 8px; }
.qty-stepper--compact input[type="number"] { width: 40px; height: 28px; font-size: 14px; }

[data-theme='light'] .qty-stepper {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
}
[data-theme='light'] .qty-stepper .qty-btn { background: rgba(0, 0, 0, 0.05); }
[data-theme='light'] .qty-stepper .qty-btn:hover:not(:disabled) { background: rgba(0, 0, 0, 0.1); }

/* ---------- блок «в корзину» на карточке ----------
   На витрине (главная / каталог) выбора количества нет —
   только одна аккуратная кнопка на всю ширину. */
.product-card .add-to-cart-form {
    margin-top: auto;
    display: block;
}

.product-card .add-to-cart-form .btn-add,
.product-card .add-to-cart-form .btn-disabled {
    width: 100%;
    justify-content: center;
}

/* степпер допустим только внутри страницы товара и корзины */
.product-card .qty-stepper { display: none !important; }

/* ---------- блок на странице товара ---------- */
.add-to-cart-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 560px;
    margin-top: 22px;
    padding: 16px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
}

.add-to-cart-inline label {
    white-space: nowrap;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: uppercase;
    opacity: .6;
    flex: 0 0 auto;
}

.add-to-cart-inline .qty-stepper { flex: 0 0 auto; }

.add-to-cart-inline .btn-add {
    flex: 1 1 190px;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
}

[data-theme='light'] .add-to-cart-inline {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.08);
}

@media (max-width: 700px) {
    .add-to-cart-inline {
        max-width: 100%;
        gap: 12px;
    }
    .add-to-cart-inline label { width: 100%; }
    .add-to-cart-inline .qty-stepper { width: 100%; justify-content: space-between; }
    .add-to-cart-inline .qty-stepper input[type="number"] { flex: 1 1 auto; width: auto; }
    .add-to-cart-inline .btn-add { width: 100%; flex: 1 1 100%; }
}

/* точное количество на складе покупателю не показываем —
   только «В наличии» / «Нет в наличии» */
.stock-hint { display: none !important; }

/* ---------- кнопка: загрузка / добавлено ---------- */
.btn-add { position: relative; }

.btn-add .btn-loader {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
}

.btn-add.is-loading { cursor: progress; }

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-top-color: transparent;
    display: inline-block;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn-add.is-added {
    background: linear-gradient(135deg, #00d67a, #00b368) !important;
    color: #04130c !important;
    box-shadow: 0 10px 34px rgba(0, 214, 122, 0.35) !important;
}

.btn-add.is-added .btn-text { animation: addedPop .35s ease; }

@keyframes addedPop {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.btn-disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- тост с кнопкой ---------- */
.toast-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.toast-text { font-weight: 700; }

.toast-link {
    font-size: 13px;
    font-weight: 800;
    color: inherit;
    opacity: .75;
    text-decoration: none;
}

.toast-link:hover { opacity: 1; text-decoration: underline; }

/* ---------- счётчик в шапке ---------- */
.cart-badge.is-bumped { animation: badgeBump .45s cubic-bezier(.34, 1.56, .64, 1); }

@keyframes badgeBump {
    0% { transform: scale(1); }
    45% { transform: scale(1.45); }
    100% { transform: scale(1); }
}

.cart-link.is-bumped .cart-icon { animation: cartNudge .5s ease; }

@keyframes cartNudge {
    0%, 100% { transform: translateY(0) rotate(0); }
    30% { transform: translateY(-3px) rotate(-8deg); }
    60% { transform: translateY(0) rotate(6deg); }
}
