/* ============================================================
   Omniai · frontend de exemplo
   Usa os tokens do design system da HIT (css/tokens.css). Nenhuma cor é
   declarada aqui em hexadecimal: tudo vem de var(--hit-*), para que a troca
   de marca do white-label alcance esta aplicação também.
   ============================================================ */

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

body {
  font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--hit-bg);
  color: var(--hit-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

/* ---------------------------------------------------------- Sidebar */
.sidebar {
  background: var(--hit-sidebar-bg);
  border-right: 1px solid var(--hit-sidebar-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-logo { padding: 22px 20px 18px; border-bottom: 1px solid var(--hit-sidebar-border); }
.sidebar-logo img { height: 30px; }
.tenant {
  margin: 16px 12px; padding: 12px;
  background: var(--hit-sidebar-elevated);
  border: 1px solid var(--hit-sidebar-border);
  border-radius: 10px;
  display: flex; gap: 10px; align-items: center;
}
.tenant-badge {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  background: var(--hit-primary-soft); color: var(--hit-primary-strong);
  display: grid; place-items: center; font-weight: 700; font-size: 11px;
}
.tenant-name { font-weight: 600; color: var(--hit-sidebar-text); font-size: 13px; }
.tenant-sub { font-size: 11px; color: var(--hit-sidebar-subtle); }

.nav { padding: 4px 12px; flex: 1; overflow-y: auto; }
.nav-group {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--hit-sidebar-subtle); padding: 16px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  color: var(--hit-sidebar-muted); font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--hit-sidebar-elevated); color: var(--hit-sidebar-text); }
.nav-item.active {
  background: var(--hit-primary-soft);
  color: var(--hit-primary-strong);
  border-left-color: var(--hit-primary);
  font-weight: 600;
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.sidebar-foot {
  padding: 12px 20px; border-top: 1px solid var(--hit-sidebar-border);
  background: var(--hit-sidebar-footer);
  font-size: 11px; color: var(--hit-sidebar-subtle);
}

/* ---------------------------------------------------------- Cabeçalho */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--hit-surface); border-bottom: 1px solid var(--hit-border);
  padding: 18px 28px; display: flex; align-items: center; gap: 20px;
  flex-wrap: wrap; position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 24px; font-weight: 600; color: var(--hit-bright); }
.page-desc { font-size: 14px; color: var(--hit-muted); }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--hit-subtle);
}
.field input, .field select {
  background: var(--hit-input); border: 1px solid var(--hit-border);
  border-radius: 8px; padding: 8px 11px; font-size: 14px;
  color: var(--hit-text); font-family: inherit; min-width: 140px;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--hit-primary);
  box-shadow: 0 0 0 3px var(--hit-primary-soft);
}
.btn {
  background: var(--hit-primary); color: #fff; border: none;
  border-radius: 8px; padding: 9px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .12s;
}
.btn:hover { background: var(--hit-primary-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost {
  background: transparent; color: var(--hit-muted);
  border: 1px solid var(--hit-border);
}
.btn-ghost:hover { background: var(--hit-surface-muted); color: var(--hit-text); }

/* ---------------------------------------------------------- Conteúdo */
.content { padding: 24px 28px 40px; }
.view { display: none; }
.view.active { display: block; }

.banner {
  background: var(--hit-primary-soft); border: 1px solid var(--hit-primary-line);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 20px;
  font-size: 13px; color: var(--hit-text); display: flex; gap: 10px; align-items: center;
}
.banner strong { color: var(--hit-primary-strong); letter-spacing: .04em; font-size: 11px; text-transform: uppercase; }

.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--hit-surface); border: 1px solid var(--hit-border);
  border-radius: 12px; overflow: hidden;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--hit-border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 16px; font-weight: 600; color: var(--hit-bright); }
.card-sub { font-size: 12px; color: var(--hit-subtle); }
.card-body { padding: 18px; }

/* KPI com faixa de cor no topo, como no design system */
.kpi { position: relative; padding: 18px; padding-top: 20px; }
.kpi::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--band, var(--hit-tone-neutral-band));
}
.kpi-label {
  font-size: 12px; font-weight: 600; color: var(--tone, var(--hit-muted));
  text-transform: lowercase;
}
.kpi-value { font-size: 24px; font-weight: 600; color: var(--value, var(--hit-bright)); margin-top: 2px; }
.kpi-hint { font-size: 12px; color: var(--hit-subtle); margin-top: 2px; }

.tone-primary { --band: var(--hit-tone-primary-band); --tone: var(--hit-tone-primary-text); --value: var(--hit-tone-primary-value); }
.tone-info    { --band: var(--hit-tone-info-band);    --tone: var(--hit-tone-info-text);    --value: var(--hit-tone-info-value); }
.tone-success { --band: var(--hit-tone-success-band); --tone: var(--hit-tone-success-text); --value: var(--hit-tone-success-value); }
.tone-warning { --band: var(--hit-tone-warning-band); --tone: var(--hit-tone-warning-text); --value: var(--hit-tone-warning-value); }
.tone-danger  { --band: var(--hit-tone-danger-band);  --tone: var(--hit-tone-danger-text);  --value: var(--hit-tone-danger-value); }
.tone-accent  { --band: var(--hit-tone-accent-band);  --tone: var(--hit-tone-accent-text);  --value: var(--hit-tone-accent-value); }

