/* ─────────────────────────────────────────────────────────────
   Zabure Pay — Checkout Page
   Mobile-first, brand-aware, Stripe-style
   ───────────────────────────────────────────────────────────── */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:        #6C47FF;
  --brand-light:  #ede9ff;
  --brand-dark:   #4f2de0;
  --success:      #16a34a;
  --success-bg:   #dcfce7;
  --error:        #dc2626;
  --error-bg:     #fee2e2;
  --warning:      #d97706;
  --gray-50:      #f9fafb;
  --gray-100:     #f3f4f6;
  --gray-200:     #e5e7eb;
  --gray-400:     #9ca3af;
  --gray-500:     #6b7280;
  --gray-700:     #374151;
  --gray-900:     #111827;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.06);
  --transition:   0.18s ease;
}

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-50);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* ── Page scaffold ────────────────────────────────────────── */
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.checkout-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
}

.checkout-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
}

/* ── Header band ──────────────────────────────────────────── */
.checkout-header {
  padding: 28px 28px 20px;
  text-align: center;
  border-bottom: 1px solid var(--gray-100);
}

.merchant-logo {
  width: auto;
  max-height: 64px;
  max-width: 160px;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: 8px;
}

.merchant-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.link-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  margin-top: 4px;
}

.link-description {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 6px;
}

/* ── Amount block ─────────────────────────────────────────── */
.amount-block {
  padding: 20px 28px 0;
}

.amount-fixed {
  text-align: center;
  font-size: 32px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.02em;
}

.amount-fixed .currency-code {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-500);
  margin-right: 4px;
  letter-spacing: 0;
}

/* Customer-defined amount input */
.amount-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.amount-input-wrap:focus-within { border-color: var(--brand); }
.amount-input-wrap.error        { border-color: var(--error); }

.amount-prefix {
  padding: 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-500);
  flex-shrink: 0;
}

.amount-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  padding: 14px 12px 14px 0;
  outline: none;
  min-width: 0;
}

.amount-hint {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 6px;
}
.amount-hint.error-msg { color: var(--error); }

/* ── Payment methods ──────────────────────────────────────── */
.methods-section {
  padding: 20px 28px 0;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.method-list { display: flex; flex-direction: column; gap: 8px; }

.method-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.method-card:hover  { border-color: var(--gray-400); }
.method-card.active { border-color: var(--brand); background: var(--brand-light); }

.method-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  flex-shrink: 0;
  position: relative;
  transition: border-color var(--transition);
}
.method-card.active .method-dot { border-color: var(--brand); }
.method-card.active .method-dot::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--brand);
}

.method-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}
.method-icon.mtn    { background: transparent; }
.method-icon.airtel { background: transparent; }
.method-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.method-icon.card    { background: #1a1a2e; color: #fff; }
.method-icon.bank    { background: #0ea5e9; color: #fff; }
.method-icon.ussd    { background: var(--gray-700); color: #fff; }

.method-info { flex: 1; min-width: 0; }
.method-name  { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.method-sub   { font-size: 12px; color: var(--gray-500); margin-top: 1px; }

/* ── Form fields ──────────────────────────────────────────── */
.form-section { padding: 20px 28px 0; }

.field + .field { margin-top: 12px; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.field-label .required { color: var(--error); margin-left: 2px; }

.field-input {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px; /* prevents iOS zoom */
  color: var(--gray-900);
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.field-input:focus { border-color: var(--brand); background: #fff; }
.field-input.error { border-color: var(--error); }
.field-input::placeholder { color: var(--gray-400); }

.field-error {
  font-size: 12px;
  color: var(--error);
  margin-top: 4px;
  display: none;
}
.field-error.visible { display: block; }

.fields-row { display: flex; gap: 10px; }
.fields-row .field { flex: 1; }

/* ── Phone row (dial code + local number) ─────────────────── */
.phone-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.dial-code-select {
  flex-shrink: 0;
  padding: 13px 10px;
  font-size: 15px;
  color: var(--gray-900);
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}
.dial-code-select:focus { border-color: var(--brand); background-color: #fff; }
.phone-local { flex: 1; }

/* ── CTA button ───────────────────────────────────────────── */
.cta-section { padding: 24px 28px 0; }

.btn-pay {
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition), transform 0.1s ease, opacity var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-pay:hover:not(:disabled)  { background: var(--brand-dark); }
.btn-pay:active:not(:disabled) { transform: scale(.99); }
.btn-pay:disabled { opacity: .6; cursor: not-allowed; }

/* ── Footer ───────────────────────────────────────────────── */
.checkout-footer {
  padding: 16px 28px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
}
.checkout-footer .lock-icon { font-size: 14px; }
.checkout-footer a { color: var(--gray-400); text-decoration: none; display: inline-flex; align-items: center; }
.checkout-footer a:hover { color: var(--gray-700); }
.checkout-footer .zabure-logo { height: 20px; width: auto; vertical-align: middle; opacity: 0.6; transition: opacity var(--transition); }
.checkout-footer a:hover .zabure-logo { opacity: 1; }

/* ── Processing state ─────────────────────────────────────── */
.processing-view {
  padding: 40px 28px;
  text-align: center;
}

.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner--lg { width: 48px; height: 48px; border-width: 4px; }

@keyframes spin { to { transform: rotate(360deg); } }

.processing-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  margin-top: 16px;
}

.processing-sub {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 8px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.countdown-bar-wrap {
  margin: 20px 0 8px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 9999px;
  overflow: hidden;
}
.countdown-bar {
  height: 100%;
  background: var(--brand);
  border-radius: 9999px;
  transition: width 1s linear;
}

.countdown-text {
  font-size: 12px;
  color: var(--gray-400);
}

/* ── Success state ────────────────────────────────────────── */
.result-view {
  padding: 48px 28px 36px;
  text-align: center;
}

.result-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 20px;
}
.result-icon.success { background: var(--success-bg); }
.result-icon.failed  { background: var(--error-bg); }
.result-icon.invalid { background: var(--gray-100); }

.result-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 8px;
}
.result-sub {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 20px;
  line-height: 1.6;
}

.ref-badge {
  display: inline-block;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  font-family: 'Courier New', monospace;
  letter-spacing: .04em;
  margin-bottom: 24px;
  word-break: break-all;
}

.redirect-countdown {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 12px;
}

.progress-ring {
  margin: 0 auto 24px;
  position: relative;
  width: 80px;
  height: 80px;
}
.progress-ring svg { transform: rotate(-90deg); }
.progress-ring__circle {
  stroke-dasharray: 201;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

/* ── Retry button ─────────────────────────────────────────── */
.btn-retry {
  background: transparent;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  width: 100%;
  margin-top: 8px;
}
.btn-retry:hover { border-color: var(--brand); color: var(--brand); }

/* ── Alert inline ─────────────────────────────────────────── */
.inline-alert {
  margin: 16px 28px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.inline-alert.error   { background: var(--error-bg);   color: var(--error); }
.inline-alert.success { background: var(--success-bg); color: var(--success); }

/* ── Divider ──────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--gray-100);
  margin: 20px 0 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (min-width: 540px) {
  .checkout-page { padding: 48px 24px 64px; }
  .link-title    { font-size: 22px; }
}
