/*
 * Checkout de links de pago.
 *
 * Sin fuentes ni hojas externas a propósito: la CSP de la distribución es
 * `default-src 'self'` y cualquier recurso de terceros quedaría bloqueado. La
 * única excepción son las imágenes (logo del comercio por https, QR en data:).
 *
 * `--brand` la pisa app.js con el color del comercio cuando el link trae uno.
 */

:root {
  --brand: #1f6feb;
  --brand-ink: #ffffff;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #14171f;
  --muted: #6b7280;
  --line: #e5e7eb;
  --ok: #0f9d58;
  --err: #d93025;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --card: #161b22;
    --ink: #e6edf3;
    --muted: #9198a1;
    --line: #30363d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .04);
}

.pane { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.hidden { display: none !important; }

/* ── Comercio ── */

.merchant {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
}
.merchant.compact { padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.merchant p { margin: 0; }
.logo { border-radius: 10px; object-fit: contain; background: #fff; }
.merchant-name { margin: 0; font-size: 18px; font-weight: 600; }

/* ── Monto ── */

.amount-box { width: 100%; padding: 16px 0; border-bottom: 1px solid var(--line); }
.amount { margin: 4px 0 0; font-size: 34px; font-weight: 700; letter-spacing: -.5px; }
.amount.small { font-size: 22px; margin: 0; }

.amount-input {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg);
}
.amount-input:focus-within { border-color: var(--brand); }
.amount-input .currency { font-size: 26px; font-weight: 700; color: var(--muted); }
#amount-field {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  color: inherit; font: 700 30px/1.2 inherit; letter-spacing: -.5px;
}

.description { width: 100%; text-align: left; margin: 0; }

/* ── Métodos ── */

.label { width: 100%; margin: 4px 0 0; text-align: left; font-weight: 600; font-size: 14px; }
.methods { display: grid; gap: 10px; width: 100%; }

.method {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: inherit;
  font: inherit; font-weight: 600; text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .05s;
}
.method:hover:not(:disabled) { border-color: var(--brand); }
.method:active:not(:disabled) { transform: scale(.99); }
.method:disabled { opacity: .5; cursor: progress; }
.method .sub { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.method .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--brand); }

/* ── Pago en curso ── */

.qr-box { padding: 12px; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
#qr-image { display: block; width: 240px; height: 240px; image-rendering: pixelated; }

.key-box { width: 100%; }
.key-row {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  padding: 12px; border: 1px dashed var(--line); border-radius: 10px;
  background: var(--bg);
}
.key-row code { flex: 1; font-size: 18px; font-weight: 700; word-break: break-all; }
.copy {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px;
  background: var(--card); color: inherit; font: 600 14px inherit; cursor: pointer;
}

.instructions { margin: 0; font-size: 15px; }
.waiting { display: flex; align-items: center; gap: 8px; }

/* ── Resultado ── */

.mark { width: 56px; height: 56px; border-radius: 50%; background: var(--muted); position: relative; }
.mark.ok { background: var(--ok); }
.mark::after {
  content: ""; position: absolute; inset: 0;
  background: no-repeat center / 26px 26px
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M4 12l6 6L20 6'/></svg>");
}
.mark:not(.ok)::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'><path d='M12 6v8M12 18h.01'/></svg>");
}

.title { margin: 0; font-size: 20px; font-weight: 600; }

.btn-link {
  display: block; width: 100%; margin-top: 6px; padding: 14px;
  border-radius: 12px; background: var(--brand); color: var(--brand-ink);
  font-weight: 600; text-decoration: none;
}

/* ── Avisos ── */

.error, .notice {
  width: 100%; margin: 0; padding: 10px 12px; border-radius: 10px;
  font-size: 14px; text-align: left;
}
.error { background: rgba(217, 48, 37, .1); color: var(--err); }
.notice { background: rgba(31, 111, 235, .1); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.expiry { width: 100%; margin: 0; }

.footer { display: flex; align-items: center; gap: 10px; }
.badge {
  padding: 3px 8px; border-radius: 999px;
  background: #fde68a; color: #78350f;
  font-size: 12px; font-weight: 700;
}

/* ── Spinner ── */

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
.spinner.small { width: 16px; height: 16px; border-width: 2px; }

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

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .method { transition: none; }
}
