/*
 * A-11 Training library: status pills, title filter and Owner select, and the training rows
 * (Training · Owner · Version · Status · Assigned · Completed · Next due · Overdue · actions).
 * Classes are prefixed tcms- (training CMS) because every page stylesheet loads everywhere.
 * Phones follow the AM-02 list pattern: title and a round "+" in the header row, the filter
 * field above the pills, compact two-line cards.
 */
@layer pages {
  .tcms-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
  }
  .tcms-filter__owner { display: flex; }

  .tcms-frame { display: block; }

  /* The title filter reloads the list frame: dim it while the request runs. */
  .tcms-frame[aria-busy="true"] .list,
  .tcms-frame[aria-busy="true"] .empty {
    opacity: 0.6;
    transition: opacity 120ms ease;
  }

  .tcms-library {
    --list-cols: minmax(0, 2.4fr) 92px 60px 104px 76px 96px 112px 112px 150px;
  }

  .tcms-row__owner {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .tcms-row__title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .tcms-row__link {
    color: var(--color-text);
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.5;
  }
  .tcms-row__link:hover { color: var(--color-text); text-decoration: underline; }
  /* The whole row is the link's hit area (the actions sit above it). */
  .tcms-row__link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
  }
  .tcms-row .list-row__end { position: relative; z-index: 1; }
  .tcms-row .list-row__end:has(.menu__panel:not([hidden])) { z-index: 5; }
  .tcms-row:has(.tcms-row__link:hover) { box-shadow: 0 0 0 2px var(--color-divider); }
  .tcms-row.list-row--archived:has(.tcms-row__link:hover) { box-shadow: none; }
  .tcms-row.list-row--archived .tcms-row__link { color: inherit; }

  .tcms-row__btn.btn--sm { height: 36px; }

  /* The nine columns take 954px before the title, which gets about 146px at 1440. Below that,
     Assigned goes first (Completed already reads "1 / 3"), so the title keeps 130px or more down
     to 1300px. */
  @media (max-width: 1439px) {
    .tcms-library { --list-cols: minmax(0, 2.4fr) 84px 56px 100px 88px 100px 104px 150px; }
    .tcms-library :is(.list-header, .tcms-row) > :nth-child(5) { display: none; }
  }

  /* Below 1300px (laptop and tablet): drop Version, Assigned and Next due; the actions column
     fits "Edit" + "…". */
  @media (max-width: 1299px) {
    .tcms-library { --list-cols: minmax(0, 2fr) 92px 104px 84px 112px 124px; }
    .tcms-library :is(.list-header, .tcms-row) > :is(:nth-child(3), :nth-child(5), :nth-child(7)) { display: none; }
  }

  /* Below 1100px the owner goes too (the Owner filter still narrows the list). */
  @media (max-width: 1099px) {
    .tcms-library { --list-cols: minmax(0, 2fr) 104px 84px 112px 124px; }
    .tcms-library :is(.list-header, .tcms-row) > :nth-child(2) { display: none; }
  }

  @media (max-width: 1023px) {
    .tcms-library { --list-cols: minmax(0, 1fr) 96px 76px 104px 124px; } /* 76: the "Completed" label */
    .tcms-library :is(.list-header, .tcms-row) { column-gap: 10px; }
  }

  @media (max-width: 767px) {
    .tcms-toolbar { gap: 14px; }
    .tcms-toolbar .toolbar__spacer { display: none; }
    .tcms-toolbar .tcms-filter { order: -1; }
    .tcms-filter,
    .tcms-filter .filter-field { width: 100%; }
    .tcms-filter { flex-wrap: nowrap; }
    .tcms-filter .filter-field { flex: 1; min-width: 0; }
    .tcms-toolbar .pill-filters { gap: 6px; }

    /*
     * Compact card: title + status chip, then "x / y completed" and the overdue chip with the
     * actions on the right. Owner, Version, Assigned and Next due are left out; an empty Completed
     * or Overdue ("—") is not shown. An archived row has only "…", on the title line.
     */
    .tcms-library { --list-cols-mobile: minmax(0, 1fr) auto auto; }
    .tcms-row { row-gap: 4px; }
    .tcms-row > :is(:nth-child(2), :nth-child(3), :nth-child(5), :nth-child(7)),
    .tcms-row > .tcms-row__none { display: none; }
    .tcms-row > .tcms-row__title { grid-area: 1 / 1; }
    .tcms-row > :nth-child(4) { grid-area: 1 / 2 / 2 / 4; justify-self: end; }
    .tcms-row > .tcms-row__completed { grid-area: 2 / 1; font-size: 13.5px; }
    .tcms-row > .tcms-row__completed::after { content: " completed"; font-weight: 400; color: var(--color-neutral-700); }
    .tcms-row > .tcms-row__overdue { grid-area: 3 / 1; }
    .tcms-row > .list-row__end { grid-area: 2 / 2 / 4 / 4; justify-content: flex-end; }
    .tcms-row.list-row--archived > :nth-child(4) { grid-area: 1 / 2; }
    .tcms-row.list-row--archived > .list-row__end { grid-area: 1 / 3; }
    .tcms-row .tcms-row__btn.btn--sm { height: 44px; }
    .tcms-row .list-row__end .icon-btn { width: 44px; height: 44px; }
  }
}
