/* ============================================================================
   Checkout Drawer / Bottom-Sheet — 2026 Premium Ecommerce
   ----------------------------------------------------------------------------
   - Mobile  : bottom-sheet modal (slides up, ~94dvh, sticky CTA).
   - Desktop : right side drawer (520px, slides in from the right).
   - Dark luxury + glassmorphism + 24px radius + smooth motion + full RTL.
   Self-contained: does NOT rely on Tailwind arbitrary-value classes being
   present in the compiled main.css (those are not purged reliably).
   ========================================================================== */

:root {
  --co-radius: 24px;
  --co-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --co-glass: hsla(222, 22%, 6%, 0.92);
  --co-border: hsla(0, 0%, 100%, 0.08);
  --co-border-soft: hsla(0, 0%, 100%, 0.06);
}

/* ── Backdrop ─────────────────────────────────────────────────────────────── */
.co-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: radial-gradient(120% 120% at 50% 0%, hsla(222, 30%, 4%, 0.6), hsla(222, 40%, 2%, 0.82));
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  opacity: 1;
  transition: opacity 0.35s ease;
}
.co-backdrop.hidden {
  display: none;
}

/* ── Modal wrapper (positioning container) ────────────────────────────────── */
/* Mirror of the original: items-end (mobile bottom-sheet) → sm:items-center
   (desktop centered) with sm:p-6. */
.co-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-end;      /* mobile: dock to bottom */
  justify-content: center;
  pointer-events: none;
}
.co-modal.open {
  display: flex;
  pointer-events: auto;
}

/* ── Panel ────────────────────────────────────────────────────────────────── */
.co-panel {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 94dvh;
  max-height: 94vh; /* fallback */
  pointer-events: auto;
  overflow: hidden;
  border: 1px solid var(--co-border);
  border-bottom: none;
  border-radius: var(--co-radius) var(--co-radius) 0 0; /* mobile: rounded top only */
  background: var(--co-glass);
  -webkit-backdrop-filter: blur(40px) saturate(160%);
  backdrop-filter: blur(40px) saturate(160%);
  box-shadow: 0 -20px 80px hsla(0, 0%, 0%, 0.5);
  /* Subtle top sheen for the luxury glass feel */
  background-image:
    linear-gradient(180deg, hsla(0, 0%, 100%, 0.04), hsla(0, 0%, 100%, 0) 120px),
    radial-gradient(120% 60% at 100% 0%, hsl(var(--brand) / 0.06), transparent 60%);
  /* Enter/exit motion = slide up (both mobile + desktop, like the original) */
  transform: translateY(100%);
  opacity: 1;
  transition: transform 0.42s var(--co-ease), opacity 0.3s ease;
}
.co-modal.open .co-panel {
  transform: translateY(0);
}

/* ── Drag handle (mobile only) ────────────────────────────────────────────── */
.co-handle {
  display: flex;
  justify-content: center;
  padding: 0.625rem 0 0.25rem;
  flex-shrink: 0;
}
.co-handle span {
  width: 2.5rem;
  height: 0.25rem;
  border-radius: 999px;
  background: hsla(0, 0%, 100%, 0.2);
}

/* ── Close button (absolute, top-left — mirrors the original) ─────────────── */
.co-close {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--co-border);
  background: hsla(0, 0%, 100%, 0.04);
  color: hsla(0, 0%, 100%, 0.4);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.co-close:hover {
  background: hsla(0, 0%, 100%, 0.09);
  color: #fff;
}
.co-close:active {
  transform: scale(0.92);
}

/* ── Form + scroll region ─────────────────────────────────────────────────── */
.co-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding-top: 1rem; /* matches original pt-4 */
}
.co-scroll {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: hsla(0, 0%, 100%, 0.15) transparent;
  padding: 1.5rem 1.25rem;
}
.co-scroll::-webkit-scrollbar {
  width: 6px;
}
.co-scroll::-webkit-scrollbar-thumb {
  background: hsla(0, 0%, 100%, 0.12);
  border-radius: 999px;
}

.co-section {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}
.co-section-title {
  font-size: 0.8125rem;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: hsla(0, 0%, 100%, 0.45);
}
.co-delivery {
  gap: 1rem;
}
.co-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.co-empty {
  border-radius: 1rem;
  border: 1px solid var(--co-border-soft);
  background: hsla(0, 0%, 100%, 0.02);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: hsla(0, 0%, 100%, 0.3);
}

