/* ============================================================
   SwiszList — CSS canônico de listas/tabelas (.swl-*)
   Consome SOMENTE tokens de tokens.css. Não sobrescrever aqui.
   Carregado junto com components.css no <head> do index.html.
   ============================================================ */

/* ── Container principal ── */
.swl-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

/* ── Toolbar (busca global + contador + limpar) ── */
.swl-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.swl-busca {
  flex: 1 1 200px;
  min-width: 160px;
  max-width: 320px;
  height: 34px;
  padding: 0 10px;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease-out;
}
.swl-busca:focus { border-color: var(--sw-netuno); }
.swl-tb-count {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  white-space: nowrap;
}
.swl-btn-sm {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .12s ease-out, border-color .12s ease-out;
}
.swl-btn-sm:hover { background: var(--danger-bg); border-color: #F0C4AE; color: var(--danger); }

/* ── Wrapper com scroll-x (responsivo) ── */
.swl-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: auto;              /* scroll-x nativo; SwiszHBar sobrepõe barra flutuante */
  max-width: 100%;
}

/* ── Tabela ── */
.swl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

/* ── Cabeçalho: sticky, compacto, uppercase ── */
.swl-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
  user-select: none;
}
/* Ao passar o mouse no cabeçalho, sobe a coluna acima das vizinhas (cada th é z-index:2 = contexto
   próprio; sem isso o balão do tooltip fica preso e as colunas à direita pintam por cima dele). */
.swl-table thead th:hover { z-index: 20; }

/* linha de rótulos */
.swl-th {
  padding: 9px 12px 8px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-muted);
  text-align: left;
  vertical-align: bottom;
}
.swl-th-r { text-align: right; }
.swl-th-acoes { text-align: center; width: 1%; }

/* rótulo clicável para ordenação */
.swl-sortable { cursor: pointer; }
.swl-sortable:hover { color: var(--ink); }
.swl-th-label { vertical-align: middle; }

/* seta de ordenação (CSS triangle — mesma técnica do sw-table) */
.swl-table thead th .sort {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 5px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0;
}
.swl-table thead th.asc .sort  { border-bottom: 5px solid var(--primary); opacity: 1; }
.swl-table thead th.desc .sort { border-top: 5px solid var(--primary);    opacity: 1; }

/* ── Tooltip de cabeçalho ── */
.swl-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  vertical-align: middle;
}
.swl-tip-ic {
  width: 13px;
  height: 13px;
  color: var(--ink-muted);
  opacity: .6;
  flex: none;
}
.swl-tip:hover .swl-tip-ic,
.swl-tip:focus-visible .swl-tip-ic { opacity: 1; color: var(--sw-netuno); }
/* balão do tooltip */
.swl-tip-pop {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-drop);
  min-width: 180px;
  max-width: 260px;
  padding: 7px 10px;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.45;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  white-space: normal;
  pointer-events: none;
}
/* pequena setinha */
.swl-tip-pop::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--ink);
}
.swl-tip:hover .swl-tip-pop,
.swl-tip:focus-visible .swl-tip-pop { display: block; }

/* ── Linha de filtros (2ª linha do thead, sticky junto com a de rótulos) ── */
.swl-filter-row th {
  background: var(--surface-2);
  padding: 4px 8px 6px;
  border-bottom: 2px solid var(--line-2);
  vertical-align: middle;
}
.swl-tf { text-align: left; }
.swl-tf-r { text-align: right; }

/* inputs de filtro */
.swl-finput,
.swl-fsel,
.swl-fnum,
.swl-fdt {
  width: 100%;
  height: 26px;
  padding: 0 7px;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  outline: none;
  transition: border-color .12s ease-out;
  box-sizing: border-box;
}
.swl-finput:focus,
.swl-fsel:focus,
.swl-fnum:focus,
.swl-fdt:focus { border-color: var(--sw-netuno); }

