@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1F1F1F;
  --ink-soft: #4b5563;
  --muted: #9aa1b1;
  --line: #e6e8ee;
  --line-strong: #c7ccd6;
  --navy: #1F1F1F;          /* fundo do botao primario / pill do metodo ativo */
  --navy-hover: #111111;
  --ring: rgba(31,31,31,.14);
  /* superficies/cores que antes eram literais — agora viram tema (light = identico ao original) */
  --field-bg: #ffffff;      /* inputs */
  --method-bg: #ffffff;     /* botoes de metodo (pix/cartao) inativos */
  --method-ink: #1F1F1F;    /* texto do metodo inativo */
  --accent-ink: #ffffff;    /* texto/icone sobre superficie --navy (botao, pill ativo) */
  --summary-bg: #fcfcfd;    /* caixa do resumo do pedido */
  --modal-bg: #ffffff;      /* modais */
  --qr-bg: #ffffff;         /* fundo do QR do PIX — fica BRANCO sempre (scanneabilidade) */
  --good: #1a8a4f;          /* desconto/cupom/sucesso */
  --good-bg: #f0faf5;       /* fundo do chip de cupom */
  --bad: #c0392b;           /* erro */
  --ls: -0.02em;
  --shadow-card: 0 4px 6px -2px rgba(16,24,40,.04), 0 24px 48px -12px rgba(16,24,40,.12);
  --shadow-field: 0 1px 2px rgba(16,24,40,.06);
}

/* ===== DARK MODE (toggle global no console admin -> /api/checkout-config theme) ===== */
[data-theme="dark"] {
  /* cinzas NEUTROS (R=G=B): sem nenhum tom azulado — preto/grafite puro */
  --bg: #0a0a0a;
  --card: #141414;
  --ink: #f0f0f0;
  --ink-soft: #b0b0b0;
  --muted: #767676;
  --line: #262626;
  --line-strong: #3d3d3d;
  --navy: #f5f5f5;          /* botao primario INVERTE: claro com texto escuro */
  --navy-hover: #e4e4e4;
  --ring: rgba(245,245,245,.16);
  --field-bg: #1c1c1c;
  --method-bg: #1c1c1c;
  --method-ink: #f0f0f0;
  --accent-ink: #141414;    /* texto escuro sobre o botao claro */
  --summary-bg: #101010;
  --modal-bg: #191919;
  --qr-bg: #ffffff;         /* mantem branco mesmo no dark */
  --good: #3ad17f;
  --good-bg: #11241a;
  --bad: #ff6f61;
  --shadow-card: 0 4px 6px -2px rgba(0,0,0,.4), 0 24px 48px -12px rgba(0,0,0,.6);
  --shadow-field: 0 1px 2px rgba(0,0,0,.4);
}
/* hairline pra dar definicao ao card sobre o fundo escuro (so no dark) */
[data-theme="dark"] .checkout { border: 1px solid var(--line); }
[data-theme="dark"] .modal-box { border: 1px solid var(--line); }
html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, sans-serif;
  letter-spacing: var(--ls);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 56px 20px;
}

