/* The File Processor workspace.
 *
 * Three columns: what you have loaded, what you are looking at, what you
 * can do to it. The old client was a sidebar of tools where each one owned
 * its own file picker and its own result, so joining two PDFs and then
 * compressing the result meant downloading it and uploading it again. Here
 * the document stays put and the tools come to it.
 */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.ws {
  display: grid;
  flex: 1 0 auto;
  grid-template-columns: 232px minmax(0, 1fr) 332px;

  /* The workspace gets a whole screen, and the footer goes below the fold.
   *
   * With only `flex: 1` the three columns shared the viewport with the
   * site footer, which is four columns of links and 305px tall: on a
   * 950px screen that left 581px for the document you are actually
   * working on, and the footer sat there competing with it the whole
   * time. A footer belongs under the work, not beside it.
   *
   * 64px is the top bar at its usual height. It wraps taller on a narrow
   * window, which costs a little scroll rather than clipping anything,
   * and `flex: 1 0 auto` still lets the workspace grow past this when a
   * document has many pages. */
  min-height: calc(100vh - 64px);
}

/* ---- Left: the documents ------------------------------------------------
 *
 * Neutral, matching .ws-panel on the other side. This column used to be
 * painted --pf-bar, so the workspace had a slab of brand green down the
 * left of every document anybody opened, and the left and right rails
 * of the same screen did not look like the same kind of thing. Green is
 * for the chrome: the bar at the top and the footer at the bottom.
 */

.ws-files {
  background: var(--pf-card);
  border-right: 1px solid var(--pf-line);
  color: var(--pf-ink);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 16px 14px;
}

