/*
 * 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);
}
/* Underlined: color alone did not say "tap me" on a phone (feedback 3VK7D).
   Buttons drawn as links (.btn) keep their own look. */
.dg-host.tabulator .tabulator-row .tabulator-cell a:not(.btn) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dg-host.tabulator.dg-rowlink .tabulator-row { cursor: pointer; }
.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-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.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, copy link, 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,
.dg-foot .dg-csv,
.dg-foot .dg-copylink {
  font-size: var(--text-xs);
  padding: 2px 8px;
}
/* copy link sits beside reset layout, the count keeps the left */
.dg-foot .dg-copylink {
  margin-left: auto;
  margin-right: var(--space-2);
}

/* 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);
}
/* A paged grid has every row drawn: its rows' box grows with them and with
   an open detail, which Tabulator's computed height (the rows alone) would
   otherwise clip to a sliver with a scrollbar of its own. */
.dg-paged .tabulator-tableholder {
  height: auto !important;
}
.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);
}

/* the duplicate horizontal scroll bar above a wide grid (data_grid.js topScrollbar) */
.dg-topscroll { overflow-x: auto; overflow-y: hidden; height: 14px; margin-bottom: 2px; }
.dg-topscroll > div { height: 1px; }
.dg-topscroll[hidden] { display: none; }

/* column views (data_grid.js columnViews) */
.dg-views { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 .4rem;
  font-size: var(--text-sm); }
.dg-views select { font: inherit; padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); }
.dg-colpanel { position: absolute; top: 100%; left: 0; z-index: 20; margin-top: 4px; padding: .7rem; min-width: 16rem;
  max-width: min(32rem, 92vw); background: var(--surface); color: var(--fg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.dg-colpanel[hidden] { display: none; }
.dg-colclose { position: absolute; top: .3rem; right: .4rem; width: 1.6rem; height: 1.6rem; border: 0; border-radius: 6px;
  background: none; color: var(--fg-muted); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.dg-colclose:hover, .dg-colclose:focus-visible { background: var(--surface-2); color: var(--fg); }
.dg-colpanel .dg-collist { margin-right: 1.6rem; }
.dg-collist { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .25rem .8rem; margin-bottom: .6rem; }
.dg-collist label { display: flex; align-items: center; gap: .35rem; cursor: pointer; }
.dg-viewactions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.dg-viewname { flex: 1 1 10rem; font: inherit; padding: 3px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); }
.dg-viewstatus { display: block; margin-top: .4rem; color: var(--fg-muted); font-size: var(--text-xs); }

/* the notes column and its popup (data_grid.js noteColumn) */
/* dg-ncell, since .dg-note is the action reply note above */
.dg-host.tabulator .dg-ncell { display: flex; align-items: center; gap: .4rem; min-width: 0; cursor: pointer; }
.dg-host.tabulator .dg-ncell-text { display: block; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.dg-ncell-text.is-empty { color: var(--fg-muted); opacity: 0; }
.tabulator-row:hover .dg-ncell-text.is-empty { opacity: .7; }
.dg-notelink { flex: none; border: 0; background: none; padding: 0; font: inherit; font-size: var(--text-xs);
  color: var(--accent); cursor: pointer; }
.dg-notelink[hidden] { display: none; }
.dg-dialog { width: min(36rem, 92vw); max-height: 85vh; overflow: auto; padding: 1rem 1.1rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--fg); box-shadow: 0 16px 48px rgba(0,0,0,.2); }
.dg-dialog::backdrop { background: rgba(0,0,0,.3); }
.dg-dlghead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dg-dlghead h3 { margin: 0; font-size: 1rem; }
.dg-notemeta { margin: .3rem 0 .6rem; color: var(--fg-muted); font-size: var(--text-xs); }
.dg-notefull { white-space: pre-wrap; line-height: 1.5; }
.dg-notefull.is-empty { color: var(--fg-muted); }
.dg-notearea { width: 100%; box-sizing: border-box; font: inherit; padding: .5rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); }
.dg-dlgactions { display: flex; gap: .5rem; margin-top: .8rem; }
.dg-notestatus { margin: .5rem 0 0; color: var(--danger, #c62828); font-size: var(--text-sm); }
.dg-notehist { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.dg-notehist .dg-notemeta { margin: 0 0 .2rem; }
.dg-notebreak { padding: .3rem .5rem; border-top: 2px dashed var(--warn, #b25e00); color: var(--warn, #b25e00);
  font-size: var(--text-xs); font-weight: 600; }

/* the photo column (data_grid.js imageColumn) */
.dg-thumb { display: block; width: 100%; height: auto; border-radius: 4px; cursor: zoom-in; }
.dg-host.tabulator .tabulator-row .tabulator-cell.dg-imgcol { padding: 3px; }
.dg-imgfull { display: block; max-width: 100%; max-height: 70vh; margin: .4rem auto; object-fit: contain; }
.dg-imgdlg { width: min(60rem, 94vw); }

/* The height handle under an auto-sizing grid (data_grid.js): drag to set
   the height, double-click to fit the rows again. */
.dg-resize { height: 10px; margin: 2px 0 4px; cursor: ns-resize; touch-action: none; border-radius: 6px;
  background: linear-gradient(var(--border, #d7dbe3), var(--border, #d7dbe3)) center / 48px 3px no-repeat; }
.dg-resize:hover { background-color: var(--surface-2, #eef0f6); }

/* one search box across the text columns (search: true) */
.dg-searchbar {
  display: flex;
  margin: var(--space-2) 0;
}
.dg-search {
  flex: 0 1 22rem;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
}

/* A grid inside a grid or flex layout (a card's stack) must not take the
   table's full width as its minimum: the table scrolls sideways inside its
   own box instead of widening the page (a phone, 2026-10-21). */
.dg-wrap {
  min-width: 0;
  max-width: 100%;
}
