/* Themia — painel web (login + gestão de usuários). Estilo compartilhado entre
 * login.html e dashboard.html — sem framework, sem build step. */

:root {
  --bg: #f4f5f7;
  --bg-card: #ffffff;
  --border: #e1e4e8;
  --text-primary: #1a1a2e;
  --text-secondary: #55596b;
  --text-muted: #8a8fa3;
  --accent: #6c4bd1;
  --accent-dark: #5638b5;
  --green: #1f9d55;
  --red: #d64545;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(20, 20, 40, 0.08), 0 4px 16px rgba(20, 20, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
}

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

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

/* Marca Themia — logo (icons/logo.png) + nome em duas cores ("Them" na cor de
 * texto padrão, "ia" na cor roxa da marca). Usado na topbar da landing, no
 * menu lateral do dashboard e no card de login (18/08). */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  height: 26px;
  width: auto;
  display: block;
}
.brand-wordmark {
  font-weight: 800;
  font-size: 16px;
  color: var(--text-primary);
}
.brand-wordmark .brand-ia { color: var(--accent-dark); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); color: var(--red); }

.container {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card h1, .card h2 {
  margin-top: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
}
.apikey-input-row {
  display: flex;
  gap: 8px;
}
.apikey-input-row input { flex: 1; }
.apikey-input-row .btn { flex-shrink: 0; white-space: nowrap; }

.apikey-teste-resultado {
  font-size: 12px;
  margin: 6px 0 0;
  font-weight: 600;
}
.apikey-teste-resultado.ok { color: var(--green); }
.apikey-teste-resultado.erro { color: var(--red); }

.prompt-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  resize: vertical;
}
.prompt-textarea:focus { outline: none; border-color: var(--accent); }

