*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

:root {
  --green: #009c3b;
  --green-dark: #007a2f;
  --yellow: #ffdf00;
  --yellow-dark: #e6c800;
  --blue: #002776;
  --blue-light: #1a3a8a;
  --red: #c0392b;
  --orange: #e67e22;
  --white: #ffffff;
  --bg: #f0f4f8;
  --card-shadow: 0 8px 32px rgba(0,0,0,0.18);
  --radius: 16px;
  --font-display: 'Oswald', sans-serif;
  --font-body: 'Inter', sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(160deg, var(--green) 0%, var(--blue) 100%);
  min-height: 100vh;
  color: var(--white);
  padding-bottom: 2rem;
}

/* ── Header ─────────────────────────────────────────────────────── */

.site-header {
  text-align: center;
  padding: 2rem 1.25rem 1.5rem;
}

.header-badge {
  display: inline-block;
  background: var(--yellow);
  color: var(--blue);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  padding: 0.3rem 1rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.site-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
  margin-bottom: 0.5rem;
}

.site-title .highlight {
  color: var(--yellow);
}

.price-tag {
  display: inline-block;
  background: var(--yellow);
  color: var(--blue);
  font-size: 1rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  margin-left: 0.3rem;
  vertical-align: middle;
}

.site-subtitle {
  font-size: 0.95rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

/* ── Container / Views ──────────────────────────────────────────── */

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* ── Histórico ───────────────────────────────────────────────────── */

#historico {
  margin-bottom: 1.75rem;
  text-align: center;
}

#historico-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.historico-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  width: 90px;
}

.historico-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  width: 100%;
}

.historico-nome {
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.historico-sub {
  font-size: 0.6rem;
  opacity: 0.7;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.historico-item .exemplo-thumb {
  cursor: pointer;
}

/* ── Exemplos ────────────────────────────────────────────────────── */

.exemplos {
  text-align: center;
  margin-bottom: 1.5rem;
}

.exemplos-label {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
  margin-bottom: 0.75rem;
}

.exemplos-grid {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.exemplo-thumb {
  width: 90px;
  height: 124px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  transition: transform 0.2s;
}

.exemplo-thumb:hover {
  transform: scale(1.06);
}

/* ── Formulário ─────────────────────────────────────────────────── */

#view-form {
  animation: fadeInUp 0.4s ease;
}

.photo-upload-area {
  margin-bottom: 1.25rem;
}

.photo-preview {
  background: rgba(255,255,255,0.12);
  border: 2.5px dashed rgba(255,255,255,0.5);
  border-radius: var(--radius);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.photo-preview:active {
  background: rgba(255,255,255,0.2);
}

.photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2rem;
}

.camera-icon {
  font-size: 3rem;
}

.upload-label {
  font-size: 0.95rem;
  text-align: center;
  opacity: 0.9;
  line-height: 1.4;
}

#preview-img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
}

.change-photo-btn {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  background: rgba(0,0,0,0.6);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-family: var(--font-body);
  cursor: pointer;
}

.form-fields {
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 1.25rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  margin-bottom: 1rem;
}

.field-group {
  margin-bottom: 1rem;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0;
}

.field-row .field-group {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  background: rgba(255,255,255,0.95);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: var(--font-body);
  color: #1a1a2e;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255,223,0,0.3);
}

input::placeholder {
  color: #9ba3af;
}

.error-msg {
  background: rgba(192,57,43,0.85);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  text-align: center;
}

/* ── Botão Gerar ─────────────────────────────────────────────────── */

.btn-gerar {
  width: 100%;
  background: var(--yellow);
  color: var(--blue);
  border: none;
  border-radius: var(--radius);
  padding: 1.1rem;
  font-family: var(--font-display);
  font-size: clamp(1rem, 4.5vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 20px rgba(255,223,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-gerar:active {
  transform: scale(0.97);
  box-shadow: 0 2px 10px rgba(255,223,0,0.3);
}

.btn-gerar:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-gerar .btn-icon {
  font-size: 1.3rem;
}

/* ── Pagamento ───────────────────────────────────────────────────── */

#view-payment {
  animation: fadeInUp 0.4s ease;
}

.payment-card {
  background: var(--white);
  color: #1a1a2e;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}

.payment-header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.pix-logo {
  display: inline-block;
  background: #32bcad;
  color: var(--white);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.15em;
  padding: 0.25rem 0.9rem;
  border-radius: 999px;
  margin-bottom: 0.6rem;
}

.payment-header h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 0.25rem;
}

.payment-hint {
  font-size: 0.88rem;
  color: #666;
}

.qr-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1.25rem 0;
  min-height: 220px;
}

#qr-img {
  width: 100%;
  max-width: 220px;
  height: auto;
  border-radius: 10px;
  border: 3px solid #e8eaf0;
}

.qr-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: #666;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e8eaf0;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.pix-copy-section {
  margin-bottom: 1.25rem;
}

