/* burble-core.css / core-tables.css: Tables, scrolling table, fill chain, table footer, bulk bar, pager, count, DataTables buttons, toolbars, action menu.
   Linked by common/burble_core_css.php, in the order listed there. */

/* ── Tables ──────────────────────────────────────────────────
   Usage: <table class="bc-table"> … </table>                   */
.bc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.bc-table thead tr {
  background: var(--sl-100);
  border-bottom: 1px solid var(--border-color);
}
.bc-table th {
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  white-space: nowrap;
}
.bc-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color-light);
  color: var(--text);
  vertical-align: middle;
}
.bc-table tbody tr:last-child td {
  border-bottom: none;
}
.bc-table tbody tr {
  transition: background 0.1s;
}
.bc-table tbody tr:hover {
  background: var(--table-row-hover);
}

/* A checked row in a bulk-select list. The page's script toggles it. */
.bc-table tbody tr.is-selected {
  background: var(--teal-bg);
}

/* ── Table: layout helpers ───────────────────────────────────────
     .bc-table-wrap     scroll sideways when the columns outgrow the card
     .bc-table-scroll   scroll both ways inside the card, header pinned (below)
     .bc-table--matrix  a grid of switches: ruled columns
     .bc-table-row-header    a cell that names its row
     .bc-table-pin      a column that stays put while the table scrolls sideways
     .bc-table--striped every other row on a faint ground
     .bc-table--sm      smaller type and tighter cells
     .bc-table-sort-arrow  a sortable heading's arrow; teal under th[aria-sort]
     .bc-table--stack   under 720px each row becomes a block, each cell a line
                        labelled from its data-label attribute
     .bc-table-footer   the total / per-page / pagination bar under a table

   Usage:
     <div class="bc-table-wrap"><table class="bc-table bc-table--matrix">…</table></div>
     <div class="bc-table-footer">
       <span>Total: 12</span>
       <div class="bc-table-footer-group">…per page, <ul class="pagination">…</div>
     </div>                                                           */
.bc-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* ── Scrolling table ──────────────────────────────────────────
   A table too big for its card scrolls inside its own box, both ways, with the
   header pinned, so the filters and footer stay in reach.
     <div class="bc-table-scroll"><table class="bc-table">…</table></div>

   Up to 70% of the window by default (--ba-table-scroll-max changes it); on a
   page that is only the table, see "Fill" below.

   Large -webkit- scrollbars, easy to grab. The standard scrollbar-width/-color
   sit behind @supports, as Chrome drops the -webkit- rules when they are set. */
.bc-table-scroll {
  overflow: auto;
  max-height: var(--ba-table-scroll-max, 70vh);
  -webkit-overflow-scrolling: touch;
}
/* The whole head is pinned rather than each cell, so a head of two rows (a
   group row over the column names) stays together instead of the second row
   sliding under the first. */
.bc-table-scroll > .bc-table > thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
.bc-table-scroll > .bc-table thead th {
  background: var(--sl-100);
}
/* A column header in a colour, so a set of columns reads as one kind (the
   permission grids colour each ACL category's columns): coloured text under a
   2px line. The line is an inset shadow, not a border: in a collapsed table a
   border is painted above every cell and shows through a pinned column
   (.bc-table-pin) as the headers scroll under it; a shadow scrolls with its cell. */
.bc-table thead th.bc-table-th--blue {
  box-shadow: inset 0 2px 0 var(--tone-blue);
  color: var(--tone-blue);
}
.bc-table thead th.bc-table-th--yellow {
  box-shadow: inset 0 2px 0 var(--tone-yellow);
  color: var(--tone-yellow);
}
.bc-table thead th.bc-table-th--green {
  box-shadow: inset 0 2px 0 var(--tone-green);
  color: var(--tone-green);
}
.bc-table thead th.bc-table-th--plum {
  box-shadow: inset 0 2px 0 var(--tone-plum);
  color: var(--tone-plum);
}
/* A column filter chip (a .bc-chip that shows or hides a set of columns) in
   its header's colour: coloured text and border on white, a faint tint on
   hover. Each tone sets --col-tone; off (.bc-chip.btn-secondary, later in
   core-badges.css) still wins.
     <button class="bc-chip bc-table-col-filter-chip--blue">Apps</button> */
