:root {
  --green: #009c3b;       /* verde bandeira */
  --green-dark: #006b27;
  --yellow: #ffdf00;      /* amarelo bandeira */
  --yellow-soft: #fff3a3;
  --blue: #002776;        /* azul bandeira */
  --bg: #fffdf6;
  --paper: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #c0392b;
  --warning-bg: #fff8e1;
  --warning-border: #f59e0b;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow-x: hidden;

  background:
    /* manchas suaves nas cores do Brasil */
    radial-gradient(circle at 12% 18%, rgba(0, 156, 59, 0.18) 0%, transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(255, 223, 0, 0.35) 0%, transparent 42%),
    radial-gradient(circle at 8% 92%, rgba(255, 223, 0, 0.28) 0%, transparent 40%),
    radial-gradient(circle at 92% 88%, rgba(0, 39, 118, 0.12) 0%, transparent 45%),
    linear-gradient(180deg, #fffbe0 0%, #fffdf6 60%, #f1ffe4 100%);
  background-attachment: fixed;
}

/* Bolas de futebol decorativas espalhadas no fundo */
body::before,
body::after {
  content: '';
  position: fixed;
  background-image: url('/img/ball.png');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.10;
  pointer-events: none;
  z-index: 0;
  animation: float 9s ease-in-out infinite alternate;
}

body::before {
  width: 280px;
  height: 280px;
  top: -60px;
  left: -60px;
  transform: rotate(-12deg);
}

body::after {
  width: 340px;
  height: 340px;
  bottom: -90px;
  right: -90px;
  transform: rotate(18deg);
  animation-delay: -3s;
  animation-duration: 11s;
}

@keyframes float {
  from {
    transform: translateY(0) rotate(-12deg);
  }
  to {
    transform: translateY(-14px) rotate(-6deg);
  }
}

/* Bolinhas extras (via spans no HTML) para enriquecer o fundo */
.deco-ball {
  position: fixed;
  background-image: url('/img/ball.png');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}

.deco-ball.b1 { width: 110px; height: 110px; top: 35%;  left: 4%;  transform: rotate(20deg); }
.deco-ball.b2 { width: 90px;  height: 90px;  top: 70%;  left: 92%; transform: rotate(-30deg); }
.deco-ball.b3 { width: 130px; height: 130px; top: 12%;  left: 80%; transform: rotate(40deg); opacity: 0.07; }

/* Faixa diagonal verde/amarela suave atrás do conteúdo (estilo "torcida") */
.bg-stripes {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0,
    transparent 80px,
    rgba(0, 156, 59, 0.025) 80px,
    rgba(0, 156, 59, 0.025) 160px,
    transparent 160px,
    transparent 240px,
    rgba(255, 223, 0, 0.05) 240px,
    rgba(255, 223, 0, 0.05) 320px
  );
}

h1 {
  margin: 0 0 8px;
  color: var(--green-dark);
  text-align: center;
}

.logo-wrap {
  margin: 0 0 12px;
  display: flex;
  justify-content: center;
}

.logo-link {
  display: block;
  text-align: center;
  margin-bottom: 12px;
}

.logo {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.logo-landing {
  width: 320px;
  max-width: 80%;
}

.logo-card {
  width: 180px;
  max-width: 60%;
}

.landing {
  text-align: center;
  max-width: 520px;
  position: relative;
  z-index: 1;
}
.landing .lead {
  font-size: 18px;
}

.card {
  width: 100%;
  max-width: 520px;
  background: var(--paper);
  border: 1px solid #ece7d0;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(0, 39, 118, 0.10),
              0 4px 14px rgba(0, 0, 0, 0.06);
  text-align: center;
  position: relative;
  z-index: 1;
  /* Faixinha sutil verde-amarela-azul no topo (cores da bandeira) */
  background-image: linear-gradient(
    90deg,
    var(--green) 0%,
    var(--green) 33%,
    var(--yellow) 33%,
    var(--yellow) 66%,
    var(--blue) 66%,
    var(--blue) 100%
  );
  background-repeat: no-repeat;
  background-size: 100% 5px;
  background-position: top;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0 0;
  padding: 0;
  text-indent: 0;
  text-align: left;
  line-height: 1.4;
}

/* Override defensivo: dentro do formulário, hint SEMPRE alinhado à esquerda
   e ocupando 100% da largura (sem max-width centralizando). */
form .hint,
form p.hint {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  text-align: left;
  width: 100%;
}

.welcome {
  font-size: 16px;
  margin: 4px 0 16px;
}

.warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: #7a4d00;
  padding: 14px 16px;
  border-radius: 10px;
  margin: 18px 0 22px;
  font-size: 14.5px;
  text-align: left;
}

