/* ============================================================
   cart-drawer.css  — design matches checkout popup
   Palette:
     --primary:      #5c3e98
     --primary-dark: #4b327d
     --deep:         #3d2470
     --accent:       #f5f1fc
     --accent-mid:   #ede8f8
     --border:       #ddd3f0
     --text:         #2f2a33
     --muted:        #7a6a9a
   ============================================================ */

/* ── Reset ── */
.cd-drawer *,
.cd-drawer *::before,
.cd-drawer *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================================
   Trigger button
   ============================================================ */
.cd-trigger {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: #2f2a33;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.15s;
}
.cd-trigger:hover {
    background: rgba(92, 62, 152, 0.08);
}

.cd-badge {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: #5c3e98;
    color: #fff;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transform: translate(30%, -30%);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
    box-shadow: 0 2px 6px rgba(92, 62, 152, 0.40);
}
.cd-badge--hidden {
    opacity: 0;
    transform: translate(30%, -30%) scale(0.5);
    pointer-events: none;
}

/* ============================================================
   Overlay
   ============================================================ */
.cd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 10, 60, 0.50);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(3px);
}
.cd-overlay.cd-overlay--open {
    opacity: 1;
    pointer-events: all;
}

/* ============================================================
   Drawer shell
   ============================================================ */
.cd-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 100vw;
    background: #f7f4fc;
    /* border-left: 1px solid #ddd3f0; */
    box-shadow: none;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s;
}
.cd-drawer.cd-drawer--open {
    transform: translateX(0);
    box-shadow: -8px 0 48px rgba(60, 30, 110, 0.18);
}

/* ============================================================
   Header  — matches checkout popup .cm-header
   ============================================================ */
.cd-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #5c3e98 0%, #3d2470 100%);
    position: relative;
    overflow: hidden;
}

/* decorative circles — same as checkout popup */
.cd-header::before {
    content: '';
    position: absolute;
    top: -38px; right: -38px;
    width: 130px; height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    pointer-events: none;
}
.cd-header::after {
    content: '';
    position: absolute;
    bottom: -28px; left: 28%;
    width: 90px; height: 90px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    pointer-events: none;
}

.cd-header__icon {
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.cd-header__title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    flex: 1;
    letter-spacing: 0.01em;
    position: relative;
    z-index: 1;
}

.cd-header__count {
    font-size: 11px;
    font-weight: 700;
    color: #5c3e98;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 20px;
    padding: 3px 11px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    position: relative;
    z-index: 1;
}

.cd-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.90);
    transition: background 0.15s;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.cd-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ============================================================
   Body (scrollable)
   ============================================================ */