.bc-chip.bc-table-col-filter-chip--blue {
  --col-tone: var(--tone-blue);
}
.bc-chip.bc-table-col-filter-chip--yellow {
  --col-tone: var(--tone-yellow);
}
.bc-chip.bc-table-col-filter-chip--green {
  --col-tone: var(--tone-green);
}
.bc-chip.bc-table-col-filter-chip--plum {
  --col-tone: var(--tone-plum);
}
.bc-chip[class*="bc-table-col-filter-chip--"] {
  background: var(--white);
  border-color: var(--col-tone);
  color: var(--col-tone);
}
.bc-chip[class*="bc-table-col-filter-chip--"]:not(.btn-secondary):hover {
  background: color-mix(in srgb, var(--col-tone) 10%, var(--white));
  border-color: var(--col-tone);
  color: var(--col-tone);
}

.bc-table-scroll > .bc-table thead .bc-table-pin {
  z-index: 3;
}
.bc-table-scroll::-webkit-scrollbar {
  width: 16px;
  height: 16px;
}
.bc-table-scroll::-webkit-scrollbar-track,
.bc-table-scroll::-webkit-scrollbar-corner {
  background: transparent;
}
.bc-table-scroll::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.42);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
}
.bc-table-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.58);
  background-clip: content-box;
}
.bc-table-scroll::-webkit-scrollbar-thumb:active {
  background: rgba(71, 85, 105, 0.72);
  background-clip: content-box;
}
@supports not selector(::-webkit-scrollbar) {
  .bc-table-scroll {
    scrollbar-width: auto;
    scrollbar-color: rgba(100, 116, 139, 0.45) transparent;
  }
}

/* ── Fill ─────────────────────────────────────────────────────
   A page that is one big table: page, card, body and table scroller each take
   the height left to them, so only the table scrolls.
     <div class="bc-page bc-page--fill">
       <div class="bc-card bc-card--fill">
         <div class="bc-card-body"><div class="bc-table-scroll">…</div></div>
       </div>
     </div>

   Every link of the chain needs min-height:0, or a flex item refuses to shrink
   below its content and the table grows the page again. */
