tr.gridjs-tr.gridjs-tr-clickable {
  td.gridjs-td * {
    cursor: pointer;
  }

  td.gridjs-td *:not(.badge, .badge *) {
    color: var(--bs-primary) !important;
  }
}

/* Sub-table "cards" layout (renderTable's layout=>'cards' option). Same
   <table>/<tr>/<td> markup as the plain table — add/delete-row, validation
   and CSRF wiring are all untouched — this only re-skins it visually, using
   the data-label each <td> now carries in place of the hidden <thead>. */
table.card-grid-table {
  border: none;
  background: transparent;

  > thead {
    display: none;
  }

  > tbody.gridjs-tbody {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    background: transparent;

    > tr[data-index] {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      position: relative;
      background: var(--bs-body-bg);
      border: 1px solid var(--bs-border-color);
      border-radius: 0.75rem;
      padding: 1rem 1rem 2.75rem;

      > td {
        display: block;
        border: none !important;
        padding: 0;
        background: transparent;

        &[data-label]:not(.d-none)::before {
          content: attr(data-label);
          display: block;
          font-size: 0.75rem;
          font-weight: 600;
          color: var(--bs-gray-600);
          margin-bottom: 0.25rem;
        }

        &:not([data-label]) {
          position: absolute;
          bottom: 0.75rem;
          right: 1rem;
          width: auto;
        }
      }
    }
  }
}
/* The action column stays in view while a wide grid scrolls sideways, pinned
   to whichever side Settings > Appearance puts it on (the first or the last
   column). An opaque background — the card's, which follows the light/dark
   theme (--kt-*, not --bs-*) — so the columns scrolling under it don't show
   through. The cards layout has no columns to pin. */
table.gridjs-table:not(.card-grid-table) {
  th[data-column-id="actions"],
  td[data-column-id="actions"] {
    position: sticky;
    z-index: 1;
    background-color: var(--kt-card-bg, var(--bs-card-bg));
  }

  th[data-column-id="actions"]:first-child,
  td[data-column-id="actions"]:first-child {
    left: 0;
    box-shadow: inset -1px 0 0 var(--kt-border-color, var(--bs-border-color));
  }

  th[data-column-id="actions"]:last-child,
  td[data-column-id="actions"]:last-child {
    right: 0;
    box-shadow: inset 1px 0 0 var(--kt-border-color, var(--bs-border-color));
  }
}

/* Grid footer: summary left, page buttons centred, rows-per-page (grid.mjs initPageSizeSelect)
   right. Sized by the card, not the window (the sidebar narrows it): below 800px the three
   overlap, so the buttons take the first row and summary + rows-per-page share the second. */
.gridjs-footer {
  container-type: inline-size;
  flex-wrap: wrap;
}

.gridjs-page-size {
  margin-left: auto;
}

@container (min-width: 800px) {
  .gridjs-page-size {
    position: absolute;
    top: 50%;
    right: 0;
    padding-right: 0.75rem;
    transform: translateY(-50%);
  }
}

@container (max-width: 799.98px) {
  .gridjs-pagination {
    display: contents;
  }

  .gridjs-pages {
    order: -1;
    width: 100%;
    text-align: center;
  }

  /* Bootstrap's position utilities are !important. */
  .gridjs-summary {
    align-self: center;
    position: static !important;
    margin-top: 0.5rem;
    padding-left: 0 !important;
    transform: none !important;
  }

  .gridjs-page-size {
    margin-top: 0.5rem;
  }
}

/* Phones: the summary is hidden (d-none d-md-block), so centre rows-per-page alone. */
@container (max-width: 575.98px) {
  .gridjs-page-size {
    margin-right: auto;
  }
}
