/* data-table.css — CSS do primitive data-table (.dt / .dt__*).
 * UX item 13 (2026-05-29): extraído de design-explorations/08-data-table-primitive.html,
 * que era o ÚNICO lugar onde esse CSS existia. Sem ele, o primitive renderiza unstyled
 * (ex.: .dt__sort-icon é um <svg> sem width/height → setas gigantes no orbit explorer e
 * na view de tabela do board). Reusa .control-bar/.btn (scout.css) e .metric-row (orbit-temp.css).
 * Carregado globalmente via index.html (preload). */

.dt { background: var(--bg); display: flex; flex-direction: column; }
.dt__caption { padding: 10px 16px 0; font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ----- HEAD (control-bar host) ----- */
.dt__head { border-bottom: 1px solid var(--border); background: var(--bg); }

/* ----- BULK BAR (substitui head quando há seleção) ----- */
.dt__bulkbar { padding: 10px 16px; background: var(--text); color: white; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--text); }
.dt__bulkbar-info { font-family: var(--sans); font-size: 13px; font-weight: 600; font-feature-settings: "tnum" 1; }
.dt__bulkbar-info strong { color: var(--gold); font-weight: 700; }
.dt__bulkbar-actions { margin-left: auto; display: flex; gap: 8px; }
.dt__bulkbar .btn { background: rgba(255,255,255,0.08); color: white; border-color: rgba(255,255,255,0.18); }
.dt__bulkbar .btn:hover { background: rgba(255,255,255,0.16); }
.dt__bulkbar .btn--primary { background: var(--gold); color: white; border-color: var(--gold); }
.dt__bulkbar .btn--primary:hover { background: #0c8650; border-color: #0c8650; }
.dt__bulkbar-clear { font-family: var(--mono); font-size: 11px; color: rgba(255,255,255,0.5); cursor: pointer; text-transform: uppercase; letter-spacing: 0.06em; }

/* ----- DENSITY TOGGLE ----- */
.dt__density-toggle { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.dt__density-toggle button { padding: 3px 8px; background: white; border: none; border-right: 1px solid var(--border); cursor: pointer; font-family: var(--mono); font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.dt__density-toggle button:last-child { border-right: none; }
.dt__density-toggle button.is-active { background: var(--text); color: white; }

/* ----- OVERFLOW MENU ----- */
.dt__overflow { position: relative; display: inline-block; }
.dt__overflow-btn { padding: 4px 8px; background: transparent; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; color: var(--text-muted); font-family: var(--sans); font-size: 13px; line-height: 1; }
.dt__overflow-btn:hover { background: var(--surface); color: var(--text); }
.dt__menu { position: absolute; right: 0; top: calc(100% + 4px); background: white; border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); min-width: 200px; padding: 4px; z-index: 20; }
.dt__menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; background: transparent; border: none; font-family: var(--sans); font-size: 12.5px; color: var(--text); cursor: pointer; text-align: left; border-radius: 4px; }
.dt__menu-item:hover { background: var(--surface); }
.dt__menu-item .dt__menu-shortcut { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-dim, var(--text-faint)); }
.dt__menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.dt__menu-label { padding: 4px 10px; font-family: var(--mono); font-size: 9.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* ----- TABLE ----- */
.dt__scroll { overflow-x: auto; width: 100%; }
.dt__table { width: 100%; border-collapse: separate; border-spacing: 0; font-family: var(--sans); font-size: 12.5px; }

/* THEAD */
.dt__thead { position: sticky; top: 0; z-index: 5; background: var(--surface); }
.dt__th { text-align: left; padding: 8px 12px; font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface); border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; vertical-align: middle; position: relative; }
.dt__th--num { text-align: right; }
.dt__th--check { width: 36px; padding-left: 14px; padding-right: 0; }
.dt__th--actions { width: 1%; text-align: right; padding-right: 14px; }
.dt__th--expand { width: 28px; padding: 0; }
.dt__th-content { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.dt__th.is-sortable .dt__th-content { cursor: pointer; }
.dt__th.is-sortable:hover { color: var(--text); }
.dt__th.is-sorted-asc, .dt__th.is-sorted-desc { color: var(--gold); }
.dt__th--num .dt__th-content { flex-direction: row-reverse; }
.dt__sort-icon { width: 10px; height: 10px; opacity: 0.4; flex: 0 0 auto; }
.dt__th.is-sorted-asc .dt__sort-icon, .dt__th.is-sorted-desc .dt__sort-icon { opacity: 1; }
.dt__th-filter-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); margin-left: 4px; display: inline-block; }
.dt__drag-handle { cursor: grab; opacity: 0; transition: opacity 80ms; margin-right: 4px; color: var(--text-dim, var(--text-faint)); font-family: var(--mono); font-size: 11px; line-height: 1; }
.dt__th:hover .dt__drag-handle { opacity: 0.7; }
.dt__drag-handle:active { cursor: grabbing; }
.dt__th.is-dragging { background: var(--gold-light, rgba(142, 45, 80, 0.08)); color: var(--gold); }
.dt__th.is-drop-target { box-shadow: inset 2px 0 0 var(--gold); }