.bc-page--fill {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  /* The page's own padding (it has some on a phone) counts inside that
     100%, or it would push the page past the content area. */
  box-sizing: border-box;
}
.bc-page--fill > .bc-card--fill {
  flex: 1 1 auto;
  /* The card ends the page: its usual gap below would push the page past
     the content area and bring back the page scrollbar. */
  margin-bottom: 0;
}
.bc-card--fill {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.bc-card--fill > .bc-card-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.bc-card--fill .bc-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
/* No rows to show: the scroller shrinks to its header row and the empty state
   after it (a .bc-empty its script reveals) takes the room, centred by its
   auto margins, instead of sitting under a tall blank table. */
.bc-card--fill .bc-table-scroll:has(~ .bc-empty:not([hidden])),
.bc-modal-body--fill > .bc-table-scroll:has(~ .bc-empty:not([hidden])) {
  flex: 0 0 auto;
}
/* The same in a dialog: the table scroller takes what the body has left, so a
   search above the table stays put while the rows scroll.
     <div class="bc-modal-body bc-modal-body--fill">
       <input class="bc-input" …>
       <div class="bc-table-scroll">…</div>
     </div> */
.bc-modal-body--fill {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.bc-modal-body--fill > .bc-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.bc-table--matrix th,
.bc-table--matrix td {
  border-right: 1px solid var(--border-color-light);
}

.bc-table--matrix th:last-child,
.bc-table--matrix td:last-child {
  border-right: none;
}
/* In the head the light rule is the head's own --sl-100, so it vanished; it
   takes the head's bottom-rule colour instead. A colour only, so the
   last-child rule above still removes the last column's. */
.bc-table--matrix thead th {
  border-right-color: var(--border-color);
}
.bc-table-row-header {
  text-align: left;
  white-space: nowrap;
  font-weight: 600;
}
.bc-table-pin {
  position: sticky;
  /* A second pinned column sits after the first: set --ba-pin-left on its
     cells to the first column's width, e.g. style="--ba-pin-left: 34px" or
     a page rule on the column. */
  left: var(--ba-pin-left, 0);
  z-index: 1;
  background: var(--white);
}
.bc-table thead .bc-table-pin {
  z-index: 3;
  background: var(--sl-100);
}
.bc-table tbody tr:hover .bc-table-pin {
  background: var(--table-row-hover);
}
/* A pinned cell paints its own ground so the columns scrolling under it stay
   hidden; a checked row's pinned cells take the row's colour with it. */
.bc-table tbody tr.is-selected .bc-table-pin {
  background: var(--teal-bg);
}

/* ── Striped ──────────────────────────────────────────────────
   Every other row on a faint ground, for a wide, dense grid you read across
   (the Manage Products lists). Stripe, then hover, then selection, so hover
   beats the stripe and a selected row keeps its colour under the pointer;
   pinned cells follow the row. */
.bc-table--striped tbody tr:nth-child(even),
.bc-table--striped tbody tr:nth-child(even) .bc-table-pin {
  background: var(--bg-light);
}
.bc-table--striped tbody tr:hover,
.bc-table--striped tbody tr:hover .bc-table-pin {
  background: var(--table-row-hover);
}
.bc-table--striped tbody tr.is-selected,
.bc-table--striped tbody tr.is-selected .bc-table-pin {
  background: var(--teal-bg);
}
/* ── Small ────────────────────────────────────────────────────
   Smaller type and tighter cells, for a short table that should not
   dominate its surroundings. */
.bc-table--sm {
  font-size: 11.5px;
}
.bc-table--sm th {
  padding: 4px 6px;
  font-size: 10px;
  white-space: wrap;
}
.bc-table--sm td {
  padding: 4px 6px;
}
/* ── Sort arrow ───────────────────────────────────────────────
   Faint while the column is not the sort, teal while it is. The page's script
   sets aria-sort on the sorted <th> and swaps the glyph.
     <th data-sort="name" aria-sort="ascending">Name <i class="bc-table-sort-arrow">↑</i></th> */
.bc-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}
.bc-table th[data-sort]:hover {
  color: var(--teal-strong);
}
.bc-table-sort-arrow {
  color: var(--sl-400);
  font-style: normal;
}
.bc-table
  th:is([aria-sort="ascending"], [aria-sort="descending"])
  .bc-table-sort-arrow {
  color: var(--teal-strong);
}
/* A column read against the right edge: amounts, and the row's buttons. Put
   it on the <th> as well as the <td>s so the heading lines up. */
.bc-table .bc-table-right {
  text-align: right;
}
.bc-table .bc-table-center {
  text-align: center;
}
/* A date or code that must stay on one line. */
.bc-table .bc-table-nowrap {
  white-space: nowrap;
}
/* A narrow leading column holding a row checkbox. */
.bc-table .bc-table-check {
  width: 36px;
  padding-right: 0;
}
/* A row's buttons, side by side at the right edge of the last column.
   Usage: <td><div class="bc-table-actions"><a class="bc-btn …">Edit</a>…</div></td> */
.bc-table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
/* The buttons in a row's first cell, before the name, rather than its last. */
.bc-table-actions--start {
  justify-content: flex-start;
}
/* The column that holds them, on its <th>: exactly as wide as its buttons,
   so it never takes a share of the table's spare width. Its heading is
   .sr-only "Actions" — the buttons say what they are. In a table-layout:
   fixed table width: 1% is 1% of the table, so the page sizes the column in
   pixels instead; pinned, the next pinned column's --ba-pin-left is that width.
   Usage: <th class="bc-table-actions-col"><span class="sr-only">Actions</span></th> */
.bc-table .bc-table-actions-col {
  width: 1%;
  white-space: nowrap;
}

/* ── Bulk bar ─────────────────────────────────────────────────
   Shown over a table while rows are selected. Starts [hidden]; the page
   script reveals it.
     <div class="bc-bulk-bar" hidden>
       <span class="bc-bulk-count"><strong>3</strong> selected</span>
       <div class="bc-row">…buttons…</div>
     </div>                                                           */
.bc-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  background: var(--blue-bg);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  animation: bc-bulk-in 0.2s ease-out both;
}
.bc-bulk-bar[hidden] {
  display: none;
}
.bc-bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-strong);
}
.bc-bulk-count strong {
  font-weight: 700;
}
@keyframes bc-bulk-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .bc-table--stack thead {
    display: none;
  }
  .bc-table--stack tr {
    display: block;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color-light);
  }
  .bc-table--stack td {
    display: block;
    padding: 4px 14px;
    border: none;
  }
  .bc-table--stack td::before {
    content: attr(data-label);
    display: inline-block;
    width: 130px;
    font-size: 11px;
    font-weight: 600;
    color: var(--sl-500);
    text-transform: uppercase;
  }
}

