/* Shared list tools (static/app/js/list-views.js): the grid / list switch,
   the numbered pager, and the grid layout of any record table. */

/* ---- Grid / list switch --------------------------------------------- */
.view-toggle {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}
.view-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}
.view-btn:hover { color: var(--ink); }
.view-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.view-btn.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--brand) 22%, transparent);
}

/* A card head / toolbar row that carries the switch keeps it at the end. */
.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
}
.list-head-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-left: auto; }
/* Added by list-views.js at the end of a list's toolbar, or in a slim bar. */
.list-toggle-auto { margin-left: auto; }
.list-head-auto { justify-content: flex-end; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.card > .list-head-auto:first-child { border-radius: var(--radius) var(--radius) 0 0; }

/* ---- Numbered pager -------------------------------------------------- */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.pager-summary { color: var(--muted); font-size: 12px; font-weight: 700; }
.pager-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: auto; }
.pager-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
a.pager-btn:hover, button.pager-btn:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); color: var(--brand); }
.pager-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pager-btn.is-current { border-color: var(--brand); background: var(--brand); color: #fff; cursor: default; }
.pager-btn.is-disabled { opacity: .4; cursor: default; }
.pager-step { font-size: 12px; }
.pager-gap { min-width: 22px; color: var(--muted); font-weight: 800; text-align: center; }
/* Inside a padded list (stock rows, cards) the pager sits flush below it. */
.pager[data-client-pager] { margin-top: 10px; padding: 12px 2px 2px; }

/* Rows another page of the list holds. */
.is-paged-out { display: none !important; }

/* While the next page loads. */
.is-page-loading { opacity: .55; pointer-events: none; transition: opacity .15s ease; }

@media (max-width: 560px) {
  .pager { justify-content: center; }
  .pager-summary { width: 100%; text-align: center; }
  .pager-pages { margin: 0 auto; }
  .pager-btn { min-width: 40px; height: 40px; }
}

/* ---- Grid view of a record table ------------------------------------- */
/* Each row becomes a card; each cell shows its column name. */
[data-list-view="grid"] .table-wrap { overflow: visible; }
[data-list-view="grid"] table { display: block; width: 100%; min-width: 0; border: 0; }
[data-list-view="grid"] table > thead { display: none; }
[data-list-view="grid"] table > tbody {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  padding: 14px;
}
[data-list-view="grid"] table > tbody > tr {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 2px 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(28, 48, 38, .05);
  transition: border-color .15s ease, box-shadow .15s ease;
}
[data-list-view="grid"] table > tbody > tr:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); box-shadow: var(--shadow); background: var(--surface); }
[data-list-view="grid"] table > tbody > tr > td {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 6px 0;
  border: 0;
  font-size: 12px;
  text-align: left;
  overflow-wrap: anywhere;
}
[data-list-view="grid"] table > tbody > tr > td::before {
  content: attr(data-label);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
/* The first cell is the card's title. */
[data-list-view="grid"] table > tbody > tr > td:first-child {
  grid-column: 1 / -1;
  margin-bottom: 4px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
[data-list-view="grid"] table > tbody > tr > td:first-child::before,
[data-list-view="grid"] table > tbody > tr > td[data-label=""]::before,
[data-list-view="grid"] table > tbody > tr > td:not([data-label])::before { display: none; }
/* Actions run along the bottom of the card. */
[data-list-view="grid"] table > tbody > tr > td:last-child:has(.btn, .row-actions, .inline-actions, form, button) {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
[data-list-view="grid"] table > tbody > tr > td:last-child .row-actions,
[data-list-view="grid"] table > tbody > tr > td:last-child .inline-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
[data-list-view="grid"] table .num { text-align: left; }
/* The "nothing here" row spans the whole grid. */
[data-list-view="grid"] table > tbody > tr:has(> td[colspan]) { grid-column: 1 / -1; display: block; border-style: dashed; box-shadow: none; }
[data-list-view="grid"] table > tbody > tr > td[colspan] { display: block; border: 0; margin: 0; padding: 0; }
[data-list-view="grid"] table > tbody > tr > td[colspan]::before { display: none; }
[data-list-view="grid"] table > tfoot { display: block; padding: 0 14px 14px; }
[data-list-view="grid"] table > tfoot > tr { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
[data-list-view="grid"] table > tfoot td, [data-list-view="grid"] table > tfoot th { border: 0; }

@media (max-width: 560px) {
  [data-list-view="grid"] table > tbody { grid-template-columns: 1fr; padding: 10px; }
}

/* ---- Card-style lists ------------------------------------------------ */
/* Stacked entries (day logs, rosters) spread into columns in grid view. */
[data-list-view="grid"] .log-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); align-items: start; }
[data-list-view="grid"] .order-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); align-items: start; }
[data-list-view="grid"] .log-list > .empty-state,
[data-list-view="grid"] .order-list > .empty-state { grid-column: 1 / -1; }
/* Tile grids (bill records) stack into one column in list view. */
body [data-list-view="list"] .billing-records-grid { grid-template-columns: 1fr; }

@media (prefers-reduced-motion: reduce) {
  .view-btn, .pager-btn, .is-page-loading, [data-list-view="grid"] table > tbody > tr { transition: none; }
}