/* ── Product card ─────────────────────────────────────────────────────────── */
.co-item {
  display: flex;
  gap: 1rem;                 /* RTL: image (first child) sits on the right */
  border-radius: 1.125rem;
  border: 1px solid var(--co-border-soft);
  background: hsla(0, 0%, 100%, 0.02);
  padding: 0.875rem;
}
.co-item-img {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 0.875rem;
  border: 1px solid var(--co-border-soft);
  background: hsla(0, 0%, 100%, 0.03);
  align-self: center;
}
.co-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.co-item-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.625rem;
  min-width: 0;
  flex: 1;
}
.co-item-name {
  font-size: 0.875rem;
  font-weight: 900;
  line-height: 1.35;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.co-item-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
}
.co-qty-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  border-radius: 0.75rem;
  border: 1px solid var(--co-border);
  background: hsla(0, 0%, 100%, 0.03);
  padding: 0.1875rem;
}
.co-qty-btn {
  display: flex;
  width: 1.875rem;
  height: 1.875rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  color: hsla(0, 0%, 100%, 0.6);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.co-qty-btn:hover {
  background: hsla(0, 0%, 100%, 0.07);
  color: #fff;
}
.co-qty-btn:active {
  transform: scale(0.88);
}
.co-qty-num {
  min-width: 1.875rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: lining-nums tabular-nums;
}
.co-item-side {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.co-item-price {
  font-size: 1rem;
  font-weight: 900;
  color: hsl(var(--brand));
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}
.co-remove-btn {
  display: flex;
  width: 1.875rem;
  height: 1.875rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  border: 1px solid var(--co-border-soft);
  color: hsla(0, 0%, 100%, 0.3);
  background: transparent;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.co-remove-btn:hover {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: hsl(var(--danger));
}

/* ── Trust cards ──────────────────────────────────────────────────────────── */
.co-trust-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
}
.co-trust-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border-radius: 1rem;
  border: 1px solid var(--co-border-soft);
  background: hsla(0, 0%, 100%, 0.02);
  padding: 1rem 0.75rem;
  text-align: center;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.co-trust-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
.co-trust-label {
  font-size: 0.6875rem;
  font-weight: 900;
  color: hsla(0, 0%, 100%, 0.5);
  line-height: 1.25;
}
/* Icon tints — colored icon only (no badge box), like the original */
.co-tint-gold .co-trust-icon    { color: #facc15; }
.co-tint-blue .co-trust-icon    { color: #60a5fa; }
.co-tint-emerald .co-trust-icon { color: #34d399; }
.co-tint-violet .co-trust-icon  { color: #a78bfa; }

/* ── Floating-label fields ────────────────────────────────────────────────── */
.co-field {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 1rem;
  border: 1px solid var(--co-border);
  background: hsla(0, 0%, 100%, 0.03);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
  /* Safety guard: the field can NEVER collapse/shrink in any state
     (error, focus, autofill). !important beats any stale/combined CSS that a
     caching plugin may still be serving. No overflow:hidden so text is never clipped. */
  min-height: 3.625rem !important;
  height: auto !important;
  overflow: visible !important;
}
.co-field:focus-within {
  border-color: hsl(var(--brand) / 0.5);
  background: hsla(0, 0%, 100%, 0.05);
  box-shadow: 0 0 0 1px hsl(var(--brand) / 0.2);
}
.co-field.co-error {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.04);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2);
}
.co-field-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: hsla(0, 0%, 100%, 0.25);
  pointer-events: none;
  display: flex;
  align-items: center;
  z-index: 1;
}
.co-field-icon--top {
  top: 1.1rem;
  transform: none;
}
.co-input {
  display: block;
  width: 100%;
  background: transparent;
  /* Constant padding (never shifts) so the field height is stable in every
     state, including error — prevents the field from collapsing. */
  padding: 1.25rem 3rem 1.25rem 1.25rem;
  font-size: 1rem;
  line-height: 1.375rem;
  font-weight: 700;
  color: #fff;
  outline: none;
  border: none;
  font-family: inherit;
  /* Hard floor on height so the input box itself can never collapse. */
  min-height: 1.375rem !important;
  box-sizing: content-box;
}
.co-input::placeholder {
  color: transparent;
}
/* Phone is typed RTL (from the right) — identical behaviour to the name field. */
.co-input--phone {
  text-align: right;
  direction: rtl;
  font-variant-numeric: lining-nums tabular-nums;
}
/* Textarea variant */
.co-field--area {
  align-items: stretch;
}
.co-input--area {
  resize: none;
  min-height: 5.5rem;
  padding-top: 1.75rem;
  line-height: 1.5;
}

/* Floating label */
.co-label {
  position: absolute;
  right: 3rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9375rem;
  font-weight: 700;
  color: hsla(0, 0%, 100%, 0.35);
  pointer-events: none;
  transition: top 0.2s ease, transform 0.2s ease, font-size 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}
.co-field--area .co-label {
  top: 1.1rem;
  transform: none;
}
/* Float up on focus or when filled (CSS-only, mirrors Next.js peer logic) */
.co-input:focus ~ .co-label,
.co-input:not(:placeholder-shown) ~ .co-label {
  top: 0.7rem;
  transform: translateY(0);
  font-size: 0.6875rem;
}
.co-field--area .co-input:focus ~ .co-label,
.co-field--area .co-input:not(:placeholder-shown) ~ .co-label {
  top: 0.55rem;
}
.co-input:focus ~ .co-label {
  color: hsl(var(--brand) / 0.85);
}
.co-input:not(:placeholder-shown):not(:focus) ~ .co-label {
  color: hsla(0, 0%, 100%, 0.5);
}

/* ── Field errors ─────────────────────────────────────────────────────────── */
.co-error {
  display: none;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.5rem;
  margin-right: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: hsl(var(--danger));
}
.co-error.is-visible {
  display: flex;
}

/* ── Payment summary ──────────────────────────────────────────────────────── */
.co-payment-box {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  border-radius: 1.125rem;
  border: 1px solid var(--co-border-soft);
  background: hsla(0, 0%, 100%, 0.02);
  padding: 1.25rem;
}
.co-payment-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.co-payment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
}
.co-payment-row dt {
  font-weight: 700;
  color: hsla(0, 0%, 100%, 0.45);
}
.co-payment-row dd {
  font-weight: 900;
  color: #fff;
}
.co-free {
  color: #34d399 !important;
}
.co-payment-total-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-top: 1px solid var(--co-border-soft);
  padding-top: 0.875rem;
}
.co-payment-total-row dt {
  font-size: 1rem;
  font-weight: 900;
  color: #fff;
}
.co-total {
  font-size: 1.875rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}
.co-total-cur {
  margin-right: 0.25rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: hsla(0, 0%, 100%, 0.4);
}
.co-num {
  font-variant-numeric: lining-nums tabular-nums;
}

/* ── General error box ────────────────────────────────────────────────────── */
.co-form-error {
  display: none;
  align-items: flex-start;
  gap: 0.75rem;
  border-radius: 1rem;
  border: 1px solid hsl(var(--danger) / 0.2);
  background: hsl(var(--danger) / 0.1);
  padding: 1rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: hsl(var(--danger));
}
.co-form-error.is-visible {
  display: flex;
}

/* ── Sticky footer / CTA ──────────────────────────────────────────────────── */
.co-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--co-border-soft);
  background: hsl(var(--canvas-dark) / 0.96);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  padding: 1rem 1.25rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}
