/* =============================================================================
   Backoffice design system — mesmo tema escuro teal/petróleo do FDchat, portado
   para este console operacional. Tokens em :root idênticos ao original (mesma
   marca, mesma identidade visual); componentes abaixo incluem só o que este
   console usa (nav/filtros/tabelas/kpis/drawer) — nada de chat/login/composer.
   ============================================================================= */
:root {
  /* superfícies (escuro cinematográfico) */
  --bg:        #0b1417;
  --bg-2:      #0f1b1f;
  --panel:     #12212642;   /* fallback abaixo p/ browsers sem alpha em hex8 */
  --panel:     #122126;
  --panel-2:   #172a30;
  --panel-3:   #1d343b;
  --border:    #24393f;
  --border-2:  #2e474e;

  /* tinta */
  --text:      #eaf1f2;
  --text-dim:  #c4d3d6;
  --muted:     #8aa1a6;

  /* marca teal */
  --brand:        #2f8b9b;
  --brand-strong: #256f7d;
  --brand-soft:   #3aa7b8;
  --brand-050:    rgba(47,139,155,0.14);
  --brand-ring:   rgba(47,139,155,0.35);
  --accent:       var(--brand);   /* compat com estilos que ainda usam var(--accent) */

  /* semânticos */
  --success:   #2fae6b;
  --warning:   #e0a63a;
  --danger:    #e5595e;
  --track:     rgba(255,255,255,0.06);

  /* forma / elevação */
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-pill: 999px;
  --shadow:   0 1px 2px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.28);
  --shadow-lg:0 12px 40px rgba(0,0,0,.45);
  --grad-brand: linear-gradient(135deg, #2f8b9b 0%, #256f7d 100%);
  --grad-app:   radial-gradient(1200px 600px at 80% -10%, rgba(47,139,155,.12), transparent 60%),
                radial-gradient(900px 500px at 0% 110%, rgba(47,139,155,.08), transparent 55%);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
/* Inter já é carregada via Google Fonts no index.html — não importar fonte aqui. */
body { background-image: var(--grad-app); background-attachment: fixed; }
#main { height: 100%; }
::selection { background: var(--brand-ring); }

/* scrollbar discreta */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--brand-strong); }

/* ---------- Marca ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -0.02em; }
.brand__mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--grad-brand);
  display: inline-grid; place-items: center; color: #fff; box-shadow: 0 4px 12px rgba(47,139,155,.4);
}
.brand__mark svg { width: 13px; height: 13px; }
.brand__fd { color: var(--text); }
.brand__accent { color: var(--brand-soft); }

/* ---------- Login ---------- */
.login {
  height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login__card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 30px 28px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow-lg);
}
.login__brand { margin-bottom: 6px; font-size: 20px; }
.login__title { font-size: 18px; font-weight: 700; margin: 0; }
.login__sub { font-size: 13px; color: var(--muted); margin: -8px 0 4px 0; line-height: 1.4; }
.login__card input {
  padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--border-2);
  background: var(--bg-2); color: var(--text); font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login__card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.login__card button {
  padding: 12px 14px; border: 0; border-radius: var(--r); background: var(--grad-brand);
  color: #fff; font-weight: 700; cursor: pointer; font-size: 14px;
  box-shadow: 0 6px 16px rgba(47,139,155,.35); transition: transform .12s, filter .15s;
}
.login__card button:hover { filter: brightness(1.06); }
.login__card button:active { transform: translateY(1px); }
.login__card button:disabled { opacity: .5; cursor: default; filter: none; }
.login__error { color: var(--danger); font-size: 13px; min-height: 16px; }

/* ---------- App shell / topbar ---------- */
.app { display: flex; flex-direction: column; height: 100vh; width: 100%; }

.appbar {
  /* 3 grupos (marca | nav | status+link) — space-between empurra as pontas,
     o gap cobre o espaçamento mínimo quando a viewport encolhe. */
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(18,33,38,.9), rgba(11,20,23,.6));
  backdrop-filter: blur(8px); /* efeito glass: conteúdo por baixo continua legível ao rolar */
}
.appbar .brand { font-size: 16px; }

