/* ============================================================
   CART DRAWER  — right-side slide-in panel + inline checkout
   Works on all screen sizes (incl. mobile ≤480px)
   ============================================================ */

/* ── Font override for the drawer: tighter, sharper ── */
.cd-root * {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    box-sizing: border-box;
}

/* ── Backdrop ── */
.cd-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .46);
    z-index: 199000;
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
}
.cd-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* ── Drawer panel ── */
.cd-root {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 100vw);
    background: #f6f8f6;
    z-index: 199100;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    box-shadow: -6px 0 40px rgba(0,0,0,.18);
    overflow: hidden;
}
.cd-root.is-open {
    transform: translateX(0);
}

/* ── Header bar ── */
.cd-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 13px;
    background: #1a5c38;
    color: #fff;
    flex-shrink: 0;
}
.cd-header-title {
    flex: 1;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .01em;
}
.cd-header-badge {
    background: #fff;
    color: #1a5c38;
    font-size: .7rem;
    font-weight: 800;
    border-radius: 99px;
    padding: 1px 7px;
    min-width: 20px;
    text-align: center;
}
.cd-close-btn {
    background: rgba(255,255,255,.18);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background .15s;
    flex-shrink: 0;
}
.cd-close-btn:hover { background: rgba(255,255,255,.30); }

/* ── Step container (slides between steps) ── */
.cd-steps {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
}
.cd-step {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 14px 0;
    display: flex;
    flex-direction: column;
    transition: transform .3s cubic-bezier(.4, 0, .2, 1), opacity .25s ease;
    will-change: transform, opacity;
    -webkit-overflow-scrolling: touch;
}
/* Step 1 is default visible */
.cd-step-cart    { transform: translateX(0);    opacity: 1; }
.cd-step-checkout { transform: translateX(100%); opacity: 0; pointer-events: none; }