/* faixa numérica e de datas: min–max lado a lado */
.swl-frange {
  display: flex;
  align-items: center;
  gap: 3px;
}
.swl-frange .swl-fnum { width: calc(50% - 8px); min-width: 40px; }
.swl-frange-dt .swl-fdt { width: calc(50% - 8px); min-width: 70px; }
.swl-fdash { font-size: var(--fs-xs); color: var(--ink-muted); flex: none; }

/* ── Corpo da tabela ── */
.swl-td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-1);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;      /* trunca colunas muito largas; title= mostra o valor completo */
  vertical-align: middle;
}
.swl-td-r {
  text-align: right;
  font-variant-numeric: tabular-nums;  /* números alinhados */
}
.swl-td-acoes {
  text-align: center;
  white-space: nowrap;
  max-width: none;
}

/* zebra (linhas pares) */
.swl-row-z td { background: var(--surface-2); }

/* hover de linha */
.swl-row:hover td { background: rgba(249, 222, 213, .4); }  /* blush 40% — igual sw-table */

/* coluna de seleção (selecao:true) */
.swl-col-sel { width: 42px; }
.swl-th-sel, .swl-td-sel { text-align: center; padding: 0 4px 0 12px; }
.swl-th-sel input, .swl-td-sel input { cursor: pointer; width: 15px; height: 15px; accent-color: var(--pumpkin, #F69861); vertical-align: middle; }
.swl-row-sel td { background: rgba(246, 152, 97, .12) !important; }

/* célula vazia (—) */
.swl-empty-cell { color: var(--ink-muted); }

/* linha de "nenhum resultado" */
.swl-empty-row {
  text-align: center;
  padding: 36px 16px !important;
  color: var(--ink-muted);
  font-size: var(--fs-sm);
  white-space: normal !important;
  max-width: none !important;
}

/* ── Paginador ── */
.swl-pager {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: 8px 0 2px;
  font-size: var(--fs-xs);
  color: var(--ink-muted);
}
.swl-pg-info { white-space: nowrap; }
.swl-pg-info b { color: var(--ink); font-weight: 700; }
.swl-pg-nav { display: flex; align-items: center; gap: 3px; }
.swl-pg-cur { font-size: var(--fs-xs); color: var(--ink-soft); padding: 0 6px; white-space: nowrap; }
.swl-pg-cur b { color: var(--ink); font-weight: 700; }
.swl-pg-b {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .1s, border-color .1s;
}
.swl-pg-b:hover:not(:disabled) { background: var(--surface-2); border-color: var(--sw-netuno); color: var(--ink); }
.swl-pg-b:disabled { opacity: .35; cursor: default; }
.swl-pg-size {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); color: var(--ink-muted);
  margin-left: auto;
}
.swl-pp-sel {
  height: 26px; padding: 0 5px;
  font-family: var(--font-ui); font-size: var(--fs-xs);
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 6px;
  cursor: pointer; outline: none;
}
.swl-pp-sel:focus { border-color: var(--sw-netuno); }

/* ── Responsivo: scroll-x sempre; cards no mobile ── */
@media (max-width: 560px) {
  .swl-toolbar { flex-direction: column; align-items: stretch; }
  .swl-busca { max-width: 100%; }

  /* cards: linha vira card empilhado */
  .swl-table-cards .swl-table,
  .swl-table-cards .swl-table tbody,
  .swl-table-cards .swl-table tr,
  .swl-table-cards .swl-table td { display: block; }
  .swl-table-cards .swl-table thead { display: none; }
  .swl-table-cards .swl-table tbody tr {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin: 0 0 10px;
    padding: 10px 12px;
    background: var(--surface);
  }
  .swl-table-cards .swl-table tbody td {
    border: none;
    padding: 3px 0;
    white-space: normal;
    max-width: none;
    display: flex;
    justify-content: space-between;
    gap: 8px;
  }
  .swl-table-cards .swl-table tbody td[data-l]::before {
    content: attr(data-l);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-muted);
  }
}
