﻿.cart-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: min(430px, 92vw);
    height: 100vh;
    background:
        radial-gradient(circle at 8% 8%, rgba(var(--primary-rgb), 0.16) 0%, transparent 36%),
        radial-gradient(circle at 88% 22%, rgba(var(--secondary-rgb), 0.08) 0%, transparent 40%),
        linear-gradient(180deg, #080910 0%, #07080d 100%);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.32s var(--ease-out), box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    visibility: hidden;
    pointer-events: none;
}

.cart-sidebar.active {
    transform: translateX(0);
    box-shadow: -22px 0 60px rgba(0, 0, 0, 0.56);
    visibility: visible;
    pointer-events: auto;
}

.cart-sidebar-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-sidebar-header h3 {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.close-sidebar {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.07);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.close-sidebar:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.35);
    color: #ef4444;
    transform: rotate(90deg);
}

.cart-items-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 22px;
    display: grid;
    gap: 12px;
    align-content: start;
}

.cart-empty-state {
    margin-top: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    padding: 22px 14px;
}

.cart-empty-icon {
    width: 74px;
    height: 74px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    display: grid;
    place-items: center;
    font-size: 1.8rem;
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.3);
}

.cart-empty-state h4 {
    margin: 0 0 8px;
    font-size: 1.05rem;
    color: var(--text-main);
}

.cart-empty-state p {
    margin: 0;
    font-size: 0.9rem;
    max-width: 28ch;
}

.cart-item {
    display: grid;
    grid-template-columns: 58px 1fr 30px;
    gap: 12px;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 10px;
    transition: var(--transition-fast);
}

.cart-item:hover {
    border-color: rgba(var(--primary-rgb), 0.35);
    background: rgba(255, 255, 255, 0.045);
    transform: translateY(-1px);
}

.cart-item-img {
    width: 58px;
    height: 58px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: grid;
    place-items: center;
    color: var(--text-muted);
    font-size: 1rem;
}

.cart-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cart-item-content {
    min-width: 0;
}

.cart-item-name {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.35;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-meta {
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cart-price-money {
    color: var(--primary-light);
    font-size: 0.93rem;
    font-weight: 700;
}

.cart-price-token {
    color: #f59e0b;
    font-size: 0.88rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.cart-item-qty {
    font-size: 0.74rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 2px 8px;
}

.cart-item-remove {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: rgba(239, 68, 68, 0.84);
    cursor: pointer;
    transition: var(--transition-fast);
}

.cart-item-remove:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.cart-sidebar-footer {
    padding: 16px 16px 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.015) 0%, rgba(255, 255, 255, 0.03) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
}

.cart-totals {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: 600;
    color: var(--text-main);
}

.total-amount {
    color: var(--primary-light);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.total-row-tokens {
    display: inline-flex;
    justify-content: flex-end;
    align-items: center;
    color: #f59e0b;
    font-size: 0.88rem;
    gap: 6px;
    font-weight: 700;
}

.cart-sidebar-footer .btn {
    width: 100%;
    margin-top: 12px;
    min-height: 48px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
}

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: 0.28s ease;
}

.cart-sidebar.active~.cart-overlay {
    opacity: 1;
    visibility: visible;
}

/* Light theme tuning */
:root[data-theme="light"] .cart-sidebar {
    background:
        radial-gradient(circle at 8% 8%, rgba(var(--primary-rgb), 0.08) 0%, transparent 38%),
        radial-gradient(circle at 88% 22%, rgba(var(--secondary-rgb), 0.06) 0%, transparent 42%),
        linear-gradient(180deg, #ffffff 0%, #f6f8fc 100%);
    border-left-color: rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .cart-sidebar.active {
    box-shadow: -18px 0 38px rgba(15, 23, 42, 0.16);
}

:root[data-theme="light"] .cart-sidebar-header {
    border-bottom-color: rgba(15, 23, 42, 0.1);
}

:root[data-theme="light"] .close-sidebar {
    background: rgba(15, 23, 42, 0.05);
    border-color: rgba(15, 23, 42, 0.14);
    color: #475569;
}

:root[data-theme="light"] .cart-empty-icon {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.1);
    color: rgba(15, 23, 42, 0.35);
}

:root[data-theme="light"] .cart-item {
    background: rgba(255, 255, 255, 0.84);
    border-color: rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .cart-item:hover {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(var(--primary-rgb), 0.35);
}

:root[data-theme="light"] .cart-item-img {
    background: rgba(15, 23, 42, 0.05);
    border-color: rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .cart-item-qty {
    background: rgba(15, 23, 42, 0.05);
    border-color: rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .cart-sidebar-footer {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.015) 0%, rgba(15, 23, 42, 0.045) 100%);
    border-top-color: rgba(15, 23, 42, 0.1);
    backdrop-filter: blur(8px);
}

:root[data-theme="light"] .total-row-tokens {
    color: #b45309;
}

:root[data-theme="light"] .cart-overlay {
    background: rgba(15, 23, 42, 0.32);
}

@media (max-width: 520px) {
    .cart-sidebar {
        top: calc(12px + env(safe-area-inset-top, 0px));
        width: 100%;
        right: 0;
        height: calc(100vh - (12px + env(safe-area-inset-top, 0px)));
        border-top-left-radius: 18px;
        border-bottom-left-radius: 18px;
    }

    .cart-sidebar-header {
        padding: 16px 16px 12px;
    }

    .cart-sidebar-header h3 {
        font-size: 1.35rem;
    }

    .total-amount {
        font-size: 1.6rem;
    }
}