.error-box {
  background: #fdecec;
  border: 1px solid #f3b8b8;
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.error-box.visible { display: block; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Peritos (01/09) — 9 colunas depois que "Varas" entrou, `table { width:100% }`
   sozinho espremia tudo (achado real, print do usuário: nome quebrando em 3
   linhas, card com aparência de "overflow"). Tabela rola HORIZONTALMENTE
   dentro do próprio card em vez de se espremer.
   Bug real (01/09, 2ª rodada — achado ao vivo pelo usuário: "onde estaria o
   botão de editar?"): o `min-width: 980px` fixo era MAIOR que o próprio
   `.card { max-width: 960px }`, então sempre precisava rolar, MESMO em tela
   cheia. Tentativa de corrigir com `position: sticky` na última coluna
   (pra ficar sempre visível) criou um bug PIOR, achado no preview antes de
   publicar de novo: sticky em `<td>` dentro de tabela `table-layout:auto`
   não respeita a largura calculada da coluna — a célula sticky ficava
   flutuando por cima da coluna anterior (Agenda), escondendo o botão dela
   inteiro (confirmado medindo os retângulos das células via
   getBoundingClientRect, os dois se sobrepunham quase 100%). Abandonada a
   ideia de sticky em `<td>` (quirk conhecido de tabela+sticky, não vale o
   risco). Solução final: junta "Agenda" e "Editar" numa coluna só "Ações"
   (economiza uma coluna inteira de largura) e larguras mais enxutas —
   sem min-width nem sticky, a tabela cresce só o necessário e cabe sem
   rolar no caso normal (validado no preview com os dados reais do usuário). */
.table-scroll {
  overflow-x: auto;
}
#tabelaPeritos td, #tabelaPeritos th {
  white-space: nowrap;
}
#tabelaPeritos td:nth-child(1) {
  white-space: normal;
  min-width: 190px;
}
#tabelaPeritos td, #tabelaPeritos th {
  padding: 10px 8px;
}
#tabelaPeritos .peritos-acoes-cell {
  display: flex;
  gap: 6px;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.pill--admin { background: #efe7fd; color: var(--accent-dark); }
.pill--usuario { background: #eef0f4; color: var(--text-secondary); }
.pill--ativo { background: #e4f6ea; color: var(--green); }
.pill--inativo { background: #fdecec; color: var(--red); }

select.inline-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: #fff;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 40, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  width: 380px;
  max-width: 90vw;
  max-height: 88vh;
  overflow-y: auto;
}
.modal--wide { width: 560px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 340px;
  max-width: 90vw;
}
.login-logo-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  margin-bottom: 4px;
}
.login-logo-img { height: 56px; width: auto; }
.login-logo-link .brand-wordmark { font-size: 22px; }
.login-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.login-voltar {
  position: absolute;
  top: 20px;
  left: 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
}
.login-voltar:hover { color: var(--accent); }

/* Painel admin — menu lateral fixo + conteúdo trocando do lado (18/08) */
.admin-shell {
  display: flex;
  min-height: 100vh;
}
.admin-nav {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.admin-nav-brand {
  padding: 8px 10px 20px;
}
.admin-nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 2px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.admin-nav-item:hover { background: var(--bg); color: var(--text-primary); }
.admin-nav-item.is-active { background: var(--accent); color: #fff; }
.admin-nav-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.admin-nav-user {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px 10px;
  word-break: break-word;
}
.admin-content {
  flex: 1;
  min-width: 0;
  padding: 32px;
}
.admin-content .card { max-width: 960px; }
.admin-section[hidden] { display: none; }

@media (max-width: 720px) {
  .admin-shell { flex-direction: column; }
  .admin-nav { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .admin-nav-brand { padding: 8px 10px; }
  .admin-nav-footer { margin-top: 0; margin-left: auto; border-top: none; display: flex; align-items: center; gap: 8px; }
  .admin-content { padding: 16px; }
}

/* Landing page pública (18/08) */
.landing-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
}
.landing-hero {
  max-width: 720px;
  margin: 48px auto 64px;
  padding: 0 24px;
  text-align: center;
}
.landing-hero h1 {
  font-size: 34px;
  line-height: 1.25;
  margin: 0 0 18px;
  color: var(--text-primary);
}
.landing-hero-sub {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 0 28px;
}
.landing-cta { padding: 12px 28px; font-size: 14px; }

.landing-features {
  max-width: 1040px;
  margin: 0 auto 64px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.landing-feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.landing-feature-icon { font-size: 24px; margin-bottom: 10px; }
.landing-feature-card h3 { margin: 0 0 8px; font-size: 15px; color: var(--text-primary); }
.landing-feature-card p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-secondary); }

.landing-footer {
  text-align: center;
  padding: 24px;
}

@media (max-width: 600px) {
  .landing-hero h1 { font-size: 26px; }
}

.muted { color: var(--text-muted); font-size: 12px; }

/* Especialidades do perito, linha sob o nome na tabela de Peritos (02/09,
   pedido do usuário: "com uma fonte azul e menor, e na mesma linha do
   perito" — vem de perito_disponibilidade, ver GET /peritos). Azul de
   propósito, não a cor de destaque roxa do resto do app — mesmo tom já
   usado noutro lugar da extensão pra dado importado do PJe (ver
   sidebar/agenda-pericias.html, --blue). */
.perito-especialidades { color: #0369a1; font-size: 11px; margin-top: 2px; }

/* Checkboxes de vara no modal de editar perito (01/09) — sem isso, `.field
   input { width:100% }` (regra genérica, pensada pra <input type="text">)
   também pega o <input type="checkbox"> aqui dentro e o estica pra ocupar a
   linha inteira, jogando o rótulo pro canto direito (achado real, visto no
   preview antes de publicar). */
#peritoVarasContainer label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 13px;
  color: var(--text-primary);
  padding: 2px 0;
  margin-bottom: 0;
}
#peritoVarasContainer input[type="checkbox"] {
  width: auto;
  flex-shrink: 0;
}
.spinner-inline {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════ Raio-X do processo (01/10) — ver raio-x.js ═══════════════ */
.admin-content #section-raiox .card { max-width: 1200px; }
.rx-h2 { font-size: 16px; margin: 0; }
.rx-h3 { font-size: 15px; margin: 28px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.rx-nota { margin: -4px 0 10px; }
.rx-sub { font-size: 11px; color: var(--text-muted); }
.rx-erro-txt { color: var(--red); font-size: 12px; }
.rx-link { color: var(--accent-dark); text-decoration: none; font-weight: 600; }
.rx-lista-topo { display: flex; align-items: center; gap: 12px; margin: 24px 0 8px; flex-wrap: wrap; }
.rx-tabela { width: 100%; margin-bottom: 8px; }
.rx-tabela td { vertical-align: top; }
.rx-linha-click { cursor: pointer; }
.rx-linha-click:hover td { background: var(--bg); }
.rx-linha-click.is-sel td { background: #efe7fd; }
.rx-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.rx-chip--ok { background: #e4f6ea; color: var(--green); }
.rx-chip--warn { background: #fff4de; color: #a15c00; }
.rx-chip--bad { background: #fdecec; color: var(--red); }
.rx-chip--neutral { background: #eef0f4; color: var(--text-secondary); }
.rx-chip-rot { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
.rx-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  margin-top: 28px; padding: 14px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.rx-chips { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.rx-aviso { background: #fff4de; color: #7a4600; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.rx-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 12px; }
.rx-card-cab { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.rx-card-tit { font-weight: 600; font-size: 14px; }
.rx-card-data { margin-left: auto; }
.rx-parecer { background: var(--bg); border-left: 3px solid var(--accent); padding: 8px 12px; font-size: 13px; line-height: 1.55; margin: 8px 0; white-space: pre-wrap; position: relative; padding-right: 92px; }
.rx-btn-copiar { position: absolute; top: 6px; right: 6px; background: var(--bg-card); }
.rx-texto { font-size: 13px; line-height: 1.6; white-space: pre-wrap; max-height: 480px; overflow: auto; }
.rx-md-h { display: block; margin-top: 6px; }
.rx-etiquetas { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.rx-etq { background: #efe7fd; color: var(--accent-dark); font-size: 11px; padding: 2px 8px; border-radius: 4px; }
.rx-kv { width: auto; margin: 8px 0; font-size: 13px; }
.rx-kv th { text-align: left; font-weight: 500; color: var(--text-secondary); padding: 3px 16px 3px 0; white-space: nowrap; background: none; text-transform: none; letter-spacing: 0; font-size: 12px; }
.rx-kv td { padding: 3px 0; overflow-wrap: anywhere; }
.rx-kv { max-width: 100%; table-layout: auto; }
.rx-grupo { margin: 10px 0; }
.rx-grupo-tit { font-weight: 600; font-size: 13px; margin: 10px 0 4px; }
.rx-itens { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.rx-itens li { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.rx-itens li:last-child { border-bottom: none; }
.rx-itens--simples li { align-items: center; }
.rx-just { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.rx-confirmado { color: var(--green); font-size: 11px; margin-top: 2px; }
.rx-ic { flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.rx-ic--ok { background: #e4f6ea; color: var(--green); }
.rx-ic--bad { background: #fdecec; color: var(--red); }
.rx-ic--neutral { background: #eef0f4; color: var(--text-secondary); }
.rx-sub-det summary, .rx-bruto summary { cursor: pointer; font-size: 12px; color: var(--accent-dark); margin-top: 6px; }
.rx-bruto pre, .rx-pre { background: #1a1a2e; color: #e8e8f0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 11.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; max-height: 420px; overflow: auto; margin: 6px 0 0; }
.rx-tempo { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.rx-tempo li { display: flex; gap: 12px; padding: 5px 0; border-left: 2px solid var(--border); padding-left: 12px; margin-left: 4px; }
.rx-tempo-data { color: var(--text-muted); font-size: 12px; white-space: nowrap; min-width: 112px; }
.rx-doc-topo { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.rx-doc-topo input { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; min-width: 240px; }
.rx-doc-acoes { display: flex; justify-content: flex-end; }
.rx-btn-mini { padding: 3px 10px; font-size: 12px; }
