/* HORUS Table — colunas redimensionáveis (estilo Excel) e ocultáveis (olhinho) */
table[data-horus-table] .horus-col-hidden { display: none !important; }

table[data-horus-table].horus-fixed { table-layout: fixed; }
table[data-horus-table].horus-fixed > thead > tr > th { box-sizing: border-box; }
table[data-horus-table].horus-fixed > thead > tr > th,
table[data-horus-table].horus-fixed > tbody > tr > td,
table[data-horus-table].horus-fixed > tfoot > tr > td {
  overflow: hidden;
  text-overflow: ellipsis;
}
table[data-horus-table].horus-measuring > thead > tr > th,
table[data-horus-table].horus-measuring > tbody > tr > td { white-space: nowrap !important; }

/* alça de arraste na borda direita do cabeçalho */
.horus-col-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
  user-select: none;
  touch-action: none;
}
.horus-col-handle::after {
  content: '';
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 3px;
  width: 1px;
  background: rgba(100, 116, 139, .35);
  transition: background .12s, width .12s, left .12s;
}
.horus-col-handle:hover::after,
.horus-col-handle.horus-dragging::after {
  top: 0;
  bottom: 0;
  left: 2px;
  width: 3px;
  background: #d4a017;
  border-radius: 2px;
}
body.horus-col-resizing { cursor: col-resize !important; user-select: none !important; }

/* barra com o olhinho */
.horus-tbl-bar { display: flex; justify-content: flex-end; padding: 4px 0; position: relative; }
.horus-tbl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.3;
  color: #475569;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
}
.horus-tbl-btn:hover { border-color: #d4a017; color: #1e293b; }
.horus-tbl-btn svg { width: 15px; height: 15px; flex: none; }
.horus-tbl-badge {
  min-width: 16px;
  padding: 0 5px;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  color: #78350f;
  background: #fde68a;
  border-radius: 8px;
}

.horus-tbl-pop {
  position: fixed;
  z-index: 10000;
  min-width: 220px;
  max-width: 300px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  font-size: 12.5px;
  color: #1e293b;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .18);
}
.horus-tbl-pop-title {
  padding: 4px 8px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #64748b;
}
.horus-tbl-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}
.horus-tbl-item:hover { background: #f1f5f9; }
.horus-tbl-item svg { width: 15px; height: 15px; flex: none; color: #0f766e; }
.horus-tbl-item.is-hidden { color: #94a3b8; }
.horus-tbl-item.is-hidden svg { color: #94a3b8; }
.horus-tbl-item.is-hidden span { text-decoration: line-through; }
.horus-tbl-sep { height: 1px; margin: 5px 2px; background: #e2e8f0; }
.horus-tbl-item.is-action { color: #475569; font-size: 12px; }

/* ===== Toque (tablet / celular) ===== */
@media (pointer: coarse) {
  .horus-col-handle { width: 24px; right: -12px; }
  .horus-col-handle::after { left: 11px; }
  .horus-tbl-btn { min-height: 38px; padding: 6px 12px; font-size: 13px; }
  .horus-tbl-item { padding: 10px 10px; font-size: 14px; }
}
@media (max-width: 1024px) {
  /* tablet: a tabela rola na horizontal dentro do painel */
  .horus-tbl-bar { padding: 6px 0; }
}

/* ===== Celular: tabela vira lista de cartões ===== */
@media (max-width: 760px) {
  table[data-horus-table],
  table[data-horus-table] > tbody,
  table[data-horus-table] > tbody > tr,
  table[data-horus-table] > tbody > tr > td { display: block; box-sizing: border-box; }
  table[data-horus-table] { width: 100% !important; min-width: 0 !important; table-layout: auto; }
  table[data-horus-table] > thead,
  table[data-horus-table] > tfoot { display: none !important; }
  .horus-col-handle { display: none; }

  table[data-horus-table] > tbody > tr {
    margin: 0 0 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
  }
  table[data-horus-table] > tbody > tr > td {
    width: 100% !important;
    min-width: 0 !important;
    padding: 8px 12px !important;
    text-align: left !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    border: 0 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    word-break: break-word;
  }
  table[data-horus-table] > tbody > tr > td:last-child { border-bottom: 0 !important; }
  table[data-horus-table] > tbody > tr > td[data-hlabel]::before {
    content: attr(data-hlabel);
    display: block;
    margin-bottom: 2px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #64748b;
  }
  /* células sem rótulo (seleção, ações): linha de botões */
  table[data-horus-table] > tbody > tr > td:not([data-hlabel]):not([colspan]) {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    background: #f8fafc;
  }
  table[data-horus-table] > tbody > tr > td:not([data-hlabel]):not([colspan]) .btn,
  table[data-horus-table] > tbody > tr > td:not([data-hlabel]):not([colspan]) a,
  table[data-horus-table] > tbody > tr > td:not([data-hlabel]):not([colspan]) button { min-height: 38px; }
  /* linhas de aviso (carregando / vazio / erro) */
  table[data-horus-table] > tbody > tr > td[colspan] { text-align: center !important; }
  table[data-horus-table] > tbody > tr > td.horus-col-hidden { display: none !important; }

  /* popover de colunas vira painel na base da tela */
  .horus-tbl-pop {
    left: 8px !important; right: 8px; top: auto !important; bottom: 8px;
    max-width: none; max-height: 70vh;
  }
}

@media print {
  .horus-tbl-bar,
  .horus-col-handle,
  .horus-tbl-pop {
    display: none !important;
  }
}
