/* ============================================================================
   tables.css - grids, DataTables, sticky headers.
   Load AFTER forms.css.

   Covers .table (Bootstrap), .dataTable / .dataTables_wrapper (DataTables) and
   .pdtable (this application's own grid class), plus .modern-table for new
   markup. Existing grids are restyled where they stand - no plugin option, no
   initialisation change, no JavaScript.
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. SHELL
   The scroll container is what makes a wide ERP grid usable on a laptop, and
   it is also what makes position: sticky work on the header row.
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .table-card,
[data-bz-theme="dark"] .table-card { padding: 0; overflow: hidden; }

[data-bz-theme="nextgen"] .table-scroll,
[data-bz-theme="dark"] .table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------------------------------------------------------------------------
   2. TABLE BASE
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .modern-table,
[data-bz-theme="dark"] .modern-table,
[data-bz-theme="nextgen"] .table,
[data-bz-theme="dark"] .table,
[data-bz-theme="nextgen"] table.dataTable,
[data-bz-theme="dark"] table.dataTable {
    width: 100%;
    background: transparent;
    border-collapse: separate;   /* separate, or sticky headers lose borders */
    border-spacing: 0;
    font-family: var(--bz-font);
    font-size: 13.5px;
    color: var(--bz-text);
}

/* --- header ------------------------------------------------------------- */
[data-bz-theme="nextgen"] .modern-table > thead > tr > th,
[data-bz-theme="dark"] .modern-table > thead > tr > th,
[data-bz-theme="nextgen"] .table > thead > tr > th,
[data-bz-theme="dark"] .table > thead > tr > th,
[data-bz-theme="nextgen"] table.dataTable > thead > tr > th,
[data-bz-theme="dark"] table.dataTable > thead > tr > th {
    background: var(--bz-surface-2);
    color: var(--bz-muted);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .55px;
    padding: 13px 14px;
    border: none;
    border-bottom: 1px solid var(--bz-border-2);
    white-space: nowrap;
    vertical-align: middle;
}

/* Sticky header. Chrome 56+, so inside the floor. It only engages when an
   ancestor actually scrolls - in a non-scrolling table it is inert, never
   harmful. z-index keeps it over cell content but under Bootstrap modals
   (1050) and the app header. */
[data-bz-theme="nextgen"] .table-scroll .modern-table > thead > tr > th,
[data-bz-theme="dark"] .table-scroll .modern-table > thead > tr > th,
[data-bz-theme="nextgen"] .table-scroll .table > thead > tr > th,
[data-bz-theme="dark"] .table-scroll .table > thead > tr > th {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 2;
}

/* --- body --------------------------------------------------------------- */
[data-bz-theme="nextgen"] .modern-table > tbody > tr > td,
[data-bz-theme="dark"] .modern-table > tbody > tr > td,
[data-bz-theme="nextgen"] .table > tbody > tr > td,
[data-bz-theme="dark"] .table > tbody > tr > td,
[data-bz-theme="nextgen"] table.dataTable > tbody > tr > td,
[data-bz-theme="dark"] table.dataTable > tbody > tr > td {
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--bz-border);
    vertical-align: middle;
    background: transparent;
}

[data-bz-theme="nextgen"] .modern-table > tbody > tr:last-child > td,
[data-bz-theme="dark"] .modern-table > tbody > tr:last-child > td,
[data-bz-theme="nextgen"] .table > tbody > tr:last-child > td,
[data-bz-theme="dark"] .table > tbody > tr:last-child > td { border-bottom: none; }

/* --- zebra + hover ------------------------------------------------------ */
[data-bz-theme="nextgen"] .table-striped > tbody > tr:nth-of-type(odd),
[data-bz-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd),
[data-bz-theme="nextgen"] table.dataTable.stripe > tbody > tr.odd,
[data-bz-theme="dark"] table.dataTable.stripe > tbody > tr.odd {
    background-color: var(--bz-surface-2);
}

[data-bz-theme="nextgen"] .modern-table > tbody > tr:hover,
[data-bz-theme="dark"] .modern-table > tbody > tr:hover,
[data-bz-theme="nextgen"] .table-hover > tbody > tr:hover,
[data-bz-theme="dark"] .table-hover > tbody > tr:hover,
[data-bz-theme="nextgen"] table.dataTable > tbody > tr:hover,
[data-bz-theme="dark"] table.dataTable > tbody > tr:hover {
    background-color: rgba(37, 99, 235, .06);
}

