/*
 * Admin → Models → Configured Models: the identity columns stay pinned.
 *
 * The table carries twelve columns (1,614 px) inside a card that is at most
 * ~1,164 px wide, so it always scrolls sideways. Reaching Save / Delete /
 * Enabled meant scrolling the model's label and id out of view: the id column
 * showed "laude-sonnet-4-…", and the admin acted on a row they could no longer
 * identify. Label and Model ID now sit together at the start and stay pinned
 * (with the drag handle) while the settings columns scroll beneath them.
 *
 * Own file on purpose: a rule added to style.css reaches the browser one visit
 * late, because the service worker serves the cached sheet first.
 *
 * Logical properties (inset-inline-start) pin to the RIGHT edge in Arabic.
 * Below 1024 px there is no room for ~460 px of pinned columns, so phones and
 * narrow windows keep the plain sideways scroll.
 */
@media (min-width: 1024px) {
  .admin-models-table {
    /* Fixed widths: each pinned column's offset is the sum of those before it.
       Label: 10.5rem input + 0.75rem padding each side; id: 13rem + padding. */
    --mt-pin-handle: 2.375rem;
    --mt-pin-label: 12rem;
    --mt-pin-id: 14.5rem;
    /* Same as the table shell, so a pinned cell hides what scrolls under it. */
    --mt-pin-bg: color-mix(in srgb, var(--card) 96%, var(--surface));
  }

  .admin-models-table .admin-models-pin {
    position: sticky;
    z-index: 2;
    box-sizing: border-box;
  }
  .admin-models-table .admin-models-pin--handle {
    inset-inline-start: 0;
    width: var(--mt-pin-handle);
    min-width: var(--mt-pin-handle);
    max-width: var(--mt-pin-handle);
  }
  .admin-models-table .admin-models-pin--label {
    inset-inline-start: var(--mt-pin-handle);
    width: var(--mt-pin-label);
    min-width: var(--mt-pin-label);
    max-width: var(--mt-pin-label);
  }
  .admin-models-table .admin-models-pin--id {
    inset-inline-start: calc(var(--mt-pin-handle) + var(--mt-pin-label));
    width: var(--mt-pin-id);
    min-width: var(--mt-pin-id);
    max-width: var(--mt-pin-id);
    /* The seam the settings columns slide under. */
    box-shadow: inset -1px 0 0 var(--card-b), 6px 0 8px -6px rgba(0, 0, 0, 0.18);
  }
  [dir="rtl"] .admin-models-table .admin-models-pin--id {
    box-shadow: inset 1px 0 0 var(--card-b), -6px 0 8px -6px rgba(0, 0, 0, 0.18);
  }

  /* Opaque so scrolled content never shows through. Zero specificity on
     purpose: the existing row-hover and is-dragging backgrounds still win. */
  :where(.admin-models-table) :where(td.admin-models-pin) {
    background-color: var(--mt-pin-bg);
  }
  /* Header cells are already sticky to the top with their own background;
     pinned ones also stick sideways, above the scrolling header cells. */
  .admin-models-table thead th.admin-models-pin {
    z-index: 3;
  }
  :where(.admin-models-table) :where(thead th.admin-models-pin) {
    background-color: var(--mt-pin-bg);
  }

  /* "CLOUD" / "LOCAL" spans every column: keep its words in view too. */
  .admin-models-table .admin-models-group-label {
    display: inline-block;
    position: sticky;
    inset-inline-start: 0.5rem;
  }
}