/* Active states */
.cd-steps.show-checkout .cd-step-cart {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}
.cd-steps.show-checkout .cd-step-checkout {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Scrollbar ── */
.cd-step::-webkit-scrollbar { width: 4px; }
.cd-step::-webkit-scrollbar-thumb { background: #cdd6ce; border-radius: 99px; }

/* ── Empty state ── */
.cd-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    text-align: center;
}
.cd-empty-icon { font-size: 3rem; }
.cd-empty h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a3326;
}
.cd-empty p {
    margin: 0;
    font-size: .85rem;
    color: #6b7a6e;
}
.cd-empty-shop-btn {
    display: inline-block;
    margin-top: 6px;
    padding: 10px 22px;
    background: #1f704c;
    color: #fff;
    border-radius: 10px;
    font-size: .88rem;
    font-weight: 700;
    text-decoration: none;
    transition: background .15s;
}
.cd-empty-shop-btn:hover { background: #175e3e; }

/* ── Item card ── */
.cd-item {
    display: grid;
    grid-template-columns: 62px 1fr;
    gap: 10px;
    background: #fff;
    border: 1px solid #e4ece6;
    border-radius: 12px;
    padding: 11px 11px 11px 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.cd-item-img {
    width: 62px;
    height: 62px;
    border-radius: 8px;
    object-fit: contain;
    background: #f2f5f2;
    padding: 4px;
    display: block;
}
.cd-item-img-ph {
    width: 62px;
    height: 62px;
    border-radius: 8px;
    background: #edf3ee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    flex-shrink: 0;
}
.cd-item-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.cd-item-brand {
    font-size: .68rem;
    color: #7a8f7c;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
}
.cd-item-name {
    font-size: .85rem;
    font-weight: 600;
    color: #182b1e;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cd-item-prices {
    display: flex;
    align-items: baseline;
    gap: 7px;
}
.cd-item-price {
    font-size: .9rem;
    font-weight: 800;
    color: #14432b;
}
.cd-item-mrp {
    font-size: .76rem;
    color: #a0a8a1;
    text-decoration: line-through;
}
.cd-item-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 5px;
}

/* Qty control inside drawer */
.cd-qty-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid #1f704c;
    border-radius: 7px;
    overflow: hidden;
    height: 30px;
}
.cd-qty-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: #1f704c;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .13s;
    line-height: 1;
}
.cd-qty-btn:hover { background: #175e3e; }
.cd-qty-val {
    min-width: 30px;
    text-align: center;
    font-weight: 700;
    font-size: .85rem;
    color: #182b1e;
    background: #fff;
    line-height: 28px;
}
.cd-del-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 4px;
    color: #b0b8b0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color .13s, background .13s;
}
.cd-del-btn:hover { color: #d32f2f; background: #fde8e8; }

/* ── Summary block ── */
.cd-summary {
    background: #fff;
    border: 1px solid #e4ece6;
    border-radius: 12px;
    padding: 13px 14px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.cd-summary-title {
    font-size: .82rem;
    font-weight: 700;
    color: #1a3326;
    margin-bottom: 10px;
}
.cd-sum-row {
    display: flex;
    justify-content: space-between;
    font-size: .82rem;
    color: #374137;
    margin-bottom: 7px;
}
.cd-sum-row:last-child { margin-bottom: 0; }
.cd-sum-divider {
    border: none;
    border-top: 1px solid #edf1ed;
    margin: 8px 0;
}
.cd-sum-savings {
    background: #f0fdf4;
    border-radius: 7px;
    padding: 7px 12px;
    text-align: center;
    font-size: .8rem;
    font-weight: 700;
    color: #16a34a;
    margin: 6px 0 4px;
}
.cd-sum-ship {
    text-align: center;
    font-size: .76rem;
    font-weight: 600;
    color: #4f7060;
    margin-top: 5px;
}

/* ── Return policy strip ── */
.cd-return-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #111;
    color: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.cd-return-icon { font-size: 1.6rem; flex-shrink: 0; }
.cd-return-text { font-size: .74rem; line-height: 1.45; }
.cd-return-title { font-size: .8rem; font-weight: 700; color: #ffd700; margin-bottom: 3px; }
.cd-return-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}
.cd-return-pill {
    font-size: .7rem;
    background: rgba(255,255,255,.12);
    border-radius: 99px;
    padding: 2px 8px;
}
.cd-return-pill::before { content: '✓ '; color: #4ade80; font-weight: 700; }

/* ── Sticky footer for cart step ── */
.cd-foot {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #e4ece6;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.cd-foot-price { flex: 1; }
.cd-foot-price-lbl {
    font-size: .68rem;
    color: #6b7a6e;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.cd-foot-price-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: #14432b;
}
.cd-checkout-btn {
    flex: 2;
    background: #1f704c;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 13px 16px;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
    text-align: center;
}
.cd-checkout-btn:hover { background: #175e3e; }

/* ── Checkout step ── */
.cd-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid #d1d9d2;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: .8rem;
    font-weight: 600;
    color: #374137;
    cursor: pointer;
    margin-bottom: 12px;
    flex-shrink: 0;
    transition: background .13s, border-color .13s;
}
.cd-back-btn:hover { background: #f0f4f0; border-color: #b0bcb1; }

.cd-checkout-title {
    font-size: .92rem;
    font-weight: 700;
    color: #14432b;
    margin: 0 0 12px;
    flex-shrink: 0;
}

/* Order mini-summary at top of checkout step */
.cd-order-mini {
    background: #fff;
    border: 1px solid #e4ece6;
    border-radius: 10px;
    padding: 10px 13px;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.cd-order-mini-row {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    color: #374137;
    padding: 4px 0;
    border-bottom: 1px solid #f0f4f0;
}
.cd-order-mini-row:last-child { border-bottom: none; }
.cd-order-mini-total {
    font-size: .9rem;
    font-weight: 800;
    color: #14432b;
}

/* Form fields */
.cd-form-label {
    display: block;
    font-size: .78rem;
    font-weight: 700;
    color: #2b4033;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.cd-form-label span {
    display: block;
    margin-bottom: 4px;
}
.cd-form-label input,
.cd-form-label select,
.cd-form-label textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1.5px solid #ced8cf;
    border-radius: 8px;
    font-size: .85rem;
    font-family: inherit;
    color: #182b1e;
    background: #fff;
    transition: border-color .15s;
    outline: none;
}
.cd-form-label input:focus,
.cd-form-label select:focus,
.cd-form-label textarea:focus {
    border-color: #1f704c;
}

.cd-place-btn {
    width: 100%;
    background: #1f704c;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-size: .92rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    margin-bottom: 20px;
    flex-shrink: 0;
    transition: background .15s;
}
.cd-place-btn:hover { background: #175e3e; }
.cd-place-btn:disabled { background: #8ab59e; cursor: not-allowed; }

/* ── Flash messages ── */
.cd-flash-ok, .cd-flash-err {
    border-radius: 9px;
    padding: 10px 13px;
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.cd-flash-ok  { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.cd-flash-err { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; }

/* ── Loading spinner inside drawer ── */
.cd-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    gap: 10px;
    color: #4f7060;
    font-size: .85rem;
}
.cd-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #c5d9cb;
    border-top-color: #1f704c;
    border-radius: 50%;
    animation: cd-spin .7s linear infinite;
}
@keyframes cd-spin { to { transform: rotate(360deg); } }

/* ── Mobile tweaks ── */
@media (max-width: 480px) {
    .cd-root {
        width: 100vw;
    }
    .cd-header { padding: 12px 14px 11px; }
    .cd-header-title { font-size: .88rem; }
    .cd-step { padding: 12px 12px 0; }
    .cd-item { grid-template-columns: 56px 1fr; gap: 8px; padding: 10px; }
    .cd-item-img, .cd-item-img-ph { width: 56px; height: 56px; }
    .cd-item-name { font-size: .82rem; }
    .cd-item-price { font-size: .85rem; }
    .cd-checkout-btn { font-size: .84rem; padding: 12px 10px; }
    .cd-foot-price-val { font-size: 1.05rem; }
}
