/* ============================================================
   Pagamento do produto — PIX
   Visual limpo, moderno, mobile-first (cara de gateway sério)
   ============================================================ */

:root {
  --pix-green: #00875a;
  --pix-green-dark: #006c48;
  --pix-green-light: #e6f4ee;
  --ink: #1a2b32;
  --ink-soft: #5a6b72;
  --line: #e4e9ec;
  --bg: #eef2f4;
  --white: #ffffff;
  --danger: #d93025;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(16, 42, 34, 0.12);
  --shadow-soft: 0 2px 10px rgba(16, 42, 34, 0.06);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -10%, #d9ede4 0%, transparent 60%),
    var(--bg);
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 16px 40px;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Card ---------------- */
.card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-top: 24px;
}

.card__header {
  background: linear-gradient(135deg, var(--pix-green) 0%, var(--pix-green-dark) 100%);
  color: var(--white);
  padding: 22px 22px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__badge {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  color: var(--white);
  flex-shrink: 0;
}

.brand__title {
  font-size: 1.18rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.secure-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

.secure-line__lock { flex-shrink: 0; }

/* ---------------- Botão instalar app (PWA) ----------------
   Discreto, no cabeçalho verde. Começa hidden (atributo no HTML);
   só aparece quando o beforeinstallprompt disparar (o JS remove o
   hidden). É independente das 3 telas (form/QR/sucesso). */
.install-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 14px 0 0;
  padding: 9px 14px;
  width: auto;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--white);
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.install-btn:hover {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.8);
}
.install-btn:active { transform: scale(0.98); }
.install-btn svg { flex-shrink: 0; }
/* respeita o atributo hidden mesmo com display inline-flex */
.install-btn[hidden] { display: none !important; }

/* ---------------- Troca de telas ----------------
   Só UMA tela visível por vez. is-hidden vence qualquer display
   de .card__body (inclusive o flex da tela de sucesso), garantindo
   que a tela de sucesso NUNCA apareça antes de o pagamento ser
   confirmado pelo polling. */
.is-hidden {
  display: none !important;
}

/* ---------------- Body ---------------- */
.card__body {
  padding: 24px 22px 8px;
}

.card__body--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 22px 40px;
}

/* ---------------- Campos ---------------- */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 7px;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: #f7f9fa;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.input-wrap:focus-within {
  border-color: var(--pix-green);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(0, 135, 90, 0.12);
}

.input-wrap--prefix .input-prefix {
  padding: 0 4px 0 14px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 1rem;
}

.input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  padding: 14px 14px;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--ink);
  width: 100%;
  min-width: 0;
}

.input-wrap--prefix input {
  padding-left: 4px;
}

.input-wrap input::placeholder {
  color: #a4b0b5;
}

/* estado de erro */
.field.has-error .input-wrap {
  border-color: var(--danger);
  background: #fdf3f2;
}
.field.has-error .input-wrap:focus-within {
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.12);
}

.error-msg {
  display: block;
  color: var(--danger);
  font-size: 0.78rem;
  margin-top: 6px;
  min-height: 0;
}
.field.has-error .error-msg {
  min-height: 1rem;
}

/* ---------------- Botões ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s, background 0.15s, opacity 0.15s;
  width: 100%;
  padding: 15px 16px;
}

.btn:active { transform: scale(0.99); }

.btn--primary {
  background: var(--pix-green);
  color: var(--white);
  margin-top: 6px;
  box-shadow: 0 6px 16px rgba(0, 135, 90, 0.28);
}
.btn--primary:hover { background: var(--pix-green-dark); }
.btn--primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  box-shadow: none;
}

/* spinner pequeno dentro do botão (estado "Gerando...") */
.btn__spinner {
  display: none;
  width: 17px;
  height: 17px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}
.btn.is-loading .btn__spinner {
  display: inline-block;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.btn--copy {
  width: auto;
  flex-shrink: 0;
  padding: 0 16px;
  background: var(--pix-green-light);
  color: var(--pix-green-dark);
  border: 1.5px solid #c9e6da;
}
.btn--copy:hover { background: #d7ece3; }
.btn--copy.is-copied {
  background: var(--pix-green);
  color: var(--white);
  border-color: var(--pix-green);
}

.btn--ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
  margin-top: 4px;
}
.btn--ghost:hover { background: #f7f9fa; }

.general-error {
  color: var(--danger);
  font-size: 0.85rem;
  text-align: center;
  margin: 12px 0 0;
  background: #fdf3f2;
  border: 1px solid #f5d2ce;
  border-radius: 10px;
  padding: 10px 12px;
}

/* ---------------- Resultado ---------------- */
.result-amount {
  text-align: center;
  margin-bottom: 18px;
}
.result-amount__label {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.result-amount__value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--pix-green-dark);
  letter-spacing: -0.02em;
}

.qr-box {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  width: 220px;
  height: 220px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-soft);
}
.qr-box__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

/* copia e cola */
.copypaste {
  margin-top: 18px;
  margin-bottom: 8px;
}
.copypaste__label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 7px;
}
.copypaste__row {
  display: flex;
  gap: 8px;
}
.copypaste__input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--line);
  background: #f7f9fa;
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 0.82rem;
  font-family: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
  color: var(--ink);
  text-overflow: ellipsis;
  outline: none;
}

/* ---------------- Sucesso / Pagamento aprovado ---------------- */
.success-check {
  margin-bottom: 6px;
}
.success-check__circle {
  stroke: var(--pix-green);
  stroke-dasharray: 226;
  stroke-dashoffset: 226;
  animation: draw-circle 0.6s ease-out forwards;
}
.success-check__tick {
  stroke: var(--pix-green);
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
  animation: draw-tick 0.35s 0.5s ease-out forwards;
}
@keyframes draw-circle {
  to { stroke-dashoffset: 0; }
}
@keyframes draw-tick {
  to { stroke-dashoffset: 0; }
}

.success-title {
  margin: 18px 0 4px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--pix-green-dark);
  letter-spacing: -0.01em;
}
.success-sub {
  margin: 0 0 4px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.success-amount {
  margin: 18px 0 22px;
  text-align: center;
}
.success-amount__label {
  display: block;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.success-amount__value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--pix-green-dark);
  letter-spacing: -0.02em;
}

.success-view .btn--primary,
#success-view .btn--primary {
  width: 100%;
}

/* ---------------- Rodapé ---------------- */
.card__footer {
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.trust {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.accepted {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.85;
}
.accepted__label {
  font-size: 0.74rem;
  color: #97a4aa;
}
.accepted__mp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.accepted__mp-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: #5a6b72;
}

/* ---------------- Responsivo ---------------- */
@media (max-width: 420px) {
  body { padding: 12px 10px 30px; }
  .card { margin-top: 8px; border-radius: 14px; }
  .brand__title { font-size: 1.08rem; }
  .qr-box { width: 200px; height: 200px; }
}

@media (min-width: 480px) {
  .card { margin-top: 40px; }
}
