/* ============================================================
   Capture Pipeline — Checkout overlay
   3-step modal: account credentials → billing info → submitting.
   Submission POSTs to /api/checkout, then redirects to Alunta's
   hosted checkout. Hijacks any /signup link click globally.
   ============================================================ */

.cp-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.cp-modal[hidden] { display: none; }

.cp-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 7, 14, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: cp-modal-fade .25s ease;
}
@keyframes cp-modal-fade { from { opacity: 0; } to { opacity: 1; } }

.cp-modal__panel {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 36px 32px 32px;
  animation: cp-modal-pop .3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cp-modal-pop {
  from { opacity: 0; transform: scale(.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.cp-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,0.05);
  color: var(--cp-text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, color .2s, transform .2s;
}
.cp-modal__close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--cp-text-primary);
  transform: scale(1.05);
}

/* ── Step indicator ──────────────────────────────────────── */
.cp-checkout__steps {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
}
.cp-checkout__step {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.10);
  transition: background .35s, flex .35s, box-shadow .35s;
}
.cp-checkout__step.active {
  flex: 2;
  background: var(--cp-gradient-primary);
  box-shadow: 0 0 10px rgba(124,92,252,0.6);
}

/* ── Header ──────────────────────────────────────────────── */
.cp-checkout__title {
  font-family: var(--cp-font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--cp-text-primary);
  margin: 0 0 6px;
  letter-spacing: -0.015em;
}
.cp-checkout__subtitle {
  font-size: 14px;
  color: var(--cp-text-secondary);
  margin: 0 0 24px;
}
.cp-checkout__subtitle strong {
  color: var(--cp-accent-light);
  font-weight: 600;
}

/* ── Form fields ─────────────────────────────────────────── */
#cp-checkout-form fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.cp-checkout-label {
  display: block;
  margin-bottom: 14px;
}
.cp-checkout-label > span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--cp-text-secondary);
  margin-bottom: 6px;
}
#cp-checkout-form input[type="text"],
#cp-checkout-form input[type="email"],
#cp-checkout-form input[type="password"],
#cp-checkout-form input[type="tel"],
#cp-checkout-form select {
  width: 100%;
  padding: 13px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  color: var(--cp-text-primary);
  font-size: 15px;
  font-family: var(--cp-font-body);
  transition: border-color .2s, background .2s, box-shadow .2s;
}
#cp-checkout-form input:focus,
#cp-checkout-form select:focus {
  outline: none;
  background: rgba(124,92,252,0.08);
  border-color: rgba(124,92,252,0.5);
  box-shadow: 0 0 16px rgba(124,92,252,0.15);
}
#cp-checkout-form select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23a0a0be' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.cp-checkout__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Customer-type toggle (private / business) ────────────── */
.cp-checkout__customer-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--cp-radius-pill);
  background: rgba(12,10,28,0.55);
  border: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 18px;
}
.cp-checkout__customer-toggle button {
  flex: 1;
  padding: 9px 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--cp-text-secondary);
  font-family: var(--cp-font-body);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--cp-radius-pill);
  cursor: pointer;
  transition: color .2s, background .2s, border-color .2s;
}
.cp-checkout__customer-toggle button:hover { color: var(--cp-text-primary); }
.cp-checkout__customer-toggle button.active {
  color: var(--cp-text-primary);
  background: linear-gradient(135deg, rgba(124,92,252,0.18), rgba(92,108,252,0.12));
  border-color: rgba(192,132,252,0.35);
  box-shadow: 0 0 12px rgba(124,92,252,0.20), inset 0 1px 0 rgba(255,255,255,0.08);
}

/* ── Action buttons row ──────────────────────────────────── */
.cp-checkout__buttons {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}
.cp-checkout__buttons .cp-btn-primary,
.cp-checkout__buttons .cp-btn-secondary {
  flex: 1;
  min-width: 0;
}
.cp-checkout__buttons .cp-btn-primary span,
.cp-checkout__buttons .cp-btn-secondary span { display: inline-block; }

/* ── Inline error banner ─────────────────────────────────── */
.cp-checkout__error {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(240, 96, 96, 0.10);
  border: 1px solid rgba(240, 96, 96, 0.30);
  color: #f8a0a0;
  font-size: 13px;
  font-family: var(--cp-font-body);
}
.cp-checkout__error[hidden] { display: none; }

