/* ────────────────────────────────────────────────────────────
   Dark Empires — Cart page
   Premium, human-grade styling. Subtle depth, warm gradients,
   tactile feedback, and careful responsive behaviour.
   ──────────────────────────────────────────────────────────── */

body.cart-page {
    scroll-behavior: smooth;
    background:
        radial-gradient(1000px 600px at 10% -10%, rgba(99,102,241,0.06), transparent 60%),
        radial-gradient(800px 500px at 110% 10%, rgba(236,72,153,0.05), transparent 55%),
        var(--bg);
    /* mobile-nav (~64px) + place-order-fixed (~72px) + safe area */
    padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

/* ── Keyframes ── */
@keyframes cart-slide-in {
    0%   { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes summary-glow {
    0%, 100% { box-shadow: 0 10px 30px -12px rgba(99,102,241,0.25), 0 2px 8px rgba(15,23,42,0.06); }
    50%      { box-shadow: 0 14px 40px -12px rgba(99,102,241,0.40), 0 2px 8px rgba(15,23,42,0.08); }
}
@keyframes empty-float {
    0%,100% { transform: translateY(0); }
    50%     { transform: translateY(-6px); }
}
@keyframes bar-slide-up {
    0%   { transform: translateY(110%); opacity: 0; }
    100% { transform: translateY(0);    opacity: 1; }
}
@keyframes bar-shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

/* ── Container ── */
.cart-container {
    max-width: 960px;
    margin: 1.5rem auto;
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cart {
    padding: 0;
    border-radius: 1rem;
}

/* ── Cart item card ── */
.cart-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
    border-radius: 0.9rem;
    margin-bottom: 0.9rem;
    border: 1px solid rgba(15,23,42,0.06);
    box-shadow:
        0 1px 2px rgba(15,23,42,0.04),
        0 4px 12px -6px rgba(15,23,42,0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    animation: cart-slide-in 0.35s ease-out both;
    overflow: hidden;
}
.cart-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary), #8b5cf6);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.cart-item:hover {
    transform: translateY(-3px);
    box-shadow:
        0 2px 4px rgba(15,23,42,0.05),
        0 12px 28px -10px rgba(99,102,241,0.22);
    border-color: rgba(99,102,241,0.22);
}
.cart-item:hover::before { opacity: 1; }

/* ── Cart item image ── */
.cart-item-image {
    position: relative;
    width: 84px; height: 84px;
    flex-shrink: 0;
    border-radius: 0.7rem;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem;
    background:
        radial-gradient(circle at 30% 20%, rgba(99,102,241,0.22), transparent 60%),
        linear-gradient(135deg, #1e1b4b 0%, #0f172a 55%, #020617 100%);
    border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 4px 12px -4px rgba(15,23,42,0.25);
}
.cart-item-image img {
    max-width: 80%;
    max-height: 80%;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.40));
    transition: transform 0.3s ease;
}
.cart-item:hover .cart-item-image img { transform: scale(1.06); }
.cart-item-image-fallback {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
}
.cart-item-image-fallback span {
    color: #fff;
    font-weight: 800;
    font-size: 1.3rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* ── Category chip ── */
.cart-item-category {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    background: rgba(99,102,241,0.08);
    color: var(--primary);
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    align-self: flex-start;
    width: fit-content;
}
.cart-item-category i { font-size: 0.65rem; }

/* ── Discount badge ── */
.cart-discount-badge {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    letter-spacing: 0.04em;
    border: 1px solid rgba(217, 119, 6, 0.15);
}

/* ── Line total ── */
.cart-item-details .line-total {
    margin-left: auto;
    font-weight: 700;
    color: var(--text);
    font-size: 0.92rem;
}

.cart-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-width: 0;
}
.cart-item-details strong {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cart-item-pricing {
    font-size: 0.95rem;
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.cart-item-pricing .original-price {
    text-decoration: line-through;
    color: var(--subtext);
    font-size: 0.9rem;
}
.cart-item-pricing .discounted-price {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.15rem;
    letter-spacing: -0.01em;
}
.cart-item-details .price-line {
    font-size: 0.9rem;
    color: var(--subtext);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.cart-item-details .qty-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 0.15rem 0.55rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(99,102,241,0.10);
    border-radius: 9999px;
    font-size: 0.85rem;
}

/* ── Actions ── */
.cart-item-actions {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    margin-left: 1rem;
    flex-shrink: 0;
}
.cart-item-actions a,
.cart-item-actions button,
.cart-item-actions .buy-now-btn {
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
    letter-spacing: 0.01em;
    text-decoration: none;
}
.action-buy-now form { display: inline; }
.action-buy-now .buy-now-btn,
.action-buy-now a {
    background: linear-gradient(135deg, #10b981 0%, #22c55e 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(34,197,94,0.35);
}
.action-buy-now .buy-now-btn:hover,
.action-buy-now a:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(34,197,94,0.45);
    filter: brightness(1.05);
}
.action-buy-now .buy-now-btn:active { transform: scale(0.96); }

.action-quantity .set-quantity-btn {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--primary);
}
.action-quantity .set-quantity-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(99,102,241,0.30);
}
.action-remove a {
    background: #fee2e2;
    color: var(--danger);
    width: 38px; height: 38px;
    padding: 0;
    justify-content: center;
}
.action-remove a:hover {
    background: var(--danger);
    color: #fff;
    transform: translateY(-2px) rotate(-4deg);
    box-shadow: 0 6px 18px rgba(220,38,38,0.40);
}

/* ── Summary ── */
.summary {
    background: linear-gradient(180deg, #ffffff 0%, #f9faff 100%);
    border: 1px solid rgba(99,102,241,0.14);
    border-radius: 1rem;
    padding: 1.4rem 1.5rem;
    margin-top: 0.5rem;
    position: relative;
    animation: summary-glow 4s ease-in-out infinite;
}
.summary::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 1rem;
    pointer-events: none;
    background: radial-gradient(circle at 100% 0%, rgba(99,102,241,0.08), transparent 45%);
}
.summary h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
    letter-spacing: -0.01em;
}
.summary .row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    color: var(--subtext);
}
.summary .row .coupon-discount { color: #059669; font-weight: 600; }
.summary .row.total {
    border-top: 1px dashed rgba(15,23,42,0.12);
    padding-top: 1rem;
    margin-top: 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
}
.summary .row.total strong {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

/* ── Coupon ── */
.coupon-container {
    display: none;
    margin-top: 0.5rem;
    background: #fff;
    border: 1px dashed rgba(99,102,241,0.30);
    border-radius: 0.85rem;
    padding: 1rem;
    animation: cart-slide-in 0.3s ease-out;
}
.coupon-container.show { display: block; }
.coupon {
    display: flex;
    gap: 0.6rem;
    align-items: stretch;
}
.coupon input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    font-size: 0.95rem;
    background: #fafbff;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.coupon input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
}
.coupon button {
    padding: 0.75rem 1.35rem;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 0.6rem;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}
.coupon button:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 8px 22px rgba(99,102,241,0.45); }
.coupon button:active { transform: scale(0.97); }
.coupon-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ── Empty state ── */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem 3rem;
    color: var(--subtext);
    gap: 1rem;
    text-align: center;
}
.empty i {
    font-size: 3.5rem;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: empty-float 2.4s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(99,102,241,0.30));
}
.empty span {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

/* ── Place-order fixed (mobile) ──
   Sits ABOVE the bottom mobile-nav (which has z-index:1000, ~64px tall).
   Safe-area inset handled by mobile-nav itself, so we only need its height. */
.place-order-fixed {
    position: fixed;
    bottom: 64px;
    left: 0; right: 0;
    padding: 0.85rem 1.1rem;
    background:
        radial-gradient(circle at 15% 0%, rgba(99,102,241,0.08), transparent 55%),
        radial-gradient(circle at 90% 100%, rgba(236,72,153,0.06), transparent 55%),
        rgba(255,255,255,0.92);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    border-top: 1px solid rgba(99,102,241,0.12);
    box-shadow:
        0 -8px 28px rgba(15,23,42,0.08),
        0 -1px 0 rgba(255,255,255,0.8) inset;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    z-index: 1001;
    animation: bar-slide-up 0.45s cubic-bezier(.2,.9,.3,1) both;
}
.place-order-fixed::before {
    content: '';
    position: absolute;
    top: 0; left: 10%; right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(99,102,241,0.5), rgba(236,72,153,0.5), transparent);
    opacity: 0.8;
}
.place-order-fixed .total-amount {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.place-order-fixed a {
    position: relative;
    overflow: hidden;
    padding: 0.75rem 1.6rem;
    background: linear-gradient(135deg, #10b981 0%, #22c55e 55%, #84cc16 100%);
    color: #fff;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    box-shadow:
        0 6px 20px rgba(34,197,94,0.50),
        0 1px 0 rgba(255,255,255,0.22) inset;
    transition: transform 0.2s, box-shadow 0.25s, filter 0.2s;
    text-decoration: none;
}
.place-order-fixed a::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 20%, rgba(255,255,255,0.30) 50%, transparent 80%);
    background-size: 200% 100%;
    animation: bar-shimmer 3.2s linear infinite;
    mix-blend-mode: overlay;
    opacity: 0.55;
    pointer-events: none;
}
.place-order-fixed a:hover { filter: brightness(1.08); box-shadow: 0 10px 28px rgba(34,197,94,0.65); }
.place-order-fixed a:active { transform: scale(0.97); }

