/* Cart Drawer v3.1 — Clean, Flat Design + Max Z-Index */

.cd-overlay, .cd-drawer, .cd-drawer * { box-sizing: border-box; }

body.cd-open {
  overflow: hidden;
  padding-right: var(--cd-scroll-width, 0px);
}
.cd-overlay, .cd-drawer, .cd-drawer *,
.cd-overlay, .cd-drawer button, .cd-drawer a,
.cd-cart-icon-trigger {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* ── Canonical Cart Icon Element (DESKTOP DEFAULT) ── */
.cd-cart-icon-trigger {
  position: relative;
  background: transparent;
  border: none;
  padding: 8px; /* Desktop padding */
  cursor: pointer;
  color: #ffffff;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}
.cd-cart-icon-trigger:hover { opacity: 0.85; }
.cd-cart-icon-trigger svg { width: 24px; height: 24px; display: block; } /* Desktop icon size */

.cd-cart-badge {
  position: absolute;
  top: 0; right: 0;
  background: #014DFA;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  height: 18px; min-width: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1;
}

/* ── Overlay ── */
.cd-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.42);
  z-index: 2147483645;
  opacity: 0;
  transition: opacity .22s ease;
}
.cd-overlay.cd-show { display: block; opacity: 1; }

/* ════════════════════════════
   DESKTOP — right drawer
════════════════════════════ */
.cd-drawer {
  position: fixed;
  top: 0; right: 0;
  width: 420px; max-width: 100vw;
  height: 100dvh; height: 100vh;
  background: #fff;
  z-index: 2147483646;
  display: flex; flex-direction: column;
  transform: translateX(110%);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
  border-left: 1px solid #e5e7eb;
  will-change: transform;
}
.cd-drawer.cd-show { transform: translateX(0); }