.copy-label {
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.pix-copy-box {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: #f5f6fa;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}

.pix-code-text {
  flex: 1;
  font-size: 0.72rem;
  color: #444;
  word-break: break-all;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.btn-copy {
  flex-shrink: 0;
  background: var(--green);
  color: var(--white);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-copy:active { background: var(--green-dark); }

.payment-status {
  text-align: center;
  margin-bottom: 1.25rem;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

.status-indicator.waiting {
  background: #fff8e1;
  color: #b8860b;
}

.status-indicator.approved {
  background: #e8f5e9;
  color: #2e7d32;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s ease-in-out infinite;
}

.btn-back {
  width: 100%;
  background: none;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  padding: 0.65rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: #666;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-back:hover { border-color: #aaa; color: #333; }

.btn-dev-simulate {
  width: 100%;
  margin-top: 0.75rem;
  background: #fff8e1;
  border: 2px dashed #f0b429;
  border-radius: 10px;
  padding: 0.65rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: #8a6d00;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-dev-simulate:hover { background: #fff3c4; }
.btn-dev-simulate:disabled { opacity: 0.6; cursor: default; }

/* ── Gerando ─────────────────────────────────────────────────────── */

#view-generating {
  animation: fadeInUp 0.4s ease;
}

.generating-card {
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ball-spinner {
  font-size: 3.5rem;
  animation: spin 1.5s linear infinite;
  display: inline-block;
  margin-bottom: 1rem;
}

.generating-card h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
}

.generating-card p {
  opacity: 0.85;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.generating-timer {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
}

.generating-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.step {
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  opacity: 0.5;
}

.step.active {
  opacity: 1;
  background: rgba(255,223,0,0.2);
  color: var(--yellow);
  font-weight: 600;
}

/* ── Pronto ──────────────────────────────────────────────────────── */

#view-ready {
  animation: fadeInUp 0.4s ease;
}

.ready-card {
  background: var(--white);
  color: #1a1a2e;
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  text-align: center;
  box-shadow: var(--card-shadow);
}

.success-badge {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.ready-card h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--green);
  margin-bottom: 0.4rem;
}

.ready-card > p {
  color: #555;
  margin-bottom: 1.25rem;
}

.sticker-preview {
  margin: 1rem auto;
  max-width: 280px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.sticker-preview img {
  width: 100%;
  height: auto;
  display: block;
}

.btn-download {
  display: block;
  width: 100%;
  background: var(--green);
  color: var(--white);
  text-decoration: none;
  border-radius: var(--radius);
  padding: 1.1rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  margin-top: 1.25rem;
  box-shadow: 0 4px 16px rgba(0,156,59,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-download:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(0,156,59,0.3);
}

.save-hint {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #666;
  background: #f5f5f5;
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
}

.btn-new {
  width: 100%;
  background: none;
  border: 2px solid #ddd;
  border-radius: 10px;
  padding: 0.7rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: #555;
  cursor: pointer;
  margin-top: 0.75rem;
  transition: border-color 0.2s;
}

.btn-new:hover { border-color: #aaa; }

/* ── Erro ────────────────────────────────────────────────────────── */

#view-error {
  animation: fadeInUp 0.4s ease;
}

.error-card {
  background: var(--white);
  color: #1a1a2e;
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: var(--card-shadow);
}

.error-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.75rem;
}

.error-card h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--red);
  margin-bottom: 0.5rem;
}

.error-card p {
  color: #555;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.btn-retry {
  background: var(--green);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 0.9rem 2rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-retry:hover { background: var(--green-dark); }

/* ── Footer ──────────────────────────────────────────────────────── */

.site-footer {
  text-align: center;
  padding: 2rem 1rem 1rem;
  font-size: 0.78rem;
  opacity: 0.6;
}

/* ── Animações ───────────────────────────────────────────────────── */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}
