/*
 * List pages — scroll container, sticky header, row density (GTM T0-B9a)
 * =====================================================================
 * Applied to the main list tables (customers, leads, quotes, jobs,
 * invoices, products).
 *
 * .list-scroll      — makes the table wrapper the scroll element so both
 *                     scrollbars are always on-screen (Ibo note #6).
 * sticky thead      — header stays visible while scrolling (Ibo note #8).
 *                     z-index layering: body sticky first-col = 2,
 *                     thead = 5, thead sticky first-col corner = 6
 *                     (templates set the first-col left:0 stickiness).
 * .density-*        — 3-way row density (Ibo note #7), persisted per
 *                     user per page via /api/list-prefs.
 */

.list-scroll {
    max-height: calc(100vh - 270px);
    min-height: 320px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

/* Sticky header row inside the scroll wrapper.
   !important + id-level selectors: table-resize.css sets
   `position: relative !important` on `#customersTable th` etc. (resizer
   positioning context) — sticky ALSO establishes a positioning context,
   so the resizer keeps working; we just need to win the cascade. */
.list-scroll thead th,
.list-scroll #customersTable thead th,
.list-scroll #jobsTable thead th,
.list-scroll #leadsTable thead th,
.list-scroll #quotesTable thead th,
.list-scroll #invoicesTable thead th,
.list-scroll #productsTable thead th,
.list-scroll table.resizable thead th {
    position: sticky !important;
    top: 0;
    z-index: 5;
    background: var(--bs-table-bg, #f8f9fa);
    /* border-collapse drops borders on sticky cells — repaint the line */
    box-shadow: inset 0 -1px 0 var(--bs-border-color, #dee2e6);
}

/* Corner cells that are ALSO sticky-left (templates add left:0 on these
   classes) must sit above both the sticky header row and sticky column.
   !important: per-template <style> blocks set z-index:3 on these same
   cells with equal-or-higher specificity and load after this file. */
.list-scroll thead th.col-name,
.list-scroll thead th.col-ticket,
.list-scroll thead th.col-number {
    z-index: 6 !important;
}

/* ── Row density ──────────────────────────────────────────────────────
   standard  = slightly tighter than Bootstrap default (the new default)
   compact   = dense data-grid feel
   comfortable = original roomy padding */
.table.density-standard > :not(caption) > * > * {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.table.density-compact > :not(caption) > * > * {
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
    font-size: 0.84rem;
}

.table.density-comfortable > :not(caption) > * > * {
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

/* Density toggle button group (rendered by partials/list_density.html) */
.density-toggle .btn {
    font-size: 11px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
}
