/* =============================================
   Magnora Pay — CSS Principal
   ============================================= */

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

:root {
  --blue: #1d4ed8;
  --blue-dark: #1e40af;
  --blue-light: #eff6ff;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --red: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-900: #111827;
  --white: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.10);
}

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

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

body {
  font-family: 'Inter', sans-serif;
  background: #f1f5f9;
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ── */
.checkout-wrapper {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 12px;
}

/* ── Header ── */
.header {
  text-align: center;
  padding: 20px 16px 12px;
}

.logo {
  height: 40px;
  object-fit: contain;
}

.logo-text {
  font-family: 'Sora', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -0.5px;
}

/* ── Produto ── */
.product-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.product-img {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--gray-100);
}

.product-info h2 {
  font-family: 'Sora', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  line-height: 1.3;
}

.product-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  margin-top: 4px;
  font-family: 'Sora', sans-serif;
}

.product-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
}

.badge-green { background: var(--green-light); color: var(--green); }
.badge-blue  { background: var(--blue-light);  color: var(--blue); }

/* ── Formulário ── */
.section-title {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 5px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,78,216,.1);
}

.form-group input.error { border-color: var(--red); }
.form-group .error-msg  { font-size: 12px; color: var(--red); margin-top: 4px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px;
}

/* CEP loading */
.cep-wrapper { position: relative; }
.cep-spinner {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
}
.cep-spinner.active { display: block; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

/* ── Endereço (oculto inicialmente) ── */
#address-section { display: none; }
#address-section.visible { display: block; }

/* ── Pagamento Cards ── */
.payment-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.payment-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
  background: var(--white);
  position: relative;
}

.payment-card:hover { border-color: var(--blue); background: var(--blue-light); }
.payment-card.selected { border-color: var(--blue); background: var(--blue-light); }

.payment-card .pay-icon { font-size: 28px; margin-bottom: 6px; }
.payment-card .pay-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
  font-family: 'Sora', sans-serif;
}
.payment-card .pay-subtitle { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

.payment-card .selected-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  background: var(--blue);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
}
.payment-card.selected .selected-check { display: flex; }

/* ── Cartão de crédito ── */
.card-form { margin-top: 14px; display: none; }
.card-form.visible { display: block; }

.card-visual {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  border-radius: 12px;
  padding: 20px;
  color: white;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.card-visual::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.card-number-display {
  font-size: 18px;
  letter-spacing: 3px;
  font-family: 'Sora', sans-serif;
  margin: 12px 0 8px;
}
.card-meta { display: flex; justify-content: space-between; font-size: 12px; opacity: .8; }

/* ── Botão Principal ── */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Sora', sans-serif;
  cursor: pointer;
  transition: background .2s, transform .1s, box-shadow .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(29,78,216,.3);
}

.btn-primary:hover   { background: var(--blue-dark); box-shadow: 0 6px 20px rgba(29,78,216,.4); }
.btn-primary:active  { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 14px;
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Sora', sans-serif;
  cursor: pointer;
  transition: all .2s;
}
.btn-secondary:hover { background: var(--gray-200); }

/* ── Selos de segurança ── */
.security-badges {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 0 4px;
}

.security-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 500;
}

/* ── Pix Page ── */
.pix-wrapper {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.pix-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-light);
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.pix-amount {
  font-family: 'Sora', sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-900);
  text-align: center;
  margin: 8px 0;
}

.pix-amount small {
  font-size: 14px;
  color: var(--gray-400);
  font-weight: 400;
}

.qrcode-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

#qrcode-img {
  width: 220px;
  height: 220px;
  display: block;
  margin: 0 auto 16px;
}

#qrcode canvas,
#qrcode img {
  width: 220px !important;
  height: 220px !important;
}

.timer-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #c2410c;
  font-weight: 600;
}

.timer-box.expired {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--red);
}

#timer-display { font-size: 18px; font-family: 'Sora', sans-serif; }

.copypaste-box {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 11px;
  color: var(--gray-600);
  word-break: break-all;
  line-height: 1.5;
  margin-bottom: 10px;
  max-height: 80px;
  overflow: hidden;
  cursor: pointer;
}

