/* The data table: toolbar, column headers with sort / filter / resize, dropdowns, pagination. */

.dt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0.75rem;
}

.dt-search {
  flex: 1 1 12rem;
  max-width: 20rem;
}

.dt-count {
  margin-right: auto;
  font-size: 0.87rem;
  color: var(--text-muted);
}

.dt-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
}

.dt-pager-text {
  margin: 0 0.5rem;
  font-size: 0.87rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.data-table .table-scroll {
  border-top: 1px solid var(--border);
}

/* Once the user has set a width, every column keeps exactly the width it was given. The
   table still fills the width there is: the last column takes what is left over. */
.dt-fixed {
  table-layout: fixed;
  min-width: 100%;
}

/* A row that leads to the details of its entry. */
.dt-opens {
  cursor: pointer;
}

.dt-fixed th,
.dt-fixed td {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Column header --- */
.data-table thead th {
  position: relative;
  padding: 0;
  user-select: none;
}

.dt-head {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.15rem 0.5rem 0.15rem 0.75rem;
}

.dt-label {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  padding: 0.3rem 0;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.dt-plain-label {
  padding: 0.3rem 0;
}

.num .dt-label {
  justify-content: flex-end;
}

/* Every column shows that it can be sorted; the one it is sorted by stands out. */
.dt-sort-mark {
  display: inline-flex;
  opacity: 0.45;
}

.dt-sort-mark .icon {
  width: 0.9rem;
  height: 0.9rem;
}

.dt-label:hover .dt-sort-mark {
  opacity: 1;
}

.dt-sort-mark.active {
  color: var(--accent);
  opacity: 1;
}

.dt-filter {
  width: 1.7rem;
  min-height: 1.7rem;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border-color: transparent;
}

.dt-filter .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.dt-filter.active {
  color: var(--accent);
}

.dt-filter.active .icon {
  fill: currentColor;
}

/* Sits inside its cell: a handle reaching past the last column would make the table a few
   pixels wider than its frame and give it a pointless scrollbar. */
.dt-resize {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  width: 7px;
  cursor: col-resize;
}

/* A thin line in its middle shows where to take hold; it is the only thing between two
   columns of the head, so it also separates them. */
.dt-resize::after {
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 3px;
  width: 1px;
  content: "";
  background: var(--grip);
}

.dt-resize:hover::after,
.dt-resize.active::after {
  top: 0;
  bottom: 0;
  left: 2px;
  width: 3px;
  background: var(--accent);
}

/* Where a dragged column will land. */
.dt-drop-before {
  box-shadow: inset 3px 0 0 var(--accent);
}

.dt-drop-after {
  box-shadow: inset -3px 0 0 var(--accent);
}

.dt-empty {
  padding: 1rem 0.75rem;
  color: var(--text-muted);
}

/* --- Dropdowns: the per-column filter and the column chooser --- */
.dt-popup {
  position: fixed;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 18rem;
  max-width: calc(100vw - 1rem);
  max-height: calc(100vh - 1rem);
  padding: 0.5rem;
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.dt-popup button {
  font-weight: 400;
}

.dt-menu-item {
  justify-content: flex-start;
  border-color: transparent;
}

.dt-values {
  display: flex;
  flex-direction: column;
  min-height: 2rem;
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* An entry that is switched on or off: values in a filter, columns in the chooser. */
.dt-option {
  flex: 1;
  justify-content: flex-start;
  min-width: 0;
  min-height: 1.9rem;
  text-align: left;
  border-color: transparent;
  border-radius: 0;
}

/* The same slide switch as in forms, smaller. */
.dt-option::before {
  content: "";
  flex: none;
  width: 1.8rem;
  height: 1rem;
  background:
    radial-gradient(circle at 0.5rem 50%, var(--surface) 0.33rem, transparent 0.37rem) var(--off);
  border-radius: 1rem;
}

.dt-option[aria-pressed="true"]::before {
  background:
    radial-gradient(circle at calc(100% - 0.5rem) 50%, var(--on-accent) 0.33rem, transparent 0.37rem)
    var(--accent);
}

.dt-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dt-column-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.dt-column-row .icon-button {
  width: 1.9rem;
  min-height: 1.9rem;
}

.dt-popup-actions {
  display: flex;
  gap: 0.5rem;
}

.dt-popup-actions button {
  flex: 1;
  font-weight: 600;
}

.dt-popup-actions .icon-button {
  flex: none;
}
