/* upload.css - the upload steps, the filter pop-up and the shared document
   checklist (UI overhaul R3, track C; docs/spec-ui-overhaul-r3-build.md §3,
   C1-C3): AW.upload's and AW.filter's sheets and AW.checklist. Print rules:
   block "R3 C" of the page's print block (none are needed: the sheets live
   in #aw-overlays, which the print block hides).

   From the prototype's screens/upload.css and screens/filter.css
   (docs/ui-overhaul/prototype/src/css/screens/) with the aw- prefix. Colours
   are tokens only (static/ui/tokens.css; scripts/test_ui_tokens.py checks);
   radii, motion and stacking come from app.css. Referenced as
   /static/ui/upload.css?v=<CACHE_VERSION number>. */

/* ---------- the shared document checklist (AW.checklist, C1) ----------
   The filter pop-up and the Settings filter-group editor. A search field,
   the rows (at least 52 px high: a real checkbox under a drawn box, the
   title, the file name under it when it differs, the "Indexing" tag), a
   count line. The list's height follows the number of documents (the
   script sets --aw-ck-rows), never the number of search matches, so nothing
   jumps while typing; it scrolls inside from --aw-ck-max. */

.aw-ck { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.aw-ck-search {
  display: flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 14px;
  border: 1px solid var(--border-hi); border-radius: var(--r-ctl);
  background: var(--field); color: var(--muted);
}
.aw-ck-search:focus-within { border-color: var(--focus); }
.aw-ck-q {
  flex: 1; min-width: 0; height: 100%; margin: 0; padding: 0;
  border: 0; outline: 0; background: transparent;
  color: var(--text-hi); font-family: var(--sans); font-size: 16px;
  appearance: none; -webkit-appearance: none;
}
.aw-ck-q::placeholder { color: var(--muted); opacity: 1; }

.aw-ck-label { margin-top: 4px; }

.aw-ck-list {
  --aw-ck-rows: 4;
  height: min(calc(var(--aw-ck-rows) * 52px + 10px), var(--aw-ck-max, 364px));
  min-height: 114px; padding: 4px;
  border: 1px solid var(--border); border-radius: var(--r-block);
  background: var(--field);
  overflow-y: auto; overscroll-behavior: contain;
}
.aw-ck-list:focus { outline: none; }
.aw-ck-list:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.aw-ck-row {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 7px 10px;
  border-radius: var(--r-row); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* the real checkbox sits over the drawn box (it takes the tap, the keyboard
   and the screen reader); the whole row is its label */
.aw-ck-input {
  position: absolute; top: 50%; left: 10px; width: 22px; height: 22px; margin: -11px 0 0;
  opacity: 0; cursor: pointer;
}
.aw-ck-box {
  display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex: none;
  border: 1.5px solid var(--muted); border-radius: 6px;
  background: var(--surface); color: transparent;
}
.aw-ck-box .aw-ic { stroke-width: 2.6; }
.aw-ck-input:checked + .aw-ck-box { border-color: var(--amber-edge); background: var(--amber); color: var(--on-amber); }
.aw-ck-input:focus-visible + .aw-ck-box { outline: 2px solid var(--focus); outline-offset: 2px; }
.aw-ck-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.aw-ck-title { font-size: 15px; line-height: 21px; color: var(--text-hi); overflow-wrap: anywhere; }
.aw-ck-file { font-family: var(--mono); font-size: 12px; line-height: 17px; color: var(--muted); overflow-wrap: anywhere; }
.aw-ck-tag {
  display: inline-flex; align-items: center; flex: none;
  padding: 2px 8px;
  border: 1px solid var(--border-hi); border-radius: 8px;
  background: var(--raised); color: var(--text-dim);
  font-size: 12px; line-height: 18px; font-weight: 500; white-space: nowrap;
}
/* plan allowances part 3 (C17, D29): a document the library rule locks:
   not tickable, the word "Locked" and a lock in the box (never a colour
   alone) */
.aw-ck-locked { cursor: default; }
.aw-ck-locked .aw-ck-input { cursor: default; }
.aw-ck-locked .aw-ck-box { border-style: dashed; color: var(--muted); }
.aw-ck-locked .aw-ck-title { color: var(--text-dim); }
.aw-ck-none { margin: 0; padding: 18px 10px; font-size: 15px; line-height: 22px; color: var(--text-dim); }

.aw-ck-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.aw-ck-count { flex: 1; min-width: 0; margin: 0; font-size: 14px; line-height: 20px; color: var(--text-dim); }

/* the group editor in Settings: the checklist under its "Documents" label */
.aw-set-form .aw-ck-list { --aw-ck-max: min(364px, 45dvh); }

@media (hover: hover) {
  .aw-ck-row:hover:not(.aw-ck-locked) { background: var(--hover); }
}

/* ---------- the filter pop-up (AW.filter, C2) ----------
   An AW.ui sheet (size m): saved groups as pills, the checklist, "Clear
   all", the 50-document limit, the "modified" row, the footer. */

.aw-flt { display: flex; flex-direction: column; gap: 10px; }
.aw-flt-sheet .aw-ck-list { --aw-ck-max: min(364px, 42dvh); }
.aw-flt-wait { display: flex; align-items: center; gap: 10px; padding: 18px 2px; font-size: 15px; line-height: 22px; color: var(--text-dim); }
.aw-flt-empty { padding: 4px 0 8px; }
.aw-flt-fail { margin-bottom: 8px; }
.aw-flt-fail .aw-btn { margin-top: 8px; }

/* saved groups: a radio group drawn as pills */
.aw-flt-groups { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.aw-flt-chips { display: flex; flex-wrap: wrap; gap: 8px; max-height: 152px; padding: 2px; overflow-y: auto; overscroll-behavior: contain; }
.aw-flt-chip {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 100%; min-height: 44px; margin: 0; padding: 0 14px 0 12px;
  border: 1px solid var(--border-hi); border-radius: var(--r-round);
  background: var(--raised); color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 20px; font-weight: 500; text-align: left;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.aw-flt-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aw-flt-chip-n { font-size: 13px; font-weight: 400; color: var(--muted); }
.aw-flt-radio { position: relative; width: 16px; height: 16px; flex: none; border: 1.5px solid var(--muted); border-radius: 50%; }
.aw-flt-chip[aria-checked="true"] { border-color: var(--amber-line); background: var(--amber-tint); color: var(--text-hi); }
.aw-flt-chip[aria-checked="true"] .aw-flt-radio { border-color: var(--amber-text); }
.aw-flt-chip[aria-checked="true"] .aw-flt-radio::after {
  content: ""; position: absolute; inset: 2.5px; border-radius: 50%; background: var(--amber-text);
}
.aw-flt-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* "Clear all", beside the count line */
.aw-flt-text-btn {
  display: inline-flex; align-items: center; flex: none;
  min-height: 44px; margin: 0 -8px 0 0; padding: 0 8px;
  border: 0; border-radius: var(--r-ctl); background: transparent;
  color: var(--text-hi); font-family: var(--sans); font-size: 14px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.aw-flt-text-btn:disabled { color: var(--disabled); text-decoration: none; cursor: default; }
.aw-flt-text-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* a message in place (today a second pop-up): the 50-document limit, the
   group messages under the "modified" row, the name dialog's refusals */
.aw-flt-limit, .aw-flt-msg { margin: 0; }
.aw-flt-limit > .aw-ic, .aw-flt-msg > .aw-ic { margin-top: 2px; }

/* a loaded group whose ticks differ from what is saved */
.aw-flt-dirty {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--border-hi); border-radius: var(--r-block);
  background: var(--raised);
}
.aw-flt-dirty-text { flex: 1 1 150px; min-width: 0; margin: 0; font-size: 14px; line-height: 20px; color: var(--text-dim); overflow-wrap: anywhere; }
.aw-flt-dirty-text strong { font-weight: 600; color: var(--text-hi); }
.aw-flt-dirty-btns { display: flex; flex-wrap: wrap; gap: 8px; flex: none; }
.aw-flt-btn-s { padding: 0 14px; font-size: 14px; background: var(--surface); }

/* the footer: "Save as group" on its own row on a phone, at the left from
   700 px */
.aw-flt-foot { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; min-width: 0; }
.aw-flt-foot .aw-flt-foot-save { flex: 1 0 100%; }
.aw-flt-foot .aw-flt-foot-cancel { flex: 1 1 0; }
.aw-flt-foot .aw-flt-foot-apply { flex: 2 1 0; }
/* compact: while the "modified" row shows, its "Save as new" stands in for
   "Save as group" (map §3), so the list keeps its height */
@media (max-width: 699px) {
  .aw-flt-sheet.aw-flt-is-dirty .aw-flt-foot-save { display: none; }
}
@media (min-width: 700px) {
  .aw-flt-foot { flex-wrap: nowrap; }
  .aw-flt-foot .aw-flt-foot-save { flex: none; margin-right: auto; }
  .aw-flt-foot .aw-flt-foot-cancel { flex: none; min-width: 104px; }
  .aw-flt-foot .aw-flt-foot-apply { flex: none; min-width: 148px; }
}

/* the "Save filter group" sheet (size s) */
.aw-flt-name-field { margin-top: 14px; }
.aw-flt-name-field .aw-input[aria-invalid="true"] { border-color: var(--red); }
.aw-flt-name-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-height: 20px; }
.aw-flt-name-meta .aw-flt-msg { flex: 1; min-width: 0; }
.aw-flt-name-count { flex: none; margin-left: auto; font-size: 13px; line-height: 20px; color: var(--muted); }
.aw-flt-name-count.aw-flt-over { font-weight: 600; color: var(--red); }

@media (hover: hover) {
  .aw-flt-chip:hover:not([aria-checked="true"]) { background: var(--selected); }
  .aw-flt-text-btn:hover:not(:disabled) { background: var(--hover); }
}

/* ---------- the upload steps (AW.upload, C3) ----------
   An AW.ui sheet (size m): choose, review, progress, result. From the
   prototype's screens/upload.css with the aw- prefix; the messages are
   app.css's .aw-note. */

.aw-upl { display: flex; flex-direction: column; gap: 14px; }

/* "Step 1 of 2 · Choose file" */
.aw-upl-step { margin: 0; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--muted); }

.aw-upl-head { display: flex; flex-direction: column; gap: 4px; }
.aw-upl-h { margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; color: var(--text-hi); }
.aw-upl-h:focus { outline: none; }   /* focused by script so a screen reader starts here; not a control */
.aw-upl-p { margin: 0; font-size: 15px; line-height: 22px; color: var(--text-dim); overflow-wrap: anywhere; }
.aw-upl-p strong { font-weight: 600; color: var(--text-hi); }

/* step 1: the drop zone */
.aw-upl-zone {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 26px 16px 22px;
  border: 1.5px dashed var(--border-hi); border-radius: var(--r-block);
  background: var(--field); text-align: center;
}
.aw-upl-zone.aw-upl-drag { border-color: var(--amber-edge); background: var(--amber-tint); }
.aw-upl-zone-ic {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--raised); color: var(--text-dim);
}
.aw-upl-zone .aw-btn-primary { padding: 0 22px; }
.aw-upl-zone-line { font-size: 14px; line-height: 20px; color: var(--text-dim); }
.aw-upl-zone-max { font-size: 13px; line-height: 18px; color: var(--muted); }
/* the smaller zone under a batch's picked files */
.aw-upl-more { flex-direction: row; flex-wrap: wrap; justify-content: space-between; padding: 8px 14px 8px 8px; text-align: left; }
.aw-upl-more .aw-btn { padding: 0 16px 0 12px; background: var(--surface); }
.aw-upl-more-count { font-size: 14px; line-height: 20px; color: var(--text-dim); }
.aw-upl-more-count:first-child { padding: 12px 6px; }

/* the picked files */
.aw-upl-files { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.aw-upl-file {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--border-hi); border-radius: var(--r-block);
  background: var(--surface); box-shadow: var(--shadow-card);
}
.aw-upl-file-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.aw-upl-file-name { font-size: 15px; line-height: 21px; font-weight: 500; color: var(--text-hi); overflow-wrap: anywhere; }
.aw-upl-file-meta { font-size: 13px; line-height: 18px; color: var(--muted); }
.aw-upl-remove { padding: 0 14px; }

/* a message in the step (today a second pop-up) */
.aw-upl-note .aw-upl-h { font-size: 15px; line-height: 22px; }
.aw-upl-note .aw-note-text { margin: 0; }
.aw-upl-note-list { display: flex; flex-direction: column; gap: 4px; margin: 0; padding-left: 18px; font-size: 14px; line-height: 20px; color: var(--text-dim); overflow-wrap: anywhere; }
.aw-upl-note-btn { margin-top: 6px; background: var(--surface); }

/* step 2: review */
.aw-upl-summary { margin: 0; border: 1px solid var(--border); border-radius: var(--r-block); overflow: hidden; }
.aw-upl-sum-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; padding: 11px 14px; }
.aw-upl-sum-row + .aw-upl-sum-row { border-top: 1px solid var(--border); }
.aw-upl-sum-row dt { font-size: 13px; line-height: 21px; color: var(--muted); }
.aw-upl-sum-row dd { margin: 0; font-size: 15px; line-height: 21px; color: var(--text); overflow-wrap: anywhere; }
.aw-upl-sum-total { background: var(--raised); }
.aw-upl-sum-total dd { font-weight: 600; color: var(--text-hi); }

