/* ==========================================================================
   Labour Life practice system: documents.css (SPEC 7.3). Owner: documents (M2).
   The document list, the upload dialog, the document page, Admin > Document
   types and Admin > Deleted items. Class prefix doc-.

   This file only ADDS classes. It restates nothing from the core files and
   uses tokens only. Phone first: the base styles are the phone.

     .doc-phone-only, .doc-wide-only   shown under 720px only, from 720px only
     .doc-act-main                     the main header button: full width on a phone
     .doc-pre                          text that keeps its line breaks
     .doc-list (__tools __seg __btns __desc)   the list on a Documents tab
     .doc-crumbs (__l __i __a)         the breadcrumb of the open folder: one line that scrolls sideways
     .doc-folders, .doc-folder (__open __icon __name __lock __n __more)   the folders of the open place
     .doc-pick (__i __t __none __new __shared)  the folder picker
     .doc-name (__open __marks)        the file name cell: the name and its badges
     .doc-up (__need __into __into-t __sum)   the upload dialog
     .doc-page (__view __side)         the document page: preview and details
     .doc-card-h, .doc-retry           a card heading, the "PDF copy failed" note
     .doc-person                       the note "Add this person as a worker" on a generated document with no worker
     .doc-vals (__h __list __items)    the values of a generated document
     .doc-people (__lead)              who may see a confidential document
     .doc-types (__row __main __name __meta __acts)   Admin > Document types
     .doc-del (__tools __acts __first __name __cell)  Admin > Deleted items
     .dv__stage--pan, --panning, .dv__tile   the viewer's moving and zooming (the one exception to the prefix:
                                       the viewer's base classes are in components.css)
   ========================================================================== */

/* ---------- helpers ---------- */

.doc-wide-only { display: none; }
@media (min-width: 720px) {
  .doc-phone-only { display: none; }
  .doc-wide-only { display: inline-flex; }
}
@media (max-width: 719px) {
  .doc-act-main { flex: 1 1 100%; }
}
.doc-pre { white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- the document list ---------- */

.doc-list { display: grid; gap: var(--s3); min-width: 0; }
.doc-list > * { min-width: 0; }
.doc-list__tools { justify-content: space-between; }
.doc-list__btns { display: flex; flex-wrap: wrap; gap: var(--s2); margin-left: auto; min-width: 0; }
.doc-list__btns:empty { display: none; }
@media (max-width: 719px) {
  .doc-list__seg { display: flex; flex: 1 1 100%; }
  .doc-list__seg > .seg__b { flex: 1 1 0; }
  .doc-list__btns { flex: 1 1 100%; margin-left: 0; }
  .doc-list__btns > .btn { flex: 1 1 100%; }
}

/* The breadcrumb stays on one line. On a narrow screen it scrolls sideways. */
.doc-crumbs { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.doc-crumbs::-webkit-scrollbar { display: none; }
.doc-crumbs__l { display: flex; align-items: center; width: max-content; margin: 0; padding: 0; list-style: none; white-space: nowrap; }
.doc-crumbs__i { display: inline-flex; align-items: center; }
.doc-crumbs__i + .doc-crumbs__i::before { content: "/"; padding: 0 var(--s1); color: var(--ink-disabled); }
.doc-crumbs__a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s2);
  border-radius: var(--r-xs); color: var(--ink-soft); font-weight: 600; text-decoration: none;
}
.doc-crumbs__a:hover { background: var(--tint); color: var(--ink); }
.doc-crumbs__a[aria-current="page"] { color: var(--ink); }
.doc-crumbs__a:focus-visible { outline-offset: -3px; }