.chart-wrap { position: relative; height: 260px; }

/* ---------------------------------------------------------- Tabela */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--hit-subtle); text-align: left;
  padding: 10px 18px; border-bottom: 1px solid var(--hit-border);
  background: var(--hit-surface-muted);
  position: sticky; top: 0;
}
tbody td { padding: 12px 18px; border-bottom: 1px solid var(--hit-border); font-size: 14px; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--hit-primary-soft); }
tbody tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--chip-soft, var(--hit-tone-neutral-soft));
  color: var(--chip-text, var(--hit-tone-neutral-text));
  border: 1px solid var(--chip-line, var(--hit-tone-neutral-line));
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-plain::before { display: none; }

/* ---------------------------------------------------------- Detalhe */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(11, 18, 32, .45);
  display: none; z-index: 40;
}
.drawer-backdrop.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 94vw);
  background: var(--hit-canvas); border-left: 1px solid var(--hit-border);
  transform: translateX(100%); transition: transform .22s ease;
  z-index: 41; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 18px 22px; border-bottom: 1px solid var(--hit-border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
}
.drawer-body { padding: 20px 22px 32px; overflow-y: auto; flex: 1; }
.close-x {
  background: none; border: none; cursor: pointer; font-size: 22px;
  color: var(--hit-subtle); line-height: 1; padding: 2px 6px;
}
.close-x:hover { color: var(--hit-text); }

.section-title {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--hit-subtle); margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

.turn { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--hit-border); }
.turn:last-child { border-bottom: none; }
.turn-who { font-weight: 600; color: var(--hit-bright); font-size: 13px; min-width: 110px; flex: none; }
.turn-time { font-size: 11px; color: var(--hit-subtle); font-variant-numeric: tabular-nums; }
.turn-text { font-size: 14px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--hit-subtle); font-size: 12px; }
.kv dd { color: var(--hit-text); }

pre.json {
  background: var(--hit-surface-muted); border: 1px solid var(--hit-border);
  border-radius: 8px; padding: 12px; font-size: 12px; overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--hit-text);
  white-space: pre-wrap; word-break: break-word;
}

.empty, .loading {
  text-align: center; padding: 48px 20px; color: var(--hit-subtle); font-size: 14px;
}
.err {
  background: var(--hit-tone-danger-soft); border: 1px solid var(--hit-tone-danger-line);
  color: var(--hit-tone-danger-value); border-radius: 10px; padding: 14px 16px;
  font-size: 14px; margin-bottom: 18px;
}