/* progress: one row per file with its own bar */
.aw-upl-rows { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }
.aw-upl-row { display: flex; flex-direction: column; gap: 6px; }
.aw-upl-row-name { font-size: 15px; line-height: 21px; font-weight: 500; color: var(--text-hi); overflow-wrap: anywhere; }
.aw-upl-bar {
  display: block; height: 8px;
  border: 1px solid var(--border-hi); border-radius: 4px;
  background: var(--raised); overflow: hidden;
}
/* --amber-text, not the prototype's --amber: the light theme's --amber is
   1.9:1 on the track and a mark needs 3:1; in the dark theme the two are
   the same colour */
.aw-upl-fill { display: block; height: 100%; background: var(--amber-text); transition: width 120ms linear; }
.aw-upl-row-text { font-size: 14px; line-height: 20px; color: var(--text-dim); overflow-wrap: anywhere; }
.aw-upl-row[data-state="processing"] .aw-upl-fill { animation: aw-upl-pulse 1.1s ease-in-out infinite; }
@keyframes aw-upl-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.aw-upl-row[data-state="queued"] .aw-upl-fill { background: var(--green); }
.aw-upl-row[data-state="duplicate"] .aw-upl-fill, .aw-upl-row[data-state="cancelled"] .aw-upl-fill { background: var(--muted); }
.aw-upl-row[data-state="rejected"] .aw-upl-fill, .aw-upl-row[data-state="failed"] .aw-upl-fill { background: var(--red); }
.aw-upl-row[data-state="rejected"] .aw-upl-row-text, .aw-upl-row[data-state="failed"] .aw-upl-row-text { color: var(--red); }