/* Folders come first: one row each, a card each on a phone. One tap opens one. */
.doc-folders { display: grid; gap: var(--s2); margin: 0; padding: 0; list-style: none; }
@media (min-width: 720px) {
  .doc-folders { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
}
.doc-folder {
  display: flex; align-items: center; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
}
.doc-folder:hover { background: var(--tint); }
.doc-folder__open {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0 var(--s3);
  flex: 1 1 auto; min-width: 0; min-height: calc(var(--tap) + var(--s3)); padding: var(--s2) var(--s3);
  border-radius: var(--r-md); color: var(--ink); text-decoration: none;
}
.doc-folder__open:focus-visible { outline-offset: -3px; }
.doc-folder__icon { grid-row: 1 / span 2; display: inline-flex; color: var(--ink-soft); }
.doc-folder__name { font-weight: 600; overflow-wrap: anywhere; }
/* A confidential folder (26 Oct 2026): a small lock after its name. */
.doc-folder__lock { display: inline-flex; margin-left: var(--s1); vertical-align: -2px; color: var(--ink-soft); }
.doc-folder__n { color: var(--ink-mute); font-size: var(--fs-sm); }
.doc-folder__more { flex: none; width: var(--tap); height: var(--tap); margin-right: var(--s1); }

/* Grid or list (9 Nov 2026, decision 424). The two buttons sit beside Folders and All documents, on a
   computer only: a phone shows one folder a line either way. The grid's names keep two lines at most. */
.doc-list__look[hidden] { display: none; }
.doc-list__lookb { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); }
.doc-list__lookb .i { margin: 0; }
@media (max-width: 719px) {
  .doc-list__look { display: none; }
}
@media (min-width: 720px) {
  .doc-folders:not(.doc-folders--list) .doc-folder__name {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  }
  /* The list: one folder a line, the name in full, the number at the end. */
  .doc-folders--list {
    grid-template-columns: minmax(0, 1fr); gap: 0;
    border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden;
  }
  .doc-folders--list .doc-folder { border: 0; border-radius: 0; border-top: 1px solid var(--line); }
  .doc-folders--list .doc-folder:first-child { border-top: 0; }
  .doc-folders--list .doc-folder__open {
    grid-template-columns: auto minmax(0, 1fr) auto; min-height: var(--tap); padding: var(--s1) var(--s3); border-radius: 0;
  }
  .doc-folders--list .doc-folder__icon { grid-row: 1; }
  .doc-folders--list .doc-folder__name { font-weight: 600; }
  .doc-folders--list .doc-folder__n { grid-column: 3; grid-row: 1; white-space: nowrap; }
}

/* ---------- the folder picker ---------- */