.co-submit-btn {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  overflow: hidden;
  border-radius: 1rem;
  padding: 1.125rem;
  font-size: 1.0625rem;
  font-weight: 900;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(234, 179, 8, 0.32);
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.2s;
}
.co-submit-btn:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.005);
  box-shadow: 0 16px 48px rgba(234, 179, 8, 0.4);
}
.co-submit-btn:active:not(:disabled) {
  transform: scale(0.98);
}
.co-submit-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.co-submit-label {
  font-variant-numeric: lining-nums tabular-nums;
}
.co-security-note {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: hsla(0, 0%, 100%, 0.28);
}

/* ════════════════════════════════════════════════════════════════════════════
   DESKTOP — centered modal (max-width 700px), like the original CheckoutModal.
   ════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 640px) {
  .co-modal {
    align-items: center;       /* center vertically */
    justify-content: center;
    padding: 1.5rem;           /* sm:p-6 */
  }
  .co-panel {
    width: 100%;
    max-width: 700px;          /* sm:max-w-[700px] */
    max-height: 90vh;          /* sm:max-h-[90vh] */
    border: 1px solid var(--co-border);
    border-radius: var(--co-radius); /* sm:rounded-[24px] — all corners */
    box-shadow: 0 40px 120px hsla(0, 0%, 0%, 0.65);
  }
  /* No drag handle on desktop */
  .co-handle {
    display: none;
  }
  .co-close {
    left: 1.5rem;
    top: 1.5rem;
  }
  .co-scroll {
    padding: 1.5rem 2rem;      /* sm:px-8 */
  }
  .co-footer {
    padding-left: 2rem;
    padding-right: 2rem;
  }
  /* 4-across trust cards on desktop (original sm:grid-cols-4) */
  .co-trust-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .co-trust-item {
    flex-direction: column;
    text-align: center;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .co-panel,
  .co-backdrop {
    transition: none;
  }
}

/* ── Product page: bundle anchor scroll highlight (unchanged behaviour) ────── */
#bundle-selector-anchor.bundle-anchor-highlight {
  box-shadow: 0 0 0 2px hsl(var(--brand)), 0 0 0 4px hsl(var(--canvas));
  border-radius: 1rem;
}
.co-sticky-suppressed {
  opacity: 0 !important;
  pointer-events: none !important;
}