[data-bz-theme="dark"] .modern-table > tbody > tr:hover,
[data-bz-theme="dark"] .table-hover > tbody > tr:hover,
[data-bz-theme="dark"] table.dataTable > tbody > tr:hover {
    background-color: rgba(96, 165, 250, .09);
}

[data-bz-theme="nextgen"] .table-bordered,
[data-bz-theme="dark"] .table-bordered,
[data-bz-theme="nextgen"] .table-bordered > tbody > tr > td,
[data-bz-theme="dark"] .table-bordered > tbody > tr > td,
[data-bz-theme="nextgen"] .table-bordered > thead > tr > th,
[data-bz-theme="dark"] .table-bordered > thead > tr > th {
    border-color: var(--bz-border);
}

/* This application's own grid class. */
[data-bz-theme="nextgen"] .pdtable > tbody > tr > td,
[data-bz-theme="dark"] .pdtable > tbody > tr > td {
    border-bottom: 1px solid var(--bz-border);
    color: var(--bz-text);
}

/* ---------------------------------------------------------------------------
   3. DATATABLES CHROME - search box, length menu, info, paging.
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_filter input,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_length select,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background-color: var(--bz-surface);
    border: 1px solid var(--bz-border-2);
    border-radius: var(--bz-r-sm);
    color: var(--bz-text);
    padding: 6px 10px;
    margin-left: 6px;
}

[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_info,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_info,
[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_length,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_length,
[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_filter,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_filter {
    color: var(--bz-muted);
    font-size: 13px;
    padding: var(--bz-s-3) var(--bz-s-4);
}

/* DataTables paging buttons are <a> with inline-ish defaults; these beat them
   on specificity without !important. */
/* [2026-09-11] RESTING BORDER -> TRANSPARENT.
   ---------------------------------------------------------------------------
   THE BUG: the pager trailed off into a row of empty outlined boxes, in BOTH
   Modern and Dark, and Standard shows nothing of the kind. That pairing is the
   tell - this rule is the only pager styling keyed to those two appearances,
   so it was the only thing it could be.

   `border: 1px solid var(--bz-border-2)` paints a visible edge on EVERY
   element carrying .paginate_button, and a full_numbers pager carries the
   class on members that have no text: the first/last stubs when
   language.paginate leaves them blank, and the spacer slots either side of the
   ellipsis. Standard leaves those invisible because DataTables' own default is
   `border: 1px solid transparent` - the border exists to reserve the 1px so
   buttons do not shift when one becomes current, and is never meant to show at
   rest. Giving it a colour does not add a border; it REVEALS one that was
   always there, on everything, empty or not.

   So the resting border goes back to transparent - matching what Standard
   PAINTS, which is the rule this whole feature follows. Definition now comes
   from the two states that should have it and already did: :hover gets a
   surface and a primary edge, .current gets the brand fill. Geometry is
   untouched (same 1px, same padding, same margin), so nothing reflows and the
   pager sits exactly where it did.

   Do not re-add a resting border colour here. If the pager needs more presence
   in Modern, put it on the container, not on every child. */
/* [2026-09-11] SCOPED TO THE ANCHOR. `.paginate_button` sits on DIFFERENT
   elements depending on which DataTables integration is in play:

       plain DataTables   <a class="paginate_button">2</a>
       Bootstrap wrapper  <li class="paginate_button"><a>2</a></li>

   This app uses the Bootstrap shape - confirmed in the DOM as
   `<li class="paginate_button ">`. Written unqualified, the rule below was
   putting `padding: 5px 11px`, `margin: 0 2px` and a border on the <li>, while
   Bootstrap and .pagination > li > a style the <a> inside it. Every item was
   therefore boxed twice and 22px wider than Standard, and an item whose anchor
   carries no label still got a padded, bordered body of its own - the stray box
   after Next.

   Qualifying with a/button keeps plain-DataTables pages working exactly as
   before and takes the <li> back out of it. The <li> now only resets, so the
   anchor is the single thing that draws a pager button, as in Standard. */
