/* The shared pager (partials/_macros.html -> pager()).

   Loaded by all five portal layouts rather than living in any one role's
   stylesheet: the same macro renders on org tables, platform ledgers and
   the contractor field pages, and it looked like three different controls
   when each shell styled it.

   Only tokens from common/_tokens.css are used here — --ink, --teal,
   --teal-deep, --teal-pale, --border, --white, --text-tertiary. The first
   cut of this file reached for --surface/--text-muted, which aren't
   defined anywhere: every colour silently fell through to a hardcoded
   hex, so the pager kept the admin palette on themes that had repainted
   everything around it. Those tokens are all re-declared per theme (see
   _tokens.css's org-theme blocks), so the pager now repaints with them.

   The selected states use --ink rather than the accent on purpose: it
   matches the chat filter chips' selected look, and white on --teal is
   nowhere near enough contrast at this size. */

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-top: 16px;
  font-size: 13px;
}

/* ── Previous / next ─────────────────────────────────────────────────── */

.pager-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pager-step,
.pager-step--off {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}

.pager-step {
  border-color: var(--border, var(--border));
  background: var(--white, var(--white));
  color: var(--ink, var(--ink));
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.pager-step:hover {
  border-color: var(--teal, var(--teal));
  background: var(--teal-pale, var(--teal-pale));
  color: var(--teal-deep, var(--teal-deep));
}

.pager-step:focus-visible {
  outline: 2px solid var(--teal, var(--teal));
  outline-offset: 2px;
}

/* Keeps its box when unavailable, so the row doesn't reflow as you move
   through it and "Next" doesn't slide under the cursor on the last page. */
.pager-step--off {
  color: var(--text-tertiary, var(--text-tertiary));
  cursor: default;
}

.pager-at {
  padding: 0 6px;
  color: var(--text-tertiary, var(--text-tertiary));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Page size, as one segmented control ─────────────────────────────── */

.pager-size {
  display: flex;
  align-items: center;
  gap: 10px;
  /* Pinned right rather than left by justify-content: on a single-page
     list the prev/next half isn't rendered, and space-between with one
     child parks it against the left edge — so the control jumped sides
     depending on how many rows happened to be in the list. */
  margin-left: auto;
}

.pager-size-label {
  color: var(--text-tertiary, var(--text-tertiary));
  white-space: nowrap;
}

/* Grouped rather than four loose links: the sizes are one choice, and
   four separate pills read as four separate actions. */
.pager-size-opts {
  display: inline-flex;
  border: 1px solid var(--border, var(--border));
  border-radius: 8px;
  overflow: hidden;
  background: var(--white, var(--white));
}

.pager-size-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 32px;
  padding: 0 10px;
  border-left: 1px solid var(--border, var(--border));
  color: var(--ink, var(--ink));
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  transition: background 120ms ease, color 120ms ease;
}

.pager-size-opt:first-child { border-left: 0; }

.pager-size-opt:hover {
  background: var(--teal-pale, var(--teal-pale));
  color: var(--teal-deep, var(--teal-deep));
}

.pager-size-opt:focus-visible {
  outline: 2px solid var(--teal, var(--teal));
  outline-offset: -2px;
}

.pager-size-opt--on {
  background: var(--ink, var(--ink));
  color: var(--white, var(--white));
  font-weight: 700;
}

.pager-size-opt--on:hover {
  background: var(--ink, var(--ink));
  color: var(--white, var(--white));
}

/* Narrow (the contractor/customer phone shells): stack the two halves and
   centre each, rather than squeezing seven controls onto one line. */
@media (max-width: 640px) {
  .pager {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .pager-nav,
  .pager-size {
    justify-content: center;
    flex-wrap: wrap;
    /* Undo the right-pin: in a column flex it would shove the row
       sideways instead of centring it. */
    margin-left: 0;
  }
}

/* ── Sortable column headings ────────────────────────────────────────
   Lives here rather than in a table stylesheet because the macro that
   renders it (partials/_macros.html sort_th) goes on tables in four
   portals, and _pagination.css is the one sheet every shell already
   loads for the pager it rides with. A heading styled only in the
   portals that happened to import a table stylesheet is the exact bug
   scripts/ui_lint.py's "unstyled" check exists to catch. */
.sort-th {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  /* The heading is a control now, so it has to look like one on hover
     without shifting the row: colour and cursor only, no weight change
     (which would reflow every cell under it). */
  cursor: pointer;
  transition: color 120ms ease;
}

.sort-th:hover { color: var(--text-primary); }
.sort-th:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 3px;
}

/* The column in force reads as selected even before the arrow is seen. */
.sort-th--on { color: var(--text-primary); }

.sort-th-dir { font-size: 13px; line-height: 1; }
