:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e6ea;
  --primary: #5b6ee1;
  --primary-dark: #4a5cc8;
  --primary-light: #eef0fd;
  --success: #22c55e;
  --success-bg: #f0fdf4;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --text: #1a202c;
  --text-2: #4a5568;
  --text-3: #718096;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ─── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  max-width: 900px; margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
}
.logo {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 1.2rem; font-weight: 700; color: var(--primary);
}
.header-auth { display: flex; align-items: center; gap: 0.75rem; }
.auth-badge {
  font-size: 0.8rem; color: var(--text-3);
}
.auth-badge.connected { color: var(--success); }

/* ─── MAIN ─── */
.app-main {
  flex: 1;
  max-width: 900px; margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* ─── STEPS BAR ─── */
.steps-bar {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 2rem; gap: 0;
}
.step-item {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  cursor: default; min-width: 80px;
}
.step-num {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--border); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600;
  transition: background var(--transition), color var(--transition);
}
.step-item span {
  font-size: 0.75rem; color: var(--text-3);
  transition: color var(--transition);
}
.step-item.active .step-num { background: var(--primary); color: #fff; }
.step-item.active span { color: var(--primary); font-weight: 600; }
.step-item.done .step-num { background: var(--success); color: #fff; }
.step-item.done .step-num::after { content: '✓'; font-size: 0.9rem; }
.step-item.done span { color: var(--success); }
.step-divider {
  flex: 1; height: 2px; background: var(--border);
  max-width: 60px; margin-bottom: 18px;
}

/* ─── WIZARD CARD ─── */
.wizard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel { display: none; padding: 2.5rem 2.5rem 1.5rem; }
.panel.active { display: block; }

.panel-title {
  font-size: 1.5rem; font-weight: 700; color: var(--text);
  margin-bottom: 0.5rem;
}
.panel-desc {
  color: var(--text-2); margin-bottom: 2rem;
}

/* ─── SOURCE GRID ─── */
.source-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem; margin-top: 1.5rem;
}
.source-card {
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  cursor: pointer; text-align: center;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
}
.source-card:hover {
  border-color: var(--primary); background: var(--primary-light);
  transform: translateY(-2px);
}
.source-card.selected {
  border-color: var(--primary); background: var(--primary-light);
}
.source-icon { font-size: 2.2rem; line-height: 1; }
.source-label { font-weight: 700; font-size: 1rem; color: var(--text); }
.source-hint { font-size: 0.78rem; color: var(--text-3); line-height: 1.4; }

/* ─── DROP ZONE ─── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  color: var(--text-2);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary); background: var(--primary-light);
}
.drop-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.drop-hint { font-size: 0.8rem; color: var(--text-3); margin-top: 0.4rem; }
.link { color: var(--primary); cursor: pointer; text-decoration: underline; }

/* ─── FILE LIST ─── */
.file-list {
  list-style: none;
  margin-top: 1.25rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  max-height: 280px; overflow-y: auto;
}
.file-item {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem 0.9rem;
}
.file-item-icon { font-size: 1.2rem; flex-shrink: 0; }
.file-item-name { flex: 1; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-size { font-size: 0.78rem; color: var(--text-3); flex-shrink: 0; }
.file-item-remove {
  background: none; border: none; cursor: pointer;
  color: var(--error); font-size: 1rem; padding: 0 0.2rem;
  flex-shrink: 0;
}

/* ─── TEXTAREA / INPUT ─── */
.textarea, .input {
  width: 100%; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.75rem;
  font-size: 0.9rem; background: var(--surface-2);
  color: var(--text); outline: none; resize: vertical;
  transition: border-color var(--transition);
}
.textarea:focus, .input:focus { border-color: var(--primary); background: var(--surface); }
.field-label {
  display: block; font-weight: 600; font-size: 0.88rem;
  color: var(--text); margin-bottom: 0.5rem; margin-top: 1.25rem;
}

/* ─── OPTIONS ─── */
.option-group { display: flex; flex-direction: column; gap: 0.75rem; }
.toggle-row {
  display: flex; align-items: flex-start; gap: 1rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem;
  cursor: pointer; transition: border-color var(--transition);
}
.toggle-row:hover { border-color: var(--primary); }
.toggle-row input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.toggle-label { display: flex; flex-direction: column; gap: 0.2rem; }
.toggle-label strong { font-size: 0.95rem; }
.toggle-label small { color: var(--text-3); font-size: 0.82rem; }
.sub-option { background: var(--primary-light); border: 1px solid var(--primary); border-radius: var(--radius-sm); padding: 1rem 1.25rem; margin-top: 0.75rem; }
.hint-text { color: var(--text-3); font-weight: 400; font-size: 0.82rem; }

/* ─── SUMMARY BOX ─── */
.summary-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem 1.25rem;
  margin-top: 1.5rem; font-size: 0.88rem; color: var(--text-2);
  line-height: 1.7;
}
.summary-box strong { color: var(--text); }

/* ─── PROGRESS LIST ─── */
.progress-list { display: flex; flex-direction: column; gap: 1rem; }
.progress-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem 1.25rem;
}
.progress-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.progress-name {
  flex: 1; font-size: 0.9rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.progress-pct { font-size: 0.85rem; color: var(--text-3); flex-shrink: 0; }
.progress-bar-wrap {
  height: 6px; background: var(--border); border-radius: 999px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--primary); border-radius: 999px;
  transition: width 0.4s ease;
}
.progress-bar.error { background: var(--error); }
.progress-bar.done { background: var(--success); }
.progress-msg { font-size: 0.8rem; color: var(--text-3); margin-top: 0.5rem; }
.progress-actions {
  display: flex; align-items: center; gap: 0.5rem;
  margin-top: 0.75rem; padding-top: 0.75rem;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.progress-lang {
  font-size: 0.78rem; background: var(--primary-light);
  color: var(--primary); padding: 0.15rem 0.5rem; border-radius: 999px;
  flex-shrink: 0;
}
.status-badge {
  font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 999px;
  font-weight: 600; flex-shrink: 0;
}
.status-badge.queued { background: var(--border); color: var(--text-3); }
.status-badge.processing { background: #dbeafe; color: #1d4ed8; }
.status-badge.complete { background: var(--success-bg); color: #15803d; }
.status-badge.error { background: var(--error-bg); color: var(--error); }

/* ─── RESULTS ─── */
.results-list { display: flex; flex-direction: column; gap: 1.5rem; }
.result-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.result-card-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.25rem; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.result-name { flex: 1; font-weight: 700; }
.result-lang {
  font-size: 0.78rem; background: var(--primary-light);
  color: var(--primary); padding: 0.15rem 0.5rem; border-radius: 999px;
}
.result-error-card {
  border-color: var(--error); background: var(--error-bg);
  padding: 1rem 1.25rem; border-radius: var(--radius);
}
.result-error-card .result-name { color: var(--error); }
.result-preview {
  padding: 1rem 1.25rem; max-height: 240px; overflow-y: auto;
  font-size: 0.88rem; line-height: 1.7; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface);
}
.result-actions {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.25rem; background: var(--surface-2);
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.results-actions {
  padding: 1.5rem 2.5rem; border-top: 1px solid var(--border);
  display: flex; justify-content: center;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 1.4rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  border: 2px solid transparent; transition: all var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.82rem; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── NOTICES ─── */
.notice {
  border-radius: var(--radius-sm); padding: 0.75rem 1rem;
  font-size: 0.88rem; margin-top: 0.75rem;
}
.notice-warn { background: var(--warn-bg); border: 1px solid #fcd34d; color: #92400e; }
.notice-error { background: var(--error-bg); border: 1px solid #fca5a5; color: var(--error); }

/* ─── WIZARD NAV ─── */
.wizard-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ─── FOOTER ─── */
.app-footer {
  text-align: center; padding: 1.25rem;
  font-size: 0.8rem; color: var(--text-3);
  border-top: 1px solid var(--border);
}

/* ─── TOAST ─── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 0.5rem; z-index: 999;
}
.toast {
  background: var(--text); color: #fff;
  padding: 0.75rem 1.25rem; border-radius: var(--radius-sm);
  font-size: 0.88rem; box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}
.toast.error { background: var(--error); }
.toast.success { background: var(--success); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── RESPONSIVE ─── */
@media (max-width: 640px) {
  .source-grid { grid-template-columns: 1fr; }
  .panel { padding: 1.5rem 1.25rem 1rem; }
  .wizard-nav { padding: 1rem 1.25rem; }
  .steps-bar .step-item span { display: none; }
}

/* Modal de chaves de API */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 1000;
}
.modal-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-body { padding: 1.25rem; }
.key-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 0.75rem;
  background: var(--surface-2);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}
.key-row-info { display: flex; flex-direction: column; gap: 2px; }
.key-row-provider { font-weight: 600; font-size: 0.9rem; }
.key-row-fp { font-family: monospace; font-size: 0.8rem; color: var(--text-2); }