.doc-pick { display: grid; gap: 2px; margin: 0 0 var(--s3); padding: 0; list-style: none; }
.doc-pick__i {
  display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: var(--tap);
  padding: var(--s2) var(--s3) var(--s2) calc(var(--s3) + var(--d, 0) * var(--s4));
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink);
  font: inherit; text-align: left; cursor: pointer;
}
.doc-pick__i:hover { background: var(--tint); }
.doc-pick__i.is-on { background: var(--tint-2); font-weight: 600; }
.doc-pick__i:disabled { color: var(--ink-disabled); cursor: not-allowed; background: transparent; }
.doc-pick__i:focus-visible { outline-offset: -3px; }
.doc-pick__i > svg { flex: none; }
.doc-pick__t { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.doc-pick__none { margin-bottom: var(--s3); }
/* The chosen folder is shared with the client (5 Nov 2026). */
.doc-pick__shared { margin: 0 0 var(--s3); }
/* A press anywhere on a row opens the preview. */
.doc-list tbody tr[data-id] { cursor: pointer; }
.doc-list__desc { overflow-wrap: anywhere; }
@media (min-width: 720px) {
  .doc-list__desc { max-width: 22rem; }
  .doc-list tbody tr[data-id]:hover td { background: var(--tint); }
}

.doc-name { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); min-width: 0; max-width: 100%; }
.doc-name__open { min-width: 0; font-weight: 600; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.doc-name__marks { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
/* The expiry date of a document (item 86): quiet text on a list row, a badge once it has passed. */
.doc-expiry__when { font-size: var(--fs-sm); color: var(--ink-mute); white-space: nowrap; }
.doc-expiry__val { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.doc-types__asks { margin-top: var(--s1); }
@media (pointer: coarse) {
  .doc-name__open { min-height: var(--tap); display: inline-flex; align-items: center; }
}

/* ---------- the upload dialog ---------- */

.doc-up { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.doc-up > * { min-width: 0; }
.doc-up__need { margin-bottom: var(--s3); }
.doc-up__into { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.doc-up__into > svg { flex: none; color: var(--ink-soft); }
.doc-up__into-t { flex: 1 1 10rem; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.doc-up__sum { margin-top: var(--s3); }

/* ---------- the document page ----------
   .cols puts the first child on the left from 960px. Under that the details
   come first and the preview follows at full width. */

@media (max-width: 959px) {
  .doc-page__view { order: 2; }
  .doc-page__side { order: 1; }
}

.doc-card-h { margin-bottom: var(--s4); font-size: var(--fs-h3); }
.doc-retry { display: grid; gap: var(--s3); justify-items: start; }
.doc-person { display: grid; gap: var(--s3); justify-items: start; }

.doc-vals__h { margin: var(--s5) 0 var(--s2); font-size: var(--fs-body); font-weight: 600; }
.doc-vals__items { display: grid; gap: var(--s3); margin: 0; padding-left: var(--s5); }
.doc-vals__items p { margin-top: var(--s1); color: var(--ink-soft); }

.doc-people { display: grid; gap: var(--s1); margin: 0; padding: 0; list-style: none; }
.doc-people li { font-weight: 600; overflow-wrap: anywhere; }
.doc-people__lead { margin-bottom: var(--s3); color: var(--ink-soft); }

/* ---------- Admin > Document types ---------- */

.doc-types { margin: 0; padding: 0; list-style: none; }
.doc-types__row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4);
  padding: var(--s3) var(--s4); border-top: 1px solid var(--line);
}
.doc-types__row:first-child { border-top: 0; }
.doc-types__main { display: grid; gap: var(--s1); flex: 1 1 14rem; min-width: 0; }
.doc-types__name { font-size: var(--fs-lg); font-weight: 600; overflow-wrap: anywhere; }
.doc-types__row.is-off .doc-types__name { color: var(--ink-mute); }
.doc-types__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.doc-types__acts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }

/* ---------- Admin > Deleted items ---------- */

.doc-del__tools .field { flex: 0 1 320px; min-width: 0; margin-bottom: 0; }
.doc-del__name { overflow-wrap: anywhere; }
.doc-del__acts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.doc-del__first { max-width: 16rem; }
@media (min-width: 720px) {
  .doc-del__cell { width: 1%; }
  .doc-del__acts { flex-wrap: nowrap; justify-content: flex-end; white-space: nowrap; }
  .doc-del__first { white-space: normal; min-width: 9rem; }
}
@media (max-width: 719px) {
  .doc-del__acts { padding-top: var(--s2); }
  .doc-del__acts > .btn { flex: 1 1 auto; }
  .doc-del__first { flex: 1 1 100%; max-width: none; }
}

/* ---------- Share with the client (2 Nov 2026, decision 372) ---------- */

/* The staff mark on a shared folder or document: the info colours, with its icon and its word. */
.badge--shared { background: var(--info-bg); border-color: var(--info-line); color: var(--info-ink); }
.share { display: grid; gap: var(--s3); }
.share__lead { display: flex; align-items: flex-start; gap: var(--s2); margin: 0; color: var(--ink-soft); }
.share__lead svg { flex: none; margin-top: 3px; }
.share__people { margin: 0; padding: 0; border: 0; }
.share__people .check { padding: var(--s1) 0; }

/* ---------- The document viewer: moving and zooming (13 Nov 2026, decision 491) ---------- */

/* The viewer's own classes are in components.css (.dv). These are the ones the
   moving and zooming add (components/doc-viewer.js): a hand while the document
   is larger than its box and can be dragged, a closed hand while it is dragged.
   A page is drawn in tiles, each placed on its page; nothing in a page or a
   picture is selected by a drag or a double-click. */
.dv__stage--pan { cursor: grab; }
.dv__stage--pan.dv__stage--panning { cursor: grabbing; }
.dv__pages, .dv__imgbox { -webkit-user-select: none; user-select: none; }
.dv__page { overflow: hidden; }
.dv__page > canvas.dv__tile { position: absolute; }

@media print {
  .doc-list__tools, .doc-folder__more, .doc-types__acts, .doc-del__acts { display: none !important; }
}

/* ---------- Many at once (24 Nov 2026, decision 521) ----------
   The bar of the ticked documents of a list (components/doc-list.js): how many are
   chosen, Labour Life and the client, Labour Life only, Clear. */
.doc-pick {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2);
  margin: 0 0 var(--s3); padding: var(--s2) var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--red-wash);
}
.doc-pick[hidden] { display: none; }
.doc-pick__n { font-weight: 600; }
