/* Styling for the shared DataTable component.
 *
 * Loaded globally from App.razor. Every selector is prefixed `dt-` AND scoped
 * under the component's `.dt` root. The extra class in the chain is not
 * cosmetic: host pages style bare elements inside their own root (see
 * `.edp-worker table`, `.edp-worker button`, `.edp-worker th, td` in
 * edp-worker/worker.css), and those stylesheets are linked from <HeadContent>,
 * i.e. after this one. A tie on specificity would therefore be lost — the rules
 * below have to win outright.
 */

.dt {
    --dt-border: #e5e7eb;
    --dt-border-strong: #d1d5db;
    --dt-muted: #6b7280;
    --dt-head: #374151;
    --dt-accent: #1b6ec2;
    --dt-surface: #f9fafb;
    --dt-hover: #f3f4f6;
}

/* ---------- toolbar above the table ---------- */

.dt .dt-toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
    font-size: .8125rem;
    color: var(--dt-muted);
}

.dt .dt-count {
    font-variant-numeric: tabular-nums;
}

/* Pushed right by margin rather than a spacer element, so the toolbar stays
   one flat row of real content. */
.dt .dt-toolbar-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

.dt .dt-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .1rem .5rem;
    border: 1px solid var(--dt-border);
    border-radius: 999px;
    background: #fff;
    font-size: .75rem;
    color: var(--dt-head);
}

.dt .dt-chip-clear {
    all: unset;
    cursor: pointer;
    line-height: 1;
    color: var(--dt-muted);
    font-size: .875rem;
}

.dt .dt-chip-clear:hover {
    color: #b02a37;
}

/* ---------- table shell ---------- */

.dt .dt-wrap {
    border: 1px solid var(--dt-border);
    border-radius: .5rem;
    overflow: auto;
    background: #fff;
}

.dt .dt-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .875rem;
}

/* ---------- header ---------- */

/* The label row is sticky so a long table keeps its column names while the
   filter row scrolls away with the data — filters are set once, column names
   are read constantly. `border-collapse: separate` above is what lets the
   sticky row keep its bottom border. */
.dt .dt-table thead tr.dt-head-row th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--dt-surface);
    padding: .5rem .625rem;
    border-bottom: 1px solid var(--dt-border);
    white-space: nowrap;
    text-align: inherit;
    vertical-align: middle;
    font-size: .6875rem;
}

/* A heading is a label that happens to be clickable, so it carries no button
   chrome at all — the affordance is the chevron and the hover colour.
   `all: unset` must stay first; the longhands after it are what survive. */
.dt .dt-sort {
    all: unset;
    display: inline-flex;
    align-items: baseline;
    gap: .3rem;
    cursor: pointer;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--dt-muted);
    transition: color .12s ease-in-out;
}

.dt .dt-sort:hover,
.dt .dt-sort:focus-visible {
    color: var(--dt-accent);
}

.dt .dt-sort:focus-visible {
    outline: 2px solid rgba(27, 110, 194, .35);
    outline-offset: 2px;
    border-radius: 2px;
}

.dt .dt-head-static {
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--dt-muted);
}

/* Reserve the arrow's width always, so labels do not shift sideways when a
   column becomes sorted. */
.dt .dt-arrow {
    display: inline-block;
    min-width: .6em;
    font-size: .625rem;
    opacity: 0;
    transition: opacity .12s ease-in-out;
}

.dt .dt-sort:hover .dt-arrow {
    opacity: .4;
}

.dt .dt-sort.is-sorted {
    color: var(--dt-accent);
}

.dt .dt-sort.is-sorted .dt-arrow {
    opacity: 1;
}

.dt .dt-rank {
    font-size: .5625rem;
    font-weight: 700;
    color: #fff;
    background: var(--dt-accent);
    border-radius: 999px;
    padding: 0 .3em;
    line-height: 1.4;
}

/* ---------- filter row ---------- */

.dt .dt-table thead tr.dt-filter-row th {
    background: #fff;
    padding: .35rem .5rem .5rem;
    border-bottom: 2px solid var(--dt-border-strong);
}

/* Selected on the row as well as the class: a host rule such as
   `.edp-worker input[type="text"]` is (0,2,1) and would beat a plain
   `.dt .dt-filter`. The text filter also deliberately renders without a `type`
   attribute, which is a second line of defence, not the only one. */
.dt .dt-filter-row input.dt-filter,
.dt .dt-filter-row select.dt-filter {
    box-sizing: border-box;
    width: 100%;
    min-width: 5rem;
    border: 1px solid transparent;
    border-radius: .375rem;
    background: var(--dt-surface);
    padding: .2rem .45rem;
    font: inherit;
    font-size: .75rem;
    font-weight: 400;
    color: var(--dt-head);
    box-shadow: none;
    transition: border-color .12s ease-in-out, background-color .12s ease-in-out;
}

.dt .dt-filter-row input.dt-filter::placeholder {
    color: #b6bcc6;
}

.dt .dt-filter-row input.dt-filter:hover,
.dt .dt-filter-row select.dt-filter:hover {
    border-color: var(--dt-border);
}

.dt .dt-filter-row input.dt-filter:focus,
.dt .dt-filter-row select.dt-filter:focus {
    outline: none;
    background: #fff;
    border-color: var(--dt-accent);
    box-shadow: 0 0 0 3px rgba(27, 110, 194, .12);
}

/* An active filter has to be obvious — otherwise an empty-looking table reads
   as missing data rather than a narrowed view. */
.dt .dt-filter-row input.dt-filter.is-active,
.dt .dt-filter-row select.dt-filter.is-active {
    background: #fff;
    border-color: var(--dt-accent);
}

/* ---------- body ---------- */

.dt .dt-table tbody td {
    padding: .45rem .625rem;
    border-bottom: 1px solid var(--dt-border);
    vertical-align: middle;
    font-size: .875rem;
    text-align: left;
}

.dt .dt-table tbody tr:last-child td {
    border-bottom: 0;
}

.dt .dt-table tbody tr:hover td {
    background: var(--dt-hover);
}

.dt .dt-table tbody td a {
    text-decoration: none;
}

.dt .dt-table tbody td a:hover {
    text-decoration: underline;
}

.dt .dt-table .dt-empty {
    padding: 1.5rem .625rem;
    text-align: center;
    color: var(--dt-muted);
}

/* Numbers read wrong ragged; tabular figures keep the columns aligned. Own
   class rather than Bootstrap's `.text-end`, which only wins by !important. */
.dt .dt-table .dt-end {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* The head-row rule sets `text-align: inherit` at a higher specificity, so a
   right-aligned column needs the heading called out explicitly. */
.dt .dt-table thead tr.dt-head-row th.dt-end {
    text-align: right;
}