.cd-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 14px;
}
.cd-body::-webkit-scrollbar { width: 4px; }
.cd-body::-webkit-scrollbar-track { background: transparent; }
.cd-body::-webkit-scrollbar-thumb { background: #c9bce6; border-radius: 4px; }

/* ============================================================
   Empty state
   ============================================================ */
.cd-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 14px;
    text-align: center;
}
.cd-empty__icon { color: #c9bce6; }
.cd-empty__text { font-size: 14px; color: #9e90bc; }

/* ============================================================
   Cart item  — card style
   ============================================================ */
.cd-item {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #ede8f8;
    align-items: flex-start;
    margin-bottom: 10px;
    transition: opacity 0.2s, transform 0.2s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(92, 62, 152, 0.06);
}
.cd-item:last-child { margin-bottom: 0; }
.cd-item:hover {
    box-shadow: 0 4px 14px rgba(92, 62, 152, 0.12);
    border-color: #ddd3f0;
}
.cd-item--removing {
    opacity: 0;
    transform: translateX(20px);
}

/* Image */
.cd-item__img {
    width: 72px;
    height: 84px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #ede8f8;
    background: #f5f1fc;
}
.cd-item__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Details */
.cd-item__details { flex: 1; min-width: 0; }

.cd-item__name {
    font-size: 13px;
    font-weight: 700;
    color: #2f2a33;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.cd-item__name a { color: inherit; text-decoration: none; }
.cd-item__name a:hover { color: #5c3e98; }

.cd-item__variant { font-size: 11px; color: #9e90bc; margin-bottom: 6px; }
.cd-item__variant-type { font-weight: 600; }

/* Variant select */
.cd-item__variant-select {
    font-size: 12px;
    font-weight: 600;
    color: #5c3e98;
    background: #f5f1fc;
    border: 1.5px solid #ddd3f0;
    border-radius: 8px;
    padding: 4px 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.cd-item__variant-select:focus {
    outline: none;
    border-color: #5c3e98;
    box-shadow: 0 0 0 3px rgba(92, 62, 152, 0.10);
}

/* Price row */
.cd-item__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cd-item__price {
    font-size: 14px;
    font-weight: 800;
    color: #5c3e98;
}

.cd-item__original-price {
    font-size: 11px;
    color: #b0a4cc;
    margin-bottom: 1px;
}

/* Qty stepper */
.cd-qty {
    display: flex;
    align-items: center;
    background: #f5f1fc;
    border: 1.5px solid #ddd3f0;
    border-radius: 10px;
    overflow: hidden;
}
.cd-qty__btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    color: #5c3e98;
    transition: background 0.12s;
}
.cd-qty__btn:hover {
    background: #ede8f8;
    color: #4b327d;
}
.cd-qty__input {
    width: 34px;
    height: 30px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #2f2a33;
    border: none;
    border-left: 1.5px solid #ddd3f0;
    border-right: 1.5px solid #ddd3f0;
    background: #fff;
    -moz-appearance: textfield;
    appearance: textfield;
}
.cd-qty__input::-webkit-inner-spin-button,
.cd-qty__input::-webkit-outer-spin-button { -webkit-appearance: none; }
.cd-qty__input:focus { outline: none; }

/* Remove button */
.cd-item__remove {
    background: none;
    border: none;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #c9bce6;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    margin-top: 2px;
}
.cd-item__remove:hover {
    background: #fdf0f0;
    color: #d94b4b;
}

/* ============================================================
   Footer
   ============================================================ */
.cd-footer {
    flex-shrink: 0;
    border-top: 1px solid #ddd3f0;
    padding: 14px 16px 18px;
    background: #fff;
}

/* Shipping */
.cd-shipping__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9e90bc;
    margin-bottom: 8px;
}
.cd-shipping__options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.cd-ship-option {
    flex: 1;
    min-width: 80px;
    border: 1.5px solid #ede8f8;
    border-radius: 10px;
    padding: 7px 10px;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    display: block;
}
.cd-ship-option input[type="radio"] { display: none; }
.cd-ship-option--selected {
    border-color: #5c3e98;
    background: #f5f1fc;
    box-shadow: 0 3px 10px rgba(92, 62, 152, 0.12);
}
.cd-ship-option__name {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #2f2a33;
}
.cd-ship-option__price {
    display: block;
    font-size: 11px;
    color: #9e90bc;
    margin-top: 2px;
}
.cd-ship-option--selected .cd-ship-option__price { color: #5c3e98; }

/* Coupon */
.cd-coupon {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}
.cd-coupon__input {
    flex: 1;
    font-size: 13px;
    padding: 9px 12px;
    border: 1.5px solid #ede8f8;
    border-radius: 9px;
    background: #fdfcff;
    color: #2f2a33;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.cd-coupon__input::placeholder { color: #c4b8e0; font-size: 12px; }
.cd-coupon__input:focus {
    outline: none;
    border-color: #5c3e98;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(92, 62, 152, 0.10);
}
.cd-coupon__input--success { border-color: #5e9b64 !important; }
.cd-coupon__input--error   { border-color: #d94b4b !important; }

.cd-coupon__btn {
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 700;
    background: #f5f1fc;
    border: 1.5px solid #ddd3f0;
    border-radius: 9px;
    cursor: pointer;
    color: #5c3e98;
    transition: background 0.15s, border-color 0.15s;
}
.cd-coupon__btn:hover {
    background: #ede8f8;
    border-color: #5c3e98;
}

.cd-coupon__msg {
    font-size: 12px;
    min-height: 18px;
    margin-bottom: 10px;
}
.cd-coupon__msg--success { color: #5e9b64; }
.cd-coupon__msg--error   { color: #d94b4b; }

/* Totals */
.cd-totals {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
    margin-bottom: 14px;
}
.cd-totals td { padding: 4px 0; }
.cd-totals td:last-child {
    text-align: right;
    font-weight: 600;
    color: #5a4d7a;
}
.cd-totals__label { color: #9e90bc; }
.cd-totals__value--discount { color: #5e9b64; font-weight: 700; }

.cd-totals__total-row td {
    font-size: 16px;
    font-weight: 800;
    padding-top: 12px;
    color: #2f2a33;
    border-top: 2px dashed #ddd3f0;
}
.cd-totals__total-row td:last-child { color: #5c3e98; }

/* Buttons */
.cd-btn {
    display: block;
    width: 100%;
    padding: 13px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s, box-shadow 0.15s;
    letter-spacing: 0.02em;
    border: none;
}
.cd-btn--primary {
    background: linear-gradient(135deg, #5c3e98 0%, #3d2470 100%);
    color: #fff;
    box-shadow: 0 6px 20px rgba(92, 62, 152, 0.35);
}
.cd-btn--primary:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(92, 62, 152, 0.42);
}
.cd-btn--primary:active { transform: translateY(0); }

.cd-btn--outline {
    background: #fff;
    color: #5c3e98;
    border: 1.5px solid #ddd3f0;
    margin-top: 8px;
}
.cd-btn--outline:hover {
    background: #f5f1fc;
    border-color: #5c3e98;
    color: #4b327d;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
    .cd-drawer { width: 100vw; }
}

/* ============================================================
   Content wrapper
   ============================================================ */
#cd-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* ── Skeleton loader ── */
.cd-skeleton {
    padding: 14px;
    display: none;
}
.cd-skeleton__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.cd-skeleton__bar {
    background: #ede8f8;
    border-radius: 6px;
    animation: cd-shimmer 1.4s infinite linear;
}
.cd-skeleton__bar--title { width: 120px; height: 18px; }
.cd-skeleton__bar--close { width: 28px; height: 28px; border-radius: 50%; }

.cd-skeleton__item {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    background: #fff;
    border-radius: 14px;
    padding: 12px;
    border: 1px solid #ede8f8;
}
.cd-skeleton__item::before {
    content: '';
    width: 72px;
    height: 84px;
    border-radius: 10px;
    background: #ede8f8;
    flex-shrink: 0;
    animation: cd-shimmer 1.4s infinite linear;
}
.cd-skeleton__item::after {
    content: '';
    flex: 1;
    height: 84px;
    border-radius: 8px;
    background: #ede8f8;
    animation: cd-shimmer 1.4s infinite linear;
}
.cd-skeleton__item--short::after { height: 56px; }

@keyframes cd-shimmer {
    0%   { opacity: 1; }
    50%  { opacity: 0.45; }
    100% { opacity: 1; }
}

/* ── Remove animation ── */
.cd-item--removing {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