/* ---------- Navegação (abas / rotas) ---------- */
.nav { display: flex; align-items: center; gap: 6px; }
.nav__btn {
  /* são <a> (dioxus Link), não <button>: sem isso herdariam sublinhado e
     alinhamento de texto inline em vez de pill centralizada. */
  display: inline-flex; align-items: center; text-decoration: none;
  padding: 9px 15px; border: 1px solid transparent; border-radius: var(--r-pill);
  background: transparent; color: var(--muted); font-weight: 600; cursor: pointer;
  font-size: 13px; transition: background .15s, color .15s, border-color .15s;
}
.nav__btn:hover { color: var(--text); background: var(--panel-2); }
.nav__btn--active { color: #fff; background: var(--grad-brand); box-shadow: 0 4px 12px rgba(47,139,155,.3); }

.logout-btn {
  /* outline neutro compartilhado por dois usos na appbar: o link de leitura
     ("API docs") e o botão "Sair" — por isso hover em --brand (neutro), não
     --danger: não é só o botão de logout. */
  display: inline-flex; align-items: center; text-decoration: none;
  padding: 8px 14px; border: 1px solid var(--border-2); border-radius: var(--r-pill);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600;
  font-family: inherit; transition: color .15s, border-color .15s;
}
.logout-btn:hover { border-color: var(--brand); color: var(--brand-soft); }

/* ---------- Cartões / superfícies ---------- */
.panel { max-width: 1240px; margin: 0 auto; padding: 26px; height: 100%; overflow-y: auto; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.section-title { font-size: 16px; font-weight: 700; margin: 0 0 14px 0; letter-spacing: -0.01em; }

/* KPI tiles */
.kpi-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.kpi {
  flex: 1; min-width: 160px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px;
  position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grad-brand); }
.kpi__label { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
/* tabular-nums: dígitos de largura fixa, o valor não "dança" a cada atualização de contagem */
.kpi__value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* variantes semânticas (enviados / falhas) — trocam só a barra esquerda */
.kpi--ok::before { background: var(--success); }
.kpi--no::before { background: var(--danger); }

/* Chips de status */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; border: 1px solid transparent;
}
.chip--ok   { background: rgba(47,174,107,.14); color: #66d69b; border-color: rgba(47,174,107,.3); }
.chip--no   { background: rgba(229,89,94,.14);  color: #f0898d; border-color: rgba(229,89,94,.3); }
.chip--info { background: var(--brand-050); color: var(--brand-soft); border-color: var(--brand-ring); }

/* ---------- Filtros ---------- */
.filters {
  /* horizontal e com wrap: aqui não há sidebar, os filtros ficam no topo do
     card, então empilham em linha e quebram quando a viewport aperta.
     align-items: flex-end alinha o botão de ação com a base dos inputs/labels. */
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.filters .f, .f {
  padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--border-2);
  background: var(--bg-2); color: var(--text); font-size: 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.f:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
select.f { appearance: auto; cursor: pointer; }
.new-btn {
  padding: 10px 12px; border: 1px solid var(--border-2); border-radius: var(--r-sm);
  background: var(--panel-2); color: var(--text); font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s;
}
.new-btn:hover { border-color: var(--brand); background: var(--brand-050); }

/* ---------- CTAs (ação primária / secundária) ---------- */
.cta-primary {
  display: inline-flex; align-items: center; gap: 8px; padding: 14px 26px; border: 0;
  border-radius: var(--r-pill); background: var(--grad-brand); color: #fff; font-weight: 700; font-size: 15px;
  cursor: pointer; box-shadow: 0 8px 22px rgba(47,139,155,.4); transition: transform .12s, filter .15s, opacity .15s;
}
.cta-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.cta-primary:active { transform: translateY(1px); filter: brightness(0.98); }
.cta-primary:disabled { opacity: .5; cursor: not-allowed; filter: none; transform: none; }

.cta-ghost {
  display: inline-flex; align-items: center; padding: 14px 26px; border: 1px solid var(--border-2);
  border-radius: var(--r-pill); background: rgba(255,255,255,.03); color: var(--text); font-weight: 700; font-size: 15px;
  cursor: pointer; transition: border-color .15s, background .15s, opacity .15s;
}
.cta-ghost:hover { border-color: var(--brand); background: var(--brand-050); }
.cta-ghost:active { background: var(--panel-2); }
.cta-ghost:disabled { opacity: .5; cursor: not-allowed; border-color: var(--border-2); background: transparent; }

/* ---------- Lista / detalhe do histórico ---------- */
.row {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 12px 14px; border-bottom: 1px solid var(--border); transition: background .12s;
}
.row:hover { background: var(--panel-2); }
.row--active { background: var(--panel-2); border-left: 3px solid var(--brand); }

.drawer {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px;
}

/* tabelas: estilo inline vem de src/style.rs, só precisamos do hover de linha */
tbody tr:hover { background: rgba(255,255,255,0.02); }

/* Linha de tabela clicável (histórico). NÃO reutiliza `.row`: aquela classe é `display:flex`,
   o que faria o <tr> perder a grade de colunas e empilhar as células. */
tbody tr.tr-click { cursor: pointer; transition: background .12s; }
tbody tr.tr-click:hover { background: var(--panel-2); }
/* Marca a linha ativa com `box-shadow: inset` em vez de `border-left`: em tabela com
   `border-collapse` uma borda extra na linha desloca as colunas ao selecionar, e a tabela
   "pula" a cada clique. O inset ocupa zero espaço de layout. */
tbody tr.tr-active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--brand); }

/* ---------- Campos de formulário nus (usados direto nas views) ---------- */
.card input, .card select, .card textarea,
.filters input, .filters select, .filters textarea {
  padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--border-2);
  background: var(--bg-2); color: var(--text); font-size: 13px; font-family: inherit;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.card input:focus, .card select:focus, .card textarea:focus,
.filters input:focus, .filters select:focus, .filters textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring);
}
/* <select> nativo herda cores do SO (branco no Windows) — sem isto fica
   ilegível sobre o tema escuro; forçamos a opção a usar as cores do painel. */
option { background: var(--panel-2); color: var(--text); }
