/* ═══════════════════════════════════════════════════════════════════
   CART DRAWER / OFFCANVAS — Design: Industrial Utilitarian + Minimal
   ════════════════════════════════════════════════════════════════════

   DFII Score: 17/15 (capped Excellent)
   Aesthetic: Iron-dark panel with precision red accent rail
   Differentiation: Uses a 4px crimson left-rail as a signature
   element — not a standard slide-in shadow, but a structural mark.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Backdrop ─────────────────────────────────────────────────────── */
.cart-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(10, 10, 15, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-drawer-backdrop.is-visible {
    opacity: 1;
    pointer-events: all;
}

/* ── Drawer Panel ─────────────────────────────────────────────────── */
.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    width: 420px;
    max-width: 100vw;

    /* Industrial dark panel */
    background: #0f0f13;
    color: #e8e8ea;

    /* Signature crimson left-rail */
    border-left: 4px solid #dc2626;

    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* Off-screen by default */
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.36s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.36s;
    will-change: transform;
    box-shadow: -12px 0 60px rgba(0, 0, 0, 0.5);
}

.cart-drawer.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.36s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0s;
}

/* ── Header ───────────────────────────────────────────────────────── */
.cart-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: #141418;
    flex-shrink: 0;
}

.cart-drawer__header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.cart-drawer__icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(220, 38, 38, 0.15);
    border: 1px solid rgba(220, 38, 38, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #dc2626;
    font-size: 16px;
}

.cart-drawer__title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.cart-drawer__subtitle {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.02em;
}

.cart-drawer__close {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.18s ease;
    flex-shrink: 0;
}

.cart-drawer__close:hover {
    background: rgba(220, 38, 38, 0.15);
    border-color: rgba(220, 38, 38, 0.4);
    color: #dc2626;
}

/* ── Body (scrollable items list) ────────────────────────────────── */
.cart-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(220, 38, 38, 0.3) transparent;
}

.cart-drawer__body::-webkit-scrollbar {
    width: 3px;
}

.cart-drawer__body::-webkit-scrollbar-track {
    background: transparent;
}

.cart-drawer__body::-webkit-scrollbar-thumb {
    background: rgba(220, 38, 38, 0.3);
    border-radius: 2px;
}

/* ── Shipping progress bar ─────────────────────────────────────────── */
.cart-drawer__shipping-bar {
    padding: 10px 20px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.cart-drawer__shipping-msg {
    font-size: 11.5px;
    color: #9ca3af;
    margin-bottom: 7px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.cart-drawer__shipping-msg strong { color: #e8e8ea; }
.cart-drawer__shipping-msg i { color: #dc2626; }

.cart-drawer__shipping-msg--ok {
    color: #34d399;
}
.cart-drawer__shipping-msg--ok i { color: #34d399; }

.cart-drawer__shipping-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.cart-drawer__shipping-fill {
    height: 100%;
    background: linear-gradient(90deg, #dc2626, #f87171);
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ── Individual Item ───────────────────────────────────────────────── */
.cart-drawer__item {
    display: grid;
    grid-template-columns: 76px 1fr 30px;
    gap: 12px;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s ease;
}

.cart-drawer__item:last-child {
    border-bottom: none;
}

.cart-drawer__item:hover {
    background: rgba(220, 38, 38, 0.04);
}

.cart-drawer__item-image {
    width: 76px;
    height: 76px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-drawer__item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.cart-drawer__item-info {
    min-width: 0;
}

.cart-drawer__item-name {
    font-size: 12.5px;
    font-weight: 600;
    color: #e8e8ea;
    line-height: 1.4;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-drawer__item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.cart-drawer__item-qty {
    font-size: 10.5px;
    color: #fff;
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid rgba(220, 38, 38, 0.3);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
}

.cart-drawer__item-unit {
    font-size: 10.5px;
    color: #6b7280;
}

.cart-drawer__item-total {
    font-size: 14px;
    font-weight: 800;
    color: #dc2626;
    letter-spacing: 0.01em;
}

/* Alias mantenuto per retrocompatibilità JS */
.cart-drawer__item-price {
    font-size: 13px;
    font-weight: 700;
    color: #dc2626;
}

.cart-drawer__item-remove {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.18s ease;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 2px;
}

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

/* ── Empty State ────────────────────────────────────────────────────── */
.cart-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
}

.cart-drawer__empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #374151;
    margin-bottom: 16px;
}

.cart-drawer__empty p {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 20px;
}

.cart-drawer__empty-cta {
    font-size: 13px;
    font-weight: 600;
    color: #dc2626;
    text-decoration: none;
    border: 1px solid rgba(220, 38, 38, 0.35);
    padding: 8px 20px;
    border-radius: 6px;
    transition: all 0.18s ease;
}

.cart-drawer__empty-cta:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #ef4444;
}

/* ── Savings banner ─────────────────────────────────────────────────── */
.cart-drawer__savings {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    margin-bottom: 14px;
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.25);
    border-radius: 7px;
    font-size: 11.5px;
    color: #6ee7b7;
}
.cart-drawer__savings i { color: #34d399; }
.cart-drawer__savings strong { color: #a7f3d0; }

/* ── Footer ─────────────────────────────────────────────────────────── */
.cart-drawer__footer {
    padding: 16px 24px 24px;
    background: #141418;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.cart-drawer__summary {
    margin-bottom: 16px;
}

.cart-drawer__summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.cart-drawer__summary-row span:first-child {
    font-size: 13px;
    color: #9ca3af;
}

.cart-drawer__summary-total {
    font-size: 20px;
    font-weight: 800;
    color: #ffffff;
    font-family: 'JetBrains Mono', monospace;
}

.cart-drawer__summary-note {
    font-size: 11px;
    color: #4b5563;
    font-style: italic;
}

.cart-drawer__actions {
    display: flex;
    gap: 10px;
}

.cart-drawer__btn {
    flex: 1;
    padding: 13px 16px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.cart-drawer__btn--secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #d1d5db;
}

.cart-drawer__btn--secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.cart-drawer__btn--primary {
    background: #dc2626;
    border: 1px solid #dc2626;
    color: #ffffff;
}

.cart-drawer__btn--primary:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

/* ── "Added!" pulse animation on cart icon ──────────────────────────── */
@keyframes cart-pulse {
    0%, 100% { transform: scale(1); }
    30%       { transform: scale(1.25); }
    60%       { transform: scale(0.95); }
}

.cart-pulse-anim {
    animation: cart-pulse 0.45s ease-in-out;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .cart-drawer {
        width: 100vw;
        border-left: none;
        border-top: 4px solid #dc2626;
    }
}

/* ── Body lock when drawer is open ──────────────────────────────────── */
body.cart-drawer-open {
    overflow: hidden;
}