[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_paginate a.paginate_button,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_paginate a.paginate_button,
[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_paginate button.paginate_button,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_paginate button.paginate_button {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--bz-r-sm);
    color: var(--bz-text) !important;
    margin: 0 2px;
    padding: 5px 11px;
}

/* The Bootstrap wrapper's <li>. It is a list item, not a button: it must carry
   no box of its own, or it double-draws around the anchor it contains. */
[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_paginate li.paginate_button,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_paginate li.paginate_button {
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
}

/* A pager slot with no label draws nothing at all. `transparent` still leaves
   a padded gap; `display:none` removes it, which is what Standard effectively
   shows. Applies to the anchor AND to a wrapper whose anchor is absent. */
[data-bz-theme="nextgen"] .dataTables_paginate li:empty,
[data-bz-theme="dark"] .dataTables_paginate li:empty,
[data-bz-theme="nextgen"] .dataTables_paginate a:empty,
[data-bz-theme="dark"] .dataTables_paginate a:empty,
[data-bz-theme="nextgen"] .pagination > li:empty,
[data-bz-theme="dark"] .pagination > li:empty,
[data-bz-theme="nextgen"] .pagination > li > a:empty,
[data-bz-theme="dark"] .pagination > li > a:empty {
    display: none !important;
}

/* Belt and braces for the same class of element: anything carrying the class
   with no content at all gets no box, whatever a skin loaded later decides. */
[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_paginate .paginate_button:empty,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button:empty {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--bz-surface-2);
    border-color: var(--bz-primary);
    color: var(--bz-primary) !important;
}

[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_paginate .paginate_button.current,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current,
[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background-image: linear-gradient(135deg, var(--bz-primary) 0%, var(--bz-primary-700) 100%);
    border-color: transparent;
    color: #fff !important;
    box-shadow: var(--bz-shadow-brand);
}

[data-bz-theme="nextgen"] .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
[data-bz-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* Sort arrows are background images on the th in DataTables' own stylesheet;
   only the spacing is adjusted so the glyph is not clipped by new padding. */
[data-bz-theme="nextgen"] table.dataTable thead .sorting,
[data-bz-theme="dark"] table.dataTable thead .sorting,
[data-bz-theme="nextgen"] table.dataTable thead .sorting_asc,
[data-bz-theme="dark"] table.dataTable thead .sorting_asc,
[data-bz-theme="nextgen"] table.dataTable thead .sorting_desc,
[data-bz-theme="dark"] table.dataTable thead .sorting_desc { padding-right: 28px; }

/* ---------------------------------------------------------------------------
   4. RESPONSIVE
   Below the tablet break a wide grid scrolls rather than crushing its columns
   to one character per line.
--------------------------------------------------------------------------- */
@media (max-width: 991px) {
    [data-bz-theme="nextgen"] .table-responsive,
    [data-bz-theme="dark"] .table-responsive {
        border: none;
        -webkit-overflow-scrolling: touch;
    }
    [data-bz-theme="nextgen"] .modern-table,
    [data-bz-theme="dark"] .modern-table,
    [data-bz-theme="nextgen"] .table,
    [data-bz-theme="dark"] .table { font-size: 12.5px; }

    [data-bz-theme="nextgen"] .modern-table > tbody > tr > td,
    [data-bz-theme="dark"] .modern-table > tbody > tr > td,
    [data-bz-theme="nextgen"] .table > tbody > tr > td,
    [data-bz-theme="dark"] .table > tbody > tr > td { padding: 10px; }
}

/* ---------------------------------------------------------------------------
   5. PRINT - a grid must print as a grid, not as glass.
--------------------------------------------------------------------------- */
@media print {
    [data-bz-theme="nextgen"] .modern-table > thead > tr > th,
    [data-bz-theme="dark"] .modern-table > thead > tr > th,
    [data-bz-theme="nextgen"] .table > thead > tr > th,
    [data-bz-theme="dark"] .table > thead > tr > th {
        background: #EEE !important;
        color: #000 !important;
        position: static !important;
    }
    [data-bz-theme="nextgen"] .table-scroll,
    [data-bz-theme="dark"] .table-scroll { overflow: visible !important; }
}