.checkout {
  width: 100%; max-width: 468px;
  background: var(--card);
  border-radius: 22px;
  padding: 38px 18px 26px;
  box-shadow: var(--shadow-card);
  /* entrada: fade-in deslizando de baixo p/ cima. 'backwards' aplica o estado inicial
     antes de comecar (sem flash) e NAO deixa transform residual no fim (senao quebraria
     o position:fixed do modal). */
  animation: bm-enter .6s cubic-bezier(.16,1,.3,1) backwards;
}
@keyframes bm-enter {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* fade-out ao redirecionar p/ a pagina de Obrigado */
.bm-leaving { opacity: 0 !important; transition: opacity .5s ease; }
@media (prefers-reduced-motion: reduce) {
  .checkout { animation: none; }
  .bm-leaving { transition: none; }
}

/* test banner */
.test-banner {
  background: #fff3cd; color: #856404;
  border: 1px solid #ffc107; border-radius: 8px;
  padding: 8px 12px; font-size: 13px; font-weight: 600;
  text-align: center; margin-bottom: 16px;
}

/* header */
.co-head { display: flex; align-items: center; gap: 16px; }
.co-head .product { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; box-shadow: var(--shadow-field); }
.co-head-info { display: flex; flex-direction: column; line-height: 1.2; }
.plan-name { font-size: 30px; font-weight: 700; letter-spacing: -0.04em; }
.plan-price { font-size: 13px; color: var(--muted); margin-top: 4px; }
.slogan { font-size: 13px; font-weight: 400; letter-spacing: -0.01em; line-height: 1.5; margin: 10px 0 22px; color: var(--muted); }

/* fields */
.lbl { display: block; font-size: 14px; font-weight: 500; color: var(--ink-soft); margin: 16px 0 7px; }
.field {
  width: 100%; background: var(--field-bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 14px; font-family: inherit; letter-spacing: inherit; font-size: 14.5px;
  box-shadow: var(--shadow-field); transition: border-color .15s, box-shadow .15s;
}
.field::placeholder { color: var(--muted); }
.field:focus { outline: none; border-color: var(--line-strong); box-shadow: 0 0 0 4px var(--ring); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* payment methods */
.methods { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 22px 0 6px; }
.method {
  display: flex; align-items: center; justify-content: center; gap: 10px; position: relative;
  background: var(--method-bg); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 16px; font-size: 16px; font-weight: 500; color: var(--method-ink);
  box-shadow: var(--shadow-field); transition: .15s; cursor: pointer;
}
.method svg { width: 22px; height: 22px; }
.method:hover { border-color: var(--line-strong); }
.method.active { background: var(--navy); border-color: var(--navy); color: var(--accent-ink); }
.method:active { transform: scale(.985); }

/* card accordion */
#card-fields {
  max-height: 0; opacity: 0; overflow: hidden;
  transform: translateY(-4px);
  transition: max-height .38s cubic-bezier(.4,0,.2,1), opacity .3s ease, transform .3s ease;
}
#card-fields.open { max-height: 460px; opacity: 1; transform: translateY(0); }

/* summary */
.summary { margin-top: 26px; border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 8px; background: var(--summary-bg); }
.summary h3 { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.srow { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.srow:last-child { border-bottom: none; }
.srow.minor { font-size: 13.5px; color: var(--ink-soft); }
.srow.total { font-weight: 700; font-size: 16px; }
.srow .old { color: var(--muted); text-decoration: line-through; }
.srow .disc { color: var(--good); }
.coupon-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--good-bg); border: 1.5px dashed var(--good);
  border-radius: 6px; padding: 2px 7px 2px 6px;
  font-size: 11.5px; font-weight: 700; color: var(--good);
  letter-spacing: 0.05em; text-transform: uppercase;
}

.coupon-box { margin-top: 22px; }
.coupon-box .lbl { margin-top: 0; }
.coupon-box .lbl span { color: var(--muted); font-weight: 400; }
.coupon-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.coupon-entry .field { text-transform: uppercase; }
.coupon-apply {
  border: 1px solid var(--line-strong); border-radius: 11px; padding: 0 17px;
  background: var(--field-bg); color: var(--ink); font: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer; box-shadow: var(--shadow-field);
}
.coupon-apply:hover { border-color: var(--ink-soft); }
.coupon-apply:disabled { opacity: .55; cursor: default; }
.coupon-message { min-height: 17px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.coupon-message.ok { color: var(--good); }
.coupon-message.err { color: var(--bad); }

#turnstile { margin-top: 16px; min-height: 0; }

/* pay button */
.pay-btn {
  width: 100%; margin-top: 24px; background: var(--navy); color: var(--accent-ink);
  border: none; border-radius: 12px; padding: 16px; font-family: inherit;
  font-size: 16.5px; font-weight: 600; letter-spacing: var(--ls); cursor: pointer;
  transition: background .15s; box-shadow: 0 6px 16px -6px rgba(31,31,31,.5);
}
.pay-btn:hover { background: var(--navy-hover); }
.pay-btn:disabled { opacity: .6; cursor: default; }
.co-msg { font-size: 14px; text-align: center; margin-top: 10px; min-height: 0; color: var(--ink-soft); }
.co-msg.ok { color: var(--good); }
.co-msg.err { color: var(--bad); }

/* footer */
.co-foot {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 30px; color: var(--muted); font-size: 12px;
  white-space: nowrap;
}
.co-foot a { color: var(--muted); text-decoration: none; }
.co-foot a:hover { color: var(--ink-soft); }
.co-foot .powered { display: inline-flex; align-items: center; gap: 5px; }
.co-foot .stripe-logo { height: 14px; width: auto; color: #737373; }
.co-foot .sep { opacity: .5; }
.foot-wordmark { height: 11px; width: auto; vertical-align: middle; }

/* modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-box {
  background: var(--modal-bg); border-radius: 20px; padding: 32px 28px 24px;
  max-width: 300px; width: 100%; text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
}
.modal-emojis { font-size: 34px; margin-bottom: 12px; line-height: 1; }
.modal-msg { font-size: 15px; color: var(--ink); line-height: 1.55; margin-bottom: 22px; }
.modal-btn {
  background: var(--navy); color: var(--accent-ink); border: none; border-radius: 10px;
  padding: 11px 34px; font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.modal-btn:hover { background: var(--navy-hover); }

/* 3DS: desafio do banco (iframe do emissor dentro do #challengeContainer) */
.tds-box { max-width: 520px; padding: 18px 14px 14px; }
.tds-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
#challengeContainer iframe { max-width: 100%; border: 0; border-radius: 10px; background: #fff; }

@media (max-width: 520px) {
  body { padding: 16px 3.5px; }
  .checkout { padding: 24px 18px 24px; border-radius: 16px; }
}

/* ===== PIX (Pagar.me) — area que substitui o form depois de gerar o QR ===== */
.pix-area { text-align: center; padding-top: 6px; }
.pix-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.pix-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }
.pix-qr {
  width: 220px; height: 220px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: var(--qr-bg);
}
.pix-qr canvas, .pix-qr img { display: block; border-radius: 6px; }
.pix-copy-row { display: flex; gap: 8px; align-items: stretch; }
.pix-copy-row .field { flex: 1; font-size: 12px; }
.pix-copy-btn {
  background: var(--navy); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 0 18px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.pix-copy-btn:hover { background: var(--navy-hover); }
.pix-status {
  margin-top: 16px; font-size: 14px; font-weight: 600; color: var(--ink-soft);
}
.pix-status.ok { color: var(--good); }
.pix-status.err { color: var(--bad); }

/* Apple Pay (botao nativo do Safari). So aparece com a aba Apple Pay ativa. */
.applepay-btn {
  display: none; width: 100%; height: 52px; margin-top: 18px; border: 0; border-radius: 12px; cursor: pointer;
  -webkit-appearance: -apple-pay-button; -apple-pay-button-type: buy; -apple-pay-button-style: black;
}
html[data-theme="dark"] .applepay-btn { -apple-pay-button-style: white; }
.applepay-btn.show { display: inline-block; }

/* parcelas: select no mesmo visual dos inputs, com seta propria (a nativa some no appearance:none) */
select.field {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 38px;
  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 d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
