/*
 * This app's own pieces that more than one page shares: the chart containers, the result
 * tables of nfsen-table.js and nfdump's aggregation controls. Generic components live in
 * ui.css, the shell's in shell.css, a single page's in pages/.
 */

/* ── Charts ─────────────────────────────────────────────────────────────── */

/* The chart fills its panel; the component sets the height it needs. */
.chart-container {
    position: relative;
    inline-size: 100%;
}

.chart-canvas {
    inline-size: 100%;
}

/* ── Result tables (nfsen-table.js, Table::generate()) ──────────────────── */

nfsen-table {
    display: flex;
    flex-direction: column;
    gap: var(--size-2);
    min-inline-size: 0;
}

.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--size-2) var(--size-3);
    margin-block-end: var(--size-3);
}

.table-toolbar > .column-selector-placeholder {
    margin-inline-start: auto;
}

sb-popover.column-selector {
    display: flex;
    justify-content: flex-end;
    margin-block-end: var(--size-2);
}

/* The panel scrolls, not the list, so the component's edge stays around the items. */
sb-popover.column-selector::part(panel) {
    min-inline-size: 12.5rem;
    max-block-size: min(20rem, 80dvh);
}

.column-selector-menu :is(label, input) {
    cursor: pointer;
    user-select: none;
}

/* A second horizontal scrollbar above a table wider than its card. */
.table-scrollbar {
    overflow-x: auto;
    overflow-y: hidden;
}

.table-scrollbar > div {
    inline-size: var(--scroll-width, 100%);
    block-size: 1px;
}

nfsen-table:not([data-overflow]) > .table-scrollbar,
nfsen-table[data-view='original'] > :is(.table-scrollbar, .table-wrap, .table-pager),
nfsen-table[data-view='original'] sb-popover.column-selector {
    display: none;
}

.sort-button {
    display: inline-flex;
    align-items: center;
    gap: var(--size-1);
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    white-space: nowrap;
}

.sort-button:hover:not(:disabled) {
    background: none;
    text-decoration: underline;
}

th[aria-sort] > .sort-button::after {
    content: '\25B2' / '';
    font-size: 0.7em;
}

th[aria-sort='descending'] > .sort-button::after {
    content: '\25BC' / '';
}

/* A wide result scrolls sideways rather than folding every cell onto three lines. */
:is(nfsen-table, .flows-protocols) :is(th, td) {
    white-space: nowrap;
}

td[data-kind='rank'] {
    inline-size: 1%;
}

/* nfdump's text, when a result cannot be read into columns or the Original view is open. */
.table-raw pre,
nfsen-table .original pre {
    max-block-size: 60vh;
    overflow: auto;
    font-size: var(--font-size-00);
    line-height: 1.35;
}

.table-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--size-2) var(--size-4);
    font-size: var(--font-size-0);
}

.table-pager-status {
    color: var(--text-2);
}

.table-pager-controls,
.table-pager-pages {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--size-1);
}

.table-pager-pages {
    padding: 0;
    list-style: none;
}

.table-pager-pages > li[aria-hidden] {
    padding-inline: var(--size-1);
    color: var(--text-2);
}

.table-pager-pages button {
    min-inline-size: 2.25rem;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}

/* The current page reads as a pressed button (2.5). */
.table-pager-pages button[aria-current='page'] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
    font-weight: var(--font-weight-semibold);
}

.table-pager-size {
    margin-inline-start: var(--size-2);
    color: var(--text-2);
}

.table-pager select {
    inline-size: auto;
}

/* ── Aggregation controls (partials/aggregation-controls.html.twig) ────── */

/* The two IP selects share a row and never shrink to a bare chevron. */
.filter-subgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: var(--size-2);
}

.filter-subgrid--tight {
    grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
    gap: var(--size-1);
}

.filter-sublabel {
    display: block;
    margin-block-end: 0.375rem;
    color: var(--text-2);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

/* The /24 beside an IP aggregation select: wide enough for three digits, no wider. */
.prefix-input {
    inline-size: 4rem;
    margin-block-start: var(--size-1);
}
