/*
 * Dense data table. Wrap in .c-tscroll so columns scroll horizontally instead
 * of crushing on small screens (the table keeps a min-width). M4 extends this
 * with multi-select, bulk bar, saved views, and sortable headers.
 */

.c-tscroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.c-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.c-table thead th {
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: var(--fw-bold);
  padding: 10px 14px;
  background: var(--surf-2);
  border-block-end: 1px solid var(--line);
  white-space: nowrap;
}

/* The heading of the column the list is currently ordered by (the Sort dropdown
 * in the toolbar, not a click target — see portal/pipeline.php). Marking it is
 * the only thing that ties the control to the table: without it the rows are in
 * an order nothing on screen accounts for. */
.c-table thead th.is-sorted { color: var(--ink); }

/* ── Quantity columns ───────────────────────────────────────────────────────
 *
 * A count column is RIGHT-aligned, and this is not a cosmetic preference: the
 * digits then stack by place value, so 1,270 is visibly wider than 89 and a
 * column can be compared by running the eye down its right edge. Left-aligned,
 * every number starts in the same place and the only way to compare two is to
 * read both. On a table whose entire purpose is comparison that is the
 * difference between scanning and reading. The heading follows the cells —
 * a heading over the far end of its own column reads as the next column's. */
.c-table__num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  white-space: nowrap;
}
.c-table thead th.c-table__num { text-align: right; }

/* Zero means "nothing has happened here yet", which is the least interesting
 * thing a progress table can say — and on a fresh cycle most cells say it. At
 * full contrast the zeros are a grid of noise that the real counts have to
 * compete with; faint, the eye lands only on what has moved. */
.c-table__zero { color: var(--ink-4); }

/* ── Dense variant ──────────────────────────────────────────────────────────
 * For the progress table, which carries thirteen count columns: at the default
 * 14px gutters and 46px rows the last stages of the funnel sit past the right
 * edge, and a funnel you cannot see the end of is not one. Tightening the
 * gutters buys those columns back without shrinking the type. */
/* Headings a step smaller and less tracked than the default caption: with
 * thirteen count columns the headings, not the numbers, are what sets the
 * column widths — "Shortlisted" is wider than any count that will ever sit
 * under it — so this is where the space to fit the funnel comes from. */
/* padding-BLOCK only. The inline half used to be set here too, at 10px, and it
 * never bought the space it was written for: the count headings take their
 * gutters from .c-table--dense .c-table__num below, which carries two classes
 * and outranks this rule, so the only column the 10px ever reached was the
 * identity one — where it pulled the heading 4px to the left of every value
 * underneath it. Leaving the inline padding to the base rule puts "College"
 * back over its own column; the count columns are untouched either way. */
.c-table--dense thead th { padding-block: 8px; font-size: 9.5px; letter-spacing: 0.02em; }
.c-table--dense tbody td { padding: 2px 10px; height: 38px; }
.c-table--dense tfoot th,
.c-table--dense tfoot td { padding: 10px; }
/* The count columns take the tightest gutters and a step down in size: thirteen
 * of them at the default measured 90px wider than the canvas, which is exactly
 * the last two stages of the funnel. Tabular figures keep them legible at 13px,
 * and the identity column is left at full size — it is the one thing on the row
 * that is read rather than compared. */
.c-table--dense .c-table__num { padding-inline: 8px; }
/* Body cells only — scoped to tbody/tfoot so it cannot outrank the heading rule
 * above it, which carries one fewer class and would otherwise silently lose. */
.c-table--dense tbody td.c-table__num,
.c-table--dense tfoot td.c-table__num { font-size: 13px; }
/* The identity column carries a name over one or two lines; without a ceiling a
 * long college name wraps into a seven-line tower and the row grows to 180px.
 * The ceiling is also what keeps the last count column on screen — it is the
 * only column here that can absorb being narrower, because it is read rather
 * than compared. */
.c-table__id { max-width: 270px; }

/* A FIGURE table — a handful of numeric columns rather than a funnel of them
 * (portal/summary.php: candidates, highest, lowest).
 *
 * The 270px ceiling exists for the funnel, where thirteen count columns are
 * fighting the identity one for width. With three, the fight is the other way
 * round: the columns sit at the far right edge with a third of the row empty
 * between them and a college name that wrapped or truncated inside 270px while
 * the space it needed sat unused beside it. Raising the ceiling spends that gap
 * on the one column that can use it.
 *
 * A modifier rather than a second .c-table__id rule on the page, so the ceiling
 * stays a decision this file makes — see the styling rule in CLAUDE.md. */
