/**
 * tables.css — Table Components
 * ============================================================
 * Data tables, table wrappers, hover states, responsive.
 * Depends on: 1-tokens.css
 * ============================================================
 */

/* --------------------------------------------------------
 * BASE TABLE (.table)
 * -------------------------------------------------------- */
.table {
    font-size: var(--text-base);
    margin-bottom: 0;
}

/* --------------------------------------------------------
 * TABLE HEADER (th)
 * -------------------------------------------------------- */
.table th {
    font-weight: var(--font-semibold);
    background: var(--color-surface-alt);
    color: var(--brand-ink);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    white-space: nowrap;
}

/* --------------------------------------------------------
 * TABLE CELL (td)
 * -------------------------------------------------------- */
.table td {
    padding: var(--space-3) var(--space-4);
    vertical-align: middle;
}

/* --------------------------------------------------------
 * HOVER STATE (.table-hover)
 * -------------------------------------------------------- */
.table-hover tbody tr:hover {
    background-color: var(--color-gray-100);
}

/* --------------------------------------------------------
 * TABLE WRAPPER (.table-wrapper) — scrollable container
 * -------------------------------------------------------- */
.table-wrapper {
    max-height: 300px;
    overflow-y: auto;
}

/* --------------------------------------------------------
 * LIST PAGER (.list-pager) -- the foot of every paged list:
 * Paginator::footer() in PHP, ismsPager() in assets/js/ui.js.
 * "Showing 26–50 of 312 items" on the left, the pages on the right.
 * -------------------------------------------------------- */
.list-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-6);
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--border-color-light);
}
.list-pager-count {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}
.list-pager .pagination { margin: 0; }
@media (max-width: 575.98px) {
    .list-pager { justify-content: center; }
}

/* --------------------------------------------------------
 * PHONES: a wide table scrolls sideways inside its card.
 * Screens only: a printed A4 page is narrower than 768px as well, and
 * there these widths ran the table off the paper.
 * -------------------------------------------------------- */
@media screen and (max-width: 767.98px) {
    /* A table with no .table-responsive around it ran past the screen edge,
       and <html> clips the overflow (2-base.css): the right-hand columns were
       simply gone. Its box scrolls instead -- unless a row holds a dropdown,
       which a scrolling box would clip. */
    :where(div, section, form):has(> table):not(.table-responsive):not(:has(.dropdown-menu)) {
        overflow-x: auto;
    }
    /* At 390px a table of five or more columns squeezed every cell to its
       longest word: a date over five lines, a code over three. Wider tables
       keep readable columns and scroll (wider as the columns add up); four
       columns or fewer still fit.
       Not a table already built for phones: one that turns into cards
       (td[data-label]: employees, students, accounts, attendance; .va-cards,
       .dir-table), one that hides columns on phones (.d-none ..., the clinic /
       guidance log .rl-table, clinic inventory .inv-table, enrolled students
       .es-table), one with a phone layout of its own (.dash-table,
       .schedule-table, .vl-table, .enrol-table). A new table of that kind
       joins this list. :where() keeps this at no specificity, so a module
       stylesheet always has the last word. */
    :where(.table:not(:has(td[data-label], .d-none)):not(.rl-table, .inv-table, .es-table, .dir-table, .va-cards, .dash-table, .schedule-table, .vl-table, .enrol-table):has(> thead > tr > :nth-child(5))) {
        min-width: 620px;
    }
    :where(.table:not(:has(td[data-label], .d-none)):not(.rl-table, .inv-table, .es-table, .dir-table, .va-cards, .dash-table, .schedule-table, .vl-table, .enrol-table):has(> thead > tr > :nth-child(7))) {
        min-width: 760px;
    }
    :where(.table:not(:has(td[data-label], .d-none)):not(.rl-table, .inv-table, .es-table, .dir-table, .va-cards, .dash-table, .schedule-table, .vl-table, .enrol-table):has(> thead > tr > :nth-child(10))) {
        min-width: 980px;
    }
}
