/* ========================================================
   CHECKOUT PIX — CSS Principal
   Design moderno, premium, 100% vanilla CSS
   ======================================================== */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:      #703200;
  --primary-light:#a04a00;
  --primary-pale: #fff0e6;
  --accent:       #ecb588;
  --bg:           #f5f0eb;
  --surface:      #ffffff;
  --border:       #e5d8cc;
  --text:         #1a0d00;
  --text-muted:   #7a5c44;
  --success:      #15803d;
  --error:        #dc2626;
  --radius:       14px;
  --shadow:       0 4px 32px rgba(112,50,0,.12);
  --transition:   .22s ease;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

/* ---- Typography ---- */
h1,h2,h3 { font-weight: 700; line-height: 1.2; }
p { color: var(--text-muted); }

/* ---- Layout ---- */
.page-wrap {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 32px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 16px 64px;
  align-items: start;
}
@media(max-width:780px){
  .page-wrap { grid-template-columns: 1fr; }
  .order-summary-col { order: -1; }
}

/* ---- Card ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  border: 1px solid var(--border);
}

/* ---- Logo / Header ---- */
.checkout-header {
  text-align: center;
  margin-bottom: 28px;
}
.checkout-header img {
  height: 40px;
  object-fit: contain;
  margin-bottom: 8px;
}
.checkout-header h1 {
  font-size: 1.1rem;
  color: var(--primary);
  font-weight: 700;
}

/* ---- Steps ---- */
.steps-bar {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
  gap: 0;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}
.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 18px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
  transition: background var(--transition);
}
.step-item.done:not(:last-child)::after,
.step-item.active:not(:last-child)::after {
  background: var(--primary);
}
.step-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .87rem;
  background: var(--surface);
  color: var(--text-muted);
  z-index: 1;
  transition: all var(--transition);
  position: relative;
}
.step-item.active .step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px var(--primary-pale);
}
.step-item.done .step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.step-item.done .step-num::after {
  content: '✓';
}
.step-item.done .step-num span { display: none; }
.step-label {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.step-item.active .step-label { color: var(--primary); }

/* ---- Section Title ---- */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-pale);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---- Form Fields ---- */
.field-group {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}
.field-group.cols-2 { grid-template-columns: 1fr 1fr; }
.field-group.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media(max-width:500px){
  .field-group.cols-2,
  .field-group.cols-3 { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field input,
.field select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}
.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}
.field input.error { border-color: var(--error); }
.field .field-error {
  font-size: .75rem;
  color: var(--error);
  display: none;
}
.field.has-error .field-error { display: block; }
.field.has-error input { border-color: var(--error); }

/* ---- CPF loading indicator ---- */
.field-loading {
  position: relative;
}
.field-loading::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
.field-loading.loading::after { display: block; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

/* ---- CEP lookup ---- */
.cep-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}
.btn-cep {
  padding: 11px 16px;
  border: none;
  border-radius: 10px;
  background: var(--primary-pale);
  color: var(--primary);
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}
.btn-cep:hover { background: var(--accent); }

/* ---- Navigation Buttons ---- */
.nav-btns {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 28px;
  border-radius: 12px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  flex: 1;
}
.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(112,50,0,.25);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--primary-pale);
  color: var(--primary);
}
.btn-secondary:hover { background: var(--accent); }
.btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none !important;
}

/* ---- Order Summary ---- */
.order-summary-col {}
.product-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.product-img {
  width: 72px; height: 72px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.product-info h3 { font-size: .95rem; margin-bottom: 4px; }
.product-info .price {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}
.product-info .original-price {
  text-decoration: line-through;
  font-size: .8rem;
  color: var(--text-muted);
  margin-left: 6px;
}
.order-lines {}
.order-line {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: .9rem;
  color: var(--text-muted);
  border-bottom: 1px dashed var(--border);
}
.order-total {
  display: flex;
  justify-content: space-between;
  padding: 14px 0 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}
.order-total span:last-child { color: var(--primary); }

/* ---- Trust badges ---- */
.trust-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.trust-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 600;
}
.trust-badge svg { width: 14px; height: 14px; color: var(--success); }

