/* Cart drawer. Loaded after main.css and animations.css; scoped to #cartModal so nothing else is affected.
   To revert: run /root/wls-rollback-cart.sh */

#cartModal.modal { background: rgba(26, 26, 46, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
#cartModal.is-open { display: flex; justify-content: flex-end; align-items: stretch; padding: 0; }

#cartModal .modal-content.cart-drawer {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 440px;
    height: 100%;
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 24px 0 0 24px;
    box-shadow: -20px 0 60px rgba(0, 0, 0, .25);
}

@keyframes cart-slide-in { from { transform: translateX(100%); } to { transform: none; } }
html.anim #cartModal.is-open .modal-content.cart-drawer { animation: cart-slide-in .38s cubic-bezier(.2, .8, .25, 1) both; }

/* Header */
.cart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 24px 16px;
    border-bottom: 1px solid rgba(233, 30, 140, .15);
}
.cart-head h2 { margin: 0; font-size: 1.4rem; line-height: 1.2; }
.cart-head-count { color: var(--brand-pink); font-weight: 600; font-size: 1rem; }
#cartModal .cart-head .modal-close {
    position: static;
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    font-size: 26px;
    line-height: 1;
    border-radius: 50%;
    background: rgba(0, 0, 0, .05);
    color: var(--text);
    transition: background .2s, transform .2s;
}
#cartModal .cart-head .modal-close:hover { background: rgba(233, 30, 140, .12); transform: rotate(90deg); }

/* Body */
.cart-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 24px; }

.cart-line {
    display: grid;
    grid-template-columns: 76px 1fr auto;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(0, 0, 0, .07);
    transition: opacity .2s;
}
.cart-line:last-child { border-bottom: 0; }
.cart-line.is-busy { opacity: .5; pointer-events: none; }

.cart-thumb {
    width: 76px;
    height: 76px;
    border-radius: 14px;
    overflow: hidden;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--brand-pink);
    background: linear-gradient(135deg, #ffe3f1, #fff0d6);
}
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cart-line-main h4 { margin: 0 0 2px; font-size: 1rem; line-height: 1.3; color: var(--text); }
.cart-line-main .cart-line-unit,
.cart-line-main .cart-line-addon { margin: 0; font-size: 13px; color: #777; line-height: 1.5; }

.cart-qty {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-top: 10px;
    padding: 2px;
    border: 1px solid #e4e4e8;
    border-radius: 999px;
    background: #fff;
}
.cart-qty .qty-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s;
}
.cart-qty .qty-btn:hover:not(:disabled) { background: rgba(233, 30, 140, .12); }
.cart-qty .qty-btn:disabled { opacity: .3; cursor: not-allowed; }
.cart-qty .qty-val { min-width: 28px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.cart-line-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }
.cart-line-total { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.cart-remove {
    padding: 4px 0;
    border: 0;
    background: none;
    font-size: 13px;
    color: #888;
    text-decoration: underline;
    cursor: pointer;
}
.cart-remove:hover { color: var(--brand-pink); }

/* Empty state */
.cart-empty { text-align: center; padding: 72px 12px 24px; }
.cart-empty-icon { font-size: 3rem; margin-bottom: 8px; }
.cart-empty h3 { margin: 0 0 6px; color: var(--text); }
.cart-empty p { margin: 0 0 22px; color: #777; }

/* Footer */
.cart-foot {
    padding: 18px 24px 22px;
    background: #fff;
    border-top: 1px solid rgba(0, 0, 0, .08);
    box-shadow: 0 -12px 24px rgba(0, 0, 0, .04);
}
.cart-foot[hidden] { display: none; }
.cart-row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; color: #555; }
.cart-sum-total {
    display: flex;
    justify-content: space-between;
    margin: 8px 0 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, .07);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}
#cartModal #checkoutBtn { width: 100%; }
.cart-continue {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 6px;
    border: 0;
    background: none;
    font-size: 14px;
    color: #777;
    text-decoration: underline;
    cursor: pointer;
}
.cart-continue:hover { color: var(--brand-pink); }

@media (max-width: 520px) {
    #cartModal .modal-content.cart-drawer { max-width: none; border-radius: 0; }
    .cart-head, .cart-foot { padding-left: 18px; padding-right: 18px; }
    .cart-body { padding: 4px 18px; }
    .cart-line { grid-template-columns: 64px 1fr auto; gap: 12px; }
    .cart-thumb { width: 64px; height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
    #cartModal .modal-content.cart-drawer { animation: none !important; }
}
