/* ── Cart Drawer: scoped styles ──────────────────── */
/* Slide-in origin as a token: `transform` is physical by spec, so the
   two directions are declared once here instead of branching in PHP —
   which is what used to make this whole stylesheet request-dependent. */
:root      { --cart-drawer-hidden-x:  100%; }
[dir="rtl"]{ --cart-drawer-hidden-x: -100%; }
#cart-drawer {
    position: fixed;
    top: 0;
    inset-inline-end: 0;
    /* v5.82 — unified with the Mobile Nav Drawer / Filters Drawer:
       same width, same backdrop blur (.yalo-overlay), same open/close
       motion. Previously min(420px,100vw) covered ~100% of the
       screen on mobile, feeling like a full page instead of a
       dismissible side panel. */
    width: var(--yalo-drawer-w);
    /* v5.80 fix: same dvh/vh issue as #filters-drawer — 100vh alone can
       exceed the visible mobile viewport while the browser's address
       bar is shown (drawer opened at the top of the page), pushing the
       footer (إتمام الطلب / مواصلة التسوق) off-screen until the user
       scrolls. 100dvh tracks the *actual* visible viewport. */
    height: 100vh;
    height: 100dvh;
    background: var(--clr-surface);
    z-index: 600;
    transform: translateX(var(--cart-drawer-hidden-x));
    transition: var(--yalo-drawer-transition);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 48px rgba(0,0,0,.15);
}
#cart-drawer.open {
    transform: translateX(0) !important;
}

/* Header */
.cart-drawer-hd {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--clr-border);
    background: var(--clr-surface);
    position: relative;
}
.cart-drawer-hd::after {
    content: '';
    position: absolute;
    inset-inline-start: 20px;
    inset-inline-end: 20px;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--clr-primary), var(--clr-secondary, var(--clr-primary)));
    border-radius: 999px;
    opacity: .6;
}
.cart-drawer-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 800;
    color: var(--clr-text);
}
.cart-drawer-title-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(var(--clr-primary-rgb), .12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--clr-primary);
}
.cart-drawer-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    background: var(--clr-primary);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}
.cart-drawer-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #e02020;
    border-radius: 10px;
    font-size: 13px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: 0 2px 8px rgba(224,32,32,.30);
}
.cart-drawer-close:hover {
    background: #c01010;
    transform: scale(1.07);
    box-shadow: 0 4px 12px rgba(224,32,32,.40);
}
.cart-drawer-close:active {
    transform: scale(.95);
}

/* Items scroll area */
.cart-drawer-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 0;
}
.cart-drawer-body::-webkit-scrollbar { width: 4px; }
.cart-drawer-body::-webkit-scrollbar-track { background: transparent; }
.cart-drawer-body::-webkit-scrollbar-thumb {
    background: var(--clr-border);
    border-radius: 999px;
}

/* Cart items list */
.cart-items-list {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Single cart item */
.cart-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 14px 0;
    border-bottom: 1px solid var(--clr-border);
    position: relative;
    animation: itemSlideIn .22s ease-out;
}
.cart-item:last-child { border-bottom: none; }
@keyframes itemSlideIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}
.cart-item-img {
    width: 68px;
    height: 68px;
    border-radius: var(--radius-thumb);
    object-fit: cover;
    background: var(--clr-surface-2);
    flex-shrink: 0;
    border: 1px solid var(--clr-border);
}
.cart-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cart-item-variant {
    font-size: 11px;
    color: var(--clr-text-3);
    font-weight: 500;
    margin-top: 1px;
    margin-bottom: 2px;
    line-height: 1.3;
}
.cart-item-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--clr-text);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.cart-item-price {
    font-size: 14px;
    font-weight: 900;
    color: var(--clr-primary);
    letter-spacing: -.01em;
}
.cart-item-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Qty stepper + delete pill */
.cart-item-stepper {
    display: inline-flex;
    align-items: center;
    background: var(--clr-surface-2);
    border: 1.5px solid var(--clr-border);
    border-radius: 999px;
    overflow: hidden;
    height: 32px;
}
.cart-item-stepper-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--clr-text-2);
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
    line-height: 1;
    flex-shrink: 0;
}
.cart-item-stepper-btn:hover {
    background: rgba(var(--clr-primary-rgb), .12);
    color: var(--clr-primary);
}
.cart-item-stepper-btn.delete-btn:hover {
    background: rgba(239,68,68,.12);
    color: #ef4444;
}
.cart-item-qty {
    min-width: 28px;
    text-align: center;
    font-size: 13px;
    font-weight: 800;
    color: var(--clr-text);
    user-select: none;
}
.cart-item-divider {
    width: 1px;
    height: 18px;
    background: var(--clr-border);
    flex-shrink: 0;
}
.cart-item-line-total {
    font-size: 12px;
    font-weight: 700;
    color: var(--clr-text-3);
    white-space: nowrap;
}