.bc-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 24px;
  font-size: 13px;
  color: var(--sl-500);
  /* A card that does not clip (.bc-card--overflow-visible) would otherwise
     show square corners under its rounded ones. */
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}
/* With only one thing in it (a pager and no per-page picker, say) there is
   nothing to spread apart, so it sits in the middle. */
.bc-table-footer:has(> :only-child) {
  justify-content: center;
}
/* ── Count ────────────────────────────────────────────────────
   The one number pill for every count in the admin: beside a card or
   section title, in a tab button, in a reaction. The same pill as a
   .bc-badge, so a count and a status sit together on one line; a single
   digit makes a circle.

     <span class="bc-count bc-count--info">3</span>

   Plain grey is an empty or neutral count; --info marks one with something
   in it; --warn one that needs attention (no calendars enabled). A count
   that is itself a link or button, opening the things it counts, gets the
   pointer and a hover; one inside a clickable row or header leaves that to
   its container.

   Consolidated from .bc-tab-badge (tab buttons), the Change Requests total
   (a .bc-badge--info) and the reaction count on a release. */
.bc-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 25px;
  padding: 4px 8px;
  border-radius: 20px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-soft);
  background: var(--sl-100);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s,
    border-color 0.12s;
}
.bc-count--info {
  background: var(--blue-bg);
  color: var(--blue);
}
.bc-count--warn {
  background: var(--warn-bg);
  color: var(--warn-strong);
}
:is(a, button).bc-count {
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.12s;
}
:is(a, button).bc-count:hover {
  filter: brightness(0.95);
}

.bc-table-footer-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bc-table-footer-label {
  font-size: 12.5px;
  white-space: nowrap;
}
/* ── Pagination ───────────────────────────────────────────────
   The markup config_pagination_page() (utilities_helper.php) gives
   CodeIgniter's create_links(); scripts that page a table build the same.
     <ul class="pagination">
       <li><span class="btn btn-primary"><a href="…?p=1">1</a></span></li>
       <li><span class="btn btn-secondary"><a href="#">2</a></span></li>   current
     </ul>
   The buttons are Bootstrap .btn spans, hence the !important over
   Bootstrap's own colours. */
.pagination {
  display: flex;
  align-items: center;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-wrap: nowrap;
}
.pagination li {
  display: flex;
  list-style: none;
}
.pagination li span.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 12px;
  border: 1.5px solid var(--border-color) !important;
  border-radius: 8px !important;
  background: var(--white) !important;
  color: var(--text-strong) !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
  margin: 0 !important;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
/* The link stretches over the pill's padding and height, so a click anywhere
   on the button lands on it. */
.pagination li span.btn a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  margin: 0 -12px;
  padding: 0 12px;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}
/* config_pagination_page() puts Font Awesome 4 arrows in Next / Previous
   (fa-long-arrow-*). The app loads Font Awesome 5, which has no such glyph,
   so they would only leave an empty gap beside the word. (BBL-4681) */