.bar-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; font-size: 14px; }
.bar-label { width: 190px; flex: none; color: var(--hit-text); }
.bar-track { flex: 1; height: 10px; background: var(--hit-surface-muted); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--hit-primary); border-radius: 999px; }
.bar-num { width: 62px; text-align: right; color: var(--hit-muted); font-variant-numeric: tabular-nums; font-size: 13px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ---------------------------------------------------------- Filtros */
.filtros {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.filtros .field input, .filtros .field select { min-width: 0; width: 100%; }
.filtro-resumo {
  margin-top: 14px; font-size: 13px; color: var(--hit-muted);
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}

/* ---------------------------------------------------------- Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(11, 18, 32, .5);
  display: none; z-index: 50;
}
.modal-backdrop.open { display: block; }
.modal {
  position: fixed; z-index: 51; display: none;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(820px, 94vw); max-height: 88vh;
  background: var(--hit-canvas); border: 1px solid var(--hit-border);
  border-radius: 14px; box-shadow: 0 24px 60px rgba(11, 18, 32, .22);
  flex-direction: column;
}
.modal.open { display: flex; }
.modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--hit-border);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
}
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--hit-border);
  background: var(--hit-surface-muted); display: flex; align-items: center; gap: 12px;
  border-radius: 0 0 14px 14px;
}
.modal-erro { font-size: 13px; color: var(--hit-tone-danger-value); }

/* Editor de configuração */
.linha-item {
  display: grid; gap: 10px; align-items: end;
  padding: 10px 0; border-bottom: 1px solid var(--hit-border);
}
.linha-cat { grid-template-columns: 1fr 1.4fr auto; }
.linha-perg { grid-template-columns: 1fr 1.1fr 90px auto; }
.linha-item:last-child { border-bottom: none; }
.btn-x {
  background: none; border: 1px solid var(--hit-border); border-radius: 8px;
  width: 34px; height: 34px; cursor: pointer; color: var(--hit-subtle);
  font-size: 17px; line-height: 1;
}
.btn-x:hover { border-color: var(--hit-tone-danger-line); color: var(--hit-tone-danger-text); }

.grupo-box {
  border: 1px solid var(--hit-border); border-radius: 10px;
  padding: 14px; margin-bottom: 12px; background: var(--hit-surface-muted);
}
.grupo-head { display: flex; gap: 10px; align-items: end; margin-bottom: 8px; }
.grupo-head .field { flex: 1; }

.aviso {
  background: var(--hit-tone-info-soft); border: 1px solid var(--hit-tone-info-line);
  color: var(--hit-text); border-radius: 8px; padding: 10px 12px;
  font-size: 13px; margin-bottom: 16px;
}
.soma-pesos { font-size: 13px; color: var(--hit-muted); margin-top: 8px; }
.soma-pesos.excede { color: var(--hit-tone-danger-value); font-weight: 600; }

/* O flex fica num wrapper, não no <td>: um `display:flex` na célula a tira do
   layout de tabela, e ela perde o alinhamento e a borda compartilhada da linha. */
.acoes-linha { text-align: right; white-space: nowrap; }
.acoes-linha .acoes { display: inline-flex; gap: 6px; justify-content: flex-end; }
.btn-mini {
  background: none; border: 1px solid var(--hit-border); border-radius: 7px;
  padding: 5px 10px; font-size: 12px; cursor: pointer; color: var(--hit-muted);
  font-family: inherit;
}
.btn-mini:hover { background: var(--hit-surface-muted); color: var(--hit-text); }
.btn-mini.perigo:hover { border-color: var(--hit-tone-danger-line); color: var(--hit-tone-danger-text); }

/* ---------------------------------------------------------- Paginação */
.paginacao {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--hit-border);
  background: var(--hit-surface-muted); font-size: 13px; color: var(--hit-muted);
}
.paginacao .pag-info { font-variant-numeric: tabular-nums; }
.paginacao .pag-nav { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.paginacao select {
  background: var(--hit-input); border: 1px solid var(--hit-border);
  border-radius: 7px; padding: 5px 8px; font-size: 13px;
  color: var(--hit-text); font-family: inherit;
}
.pag-btn {
  background: var(--hit-surface); border: 1px solid var(--hit-border);
  border-radius: 7px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  color: var(--hit-text); font-family: inherit; min-width: 34px;
}
.pag-btn:hover:not(:disabled) { background: var(--hit-primary-soft); border-color: var(--hit-primary-line); }
.pag-btn:disabled { opacity: .45; cursor: not-allowed; }
.pag-btn.atual {
  background: var(--hit-primary); border-color: var(--hit-primary);
  color: #fff; font-weight: 600;
}
.pag-req {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px;
  color: var(--hit-subtle); background: var(--hit-surface);
  border: 1px solid var(--hit-border); border-radius: 6px; padding: 3px 7px;
}

/* ---------------------------------------------------------- Envio */
.solta {
  border: 2px dashed var(--hit-border-strong); border-radius: 12px;
  padding: 34px 20px; text-align: center; color: var(--hit-muted);
  background: var(--hit-surface-muted); transition: border-color .15s, background .15s;
  cursor: pointer;
}
.solta:hover, .solta.sobre {
  border-color: var(--hit-primary); background: var(--hit-primary-soft);
}
.solta.sobre { border-style: solid; }
.solta-icone { color: var(--hit-subtle); margin-bottom: 10px; }
.solta strong { color: var(--hit-bright); }
.solta-dica { font-size: 12px; color: var(--hit-subtle); margin-top: 8px; }

.btn-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--hit-primary-strong); font: inherit; text-decoration: underline;
}

.envio-opcoes {
  display: flex; gap: 24px; align-items: flex-end; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--hit-border);
}
.opcao { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.opcao input { margin-top: 3px; }
.opcao small { display: block; color: var(--hit-subtle); font-size: 12px; }

.linha-pulada { opacity: .5; }
.prog {
  height: 4px; background: var(--hit-border); border-radius: 999px;
  overflow: hidden; margin-top: 6px;
}
.prog-fill { height: 100%; background: var(--hit-primary); transition: width .3s; }

/* Ações no cabeçalho de um card: ficam na mesma linha do título, à direita. */
.card-head .acoes { display: flex; gap: 8px; align-items: center; }

/* ------------------------------------------------ seleção de chamadas */
.col-sel { width: 36px; }
.col-sel input { cursor: pointer; }

/* Apagar é irreversível: o botão se distingue dos demais sem gritar. */
.btn-perigo {
  border-color: var(--hit-tone-danger-line);
  color: var(--hit-tone-danger-value);
}
.btn-perigo:hover:not(:disabled) {
  background: var(--hit-tone-danger-soft);
  border-color: var(--hit-tone-danger-band);
}

tr.selecionada > td { background: var(--hit-tone-info-soft); }