/* Footer */
.cart-drawer-ft {
    flex-shrink: 0;
    padding: 14px 16px 18px;
    border-top: 1px solid var(--clr-border);
    background: var(--clr-surface);
    display: none;
}
.cart-drawer-ft.visible { display: block; }

/* Total block — prominent card */
.cart-total-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--clr-surface-2);
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 12px;
}
.cart-total-left {}
.cart-total-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--clr-text-3);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: 3px;
}
.cart-total-amount {
    font-size: 22px;
    font-weight: 900;
    color: var(--clr-primary);
    letter-spacing: -.02em;
    line-height: 1;
}

/* ── Action buttons: stacked full-width pills ──────────── */
.cart-action-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 0 20px;
    height: 48px;
    /* Central Buttons family. --cta-hover-shadow's own comment already
       names this button alongside the PDP "Buy now" and the checkout
       submit as the three primary CTAs — but it was the only one of the
       three still pinned at 999px, so it kept its pill while the other
       two followed the merchant's setting. */
    border-radius: var(--btn-radius, 999px);
    font-weight: 800;
    font-size: 14px;
    font-family: inherit;
    text-decoration: none;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform .18s cubic-bezier(.4,0,.2,1),
                box-shadow .18s cubic-bezier(.4,0,.2,1),
                opacity .18s;
    white-space: nowrap;
    letter-spacing: .01em;
}
.cart-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,.18) 0%, transparent 55%);
    pointer-events: none;
}
.cart-btn:hover  { transform: translateY(-2px); }
.cart-btn:active { transform: translateY(0);   }

/* Continue shopping — secondary action (top) */
.cart-btn-continue {
    background: #16a34a;
    color: #fff;
    box-shadow: 0 4px 14px rgba(22,163,74,.28);
}
.cart-btn-continue:hover { box-shadow: 0 8px 22px rgba(22,163,74,.42); }

/* Checkout — primary CTA (bottom) — unified action colour (--clr-buy) */
.cart-btn-checkout {
    background: var(--clr-buy);
    color: #fff;
    box-shadow: none;
    transition: background .18s ease, box-shadow .18s ease;
}
/* Quiet hover: the fill deepens one step and a small neutral shadow
   appears. No coloured halo, no lift — see --cta-hover-shadow. */
.cart-btn-checkout:hover  { background: var(--clr-buy-700); box-shadow: var(--cta-hover-shadow); }
.cart-btn-checkout:active { background: var(--clr-buy-700); box-shadow: none; filter: brightness(.96); }


/* Just-added item highlight */
.cart-item--just-added {
    animation: itemJustAdded .4s ease-out forwards;
}
@keyframes itemJustAdded {
    0%   { background: rgba(var(--clr-primary-rgb), .18); border-radius: var(--radius); }
    60%  { background: rgba(var(--clr-primary-rgb), .10); border-radius: var(--radius); }
    100% { background: transparent; }
}

/* Button success state (v5.81) — fixed box, green, check icon only */
.btn-added-state {
    background: #16a34a !important;
    box-shadow: 0 4px 14px rgba(22,163,74,.35) !important;
    color: #fff !important;
    pointer-events: none;
    overflow: hidden;
    gap: 0 !important;
}
.btn-added-state .add-btn-label { display: none; }

/* Dark mode overrides */
body.dark-mode #cart-drawer {
    background: var(--clr-surface);
    box-shadow: -8px 0 48px rgba(0,0,0,.45);
}
body.dark-mode .cart-drawer-hd,
body.dark-mode .cart-drawer-ft { background: var(--clr-surface); }
body.dark-mode .cart-total-block {
    background: var(--clr-surface-2);
    border-color: var(--clr-border);
}
body.dark-mode .cart-item-stepper {
    background: var(--clr-surface-2);
    border-color: var(--clr-border);
}
body.dark-mode .cart-item-img { border-color: var(--clr-border); }