/* result */
.aw-upl-res-head { display: flex; align-items: flex-start; gap: 10px; }
.aw-upl-res-ok > .aw-ic { color: var(--green); }
.aw-upl-res-bad > .aw-ic { color: var(--red); }
.aw-upl-res-info > .aw-ic { color: var(--text-dim); }
.aw-upl-err {
  padding: 10px 14px;
  border: 1px solid var(--red-line); border-radius: var(--r-ctl);
  background: var(--red-bg); color: var(--text);
  font-size: 14px; line-height: 20px; overflow-wrap: anywhere;
}
.aw-upl-when { margin: 0; font-size: 13px; line-height: 18px; color: var(--muted); }
.aw-upl-counts { margin: 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text-dim); }
.aw-upl-res-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.aw-upl-res-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.aw-upl-res-item .aw-upl-row-text { font-size: 13px; line-height: 18px; }
.aw-upl-res-item[data-state="queued"] .aw-upl-row-text { color: var(--green); }
.aw-upl-res-item[data-state="rejected"] .aw-upl-row-text, .aw-upl-res-item[data-state="failed"] .aw-upl-row-text { color: var(--red); }

/* "Typical indexing times" */
.aw-upl-times {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px 14px;
  border: 1px solid var(--border); border-radius: var(--r-block);
  background: var(--field);
}
.aw-upl-times-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; margin: 0; font-size: 14px; line-height: 20px; }
.aw-upl-times-grid dt { color: var(--text-dim); }
.aw-upl-times-grid dd { margin: 0; color: var(--text-hi); text-align: right; white-space: nowrap; }
.aw-upl-times-note { margin: 0; font-size: 13px; line-height: 18px; color: var(--muted); }

/* the footer keeps its buttons in one row; a lone button fills it */
.aw-upl-sheet .aw-ov-foot .aw-btn { min-width: 0; }

@media (hover: hover) {
  .aw-upl-more .aw-btn:hover { background: var(--hover); }
}
