/* fsq-admin-table.css - search/filter card and admin list table (CMP-330 / CMP-331). Adapted from the mERP UI library; provenance in the FSQ Brain (brain/ui/fsq_ui_registry.md). */

.merp-admin-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 12px; margin-bottom: 1rem;
}
.merp-admin-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 2px 0; }
.merp-admin-header .merp-admin-sub { color: var(--fsq-text-muted); font-size: .88rem; }

/* Search / filter card */
.merp-admin-filters {
  background: var(--fsq-surface); border: 1px solid var(--fsq-border); border-radius: 8px;
  padding: 16px 20px; margin-bottom: 1rem; box-shadow: var(--fsq-shadow);
}
.merp-admin-filters .form-label { font-size: .78rem; font-weight: 600; color: var(--fsq-text-2); margin-bottom: 4px; }
.merp-admin-filters .form-control,
.merp-admin-filters .form-select { font-size: .88rem; }

/* Table card wrapper */
.merp-admin-table-card {
  background: var(--fsq-surface); border: 1px solid var(--fsq-border); border-radius: 8px;
  overflow: hidden; box-shadow: var(--fsq-shadow);
}
.merp-admin-table-header {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--fsq-border); background: var(--fsq-surface);
}
.merp-admin-table-header .merp-admin-table-title { font-weight: 600; font-size: .95rem; }
.merp-admin-table-header .merp-admin-table-count { color: var(--fsq-text-muted); font-weight: 400; }
.merp-admin-table-header .merp-admin-table-hint { color: var(--fsq-text-muted); font-size: .78rem; }

/* Positioned so an absolutely placed visually-hidden header cell label is clipped with the scroller
   (otherwise it sits at the far right and widens the whole page). */
.merp-admin-table-card .table-responsive { position: relative; }

/* The table itself */
.merp-admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.merp-admin-table thead th {
  background: var(--fsq-surface-alt); font-weight: 600; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .3px; color: var(--fsq-text-2); padding: 10px 16px;
  border-bottom: 2px solid var(--fsq-border); white-space: nowrap; user-select: none;
}
.merp-admin-table thead th.sortable { cursor: pointer; }
.merp-admin-table .fsq-sort-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 0; box-sizing: border-box; min-height: 24px; }
.merp-admin-table .fsq-sort-btn:focus-visible { outline: 2px solid var(--fsq-focus); outline-offset: 2px; }
.merp-admin-table thead th.sortable:hover { color: var(--fsq-text); background: var(--fsq-surface-hover); }
.merp-admin-table .sort-arrow { font-size: .65rem; opacity: .5; margin-left: 4px; }
.merp-admin-table thead th.sorted .sort-arrow { opacity: 1; color: var(--fsq-brand); }

/* Rows: no striping, hover only */
.merp-admin-table tbody tr { border-bottom: 1px solid var(--fsq-border-soft); transition: background .12s; }
.merp-admin-table tbody tr:last-child { border-bottom: none; }
.merp-admin-table tbody tr:hover { background: var(--fsq-surface-hover); }
.merp-admin-table tbody td { padding: 12px 16px; vertical-align: middle; color: var(--fsq-text); }
.merp-admin-table .text-end { text-align: right; }

/* Name column (primary text) */
.merp-admin-table .merp-admin-name { font-weight: 600; color: var(--fsq-brand); text-decoration: none; }
.merp-admin-table tbody tr:hover .merp-admin-name { text-decoration: underline; }
.merp-admin-table .merp-admin-name-sub { font-size: .78rem; color: var(--fsq-text-muted); font-weight: 400; }

/* Right chevron column */
.merp-admin-table .merp-admin-chevron { color: var(--fsq-text-muted); opacity: .55; font-size: .75rem; text-align: right; width: 32px; padding-right: 20px; }
.merp-admin-table tbody tr:hover .merp-admin-chevron { opacity: 1; }

/* Empty state */
.merp-admin-empty { padding: 40px 20px; text-align: center; color: var(--fsq-text-muted); font-size: .95rem; }

/* Pagination row */
.merp-admin-pagination {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--fsq-border); font-size: .82rem; color: var(--fsq-text-muted);
}

/* Phone: the table scrolls inside its card (never the page); keep the primary column readable. */
@media (max-width: 767px) {
  .merp-admin-filters { padding: 14px 14px; }
  .merp-admin-table-header, .merp-admin-pagination { padding-left: 14px; padding-right: 14px; }
  .merp-admin-table thead th, .merp-admin-table tbody td { padding-left: 12px; padding-right: 12px; }
  .merp-admin-table td:first-child { min-width: 200px; }
}

/* SOP D-TBL-1: a linked name is underlined (colour is not the only cue); a plain name in a link-mode table is ink, not link-coloured. */
.merp-admin-table a.merp-admin-name { text-decoration: underline; text-underline-offset: 2px; }
.merp-admin-table .merp-admin-name--static { color: var(--fsq-text); }
.merp-admin-table tbody tr:hover .merp-admin-name--static { text-decoration: none; }

/* SOP D-TBL-1b (#230 repair V-06): below 576px a row is stacked - the name cell is the row heading, every other cell is "LABEL  value"
   (label from data-label), so the state / access cells are visible without scrolling the card. The header row is visually hidden (sorting is a
   wide-screen aid; the filters still work). From 576px the table is the upstream table (scrolls inside its card). */
@media (max-width: 575px) {
  .merp-admin-table, .merp-admin-table tbody, .merp-admin-table tbody tr, .merp-admin-table tbody td { display: block; width: 100%; }
  .merp-admin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .merp-admin-table tbody tr { padding: 12px 14px; }
  .merp-admin-table tbody td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 3px 0; min-width: 0; text-align: right; }
  .merp-admin-table tbody td::before { content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; color: var(--fsq-text-muted); }
  .merp-admin-table tbody td:has(.merp-admin-name) { display: block; text-align: left; padding: 0 0 6px; }
  .merp-admin-table tbody td:has(.merp-admin-name)::before { content: none; }
  .merp-admin-table td:first-child { min-width: 0; }
  .merp-admin-table tbody td.merp-admin-chevron { display: none; }
}
