/* [GRP: CART BAR + PRODUCT FOOTER] */

/* Убираем синее подсвечивание при таче на мобильных */
button,
a,
.nav-item {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

button:focus,
button:active,
a:focus,
a:active {
    outline: none;
}

/* Десктоп — кнопки в боковой панели */
.desktop-actions {
    display: flex;
    gap: 12px;
}

.desktop-actions .btn-buy-now,
.desktop-actions .btn-add-cart,
.desktop-actions [data-cart-qtybox] {
    flex: 0 0 calc(50% - 6px);
    /* Строго 50% минус половина gap */
    border: 0;
    border-radius: 100px;
    height: 52px;
    padding: 0 24px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Убрали transition чтобы не мигало при +/- */
}

.desktop-actions .btn-buy-now {
    background: #f4e8ff;
    color: var(--accent);
}

.desktop-actions .btn-add-cart {
    background: var(--accent);
    color: #fff;
}

.desktop-actions .btn-buy-now:active,
.desktop-actions .btn-add-cart:active {
    transform: scale(.96);
}

/* Убираем active transform для qty-box чтобы не дергалось при +/- */
.desktop-actions [data-cart-qtybox]:active {
    transform: none;
}

/* Мобильный футер */
.product-footer {
    display: none;
}

/* Мобильная версия */
@media (max-width: 768px) {
    body {
        padding-bottom: 160px;
    }

    .desktop-actions {
        display: none;
    }

    .product-footer {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 54px;
        background: #fff;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        padding: 16px 16px calc(12px + env(safe-area-inset-bottom));
        z-index: 1200;
    }

    .price-row {
        text-align: left;
        margin-bottom: 12px;
    }

    .main-price {
        font-size: 24px;
        font-weight: 800;
        color: #111;
    }

    .action-buttons {
        display: flex;
        gap: 10px;
        align-items: center;
    }

    .btn-buy,
    .btn-cart,
    [data-cart-qtybox] {
        flex: 1;
        border: 0;
        border-radius: 16px;
        padding: 0 8px;
        height: 48px;
        min-height: 48px;
        font: inherit;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        transition: transform .1s ease, opacity .1s ease;
    }

    .btn-buy {
        background: #FF8C42;
        color: #fff;
    }

    /* Убираем hover-эффекты на тач-устройствах чтобы не "залипали" */
    @media (hover: hover) {
        .btn-buy:hover {}

        .btn-cart:hover {}
    }

    .btn-cart {
        background: #8B5CF6;
        color: #fff;
    }

    .btn-buy:active,
    .btn-cart:active {
        transform: scale(0.98);
    }

    /* Нижняя навигация */
    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        border-top: 1px solid #eee;
        padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        height: 54px;
    }

    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: #6b7280;
        font-size: 11px;
        gap: 2px;
        flex: 1;
        position: relative;
    }

    .nav-item .material-icons-round {
        font-size: 24px;
    }

    .nav-item.active {
        color: #8B5CF6;
    }

    .nav-label {
        font-size: 10px;
    }

    .nav-cart {
        position: relative;
    }

    .nav-badge {
        position: absolute;
        top: -2px;
        right: 50%;
        transform: translateX(12px);
        background: #FF2465;
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        min-width: 16px;
        height: 16px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        opacity: 0;
        transition: opacity .2s ease;
    }

    .nav-badge.show {
        opacity: 1;
    }
}

/* [SEC: Inline qty control inside add-to-cart] */
/* ВАЖНО: реальные кнопки +/− нельзя вкладывать внутрь <button>.
Поэтому делаем визуально одну кнопку, а технически — wrapper с двумя состояниями. */
.cart-action {
    flex: 1;
    min-width: 0;
}

.cart-action>[data-cart-trigger],
.cart-action>[data-cart-qtybox] {
    width: 100%;
}

[data-cart-qtybox] {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, .25);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    padding: 0;
}

/* ВАЖНО: hidden должен скрывать элемент несмотря на display: flex */
[data-cart-qtybox][hidden],
[data-cart-trigger][hidden] {
    display: none !important;
}

.desktop-actions [data-cart-qtybox] {
    border-radius: 100px;
    padding: 0;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
}

[data-cart-qtybox]::before,
[data-cart-qtybox]::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    opacity: 0;
}

[data-cart-qtybox]::before {
    background: linear-gradient(120deg,
            transparent 0%,
            transparent 32%,
            rgba(255, 255, 255, .18) 50%,
            transparent 68%,
            transparent 100%);
    transform: translateX(-130%);
}

[data-cart-qtybox]::after {
    box-shadow: inset 0 0 0 0 rgba(255, 255, 255, .35);
}

[data-cart-qtybox].is-sheen::before {
    animation: cart-qty-sheen .42s ease;
}

[data-cart-qtybox].is-burst::after {
    animation: cart-qty-burst .38s ease-out;
}

.btn-cart-mid {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
}

.btn-cart-count {
    font-size: 18px;
    /* font-weight: 800; */
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.btn-cart-note {
    font-size: 10px;
    font-weight: 500;
    opacity: .9;
    margin-top: 2px;
}

[data-cart-qtybox] .btn-qty {
    flex: 0 0 48px;
    width: 48px;
    height: 100%;
    border: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 24px;
    font-weight: 400;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color .1s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    [data-cart-qtybox] .btn-qty:hover {
        background: rgba(0, 0, 0, 0.05);
    }
}

[data-cart-qtybox] .btn-qty:active {
    background: rgba(0, 0, 0, .08);
}

[data-cart-qtybox] .btn-qty:disabled {
    opacity: .45;
}

.btn-cart-count.is-bump {
    animation: cart-qty-count .22s ease;
}

@keyframes cart-qty-sheen {
    0% {
        opacity: 0;
        transform: translateX(-130%);
    }

    25% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateX(130%);
    }
}

@keyframes cart-qty-burst {
    0% {
        opacity: .28;
        box-shadow: inset 0 0 0 0 rgba(255, 255, 255, .34);
    }

    100% {
        opacity: 0;
        box-shadow: inset 0 0 0 10px rgba(255, 255, 255, 0);
    }
}

@keyframes cart-qty-count {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {

    [data-cart-qtybox],
    [data-cart-qtybox] .btn-qty,
    .btn-cart-count {
        animation: none !important;
        transition: none !important;
    }
}

/* Toast уведомление */
.cart-toast {
    position: fixed;
    left: 50%;
    bottom: 170px;
    transform: translate(-50%, 10px);
    background: rgba(31, 31, 31, .94);
    color: #fff;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    z-index: 1300;
    white-space: nowrap;
}

.cart-toast.is-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Состояния кнопок */
[data-busy="1"] {
    /* Убрали opacity чтобы не мигало при +/- */
    pointer-events: none;
}

.is-success {
    filter: saturate(1.15);
}
