/**
 * Graph Editor - Tables
 * Padrao visual SIGMA-PLI (tema claro)
 */

/* Table Wrapper - quando dentro de section-card, herda do container */
.table-wrapper {
  background: #ffffff;
  overflow: hidden;
}

.editor-section-card .table-wrapper {
  border-radius: 0;
  border: none;
  box-shadow: none;
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.data-table thead {
  background: var(--pli-gray-bg, #f0f0f1);
  color: var(--vw-text, #1e293b);
  border-bottom: 2px solid var(--vw-border, #e2e8f0);
}

.data-table th {
  padding: 12px 18px;
  text-align: center;
  font-weight: 600;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--vw-text-muted, #64748b);
}

.data-table tbody tr {
  background: #ffffff;
  border-bottom: 1px solid var(--vw-border, #e2e8f0);
  transition: background 0.2s;
}

.data-table tbody tr:hover {
  background: #e8f0fe;
}

.data-table td {
  padding: 12px 18px;
  text-align: center;
  vertical-align: middle;
  color: #1a2a4a;
}

/* Loading Row */
.loading-row td {
  text-align: center;
  padding: 40px 20px;
  color: #5a6a7a;
  font-size: var(--font-size-base);
}

/* Action Buttons in Table */
.table-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.btn-table-action {
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: #5a6a7a;
}

.btn-table-action:hover {
  background: rgba(26, 42, 74, 0.08);
}

.btn-table-action.edit {
  color: #1565c0;
}

.btn-table-action.edit:hover {
  background: rgba(21, 101, 192, 0.12);
}

.btn-table-action.delete {
  color: #c62828;
}

.btn-table-action.delete:hover {
  background: rgba(198, 40, 40, 0.1);
}

.btn-table-action.view {
  color: #2e7d32;
}

.btn-table-action.view:hover {
  background: rgba(46, 125, 50, 0.1);
}

/* Properties Cell */
.properties-preview {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Monaco", "Courier New", monospace;
  font-size: var(--font-size-xs);
  color: #3a4a5a;
}

/* Type Badge */
.type-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.type-badge.pessoa {
  background: rgba(25, 118, 210, 0.15);
  color: #1565c0;
}

.type-badge.usuario {
  background: rgba(56, 142, 60, 0.15);
  color: #2e7d32;
}

.type-badge.papel {
  background: rgba(123, 31, 162, 0.15);
  color: #7b1fa2;
}

.type-badge.permissao {
  background: rgba(198, 40, 40, 0.15);
  color: #c62828;
}

.type-badge.instituicao {
  background: rgba(136, 14, 79, 0.15);
  color: #880e4f;
}

.type-badge.arquivo {
  background: rgba(230, 81, 0, 0.15);
  color: #e65100;
}

.type-badge.produtor {
  background: rgba(0, 105, 92, 0.15);
  color: #00695c;
}

.type-badge.extensao {
  background: rgba(40, 53, 147, 0.15);
  color: #283593;
}

.type-badge.perfil {
  background: rgba(245, 124, 0, 0.15);
  color: #e65100;
}

.type-badge.tipousuario {
  background: rgba(121, 85, 72, 0.15);
  color: #4e342e;
}

/* ============================================
   CELL: Entidade (multi-linha: badge + nome + id)
   ============================================ */
.cell-entity {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cell-entity .type-badge {
  align-self: flex-start;
}

.cell-entity__name {
  font-weight: 500;
  color: #1a2a4a;
  font-size: var(--font-size-sm);
}

.cell-entity__id {
  font-family: "Monaco", "Courier New", monospace;
  font-size: 11px;
  color: #5a6a7a;
  opacity: 0.7;
}

/* ============================================
   CELL: Identificação (multi-linha: label + nome)
   ============================================ */
/* Node ID Cell (legado) */
.node-id {
  font-family: "Monaco", "Courier New", monospace;
  font-size: var(--font-size-xs);
  color: var(--dashboard-muted);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #5a6a7a;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: var(--font-size-base);
  margin: 0;
}

/* Edge info cells */
.edge-source,
.edge-target {
  vertical-align: middle;
  text-align: center;
}

/* Node cell inside edge source/target */
.node-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.3;
}

.node-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(21, 101, 192, 0.12);
  color: #1565c0;
}

.node-display {
  font-size: var(--font-size-sm, 13px);
  color: #1a2a4a;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.node-id {
  font-family: "Monaco", "Courier New", monospace;
  font-size: 10px;
  color: #7a8a9a;
}

.edge-type-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(21, 101, 192, 0.12);
  color: #1565c0;
}

/* Scrollbar */
.table-wrapper::-webkit-scrollbar {
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: var(--pli-gray-bg, #f0f0f1);
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(28, 61, 89, 0.2);
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(28, 61, 89, 0.35);
}

/* Compact Table Variant */
.data-table--compact th,
.data-table--compact td {
  padding: 8px 14px;
  font-size: var(--font-size-xs);
}

.data-table--compact code {
  font-family: "Monaco", "Courier New", monospace;
  font-size: 11px;
  background: rgba(28, 61, 89, 0.06);
  padding: 2px 6px;
  border-radius: 3px;
}

.type-desc-cell {
  text-align: left;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--vw-text-muted, #64748b);
  font-size: var(--font-size-xs);
}

/* Responsive */
@media (max-width: 768px) {
  .data-table {
    font-size: var(--font-size-xs);
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
  }

  .properties-preview {
    max-width: 150px;
  }
}