/* ── Loading state (step 3) ──────────────────────────────── */
.cp-checkout__loading {
  text-align: center;
  padding: 48px 0 32px;
}
.cp-checkout__loading p {
  color: var(--cp-text-secondary);
  font-size: 14px;
  margin: 16px 0 0;
}
.cp-checkout__loading .cp-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(124,92,252,0.20);
  border-top-color: var(--cp-accent);
  border-radius: 50%;
  margin: 0 auto;
  animation: cp-spin .8s linear infinite;
}
@keyframes cp-spin { to { transform: rotate(360deg); } }

/* ── Mobile tweaks ───────────────────────────────────────── */
@media (max-width: 540px) {
  .cp-modal__panel { padding: 28px 22px 24px; border-radius: 28px; }
  .cp-checkout__row { grid-template-columns: 1fr; }
}

/* ── Mode-toggle link (create ↔ login) ──────────────────── */
.cp-checkout__mode-toggle {
  margin: 16px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--cp-text-muted);
  font-family: var(--cp-font-body);
}
.cp-checkout__mode-toggle a {
  color: var(--cp-accent-light);
  text-decoration: none;
  font-weight: 600;
  margin-left: 4px;
  transition: color .2s;
}
.cp-checkout__mode-toggle a:hover { color: var(--cp-text-primary); }

/* ── Confirm step: plan summary card + interval picker ───── */
.cp-checkout__summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  margin: 0 0 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(124,92,252,0.10) 0%, rgba(92,108,252,0.06) 100%);
  border: 1px solid rgba(192,132,252,0.25);
}
.cp-checkout__summary-name {
  font-family: var(--cp-font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--cp-text-primary);
  letter-spacing: -0.015em;
}
.cp-checkout__summary-desc {
  font-size: 13px;
  color: var(--cp-text-secondary);
  margin-top: 4px;
}
.cp-checkout__summary-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--cp-font-heading);
  white-space: nowrap;
}
.cp-checkout__summary-price [data-summary-currency] {
  font-size: 14px;
  font-weight: 600;
  color: var(--cp-text-secondary);
}
.cp-checkout__summary-price [data-summary-amount] {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.2px;
  color: var(--cp-text-primary);
}
.cp-checkout__summary-period {
  font-size: 13px;
  font-weight: 500;
  color: var(--cp-text-secondary);
}

.cp-checkout__intervals {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.cp-checkout__intervals-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--cp-text-secondary);
  margin-bottom: 4px;
}
.cp-interval-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: var(--cp-text-secondary);
  font-family: var(--cp-font-body);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color .2s, background .2s, color .2s, box-shadow .2s;
}
.cp-interval-btn:hover {
  background: rgba(124,92,252,0.06);
  border-color: rgba(124,92,252,0.30);
  color: var(--cp-text-primary);
}
.cp-interval-btn.active {
  color: var(--cp-text-primary);
  background: linear-gradient(135deg, rgba(124,92,252,0.18), rgba(92,108,252,0.10));
  border-color: rgba(192,132,252,0.45);
  box-shadow: 0 0 14px rgba(124,92,252,0.20), inset 0 1px 0 rgba(255,255,255,0.08);
}
.cp-interval-btn__label {
  font-weight: 600;
}
.cp-interval-btn__price {
  font-family: var(--cp-font-heading);
  font-weight: 700;
  font-size: 15px;
}
.cp-interval-btn__save {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(52,211,153,0.15);
  color: #34d399;
  font-size: 11px;
  font-weight: 600;
}

/* ── Manage-subscription view (existing-subscriber flow) ────── */
.cp-checkout__manage-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  margin: 0 0 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(52,211,153,0.10) 0%, rgba(124,92,252,0.06) 100%);
  border: 1px solid rgba(52,211,153,0.25);
}
.cp-checkout__manage-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(52,211,153,0.18);
  color: #34d399;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.cp-checkout__manage-title {
  font-family: var(--cp-font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--cp-text-primary);
  margin-bottom: 4px;
}
.cp-checkout__manage-current {
  font-size: 13px;
  color: var(--cp-text-secondary);
}
.cp-checkout__manage-current strong { color: var(--cp-accent-light); }

.cp-checkout__manage-target-label {
  font-family: var(--cp-font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--cp-text-primary);
  margin: 0 0 12px;
}