@media (min-width: 1025px) {
    .place-order-fixed { display: none; }
    body.cart-page { padding-bottom: 2rem; }
}

/* ── Responsive (phone) ── */
@media (max-width: 640px) {
    .cart-item {
        flex-wrap: wrap;
        padding: 0.9rem;
        gap: 0.85rem;
    }
    .cart-item-image { width: 68px; height: 68px; padding: 0.35rem; }
    .cart-item-image-fallback span { font-size: 1rem; }
    .cart-item-details strong { font-size: 1rem; }
    .cart-item-category { font-size: 0.68rem; padding: 0.12rem 0.5rem; }
    .cart-item-details .line-total { font-size: 0.85rem; }
    .cart-item-actions {
        margin-left: 0;
        margin-top: 0.8rem;
        width: 100%;
        gap: 0.5rem;
        flex-wrap: nowrap;
        justify-content: flex-end;
    }
    .action-buy-now { display: inline-flex; flex: 0 0 auto; }
    .action-buy-now form { display: inline-flex; }
    .action-buy-now .buy-now-btn,
    .action-buy-now > a {
        padding: 0.55rem 1.1rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    .action-remove a { width: 40px; height: 40px; flex-shrink: 0; }
    .cart-item-details strong { white-space: normal; }
    .summary .row.total { font-size: 1.1rem; }
    .summary .row.total strong { font-size: 1.25rem; }

    /* Tighter place-order bar on phone */
    .place-order-fixed {
        padding: 0.75rem 0.95rem;
        gap: 0.6rem;
    }
    .place-order-fixed .total-amount { font-size: 1.1rem; }
    .place-order-fixed a { padding: 0.65rem 1.2rem; font-size: 0.9rem; }
}

/* Very small phones */
@media (max-width: 380px) {
    .cart-item-actions { gap: 0.4rem; }
    .action-buy-now .buy-now-btn,
    .action-buy-now > a { padding: 0.6rem 0.75rem; font-size: 0.82rem; }
    .place-order-fixed .total-amount { font-size: 1rem; }
    .place-order-fixed a { padding: 0.6rem 1rem; font-size: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
    .cart-item, .summary, .empty i, .place-order-fixed, .place-order-fixed a::after {
        animation: none !important;
    }
}