.warning-title {
  margin: 0;
  line-height: 1.45;
}

.warning-subtitle {
  margin: 12px 0 6px;
  font-size: 14px;
  color: #5b3a00;
  border-top: 1px dashed rgba(122, 77, 0, 0.35);
  padding-top: 10px;
}

.tips-list {
  margin: 0;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #5b3a00;
}

.tips-list li {
  margin-bottom: 3px;
}

.tips-list li::marker {
  color: var(--warning-border);
}

.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 14px;
  text-align: left;
}

input[type='file'] {
  width: 100%;
  padding: 10px;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  background: #fafafa;
}

input[type='text'] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
}

input[type='text']:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 156, 59, 0.15);
}

.required {
  color: var(--danger);
}

.row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.row .col {
  flex: 1;
  min-width: 0;
}

.row .field-label {
  margin-top: 8px;
}

@media (max-width: 520px) {
  .row {
    flex-direction: column;
  }
}

button,
.btn-secondary {
  margin-top: 18px;
  width: 100%;
  background: var(--green);
  color: #fff;
  border: 0;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover,
.btn-secondary:hover {
  background: var(--green-dark);
}
button:active,
.btn-secondary:active {
  transform: translateY(1px);
}
button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.error {
  color: var(--danger);
  margin-top: 12px;
  font-size: 14px;
  text-align: center;
}

.error-title {
  color: var(--danger);
}
.success-title {
  color: var(--green-dark);
}

.hidden {
  display: none !important;
}

#preview-wrap,
.result-wrap {
  margin-top: 16px;
  text-align: center;
}
#preview,
#result-img {
  max-width: 100%;
  max-height: 420px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--green);
  border-right-color: var(--yellow);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 18px auto;
  display: block;
}

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

.state {
  text-align: center;
}
.state.hidden {
  display: none;
}
/* Apenas parágrafos DIRETOS de .state ficam centralizados (loading, done, etc).
   Os <p class="hint"> dentro do <form> NÃO devem cair nessa regra. */
.state > p {
  margin: 8px auto;
  max-width: 380px;
}
.state h2 {
  margin: 8px 0;
}

form {
  text-align: left;
}

/* ============================================
   ÁREA DO CLIENTE
   ============================================ */
.card-wide {
  max-width: 680px;
}

.text-link {
  color: var(--green);
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
  font-size: 14px;
}
.text-link:hover {
  color: var(--green-dark);
}

.purchases-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
  text-align: left;
}

.purchase-card {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid #ece7d0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.purchase-preview {
  width: 88px;
  height: 110px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f0;
  border: 1px solid #ece7d0;
}

.purchase-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.purchase-preview--placeholder {
  font-size: 36px;
  background: linear-gradient(135deg, #fff8d6 0%, #f1ffe4 100%);
}

.purchase-info {
  min-width: 0;
}

.purchase-name {
  margin: 0 0 4px;
  font-size: 15.5px;
  color: var(--green-dark);
}

.purchase-meta {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.purchase-action .btn-secondary,
.purchase-action button {
  margin-top: 0;
  width: auto;
  white-space: nowrap;
  padding: 10px 16px;
  font-size: 14px;
}

.btn-disabled {
  background: #d1d5db;
  color: #6b7280;
  border: 0;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  cursor: not-allowed;
  font-family: inherit;
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge.ok {
  background: #e8f5ec;
  color: var(--green-dark);
}

.badge.warn {
  background: #fff3cd;
  color: #8a5a00;
}

.badge.muted {
  background: #f3f4f6;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--muted);
}

/* mobile: card empilhado */
@media (max-width: 520px) {
  .purchase-card {
    grid-template-columns: 70px 1fr;
    grid-template-rows: auto auto;
  }
  .purchase-preview {
    width: 70px;
    height: 88px;
    grid-row: span 2;
  }
  .purchase-action {
    grid-column: 2;
  }
  .purchase-action .btn-secondary,
  .purchase-action button,
  .btn-disabled {
    width: 100%;
  }
}

/* ============================================
   AUTO-REDIRECT COUNTDOWN (página /app)
   ============================================ */
.redirect-bar {
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid #d3e8d8;
  background: #ebf6ee;
  border-radius: 10px;
  color: var(--green-dark);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.redirect-bar .cancel-link {
  background: transparent;
  border: 0;
  color: var(--green-dark);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13.5px;
}
