/* ===== KastPix - Estilo Mercado Pago (branco/preto) ===== */

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

:root {
  --bg: #ffffff;
  --bg-alt: #fafbfc;
  --text: #0f1419;
  --text-muted: #5f6368;
  --border: #e8eaed;
  --border-strong: #d1d5db;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== TOPBAR ===== */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: white;
  position: sticky; top: 0; z-index: 10;
}
.topbar-logo { height: 26px; }
.topbar-actions { display: flex; gap: 4px; align-items: center; }
.topbar-link, .topbar-logout {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none;
  font-size: 14px; font-weight: 500;
  padding: 6px 12px; border-radius: 6px;
  transition: background 0.15s ease;
}
.topbar-link:hover, .topbar-logout:hover { background: var(--bg-alt); color: var(--text); }

/* ===== MAIN ===== */
.main {
  max-width: 640px; margin: 0 auto; padding: 32px 20px 60px;
}
.title {
  font-size: 26px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em; margin-bottom: 6px;
}
.subtitle {
  color: var(--text-muted); font-size: 15px; margin-bottom: 28px;
}

/* ===== CARDS ===== */
.card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* ===== DROPZONE ===== */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-muted);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--text);
  background: var(--bg-alt);
  color: var(--text);
}
.dropzone svg { stroke: currentColor; margin-bottom: 12px; }
.dropzone-title {
  font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px;
}
.dropzone-sub { font-size: 13px; color: var(--text-muted); }

/* ===== LOADING ===== */
.loading {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 48px 24px; color: var(--text-muted); font-size: 14px;
}
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== PREVIEW ===== */
.preview-header { margin-bottom: 20px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-success {
  background: var(--green-light); color: var(--green);
}
.badge-status {
  background: var(--green); color: white;
  padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 700;
}

.preview-amount {
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  position: relative;
}
.preview-amount-label {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; color: var(--text-muted);
  width: 100%;
}
.preview-amount-value {
  font-size: 32px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em; flex: 1;
}

.preview-section { margin-bottom: 22px; }
.preview-section:last-of-type { margin-bottom: 28px; }
.preview-section h3 {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.preview-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; gap: 16px;
}
.preview-row span {
  color: var(--text-muted); font-size: 14px;
}
.preview-row strong {
  color: var(--text); font-size: 14px; font-weight: 600;
  text-align: right; word-break: break-all;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, 'Courier New', monospace; font-size: 12px !important; }

/* ===== ACTIONS ===== */
.actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.actions .btn-primary { grid-column: 1 / -1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.btn svg { flex-shrink: 0; }
.btn-primary {
  background: var(--text); color: white; border-color: var(--text);
}
.btn-primary:hover { background: #1f2937; border-color: #1f2937; }
.btn-secondary {
  background: white; color: var(--text); border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-alt); }
.btn-block { width: 100%; }

/* ===== LOGIN ===== */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg-alt);
}
.login-card {
  background: white; border-radius: var(--radius);
  padding: 40px 32px; max-width: 400px; width: 100%;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.login-logo {
  height: 56px; display: block; margin: 0 auto 32px;
}
.login-title {
  font-size: 24px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.02em;
}
.login-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 500; color: var(--text); }
.field input {
  padding: 11px 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  transition: border-color 0.15s ease;
  background: white; color: var(--text);
}
.field input:focus {
  outline: none; border-color: var(--text);
}
.alert {
  background: #fee2e2; color: var(--red); padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
  border: 1px solid #fecaca;
}

/* ===== MODAL PDF ===== */
.pdf-modal {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg-alt);
  display: flex; flex-direction: column;
  animation: modalFadeIn 0.2s ease;
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
.pdf-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: white;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  gap: 12px;
}
.modal-back, .modal-action {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 8px;
  background: white; color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s ease;
  font-family: inherit;
}
.modal-back:hover, .modal-action:hover {
  background: var(--bg-alt);
  border-color: var(--text);
}
.modal-action {
  background: var(--text); color: white; border-color: var(--text);
}
.modal-action:hover {
  background: #1f2937; border-color: #1f2937; color: white;
}
.modal-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  flex: 1; text-align: center;
}
.modal-actions-group {
  display: flex; gap: 8px;
}
.pdf-modal-body {
  flex: 1; overflow: hidden; background: var(--bg-alt);
  display: flex; justify-content: center;
}
#pdf-frame {
  width: 100%; height: 100%; border: 0;
  background: var(--bg-alt);
  max-width: 1000px;
}
@media (max-width: 540px) {
  .modal-title { display: none; }
  .pdf-modal-header { padding: 10px 14px; }
  .modal-back, .modal-action { padding: 7px 10px; font-size: 13px; }
}

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--text); color: white;
  padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 100;
  animation: toastIn 0.25s ease;
}
.toast.error { background: var(--red); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Responsivo ===== */
@media (max-width: 540px) {
  .main { padding: 24px 16px 60px; }
  .title { font-size: 22px; }
  .card { padding: 20px; }
  .actions .btn { flex: 1 1 100%; }
  .preview-amount-value { font-size: 28px; }
}
