/* portal/static/estilo-escuro.css — modo escuro do Portal Link e o switch que troca o tema.
   O js/tema.js põe data-tema="claro" ou "escuro" no <html> antes de a página aparecer (padrão: o tema do sistema).
   No escuro, as variáveis de cor mudam e os fundos, bordas e textos de cor fixa do estilo.css (gerado do vendedor)
   e do estilo-link.css ganham versão escura aqui. O tests/test_tema.py acusa cor fixa nova sem versão escura.
   As regras usam :where(), que não soma especificidade: cada uma empata com a regra clara que substitui e ganha
   por vir depois, sem atropelar os estados do vendedor (campo inválido, arquivo escolhido, linha do motivo etc.). */

:root { color-scheme: light; }
html[data-tema="escuro"] {
  color-scheme: dark;
  --navy: #b9c6f2;          /* o navy é cor de título e valor: vira claro; o fundo da marca fica no --brand */
  --brand: #4a5b9e;
  --brand-dark: #3c4b86;
  --brand-grad: linear-gradient(155deg, #2b375f 0%, #1b2340 100%);
  --ink: #e4e9f1;
  --muted: #9aa6b7;
  --gray: #b4bfcd;
  --line: #2a3450;
  --line-2: #212a42;
  --bg: #0e1524;
  --card: #151d31;
  --ok: #5fd3a0;
  --ok-bg: #10291f;
  --warn: #f0c35a;
  --warn-bg: #2f2511;
  --danger: #ff8f86;
  --danger-bg: #351717;
  --gray-bg: #222b3f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.25);
}

/* ---------- Página ---------- */
:where(html[data-tema="escuro"]) body { background: var(--bg); }
:where(html[data-tema="escuro"]) .main { background: radial-gradient(900px 500px at 100% -10%, #18233f 0, var(--bg) 55%); }
:where(html[data-tema="escuro"]) a:not([class]) { color: #9fb3ff; }

/* ---------- Campos ---------- */
:where(html[data-tema="escuro"]) input[type=text], :where(html[data-tema="escuro"]) input[type=date],
:where(html[data-tema="escuro"]) input[type=file], :where(html[data-tema="escuro"]) input[type=password],
:where(html[data-tema="escuro"]) input[type=email], :where(html[data-tema="escuro"]) select,
:where(html[data-tema="escuro"]) textarea {
  background: #0f1628; border-color: #33405e; }
:where(html[data-tema="escuro"]) input[type=file] { background: #111a2d; }
:where(html[data-tema="escuro"]) input::placeholder { color: #6d7a8f; }
/* A regra de cima empata com o input:focus do vendedor e viria depois: o foco precisa voltar aqui. */
:where(html[data-tema="escuro"]) input:focus, :where(html[data-tema="escuro"]) select:focus {
  border-color: #8797d8; box-shadow: 0 0 0 3px rgba(135, 151, 216, .22); }
:where(html[data-tema="escuro"]) textarea:focus {
  border-color: #8797d8; box-shadow: 0 0 0 3px rgba(135, 151, 216, .22); }

/* ---------- Botões e mensagens ---------- */
:where(html[data-tema="escuro"]) .btn-outline, :where(html[data-tema="escuro"]) .sair {
  background: var(--card); border-color: #3a4768; }
:where(html[data-tema="escuro"]) .btn-outline:hover, :where(html[data-tema="escuro"]) .sair:hover {
  background: var(--line-2); border-color: #4c5b82; }
:where(html[data-tema="escuro"]) .erro { border-color: #5c2a27; border-left-color: var(--danger); }
:where(html[data-tema="escuro"]) .pending { background: linear-gradient(120deg, #2a2213, #30260f); border-color: #5a4718; }
:where(html[data-tema="escuro"]) .pending-txt strong { color: #f0c35a; }
:where(html[data-tema="escuro"]) .ok-banner { border-color: #1f5a40; }

/* ---------- Selos ---------- */
:where(html[data-tema="escuro"]) .badge-aberta, :where(html[data-tema="escuro"]) .badge-alerta { border-color: #5a4718; }
:where(html[data-tema="escuro"]) .badge-divergente, :where(html[data-tema="escuro"]) .badge-recusada,
:where(html[data-tema="escuro"]) .badge-atraso { border-color: #5c2a27; }
:where(html[data-tema="escuro"]) .badge-enviada { border-color: #1f5a40; }
:where(html[data-tema="escuro"]) .badge-substituida, :where(html[data-tema="escuro"]) .badge-cancelada,
:where(html[data-tema="escuro"]) .badge-prazo { border-color: #34405c; }

/* ---------- Cartões e tabelas ---------- */
:where(html[data-tema="escuro"]) .card, :where(html[data-tema="escuro"]) .summary,
:where(html[data-tema="escuro"]) .form-card, :where(html[data-tema="escuro"]) .painel-bloco,
:where(html[data-tema="escuro"]) table.grid { background: var(--card); }
:where(html[data-tema="escuro"]) .secao-alerta { border-color: #5a4718; }
:where(html[data-tema="escuro"]) .contador { background: var(--brand); }
:where(html[data-tema="escuro"]) table.grid th { background: #1b2439; }
:where(html[data-tema="escuro"]) table.grid tbody tr:hover td { background: #1a2338; }
:where(html[data-tema="escuro"]) table.grid tr.linha-motivo td { color: #f0d08a; }
@media (max-width: 760px) {
  :where(html[data-tema="escuro"]) table.grid.cartoes tr { background: var(--card); }
}

/* ---------- Envio da fatura ---------- */
:where(html[data-tema="escuro"]) .envio-resumo { background: linear-gradient(120deg, #172036, #1a2440); border-color: var(--line); }
:where(html[data-tema="escuro"]) .req-card { background: linear-gradient(180deg, #172036, #131b2e); border-color: var(--line); }
:where(html[data-tema="escuro"]) .filedrop { background: #111a2d; border-color: #3a4768; }
:where(html[data-tema="escuro"]) .filedrop:hover { background: #151f36; border-color: #56668f; }
:where(html[data-tema="escuro"]) .filedrop.has-file { background: #0f2a1f; border-color: #2fbf71; }
:where(html[data-tema="escuro"]) .filedrop.sem-arquivo { background: #2d1518; border-color: #e5484d; }

/* ---------- Canhotos pendentes ---------- */
:where(html[data-tema="escuro"]) .pick-foto { background: #111a2d; border-color: #3a4768; color: #c9d4ee; }
:where(html[data-tema="escuro"]) .pick-foto:hover { background: #151f36; border-color: #56668f; }
:where(html[data-tema="escuro"]) .pick-foto.has-file { background: #0f2a1f; border-color: #2fbf71; color: #7fe0a9; }
:where(html[data-tema="escuro"]) .pick-foto.sem-arquivo { background: #2d1518; border-color: #e5484d; color: #ff9a9e; }

/* ---------- Login ---------- */
:where(html[data-tema="escuro"]) .authx {
  background: radial-gradient(1200px 600px at 15% -10%, #1b2748 0%, #111a2d 45%, var(--bg) 100%); }
:where(html[data-tema="escuro"]) .authx-card, :where(html[data-tema="escuro"]) .authx-form { background: var(--card); }
:where(html[data-tema="escuro"]) .authx-form input { background: #0f1628; border-color: var(--line); }
:where(html[data-tema="escuro"]) .authx-form input:focus { background: #0f1628; border-color: #8797d8; }
/* A onda branca entre a marca e o formulário tem a cor do cartão. */
:where(html[data-tema="escuro"]) .authx-wave path:last-child { fill: var(--card); }
@media (max-width: 560px) {
  :where(html[data-tema="escuro"]) .authx { background: var(--brand-grad); }
}

/* ---------- Switch do tema (mesmo visual nos dois temas) ---------- */
.tema-switch { display: inline-flex; align-items: center; gap: .4rem; flex: none; padding: .32rem .55rem;
  border: 1px solid rgba(255,255,255,.28); border-radius: 999px; background: rgba(255,255,255,.08);
  color: #fff; font: inherit; line-height: 1; cursor: pointer; transition: background .15s; }
.tema-switch:hover { background: rgba(255,255,255,.16); }
.tema-switch:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.tema-switch .ic { width: 15px; height: 15px; opacity: .5; transition: opacity .2s; }
.tema-switch[aria-checked="false"] .tema-ic-sol, .tema-switch[aria-checked="true"] .tema-ic-lua { opacity: 1; }
.tema-switch .tema-trilho { position: relative; width: 30px; height: 16px; border-radius: 999px;
  background: rgba(255,255,255,.3); transition: background .2s; }
.tema-switch .tema-bola { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .2s; }
.tema-switch[aria-checked="true"] .tema-trilho { background: var(--coral); }
.tema-switch[aria-checked="true"] .tema-bola { transform: translateX(14px); }
/* Na barra lateral: acima da marca, no canto superior esquerdo. */
.side > .tema-switch { align-self: flex-start; margin: 0 .5rem .5rem; }
/* Na barra do celular: sem o sol, para caber ao lado do menu. */
.topnav .tema-switch { padding: .3rem .45rem; }
.topnav .tema-switch .tema-ic-sol { display: none; }
/* No login: preso no canto superior esquerdo da tela. */
.tema-canto { position: fixed; top: 1rem; left: 1rem; z-index: 20;
  background: var(--brand); border-color: rgba(255,255,255,.35); box-shadow: var(--shadow-sm); }
.tema-canto:hover { background: var(--brand-dark); }
@media (prefers-reduced-motion: reduce) {
  .tema-switch .tema-trilho, .tema-switch .tema-bola, .tema-switch .ic { transition: none; }
}