.ws-files h2 {
  color: var(--pf-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.ws-add {
  align-items: center;
  background: var(--pf-surface);
  border: 1px dashed var(--pf-line);
  border-radius: 10px;
  color: var(--pf-ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  padding: 16px 10px;
  text-align: center;
}

.ws-add:hover,
.ws-add.is-dragging {
  background: var(--pf-tint);
  border-color: var(--pf-primary);
}

.ws-add input {
  display: none;
}

.ws-add small {
  color: var(--pf-muted);
  font-weight: 400;
}

.ws-doc {
  background: var(--pf-surface);
  border: 1.5px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  grid-template-columns: 38px minmax(0, 1fr);
  padding: 8px;
  text-align: left;
  width: 100%;
}

.ws-doc:hover {
  background: var(--pf-tint);
}

.ws-doc.is-active {
  background: var(--pf-tint);
  border-color: var(--pf-primary);
}

.ws-doc img {
  background: var(--pf-surface);
  border-radius: 4px;
  display: block;
  height: 50px;
  object-fit: cover;
  object-position: top;
  width: 38px;
}

.ws-doc-name {
  color: var(--pf-ink);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-doc-meta {
  color: var(--pf-muted);
  font-size: 11.5px;
}

.ws-doc-tools {
  display: flex;
  gap: 3px;
  margin-top: 3px;
}

.ws-mini {
  background: transparent;
  border: 1px solid var(--pf-line);
  border-radius: 5px;
  color: var(--pf-muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
}

.ws-mini:hover:not(:disabled) {
  background: var(--pf-tint);
  color: var(--pf-ink);
}

.ws-mini:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

/* ---- Centre: the pages -------------------------------------------------- */

.ws-stage {
  background: var(--pf-surface);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ws-stage-bar {
  align-items: center;
  background: var(--pf-card);
  border-bottom: 1px solid var(--pf-line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 16px;
}

.ws-stage-title {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-stage-sub {
  color: var(--pf-muted);
  font-size: 12.5px;
}

.ws-stage-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

/* One page per row, down a single column.
 *
 * This was a grid of thumbnails several to a row, which is wrong for a
 * document: a document is read downwards, and tiling it turns reading into
 * scanning while making the page order something you have to work out from
 * the numbers. Capped at a comfortable reading width rather than stretched
 * to whatever the window is. */
.ws-pages {
  align-items: center;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 20px 18px 40px;
}

.ws-empty {
  align-items: center;
  color: var(--pf-muted);
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  padding: 40px;
  text-align: center;
}

.ws-empty strong {
  color: var(--pf-ink);
  font-size: 17px;
}

.ws-page {
  background: var(--pf-card);
  border: 2px solid var(--pf-line);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(16, 43, 23, 0.08);
  cursor: pointer;
  flex: none;
  padding: 0;
  position: relative;
  width: min(100%, 680px);
}

.ws-page img {
  border-radius: 6px;
  display: block;
  width: 100%;
}

.ws-page.is-pickable {
  cursor: pointer;
}

.ws-page.is-pickable:hover {
  border-color: var(--pf-primary);
}

.ws-page.is-picked {
  border-color: var(--pf-primary);
  box-shadow: 0 0 0 3px var(--pf-tint-line);
}

/* Removal is destructive, so a page marked for it is marked in the colour
   the rest of the interface uses for danger, not in the brand green. */
.ws-page.is-picked.is-danger {
  border-color: var(--pf-danger);
  box-shadow: 0 0 0 3px var(--pf-danger-soft);
}

.ws-page-no {
  background: var(--pf-bar);
  border-radius: 999px;
  bottom: 8px;
  color: var(--pf-on-bar);
  font-size: 11px;
  font-weight: 700;
  left: 8px;
  padding: 2px 8px;
  position: absolute;
}

.ws-page-tick {
  align-items: center;
  background: var(--pf-card);
  border: 2px solid var(--pf-line);
  border-radius: 6px;
  display: flex;
  height: 24px;
  justify-content: center;
  position: absolute;
  right: 8px;
  top: 8px;
  width: 24px;
}

.ws-page.is-picked .ws-page-tick {
  background: var(--pf-primary);
  border-color: var(--pf-primary);
  color: var(--pf-on-primary);
}

.ws-page.is-picked.is-danger .ws-page-tick {
  background: var(--pf-danger);
  border-color: var(--pf-danger);
}

/* ---- Right: the processor ---------------------------------------------- */

.ws-panel {
  background: var(--pf-card);
  border-left: 1px solid var(--pf-line);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 16px;
}

.ws-panel h2 {
  font-size: 16px;
  margin: 0;
}

.ws-panel-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

/* The title takes the slack, so the back chevron stays pinned to the
   left of it and the drafts chip to the right edge. */
.ws-panel-head #panelTitle {
  flex: 1 1 auto;
  min-width: 0;
}

.ws-tools {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.ws-tool {
  align-items: center;
  background: var(--pf-card);
  /* Explicit, because a <button> with no colour inherits the browser's
     own near-black, which on the dark card measured 1.13:1. It looked
     fine in light mode purely by accident. */
  color: var(--pf-ink);
  border: 1px solid var(--pf-line);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 8px;
  text-align: center;
}

.ws-tool:hover:not(:disabled) {
  background: var(--pf-tint);
  border-color: var(--pf-primary);
}

.ws-tool:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.ws-tool span:last-child {
  font-size: 12.5px;
  font-weight: 650;
}

.ws-tool svg {
  color: var(--pf-primary);
  height: 21px;
  width: 21px;
}

.ws-hint {
  background: var(--pf-surface);
  border-radius: 8px;
  color: var(--pf-muted);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 10px 12px;
}

.ws-field {
  display: grid;
  gap: 4px;
}

.ws-field > span {
  font-size: 12px;
  font-weight: 700;
}

.ws-field select {
  border: 1px solid var(--pf-line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 10px;
}

/* ---- The chain ---------------------------------------------------------- */

.ws-chain {
  display: grid;
  gap: 4px;
}

.ws-chain-step {
  align-items: center;
  color: var(--pf-muted);
  display: flex;
  font-size: 12px;
  gap: 6px;
}

.ws-chain-step b {
  color: var(--pf-link);
}

/* ---- The result --------------------------------------------------------- */

.ws-result {
  background: var(--pf-tint);
  border: 1px solid var(--pf-tint-line);
  border-radius: 12px;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.ws-result-name {
  font-size: 13.5px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.ws-result-meta {
  color: var(--pf-muted);
  font-size: 12.5px;
}

.ws-result .primary-btn,
.ws-result .secondary-btn,
.ws-result .primary-link {
  justify-content: center;
  width: 100%;
}

.ws-busy {
  align-items: center;
  color: var(--pf-muted);
  display: flex;
  font-size: 13px;
  gap: 10px;
  justify-content: center;
  padding: 18px 0;
}

.ws-busy .spinner {
  height: 20px;
  margin: 0;
  width: 20px;
}

/* ---- Narrow screens ----------------------------------------------------- */

@media (max-width: 1100px) {
  .ws {
    grid-template-columns: 196px minmax(0, 1fr) 290px;
  }
}

@media (max-width: 920px) {
  /* One column, in the order you work: what you loaded, what you are
     doing, then the pages you are doing it to. */
  .ws {
    grid-template-columns: 1fr;
  }

  .ws-files {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
    overflow: visible;
  }

  .ws-files h2 {
    width: 100%;
  }

  .ws-doc {
    width: auto;
    min-width: 170px;
  }

  .ws-panel {
    border-left: 0;
    border-top: 1px solid var(--pf-line);
    order: 3;
  }

  .ws-stage {
    order: 4;
  }
}

/* ---- Jobs ---------------------------------------------------------------
 *
 * The workspace used to be a single draft under a fixed id, so starting
 * anything new wrote over whatever was open. Each job now has its own
 * draft and its own tab, and the strip stays hidden until there is
 * actually something to switch between: one tab is furniture.
 */

.ws-jobs {
  align-items: center;
  background: var(--pf-surface);
  border-bottom: 1px solid var(--pf-line);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 16px;
}

.ws-job-tab,
.ws-job-new {
  align-items: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--pf-muted);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 13px;
  gap: 7px;
  max-width: 230px;
  min-height: 34px;
  padding: 0 11px;
}

.ws-job-tab:hover,
.ws-job-new:hover {
  background: var(--pf-card);
  color: var(--pf-ink);
}

.ws-job-tab.is-on {
  background: var(--pf-card);
  border-color: var(--pf-line-strong);
  color: var(--pf-ink);
  font-weight: 600;
}

.ws-job-no {
  background: var(--pf-tint);
  border-radius: 5px;
  color: var(--pf-primary);
  flex: none;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 5px;
}

.ws-job-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-job-new {
  color: var(--pf-primary);
  font-weight: 600;
}

.ws-job-new svg {
  height: 15px;
  width: 15px;
}

/* ---- Saving, discarding ------------------------------------------------
 *
 * Always on screen while a document is loaded, rather than only on the
 * result card. The card held the only download link, so continuing from
 * a result removed the one way to get the file out.
 */

.ws-job-actions {
  align-items: center;
  background: var(--pf-surface);
  border-bottom: 1px solid var(--pf-line);
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px 16px;
}

.ws-job-status {
  color: var(--pf-muted);
  font-size: 13px;
  margin-left: auto;
}

.ws-job-status.is-error {
  color: var(--pf-warn);
}

@media (max-width: 900px) {
  .ws-job-status {
    flex-basis: 100%;
    margin-left: 0;
  }
}

/* The result is already on the stage by the time this shows, so the
   card says so rather than implying the download is the only copy. */
.ws-result-live {
  align-items: flex-start;
  background: var(--pf-tint);
  border: 1px solid var(--pf-tint-line);
  border-radius: 9px;
  color: var(--pf-ink);
  display: flex;
  font-size: 13px;
  gap: 8px;
  line-height: 1.5;
  margin: 10px 0 2px;
  padding: 9px 11px;
}

.ws-result-live svg {
  color: var(--pf-primary);
  flex: none;
  height: 16px;
  margin-top: 2px;
  width: 16px;
}