.pagination li span.btn a i {
  display: none;
}
.pagination li span.btn:hover {
  background: var(--sl-100) !important;
  border-color: var(--border-hover) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
/* The current page: outlined in teal, teal text on white. */
.pagination li span.btn-secondary {
  background: var(--white) !important;
  border-color: var(--teal) !important;
  color: var(--teal-strong) !important;
  font-weight: 700 !important;
  pointer-events: none;
}
.pagination li span.btn-secondary a {
  color: var(--teal-strong) !important;
}

/* ── DataTables buttons ───────────────────────────────────────
   The vendor's .dt-button drawn as the teal .bc-btn--secondary, for a .bc-page
   that renders DataTables Buttons (none currently does). The vendor sheet's
   high-specificity rules need the !important. */
.bc-page .dt-button,
.bc-page .dt-buttons .dt-button,
.bc-page button.dt-button,
.bc-page a.dt-button {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 7px 14px !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  color: var(--white) !important;
  text-shadow: none !important;
  white-space: nowrap;
  background-color: var(--teal-strong) !important;
  background-image: linear-gradient(
    90deg,
    var(--teal),
    var(--teal-strong)
  ) !important;
  border: 1.5px solid var(--teal-strong) !important;
  border-radius: 9px !important;
  box-shadow: 0 1px 3px rgba(14, 147, 166, 0.3) !important;
  cursor: pointer;
  transition:
    background 0.15s,
    box-shadow 0.15s,
    transform 0.1s !important;
}
.bc-page .dt-button:hover,
.bc-page .dt-buttons .dt-button:hover {
  background-color: var(--teal-strong) !important;
  background-image: none !important;
  border-color: var(--teal-strong) !important;
  color: var(--white) !important;
  box-shadow: 0 3px 8px rgba(14, 147, 166, 0.35) !important;
  transform: translateY(-1px);
}
.bc-page .dt-button:active {
  transform: translateY(0) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}
/* Their container: a wrapping row. The display:contents rule comes first and
   the flex one after at the same weight, so the row wins; the margin reset
   drops the vendor's gap between buttons. */
.bc-card-actions .dt-buttons {
  display: contents;
}
.bc-card-actions button.dt-button {
  margin: 0;
}
.bc-page .dt-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Table toolbar ────────────────────────────────────────────
   The filter strip across the top of a table card, between the card header
   and the table. Stacks on a phone. Filters over anything that is not a
   table go in the .bc-card-header, beside its title.
     <div class="bc-table-toolbar">
       <label class="bc-label" for="x">Status</label> <select class="bc-select" id="x">…
     </div>                                                              */
.bc-table-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 10px;
}

/* A select in the toolbar is as wide as its longest option, not the row:
   .bc-select's width:100% would otherwise put each one on a line of its own.
   extensions/ba-select-fit.js holds that width steady whatever is chosen. */
.bc-table-toolbar .bc-select:not([multiple]) {
  width: auto;
  max-width: 100%;
}
/* A .bc-label in the toolbar stays on one line, and its icon is muted. */
.bc-table-toolbar .bc-label {
  white-space: nowrap;
}
.bc-table-toolbar .bc-label i {
  font-size: 11px;
  color: var(--sl-400);
}
/* A control in the toolbar that needs a floor width — a Chosen select, which
   is otherwise only as wide as its placeholder. */
.bc-table-toolbar-field {
  position: relative;
  min-width: 240px;
}
/* A .bc-row that lays out the toolbar's contents takes the toolbar's whole
   width — as a flex item it would otherwise shrink to its content, and
   --between would have no room to spread into. */
.bc-table-toolbar > .bc-row {
  flex: 1 1 100%;
  min-width: 0;
}
@media (max-width: 640px) {
  .bc-table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ── Menu ─────────────────────────────────────────────────────
   A button that opens a short list of actions. burble-admin.js toggles .open
   on anything carrying data-ba-menu and closes it on a click outside or Esc.

   Usage: <div class="bc-menu" data-ba-menu=".bc-menu-list">
            <button type="button" class="bc-btn bc-btn--outline">Export</button>
            <div class="bc-menu-list"><a class="bc-menu-item" href="…">CSV</a></div>
          </div> */
.bc-menu {
  position: relative;
  display: inline-block;
}
.bc-menu-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 140px;
  padding: 8px;
  background: var(--white);
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
}
.bc-menu.open .bc-menu-list {
  display: block;
}
.bc-menu-item {
  display: block;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--sl-800);
  text-decoration: none;
  transition: background 0.1s;
}
.bc-menu-item:hover,
.bc-menu-item:focus {
  background: var(--sl-100);
  color: var(--sl-800);
  text-decoration: none;
}
