/* ============================================================
   Docling API — sistema de design (tema escuro)
   ============================================================ */
:root {
  /* superfícies */
  --bg: #0b0e17;
  --surface: #141926;
  --surface-2: #1b2231;
  --surface-3: #232c40;
  --border: #262f45;
  --border-2: #34405c;
  /* texto */
  --text: #e8ebf3;
  --muted: #9aa3bd;
  --faint: #6c7590;
  /* acento */
  --accent: #6d8bff;
  --accent-2: #5a78f0;
  --accent-weak: rgba(109, 139, 255, 0.14);
  /* semânticos */
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.14);
  --err: #f87171;
  --err-bg: rgba(248, 113, 113, 0.14);
  /* forma */
  --r-sm: 9px;
  --r: 12px;
  --r-lg: 16px;
  --pill: 999px;
  --shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.65);
  --ring: 0 0 0 3px var(--accent-weak);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #121a2e 0%, var(--bg) 60%);
  min-height: 100vh;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 19, 30, 0.6);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 1.4rem; line-height: 1;
  background: var(--accent-weak); border: 1px solid var(--border-2);
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px;
}
.brand-mark.lg { width: 56px; height: 56px; font-size: 1.9rem; margin: 0 auto; }
.brand h1 { font-size: 1.2rem; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }

.userbar { display: flex; align-items: center; gap: 10px; }
.user-chip {
  color: var(--muted); font-size: 0.85rem;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: var(--pill);
}
.mode-badge {
  font-size: 0.78rem; font-weight: 600; padding: 5px 11px; border-radius: var(--pill);
  border: 1px solid var(--border-2);
}
.mode-badge.cpu { color: var(--muted); background: var(--surface-2); }
.mode-badge.gpu { color: var(--ok); background: var(--ok-bg); border-color: transparent; }

/* ---------- Layout ---------- */
.container {
  max-width: 920px; margin: 0 auto; padding: 28px 24px 60px;
  display: grid; gap: 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card > h2 { font-size: 1.05rem; margin-bottom: 18px; }

/* ---------- Botões ---------- */
.primary-btn, .ghost-btn, .chip-btn, .icon-btn {
  font: inherit; cursor: pointer; border-radius: var(--r-sm);
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s, transform 0.05s;
}
.primary-btn:active, .ghost-btn:active, .chip-btn:active { transform: translateY(1px); }

.primary-btn {
  background: var(--accent-2); color: #fff; border: 1px solid transparent;
  padding: 11px 18px; font-weight: 600; font-size: 0.95rem;
}
.primary-btn:hover { background: var(--accent); }
.primary-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }

.ghost-btn {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); padding: 8px 14px; font-size: 0.85rem;
}
.ghost-btn:hover { border-color: var(--border-2); background: var(--surface-3); }

.chip-btn {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); padding: 5px 11px; font-size: 0.8rem;
  text-decoration: none; display: inline-block;
}
.chip-btn:hover { border-color: var(--accent); color: #fff; }

.icon-btn {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); padding: 5px 10px; font-size: 0.78rem;
}
.icon-btn:hover { border-color: var(--accent); color: var(--text); }

.link-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font: inherit; padding: 4px; line-height: 1; border-radius: 6px;
}
.link-btn:hover { color: var(--text); background: var(--surface-2); }

/* ---------- Campos / inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.field > span { color: var(--muted); }

.input,
.field input,
.field select,
.key-form input {
  width: 100%;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 12px; font: inherit;
}
.input:focus,
.field input:focus, .field select:focus, .key-form input:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
input::placeholder { color: var(--faint); }
.field input:disabled, .field select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Autofill do Chrome: mantém o tema escuro */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;
  caret-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
}

/* checkbox */
.checkbox { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 0.92rem; }
.checkbox input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.checkbox small { color: var(--muted); }

/* ---------- Upload ---------- */
.dropzone {
  border: 1.5px dashed var(--border-2); border-radius: var(--r);
  padding: 30px 18px; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-weak); }
.dz-text { margin: 0; }
.dz-hint { margin: 10px 0 0; color: var(--faint); font-size: 0.82rem; }
.file-name { margin: 10px 0 0; color: var(--accent); font-weight: 600; }

.options { margin: 20px 0; display: grid; gap: 14px; }
.ocr-engine {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px;
}

.formats {
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 16px 12px; margin: 2px 0 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px;
}
.formats legend { color: var(--muted); padding: 0 6px; font-size: 0.85rem; }

/* mensagens de formulário */
.form-msg { margin: 12px 0 0; min-height: 1.2em; font-size: 0.9rem; }
.form-msg.ok { color: var(--ok); }
.form-msg.err { color: var(--err); }

/* ---------- Tabelas / jobs ---------- */
.jobs-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 12px; }
.jobs-header h2 { font-size: 1.05rem; }
.queue-info { color: var(--muted); font-size: 0.82rem; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th {
  color: var(--faint); font-weight: 600; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.06em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.015); }
tr.empty td { text-align: center; color: var(--muted); padding: 26px; }

.status {
  display: inline-block; padding: 3px 11px; border-radius: var(--pill);
  font-size: 0.76rem; font-weight: 600; white-space: nowrap;
}
.status.queued { background: var(--surface-3); color: var(--muted); }
.status.processing { background: var(--warn-bg); color: var(--warn); }
.status.done { background: var(--ok-bg); color: var(--ok); }
.status.failed { background: var(--err-bg); color: var(--err); }

.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.err-text { color: var(--err); font-size: 0.8rem; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; padding: 24px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 9, 16, 0.6); backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); width: min(720px, 100%);
  max-height: 86vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; }
.modal-body { margin: 0; padding: 20px; overflow: auto; }
/* o modal de resultado usa <pre> como corpo */
pre.modal-body { white-space: pre-wrap; word-break: break-word; font-size: 0.88rem; font-family: var(--mono); }

/* ---------- Código ---------- */
.codeblock {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; margin: 10px 0 18px; overflow-x: auto;
  font-family: var(--mono); font-size: 0.82rem; color: #c7d2fe;
}
code { font-family: var(--mono); }

/* ---------- Login ---------- */
.login-screen {
  min-height: calc(100vh - 75px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 30px; width: min(380px, 100%);
  display: grid; gap: 16px; box-shadow: var(--shadow);
}
.auth-head { text-align: center; display: grid; gap: 6px; margin-bottom: 4px; }
.auth-head h2 { font-size: 1.3rem; }

/* ---------- Chaves de API ---------- */
.key-form { display: flex; gap: 10px; margin: 4px 0 6px; }
.key-form input { flex: 1; }
.key-form .primary-btn { white-space: nowrap; }

.cred-card {
  background: var(--accent-weak); border: 1px solid var(--border-2);
  border-radius: var(--r); padding: 16px; margin: 16px 0 22px;
  display: grid; gap: 14px;
}
.cred-warn {
  display: flex; gap: 8px; align-items: center;
  color: var(--warn); background: var(--warn-bg);
  padding: 8px 12px; border-radius: var(--r-sm); font-size: 0.85rem;
}
.cred-row { display: grid; gap: 6px; }
.cred-row > label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.cred-value { display: flex; gap: 8px; align-items: stretch; }
.cred-value code {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 9px 12px; font-size: 0.82rem;
  overflow-x: auto; white-space: nowrap; color: #c7d2fe;
}

.section-label {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--faint); margin: 4px 0 8px;
}
.keys-table code { font-size: 0.8rem; color: var(--muted); }

/* ---------- Responsivo ---------- */
@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .key-form { flex-direction: column; }
  .subtitle { display: none; }
}
