/*
 * data_grid.css -- Tabulator on the design tokens. Imports the vendored
 * "simple" Tabulator theme, then overrides its colors, fonts and spacing
 * with our tokens, so the grid follows the app's theme (dark mode
 * included) without a build. Tabulator's stylesheets carry no CSS
 * variables, hence selector overrides rather than a variable map.
 */
@import url("./vendor/tabulator/tabulator_simple.min.css");

.dg-host.tabulator {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  overflow: hidden;
}

/* header */
.dg-host.tabulator .tabulator-header {
  background: var(--surface-2);
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border-strong);
  font-weight: 600;
}
.dg-host.tabulator .tabulator-header .tabulator-col {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}
.dg-host.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
  background: var(--surface-3);
}
.dg-host.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}
.dg-host.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="ascending"] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
  border-bottom-color: var(--accent);
}
.dg-host.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="descending"] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
  border-top-color: var(--accent);
}
.dg-host.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input,
.dg-host.tabulator .tabulator-header .tabulator-col .tabulator-header-filter select {
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  box-sizing: border-box;
  width: 100%;
}

/* rows */
.dg-host.tabulator .tabulator-tableholder {
  background: var(--surface);
}
.dg-host.tabulator .tabulator-row {
  background: var(--surface);
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}
.dg-host.tabulator .tabulator-row.tabulator-row-even {
  background: var(--bg-subtle);
}
.dg-host.tabulator .tabulator-row.tabulator-selectable:hover {
  background: var(--accent-soft);
  cursor: default;
}
.dg-host.tabulator .tabulator-row.tabulator-selected,
.dg-host.tabulator .tabulator-row.tabulator-selected:hover {
  background: var(--accent-border);
}
.dg-host.tabulator .tabulator-row .tabulator-cell {
  padding: var(--space-2) var(--space-3);
  border-right: 1px solid var(--border);
}
.dg-host.tabulator .tabulator-row .tabulator-cell a {
  color: var(--accent);
}
.dg-host.tabulator .tabulator-row .tabulator-cell .dg-meta,
.dg-host.tabulator .tabulator-row .tabulator-cell .dg-note {
  display: block;
  font-size: var(--text-xs);
  color: var(--fg-muted);
  white-space: normal;
  line-height: 1.3;
}
.dg-host.tabulator .tabulator-row .tabulator-cell.dg-actions {
  overflow: visible;
}
.dg-host.tabulator .tabulator-tableholder .tabulator-placeholder .tabulator-placeholder-contents {
  color: var(--fg-muted);
  font-size: var(--text-base);
  background: transparent;
}

/* actions */
.dg-actions-box .dg-action {
  font-size: var(--text-xs);
  padding: 2px 8px;
  margin-right: 4px;
}
.dg-actions-box .dg-action.dg-failed {
  color: var(--danger);
  border-color: var(--danger);
}

/* footer and pagination */
.dg-host.tabulator .tabulator-footer {
  background: var(--surface-2);
  color: var(--fg-muted);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
}
.dg-host.tabulator .tabulator-footer .tabulator-page,
.dg-host.tabulator .tabulator-footer .tabulator-page-size {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}
.dg-host.tabulator .tabulator-footer .tabulator-page.active {
  color: var(--accent);
  border-color: var(--accent);
}
.dg-host.tabulator .tabulator-footer .tabulator-page:not(:disabled):hover {
  background: var(--accent-soft);
  color: var(--fg);
}

/* our own footer line (count, reset layout) */
.dg-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: var(--space-2) 0 var(--space-5);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}
.dg-foot .dg-reset {
  font-size: var(--text-xs);
  padding: 2px 8px;
}

/* the popup a "list" header filter opens (top layer, outside .dg-host) */
.tabulator-edit-list {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}
.tabulator-edit-list .tabulator-edit-list-item {
  color: var(--fg);
}
.tabulator-edit-list .tabulator-edit-list-item.active,
.tabulator-edit-list .tabulator-edit-list-item:hover {
  background: var(--accent-soft);
  color: var(--fg);
}

/* the pager of a paged grid, above the rows (Tabulator's footer markup, moved) */
.dg-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0;
  font-size: var(--text-xs);
  color: var(--fg-muted);
}
.dg-pager .tabulator-paginator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.dg-pager .tabulator-page,
.dg-pager .tabulator-page-size {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  padding: 2px 8px;
  cursor: pointer;
}
.dg-pager .tabulator-page.active {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.dg-pager .tabulator-page:disabled {
  opacity: .45;
  cursor: default;
}
.dg-pager .tabulator-page:not(:disabled):hover {
  background: var(--accent-soft);
}
.dg-pager .dg-page-counter {
  margin-right: var(--space-3);
  font-weight: 600;
  color: var(--fg);
}
.dg-pager label {
  margin: 0 4px 0 var(--space-3);
}
.dg-pager .tabulator-page-size {
  width: auto;
  margin-right: var(--space-3);
}

/* the expand arrow and the row it opens (opts.detail) */
/* the arrow sits at the bottom of a tall cell (a row is subject plus
   snippet), where the eye leaves the row, not floating above the text */
/* the arrow sits at the bottom of a tall cell (a row is subject plus
   snippet), where the eye leaves the row. Absolute, not flex: Tabulator
   lays its cells out inline-block, and a flex cell drops the rest of the
   row onto the next line. */
.dg-host.tabulator .tabulator-cell.dg-expander {
  padding: 0;
  position: relative;
}
.dg-host.tabulator .tabulator-cell.dg-expander .dg-expand {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
}
.dg-expand {
  background: none;
  border: 0;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  line-height: 1;
  padding: 4px 6px;
}
.dg-expand:hover {
  color: var(--accent);
}
.dg-detail {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--fg);
  max-height: 32rem;
  overflow: auto;
}
.dg-detail pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.dg-detail.dg-failed {
  color: var(--danger);
}


/* searchHistory: the arrow inside a text box and its dropdown */
.sh-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.sh-wrap > input {
  flex: 1;
  min-width: 0;
  padding-right: 1.8rem;
}
.sh-arrow {
  position: absolute;
  right: 4px;
  background: none;
  border: 0;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: var(--text-sm);
  line-height: 1;
  padding: 3px 5px;
}
.sh-arrow:hover {
  color: var(--accent);
}
.sh-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 18rem;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  font-size: var(--text-sm);
}
.sh-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-3);
  cursor: pointer;
}
.sh-item:hover, .sh-item.sh-active {
  background: var(--accent-soft);
}
.sh-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.sh-forget {
  background: none;
  border: 0;
  color: var(--fg-subtle);
  cursor: pointer;
  padding: 0 4px;
}
.sh-forget:hover {
  color: var(--danger);
}
.sh-empty {
  padding: 4px var(--space-3);
  color: var(--fg-muted);
  font-size: var(--text-xs);
}