/* TBODY */
.dt__tr { background: white; transition: background 60ms; }
.dt__tr:hover { background: var(--surface); }
.dt__tr.is-selected { background: var(--gold-light, rgba(142, 45, 80, 0.08)); }
.dt__tr.is-selected:hover { background: rgba(142, 45, 80, 0.12); }
.dt--zebra .dt__tbody .dt__tr:nth-child(even):not(.is-selected) { background: var(--surface); }
.dt--zebra .dt__tbody .dt__tr:nth-child(even):not(.is-selected):hover { background: var(--surface-2, #F3F4F6); }
.dt__td { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text); font-family: var(--sans); font-size: 12.5px; vertical-align: middle; position: relative; }
.dt__td--num { text-align: right; font-feature-settings: "tnum" 1; font-variant-numeric: tabular-nums; }
.dt__td--check { width: 36px; padding-left: 14px; padding-right: 0; }
.dt__td--actions { width: 1%; text-align: right; white-space: nowrap; padding-right: 14px; }
.dt__td--expand { width: 28px; padding: 0; text-align: center; }
.dt__td--badge { padding-top: 6px; padding-bottom: 6px; }
.dt__td--date { font-family: var(--sans); font-feature-settings: "tnum" 1; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.dt__td--empty { color: var(--text-dim, var(--text-faint)); font-family: var(--mono); font-size: 12px; }

/* Sticky columns */
.dt__th--sticky-left, .dt__td--sticky-left { position: sticky; left: 0; z-index: 2; background: var(--surface); box-shadow: 2px 0 0 -1px var(--border); }
.dt__tbody .dt__td--sticky-left { background: white; }
.dt__tr:hover .dt__td--sticky-left { background: var(--surface); }
.dt__tr.is-selected .dt__td--sticky-left { background: var(--gold-light, rgba(142, 45, 80, 0.08)); }
.dt__th--sticky-right, .dt__td--sticky-right { position: sticky; right: 0; z-index: 2; background: var(--surface); box-shadow: -2px 0 0 -1px var(--border); }
.dt__tbody .dt__td--sticky-right { background: white; }
.dt__tr:hover .dt__td--sticky-right { background: var(--surface); }
.dt__tr.is-selected .dt__td--sticky-right { background: var(--gold-light, rgba(142, 45, 80, 0.08)); }

/* Truncate + tooltip */
.dt__cell-trunc { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; cursor: default; }
.dt__td[data-tooltip]:hover::after { content: attr(data-tooltip); position: absolute; z-index: 30; background: var(--text); color: white; padding: 4px 8px; border-radius: 3px; font-family: var(--mono); font-size: 11px; white-space: normal; max-width: 300px; margin-top: 22px; margin-left: -8px; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }

/* Check / row actions */
.dt__check { width: 14px; height: 14px; accent-color: var(--text); cursor: pointer; vertical-align: middle; }
.dt__row-actions { display: inline-flex; gap: 4px; align-items: center; }
.dt__row-actions .btn { padding: 3px 8px; font-size: 11px; }
.dt__row-actions--reveal { opacity: 0; transition: opacity 80ms; }
.dt__tr:hover .dt__row-actions--reveal { opacity: 1; }

/* Numeric tone */
.dt__num-tone--good { color: var(--gold); font-weight: 600; }
.dt__num-tone--bad { color: var(--red); font-weight: 600; }

/* Density modifiers */
.dt--compact .dt__th { padding: 5px 10px; font-size: 10px; }
.dt--compact .dt__td { padding: 4px 10px; font-size: 12px; }
.dt--compact .dt__check { width: 13px; height: 13px; }
.dt--spacious .dt__th { padding: 12px 14px; }
.dt--spacious .dt__td { padding: 14px 14px; font-size: 13px; }

/* Expand row */
.dt__expand-btn { width: 18px; height: 18px; background: transparent; border: 1px solid var(--border); border-radius: 3px; cursor: pointer; font-family: var(--mono); font-size: 11px; line-height: 1; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.dt__expand-btn:hover { border-color: var(--text); color: var(--text); }
.dt__tr.is-expanded .dt__expand-btn { background: var(--text); color: white; border-color: var(--text); }
.dt__expand-row { background: var(--surface); }
.dt__expand-row > td { padding: 14px 18px 18px 46px; border-bottom: 1px solid var(--border); }
.dt__expand-content { font-size: 12.5px; line-height: 1.6; color: var(--text); }
.dt__expand-content dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.dt__expand-content dt { font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.dt__expand-content dd { font-family: var(--sans); font-size: 12.5px; color: var(--text); }
.dt__expand-content dd code { font-family: var(--mono); font-size: 11.5px; background: white; padding: 1px 5px; border-radius: 2px; border: 1px solid var(--border); }

/* Pagination / tfoot */
.dt__tfoot { background: var(--surface); border-top: 1px solid var(--border); }
.dt__pagination { padding: 8px 14px; display: flex; align-items: center; gap: 14px; font-family: var(--sans); font-size: 12px; }
.dt__pagination-info { color: var(--text-muted); font-family: var(--mono); font-size: 11px; font-feature-settings: "tnum" 1; text-transform: uppercase; letter-spacing: 0.04em; }
.dt__pagination-info strong { color: var(--text); font-weight: 700; }
.dt__pagination-btns { display: flex; gap: 2px; margin-left: auto; }
.dt__page-btn { min-width: 26px; height: 26px; padding: 0 8px; border: 1px solid var(--border); background: white; font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: 3px; font-feature-settings: "tnum" 1; }
.dt__page-btn:hover:not(.is-disabled):not(.is-active) { color: var(--text); border-color: var(--text); }
.dt__page-btn.is-active { background: var(--text); color: white; border-color: var(--text); }
.dt__page-btn.is-disabled { color: var(--text-dim, var(--text-faint)); cursor: not-allowed; opacity: 0.5; }
.dt__page-ellipsis { padding: 0 6px; color: var(--text-dim, var(--text-faint)); font-family: var(--mono); font-size: 11px; align-self: center; }
.dt__page-size { margin-left: 8px; display: inline-flex; align-items: center; gap: 6px; }
.dt__page-size select { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 3px; background: white; color: var(--text); cursor: pointer; }

/* Infinite scroll */
.dt__infinite-sentinel { padding: 18px; text-align: center; font-family: var(--mono); font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); text-transform: uppercase; letter-spacing: 0.08em; }
.dt__infinite-sentinel.is-loading::before { content: ''; display: inline-block; width: 10px; height: 10px; border: 2px solid var(--border-strong); border-top-color: var(--gold); border-radius: 50%; margin-right: 8px; animation: dt-spin 0.7s linear infinite; vertical-align: -2px; }
@keyframes dt-spin { to { transform: rotate(360deg); } }

/* Skeleton */
.dt__skeleton-cell { height: 12px; background: linear-gradient(90deg, var(--surface-2, #F3F4F6) 0%, var(--surface) 50%, var(--surface-2, #F3F4F6) 100%); background-size: 200% 100%; border-radius: 3px; animation: dt-shimmer 1.2s ease-in-out infinite; }
@keyframes dt-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.dt__skeleton-cell--sm { width: 60%; }
.dt__skeleton-cell--md { width: 80%; }
.dt__skeleton-cell--lg { width: 100%; }

/* Empty / error */
.dt__empty, .dt__error { padding: 48px 24px; text-align: center; border-bottom: 1px solid var(--border); }
.dt__empty-glyph, .dt__error-glyph { width: 32px; height: 32px; margin: 0 auto 14px; color: var(--text-dim, var(--text-faint)); }
.dt__error-glyph { color: var(--red); }
.dt__empty-title, .dt__error-title { font-family: var(--sans); font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; letter-spacing: -0.01em; }
.dt__empty-body, .dt__error-body { font-family: var(--sans); font-size: 12.5px; color: var(--text-muted); line-height: 1.6; max-width: 380px; margin: 0 auto 14px; }
.dt__empty-cta { margin-top: 4px; }

/* Responsive card collapse */
.dt__card-list { display: none; }
.dt__card { padding: 14px 16px; border-bottom: 1px solid var(--border); background: white; display: flex; flex-direction: column; gap: 8px; }
.dt__card:hover { background: var(--surface); }
.dt__card.is-selected { background: var(--gold-light, rgba(142, 45, 80, 0.08)); }
.dt__card-header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.dt__card-title { font-family: var(--sans); font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.dt__card-meta { font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); font-feature-settings: "tnum" 1; text-transform: uppercase; letter-spacing: 0.04em; }
.dt__card-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.dt__card-row dt { font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.dt__card-row dd { font-family: var(--sans); color: var(--text); font-feature-settings: "tnum" 1; text-align: right; }
.dt__card-actions { display: flex; gap: 6px; margin-top: 4px; }

@media (max-width: 768px) {
  .dt__scroll { display: none; }
  .dt__card-list { display: block; }
  .dt__pagination { flex-wrap: wrap; gap: 8px; }
  .dt__pagination-btns { width: 100%; justify-content: center; }
}