.c-table--figures .c-table__id { max-width: 560px; }

/* th as well as td. A body row may lead with a ROW HEADER rather than a data
 * cell — the section headings on portal/fees.php are `th`, because "Govt. Dues"
 * heads the rows under it and is not a value in the row. Every padding rule in
 * this component was written for `td` alone, so such a cell inherited NO padding
 * at all: the heading sat flush against the cell edge, 14px to the left of the
 * item names it was heading, which is exactly the misalignment a grouped table
 * cannot afford — the indent is the only thing saying which rows belong to it. */
.c-table tbody td,
.c-table tbody th {
  padding: 2px 14px;
  height: 46px;
  border-block-end: 1px solid var(--line-2);
  vertical-align: middle;
}
.c-table tbody tr:last-child td { border-block-end: 0; }
.c-table tbody tr { transition: background var(--dur-fast); }
.c-table tbody tr:hover { background: var(--teal-wash); }

.c-table__actions { text-align: right; white-space: nowrap; }

/* An actions cell holding MORE THAN ONE affordance — on portal/fees.php an Edit
 * link sits beside a one-button toggle form. A <form> is block-level, so under
 * the plain cell above the two stack and the row grows to twice its height. A
 * modifier rather than a change to .c-table__actions itself: eight other pages
 * put a single control in that cell and must not shift.
 *
 * display: contents on the form promotes its button to a flex child, so the
 * wrapper the CSRF token has to live in costs no layout box of its own. */
.c-table__actions--multi { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-xs); }
.c-table__actions--multi form { display: contents; }

/* A section heading INSIDE the body — portal/fees.php groups the catalogue into
 * the same sections the challan prints, subtotal and all, so the page reads as a
 * preview of the document rather than a flat table that shares its rows.
 *
 * It borrows the totals row's surface (it is the same kind of thing: a summary,
 * not a record) and drops the hover, because there is nothing in it to click. */
.c-table tbody tr.c-table__group > * {
  background: var(--surf-2);
  border-block-end: 1px solid var(--line);
  font-weight: var(--fw-bold);
  text-align: start;
  color: var(--ink);
}
.c-table tbody tr.c-table__group:hover > * { background: var(--surf-2); }

/* Mono cell for codes / ids / numbers. */
/* A link in a cell has to LOOK like one.
 *
 * The generic reset strips colour and underline from every anchor, which left
 * the application number — the one thing in the row anyone is meant to click —
 * rendering identically to the text beside it. A .c-btn is excluded: it already
 * carries its own affordance, and a rule through a button reads as broken. */
.c-table a:not(.c-btn) {
  color: var(--teal);
  text-decoration: underline;
  text-decoration-thickness: from-font;
  text-underline-offset: 2px;
}
.c-table a:not(.c-btn):hover { text-decoration-thickness: 2px; }

.c-table__mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* Totals row. Reads as a summary of the rows above rather than one more of
 * them: the header's surface, a firm rule to break from the last data row, and
 * no hover — there is nothing to click.
 *
 * text-align is `start` and not `left` because a <th> defaults to center and the
 * label cell has to sit under the identity column, not float in the middle of
 * it. It is the LABEL cell that needs this, though — see the override below. */
.c-table tfoot th,
.c-table tfoot td {
  padding: 12px 14px;
  text-align: start;
  vertical-align: middle;
  background: var(--surf-2);
  border-block-start: 2px solid var(--line);
  font-weight: var(--fw-bold);
}

/* A TOTAL KEEPS ITS COLUMN'S ALIGNMENT.
 *
 * The rule above carries one more element selector than .c-table__num, so it
 * silently won: every count in the totals row of the College progress table was
 * flushed left while the thirteen columns above it were flush right. A total is
 * the one number on the table that is read against the column it closes — the
 * eye runs down the right edge and lands on a figure that has stepped out of
 * line — and it is also the widest, so the step is at its most obvious exactly
 * where it matters most.
 *
 * This is the same trap the dense variant documents forty lines up, where a
 * heading rule outranked the cell rule for font-size. The fix is the same shape:
 * name the class AND the element so the total cannot lose to the row it sits in.
 * Both th and td, because a totals row may lead with either. */