.cd-handle { display: none; touch-action: pan-y; cursor: grab; }
.cd-handle-pill { width: 40px; height: 4px; background: #d1d5db; border-radius: 4px; }

/* ── Header ── */
.cd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 26px 28px 22px; flex-shrink: 0;
}
.cd-title { font-size: 22px; font-weight: 700; color: #000; letter-spacing: -.3px; line-height: 1; }
.cd-close {
  background: none; border: none; font-size: 20px; color: #9ca3af; cursor: pointer; padding: 0;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s, color .14s; line-height: 1;
}
.cd-close:hover { background: #f3f4f6; color: #111; }
.cd-divider { height: 1px; background: #f3f4f6; flex-shrink: 0; }

/* ── Scrollable body ── */
.cd-body {
  flex: 1; overflow-y: auto; padding: 28px 28px 8px;
  scrollbar-width: thin; scrollbar-color: #e5e7eb transparent;
}
.cd-body::-webkit-scrollbar { width: 3px; }
.cd-body::-webkit-scrollbar-track { background: transparent; }
.cd-body::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 3px; }

/* ── Empty state ── */
.cd-empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 52px 20px 32px; gap: 14px; text-align: center;
}
.cd-empty-icon { width: 120px; height: 120px; }
.cd-empty h3 { font-size: 18px; font-weight: 700; color: #111; margin: 0; line-height: 1.3; }
.cd-empty p  { font-size: 14px; color: #9ca3af; margin: 0; }
.cd-empty-links { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.cd-empty-tag {
  font-size: 13px; font-weight: 500; color: #374151;
  border: 1.5px solid #e5e7eb; border-radius: 20px;
  padding: 7px 16px; text-decoration: none;
  transition: border-color .14s, color .14s, background .14s;
}
.cd-empty-tag:hover { border-color: #014DFA; color: #014DFA; background: #e6eeff; }

/* ════════════════════════════
   CART ITEM
════════════════════════════ */
.cd-item { display: flex; align-items: flex-start; gap: 18px; transition: opacity .16s; }
.cd-item.cd-removing { opacity: 0; }

.cd-img {
  width: 110px; height: 110px; min-width: 110px;
  background: #f3f4f6; border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.cd-img img { width: 100%; height: 100%; object-fit: contain; image-rendering: crisp-edges; }

.cd-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding-top: 2px; }
.cd-info-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cd-name { font-size: 16px; font-weight: 700; color: #000; margin: 0; line-height: 1.35; flex: 1; min-width: 0; }
.cd-item-meta { font-size: 12px; color: #6b7280; margin: 0; }

.cd-del {
  background: none; border: none; cursor: pointer; color: #9ca3af; padding: 2px; flex-shrink: 0;
  transition: color .14s, transform .15s; line-height: 0; display: flex;
}
.cd-del:hover { color: #ef4444; transform: scale(1.15); }
.cd-del svg { width: 18px; height: 18px; display: block; }

.cd-row { display: flex; align-items: center; gap: 14px; }
.cd-qty { display: flex; align-items: center; border: 1px solid #e5e7eb; border-radius: 6px; overflow: hidden; height: 38px; }
.cd-q-btn {
  background: none; border: none; width: 36px; height: 100%; font-size: 18px; line-height: 1;
  cursor: pointer; color: #374151; display: flex; align-items: center; justify-content: center;
  transition: background .12s, transform .1s; flex-shrink: 0;
}
.cd-q-btn:hover { background: #f3f4f6; }
.cd-q-btn:active { transform: scale(0.85); }
.cd-q-num { width: 36px; text-align: center; font-size: 15px; font-weight: 700; color: #000; user-select: none; }

.cd-price { font-size: 16px; font-weight: 700; color: #000; display: flex; align-items: center; gap: 5px; }
.cd-times { font-size: 14px; font-weight: 400; color: #6b7280; }

.cd-sep { border: none; border-top: 1px dashed #e5e7eb; margin: 20px 0; }

/* ── Footer ── */
.cd-foot {
  padding: 16px 28px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; flex-shrink: 0;
  border-top: 1px solid #f3f4f6;
}

/* Primary Order Button */
.cd-checkout-btn {
  width: 100%;
  background: #014DFA;
  color: #fff; border: none; border-radius: 6px;
  padding: 18px 24px; font-size: 17px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: opacity .16s, transform .16s; line-height: 1; position: relative; overflow: hidden;
}
.cd-checkout-btn:hover  { opacity: .92; transform: translateY(-1px); }
.cd-checkout-btn:active { opacity: .85; transform: translateY(0); }
.cd-checkout-btn::after {
  content: ''; position: absolute; inset: 0; background: rgba(255,255,255,0.25);
  opacity: 0; border-radius: inherit; transition: opacity 0.3s;
}
.cd-checkout-btn:active::after { opacity: 1; transition: none; }
.cd-btn-dot   { margin: 0 8px; opacity: .7; font-size: 20px; line-height: 1; }
.cd-btn-total { font-weight: 700; }

/* ════════════════════════════
   MOBILE — bottom sheet ≤640px
════════════════════════════ */
@media (max-width: 640px) {
  /* Shrink icon on mobile only */
  .cd-cart-icon-trigger { padding: 6px; }
  .cd-cart-icon-trigger svg { width: 20px; height: 20px; }

  /* Mobile Drawer sizing */
  .cd-drawer {
    top: auto; bottom: 0; right: 0; left: 0; width: 100%; height: 60vh; max-height: 60vh;
    border-radius: 20px 20px 0 0; transform: translateY(102%);
    border-left: none; border-top: 1px solid #e5e7eb;
  }
  .cd-drawer.cd-show { transform: translateY(0); }
  .cd-handle { display: flex; justify-content: center; align-items: center; padding: 10px 0 4px; flex-shrink: 0; cursor: grab; touch-action: none; }
  .cd-head { padding: 6px 18px 12px; }
  .cd-title { font-size: 17px; }
  .cd-close { width: 40px; height: 40px; }
  .cd-body { padding: 12px 16px 4px; }
  .cd-item { padding: 10px 0; }
  .cd-img { width: 72px; height: 72px; min-width: 72px; }
  .cd-name, .cd-price { font-size: 13px; }
  .cd-qty { height: 32px; }
  .cd-q-btn { width: 30px; font-size: 15px; }
  .cd-q-num { width: 26px; font-size: 13px; }
  .cd-foot { padding: 10px 16px 18px; }
  .cd-checkout-btn { padding: 13px 20px; font-size: 15px; border-radius: 12px; }
  .cd-divider { margin: 0; }
}

/* ══ ANIMATIONS ══ */
.cd-item-removing { animation: cd-slide-out 0.35s cubic-bezier(0.4, 0, 0.6, 1) forwards; pointer-events: none; }
@keyframes cd-slide-out { 0% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(80px); } }

.cd-item { animation: cd-slide-in 0.3s cubic-bezier(0.2, 0, 0.2, 1) both; }
@keyframes cd-slide-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

.cd-num-pop { animation: cd-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both; display: inline-block; }
@keyframes cd-pop { 0% { transform: scale(1); } 50% { transform: scale(1.45); color: #014DFA; } 100% { transform: scale(1); } }

.cd-btn-pulse { animation: cd-pulse 0.25s ease both; }
@keyframes cd-pulse { 0% { transform: scale(1); } 50% { transform: scale(0.82); } 100% { transform: scale(1); } }

.cd-show .cd-item:nth-child(1) { animation-delay: 0.03s; }
.cd-show .cd-item:nth-child(2) { animation-delay: 0.08s; }
.cd-show .cd-item:nth-child(3) { animation-delay: 0.13s; }
.cd-show .cd-item:nth-child(4) { animation-delay: 0.18s; }
.cd-show .cd-item:nth-child(5) { animation-delay: 0.22s; }