/* ---- Qty selector ---- */
.qty-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.qty-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.qty-btn:hover { background: var(--primary-pale); }
.qty-display {
  font-weight: 700;
  font-size: 1rem;
  min-width: 28px;
  text-align: center;
}

/* ---- STEP panels ---- */
.step-panel { display: none; }
.step-panel.active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Pix Method ---- */
.pix-info-box {
  background: var(--primary-pale);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.pix-info-box svg { width: 22px; height: 22px; color: var(--primary); flex-shrink: 0; margin-top: 2px; }
.pix-info-box p { color: var(--text-muted); font-size: .88rem; }

/* ---- Loading overlay ---- */
#loading-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(26,13,0,.6);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
#loading-overlay.show { display: flex; }
.loading-spinner {
  width: 52px; height: 52px;
  border: 4px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.loading-text { color: #fff; font-weight: 600; font-size: 1rem; }

/* ---- Footer ---- */
.checkout-footer {
  text-align: center;
  margin-top: 28px;
  font-size: .78rem;
  color: var(--text-muted);
}
.checkout-footer a { color: var(--primary); text-decoration: none; }

/* ========================
   PAGAMENTO (QR Code)
   ======================== */
.payment-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.payment-card {
  max-width: 460px;
  width: 100%;
}
.payment-header {
  text-align: center;
  margin-bottom: 20px;
}
.payment-header h2 {
  font-size: 1.3rem;
  color: var(--primary);
  margin-bottom: 4px;
}
.payment-header p { font-size: .9rem; }

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
}
.qr-img {
  width: 200px; height: 200px;
  border: 6px solid var(--primary-pale);
  border-radius: 14px;
  object-fit: contain;
}
.qr-img-placeholder {
  width: 200px; height: 200px;
  border: 6px solid var(--primary-pale);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.pix-code-area {
  width: 100%;
}
.pix-code-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.pix-code-box {
  display: flex;
  gap: 8px;
}
.pix-code-box input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .78rem;
  color: var(--text-muted);
  background: var(--bg);
  cursor: text;
}
.btn-copy {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}
.btn-copy:hover { background: var(--primary-light); }
.btn-copy.copied { background: var(--success); }

/* Timer */
.pix-timer {
  text-align: center;
  padding: 8px 16px;
  background: var(--primary-pale);
  border-radius: 8px;
  font-size: .88rem;
  color: var(--primary);
  font-weight: 600;
}
.pix-timer span { font-size: 1.1rem; font-weight: 800; }

/* Status de pagamento */
.payment-status {
  border-radius: 12px;
  padding: 14px 18px;
  text-align: center;
}
.status-waiting {
  background: var(--primary-pale);
  border: 1px solid var(--accent);
}
.status-waiting h3 { color: var(--primary); font-size: 1rem; margin-bottom: 4px; }
.status-waiting p { font-size: .85rem; }

.status-success {
  display: none;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}
.status-success h3 { color: var(--success); font-size: 1rem; margin-bottom: 4px; }
.status-success p { font-size: .85rem; }

/* Pulse animation for waiting */
.pulse-dot {
  display: inline-block;
  width: 10px; height: 10px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
  margin-right: 6px;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.6); }
}

/* Progress bar */
.polling-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}
.polling-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  animation: polling 2s linear infinite;
}
@keyframes polling {
  0% { width: 0; margin-left: 0; }
  50% { width: 60%; }
  100% { width: 0; margin-left: 100%; }
}

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: .88rem;
  margin-bottom: 12px;
}
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: var(--error);   border: 1px solid #fecaca; }
.alert-info    { background: var(--primary-pale); color: var(--primary); border: 1px solid var(--accent); }

/* ---- Secure lock icon row ---- */
.secure-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 14px;
}
.secure-row svg { width: 14px; color: var(--success); }

/* ---- Responsive ---- */
@media(max-width:400px) {
  .card { padding: 20px 14px; }
  .page-wrap { padding: 16px 10px 48px; }
}