.discount-banner {
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  color: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  text-align: center;
}

.discount-banner h3 { font-family: 'Sora', sans-serif; font-size: 15px; margin-bottom: 4px; }
.discount-banner p  { font-size: 13px; opacity: .9; }

/* ── Obrigado ── */
.obrigado-wrapper {
  max-width: 420px;
  margin: 60px auto;
  padding: 24px;
  text-align: center;
}

.check-circle {
  width: 80px;
  height: 80px;
  background: var(--green-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 36px;
}

/* ── Admin ── */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: var(--gray-50);
}

.admin-sidebar {
  width: 240px;
  background: var(--gray-900);
  color: white;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-family: 'Sora', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.nav-item:hover  { background: rgba(255,255,255,.07); color: white; }
.nav-item.active { background: rgba(29,78,216,.3); color: white; border-left-color: var(--blue); }

.admin-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.admin-topbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-content { padding: 24px; flex: 1; overflow-y: auto; }

.page-title {
  font-family: 'Sora', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 20px;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label { font-size: 12px; color: var(--gray-400); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-family: 'Sora', sans-serif; font-size: 26px; font-weight: 700; color: var(--gray-900); margin-top: 4px; }
.stat-card .stat-sub   { font-size: 12px; color: var(--green); margin-top: 2px; }

/* Table */
.table-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.table-header h3 { font-family: 'Sora', sans-serif; font-size: 15px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--gray-50);
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.status-paid       { background: #dcfce7; color: #15803d; }
.status-pending    { background: #fef9c3; color: #a16207; }
.status-expired    { background: #fee2e2; color: #b91c1c; }
.status-refused    { background: #fce7f3; color: #9d174d; }
.status-refunded   { background: #e0e7ff; color: #3730a3; }
.status-shipped    { background: #d1fae5; color: #065f46; }
.status-cancelled  { background: var(--gray-100); color: var(--gray-600); }

/* Action buttons */
.btn-action {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all .15s;
}
.btn-action-blue  { background: var(--blue-light); color: var(--blue); }
.btn-action-blue:hover { background: var(--blue); color: white; }
.btn-action-green { background: var(--green-light); color: var(--green); }
.btn-action-green:hover { background: var(--green); color: white; }
.btn-action-gray  { background: var(--gray-100); color: var(--gray-600); }
.btn-action-gray:hover  { background: var(--gray-200); }
.btn-action-red   { background: #fee2e2; color: var(--red); }
.btn-action-red:hover   { background: var(--red); color: white; }

/* Forms admin */
.admin-form .form-group { margin-bottom: 16px; }
.admin-form label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.admin-form input,
.admin-form select,
.admin-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--gray-900);
  transition: border-color .15s;
}
.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus { outline: none; border-color: var(--blue); }
.admin-form textarea { resize: vertical; min-height: 80px; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--gray-200);
  background: white;
  cursor: pointer;
  transition: all .15s;
  color: var(--gray-600);
}
.filter-btn:hover  { border-color: var(--blue); color: var(--blue); }
.filter-btn.active { background: var(--blue); color: white; border-color: var(--blue); }

/* Login */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: var(--green-light); color: var(--green); }
.alert-error   { background: #fee2e2; color: var(--red); }
.alert-info    { background: var(--blue-light); color: var(--blue); }

/* Mobile */
@media (max-width: 640px) {
  .payment-options { grid-template-columns: 1fr 1fr; }
  .form-row        { grid-template-columns: 1fr; }
  .form-row-3      { grid-template-columns: 1fr 1fr; }
  .form-row-3 .full { grid-column: 1/-1; }
  .admin-sidebar   { display: none; }
  .stats-grid      { grid-template-columns: 1fr 1fr; }
  table { font-size: 12px; }
  thead th, tbody td { padding: 8px 10px; }
}

/* Spinner botão */
.btn-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
}
.loading .btn-spinner { display: inline-block; }
.loading .btn-text    { display: none; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-900);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transition: transform .3s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateX(-50%) translateY(0); }