.c-table tfoot th.c-table__num,
.c-table tfoot td.c-table__num { text-align: right; }

.c-table tfoot .u-muted { font-weight: var(--fw-regular); }

/* Empty state inside a panel body. */
.c-table-empty {
  padding: var(--space-xl);
  text-align: center;
  color: var(--ink-3);
}

/* "The query failed", not "nothing matched" — see list_empty() in
   includes/_pagination.php. Reads as a fault, because it is one. */
.c-table-empty--broken { color: var(--danger); }
.c-table-empty--broken strong { color: var(--danger); font-weight: var(--fw-bold); }

/* Multi-select + per-row quick actions (used by the verification worklist). */
.c-table__check { width: 38px; text-align: center; }
.c-table input[type="checkbox"] {
  width: auto;
  accent-color: var(--teal);
  cursor: pointer;
  vertical-align: middle;
}
.c-table tbody tr.is-selected { background: var(--teal-wash); }

.c-table__qa { display: inline-flex; gap: 4px; }
.c-table__qa button {
  width: 28px; height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surf);
  color: var(--ink-2);
  display: grid; place-items: center;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.c-table__qa .is-accept:hover { border-color: var(--teal);   color: var(--teal); }
.c-table__qa .is-reject:hover { border-color: var(--garnet); color: var(--garnet); }
.c-table__qa .is-reset:hover  { border-color: var(--ink-4);  color: var(--ink); }

/* --- Paired figure columns (portal/summary.php's college × category grid) ----
   Two columns per heading — High and Low — repeated once per category. Without a
   boundary the row is an undifferentiated run of numbers and the eye loses which
   figure belongs to which category halfway across.

   The rule is a RULE LINE ON THE PAIR'S FIRST CELL, not a background band: a band
   would have to alternate, and an alternating pattern breaks the moment the
   Category filter leaves an odd number of columns. The line is also what a printed
   sheet needs, where colour is the first thing to go.

   EVERY pair carries it, the leading one included: its left edge is the boundary
   with the College column, which wants the same line for the same reason.

   Placed at the END of the file on purpose: the generic .c-table blocks sit at the
   bottom at equal specificity, and in this file later wins. A variant added near
   the top would silently do nothing. */
.c-table--pairs th.c-table__pair,
.c-table--pairs td.c-table__pair {
  border-inline-start: 1px solid var(--line);
}

/* The spanning category heading sits above two right-aligned figure columns, so
   centring it over the pair is what makes it read as their heading rather than as
   the left one's. Overrides .c-table thead th.c-table__num, which is one class +
   two elements — matched here with the same element count plus the modifier. */
.c-table--pairs thead th.c-table__pair[colspan] { text-align: center; }

/* The second header row is a sub-label, not a heading: it repeats every few
   columns and must not compete with the category names above it. */
.c-table--pairs thead tr + tr th {
  font-size: 11px;
  font-weight: var(--fw-medium);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* --- An editable figure inside a cell (includes/_challan-form.php) -----------
   Fixed width, so the column does not resize between a three-digit fee and a
   seven-digit one, and right-aligned to sit under a .c-table__num heading with
   the printed amounts it is about to become.

   THE SELECTOR IS NOT DECORATIVE. 04-elements/_forms.css sets width:100% on
   `input:not([type="checkbox"]):not([type="radio"])`, which is (0,2,1) — a bare
   .c-table__amount is (0,1,0) and loses, silently, leaving the input stretched
   across whatever the cell was given. Naming the cell and the element as well
   takes it to (0,2,2), which wins without resorting to !important. Another
   instance of the specificity shape this file keeps hitting — see the three
   notes higher up. */
.c-table td input.c-table__amount {
  width: 108px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* A column that should be exactly as wide as its content, in a table that is
   width:100%. The 1% is the standard trick: it is smaller than the content can
   ever be, so the layout gives the column its minimum and hands every remaining
   pixel to the unconstrained columns beside it. Without it a three-column form
   splits the width in thirds and the labels are cramped next to acres of gap. */
.c-table th.c-table__fit,
.c-table td.c-table__fit {
  width: 1%;
  white-space: nowrap;
}
