/* Styling that belongs to the hand-written additions, shared by index.html
   (grafted onto the React bundle) and settings.html (a standalone page).
   Not build output - a frontend rebuild overwrites index.html but leaves this
   file alone, so the link tag has to be re-added there afterwards. */

/* ---------------------------------------------------------------- dark mode
   The app's own CSS is almost entirely var()-driven - including the inline
   styles the code-block nodes carry - so redefining the palette themes most of
   it. What follows the palette are the places that hardcode a colour: the
   badges, and React Flow's built-in node/handle/control styling.

   One class rather than a media query, because the choice has three states
   (follow the system, force light, force dark). ascioflow-theme.js decides and
   sets the class before first paint. */
.ascioflow-dark {
  --bg: #14141b;
  --surface: #1e1e29;
  --border: #32323f;
  --text: #e9e9f2;
  --text-dim: #a2a2b4;
  --accent: #8b83f7;
  --accent-dim: #272348;
  --danger: #f4736f;
  color-scheme: dark;
}
/* .btn puts white on the accent, which is too pale once the accent is
   brightened for a dark background; dark text on it reads far better. Not
   .secondary though - that one is text on a dark surface, where dark text
   would disappear. */
.ascioflow-dark .btn:not(.secondary),
.ascioflow-dark .backoffice-nav .links a.taskflow-current { color: #14141b; }
.ascioflow-dark .badge.done { background: #14331f; color: #63d394; }
.ascioflow-dark .step-dot.done { background: #63d394; }
.ascioflow-dark .badge.error,
.ascioflow-dark .badge.done.taskflow-cancelled { background: #3a1d1f; color: var(--danger); }
.ascioflow-dark .modal-overlay { background: rgba(0, 0, 0, 0.55); }

/* React Flow's built-in styling for the Start/Afgerond/Geannuleerd nodes and
   the canvas furniture; the code-block nodes already follow the variables. */
.ascioflow-dark .react-flow__node-default,
.ascioflow-dark .react-flow__node-input,
.ascioflow-dark .react-flow__node-output,
.ascioflow-dark .react-flow__node-group {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.ascioflow-dark .react-flow__handle { background: var(--text-dim); border-color: var(--surface); }
.ascioflow-dark .react-flow__edge-textbg { fill: var(--surface); }
.ascioflow-dark .react-flow__edge-text { fill: var(--text); }
.ascioflow-dark .react-flow__controls-button {
  background: var(--surface);
  border-bottom-color: var(--border);
  fill: var(--text);
}
.ascioflow-dark .react-flow__controls-button:hover { background: var(--bg); }
.ascioflow-dark .react-flow__controls-button svg { fill: var(--text); }
.ascioflow-dark .react-flow__attribution { background: rgba(0, 0, 0, 0.4); }
.ascioflow-dark .react-flow__attribution a { color: var(--text-dim); }

/* The outcome colours need more punch against a dark canvas. */
.ascioflow-dark .react-flow__edge.taskflow-edge-ok .react-flow__edge-path { stroke: #63d394; }
.ascioflow-dark .react-flow__edge.taskflow-edge-ok .react-flow__edge-text { fill: #63d394; }
.ascioflow-dark .react-flow__edge.selected .react-flow__edge-path { stroke: var(--text); }

/* The nameserver field grafted into the "Add task" modal. */
.ascioflow-ns { margin: 0 0 1rem; }
.ascioflow-ns > label { font-size: 0.85rem; font-weight: 600; color: var(--text-dim); }
.ascioflow-ns-note { font-size: 0.8rem; color: var(--text-dim); margin: 0.15rem 0 0.5rem; }
.ascioflow-ns-set { width: 100%; box-sizing: border-box; padding: 0.5rem 0.7rem;
                    border: 1px solid var(--border); border-radius: 8px; font: inherit;
                    background: var(--surface); color: var(--text); margin-bottom: 0.5rem; }
.ascioflow-ns-hosts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.ascioflow-ns-hosts input {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}

/* The owner contact block, next to the nameserver field in "Add task". */
.ascioflow-owner { margin: 0 0 1rem; }
.ascioflow-owner > label { font-size: 0.85rem; font-weight: 600; color: var(--text-dim); }
.ascioflow-owner-text {
  width: 100%;
  box-sizing: border-box;
  min-height: 8.5rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  /* Tabs are the point here, so keep them a sane width and don't wrap them
     away. */
  tab-size: 18;
  white-space: pre;
  overflow-x: auto;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.ascioflow-owner-preview { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.4rem; }
.ascioflow-owner-preview.warn { color: var(--danger); }

/* A code block's result, built by renderStepResults() on its own line under the
   step: the result code in a block of its own, the message beside it. Monospace
   because it is machine output; the muted accent the bundle used was nearly
   invisible in dark mode. */
.ascioflow-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.ascioflow-result-code {
  flex: none;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.02em;
}
.ascioflow-result-text {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  word-break: break-word;
  color: var(--text);
}
.ascioflow-result-ok .ascioflow-result-code {
  background: #dff3e7;
  border-color: #a8dcc2;
  color: #0c5f43;
}
.ascioflow-result-bad .ascioflow-result-code {
  background: #fbe3e1;
  border-color: #f2bdb9;
  color: #91201b;
}
/* .step-item.done dims the whole row to 0.6, which is exactly the thing that
   made this unreadable. Keep the result at full strength. */
.step-item.done { opacity: 1; }
.step-item.done > div > strong,
.step-item.done > div > .meta { opacity: 0.65; }

.ascioflow-dark .ascioflow-result-ok .ascioflow-result-code {
  background: #10301f;
  border-color: #2a7049;
  color: #86e8b1;
}
.ascioflow-result-info .ascioflow-result-code {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}
.ascioflow-dark .ascioflow-result-bad .ascioflow-result-code {
  background: #3a1a1c;
  border-color: #7d3130;
  color: #ffa6a1;
}

/* The archive control on a task card. The card is a link, so the control is a
   span with a button role sitting on top of it, and its click never reaches the
   link. */
.card-list a.name-card.ascioflow-archivable { position: relative; }
.ascioflow-archive {
  position: absolute;
  top: 50%;
  right: 0.85rem;
  transform: translateY(-50%);
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.3;
  cursor: pointer;
  user-select: none;
}
.ascioflow-archive:hover { color: var(--text); border-color: var(--text-dim); }
.ascioflow-archive:focus-visible { outline: 2px solid var(--accent, #5b5bd6); outline-offset: 1px; }
.ascioflow-archive[aria-disabled="true"] { opacity: 0.5; cursor: default; }
/* The badge sits at the right edge of the card; make room for the control. */
.card-list a.name-card.ascioflow-archivable .badge { margin-right: 4.8rem; }

/* The owner contact of a task, editable under its timeline. */
.ascioflow-owner-edit {
  margin: 1.5rem 0 2rem;
  padding: 1rem 1.15rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.ascioflow-owner-edit > h2 { margin: 0; font-size: 1.05rem; }
.ascioflow-owner-note { font-size: 0.8rem; color: var(--text-dim); margin: 0.35rem 0 0.75rem; }
.ascioflow-owner-problems {
  margin: 0 0 0.85rem;
  padding: 0.5rem 0.7rem 0.5rem 1.6rem;
  border: 1px solid var(--danger);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--danger);
}
.ascioflow-owner-line {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr) 10rem;
  gap: 0.6rem;
  align-items: center;
  padding: 0.15rem 0;
}
.ascioflow-owner-label {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.76rem;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}
.ascioflow-owner-value {
  width: 100%;
  box-sizing: border-box;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.82rem;
}
.ascioflow-owner-field {
  font-size: 0.74rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The line feeding a field Ascio complained about. */
.ascioflow-owner-line.blamed .ascioflow-owner-value { border-color: var(--danger); }
.ascioflow-owner-line.blamed .ascioflow-owner-field { color: var(--danger); }
.ascioflow-owner-resolved {
  margin-top: 0.7rem;
  font-size: 0.76rem;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}
.ascioflow-owner-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
}
.ascioflow-owner-status { font-size: 0.78rem; color: var(--text-dim); }
.ascioflow-owner-status.ok { color: #0f6b4d; }
.ascioflow-owner-status.warn { color: var(--danger); }
.ascioflow-dark .ascioflow-owner-status.ok { color: #79e0a8; }

/* When a task was finished: under its name in a list, beside the badge on its
   own page. */
.ascioflow-when {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}
.page-header > .ascioflow-when { margin: 0 0 0 0.15rem; align-self: center; }
/* A task counting down reads as pending work, not as something finished. */
.ascioflow-when.waiting { color: var(--text); }

/* What a code block answered, folded away under its step on a task. */
.ascioflow-answer {
  margin-top: 0.4rem;
  font-size: 0.78rem;
}
.ascioflow-answer > summary {
  cursor: pointer;
  color: var(--text-dim);
  padding: 0.1rem 0;
  width: fit-content;
}
.ascioflow-answer > summary:hover { color: var(--text); }
.ascioflow-answer-rows {
  margin-top: 0.35rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  max-height: 22rem;
  overflow-y: auto;
}
.ascioflow-answer-row {
  display: grid;
  grid-template-columns: minmax(10rem, 22rem) 1fr;
  gap: 0.6rem;
  padding: 0.12rem 0;
  align-items: baseline;
}
/* The path is the same text the parameter dropdown in the type editor uses, so
   it is selectable rather than decorative. */
.ascioflow-answer-path {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}
.ascioflow-answer-value {
  color: var(--text);
  overflow-wrap: anywhere;
}
/* .step-item.done dims its whole contents; the answer has to stay readable. */
.step-item.done .ascioflow-answer,
.step-item.done .ascioflow-answer-value { opacity: 1; }

/* The parameter panel under the canvas in the type editor
   (ascioflow-node-params.js). Full width, because a row is a checkbox, a name,
   two dropdowns and a type hint. */
.ascioflow-np {
  max-width: 1280px;
  margin: 1.25rem auto 2.5rem;
  padding: 1rem 1.15rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.ascioflow-np-head h2 { margin: 0; font-size: 1.05rem; }
.ascioflow-np-note { font-size: 0.8rem; color: var(--text-dim); margin: 0.35rem 0 0.75rem; }
.ascioflow-np-unsaved { color: var(--danger); }
.ascioflow-np-picker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.ascioflow-np-picker label { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.ascioflow-np-node { min-width: 20rem; }
.ascioflow-np-name-box { min-width: 14rem; }
.ascioflow-np-picker label { white-space: nowrap; }
.ascioflow-np select,
.ascioflow-np input[type="text"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  box-sizing: border-box;
}
.ascioflow-np-body { max-height: 26rem; overflow-y: auto; padding-right: 0.25rem; }
/* Sends on the left, shown-on-the-task on the right; stacked when there is no
   room for two. */
/* The left column carries the value boxes, the right one a list of tick boxes,
   so the room goes to the left. */
.ascioflow-np-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr);
  gap: 1.5rem;
}
@media (max-width: 1100px) {
  .ascioflow-np-columns { grid-template-columns: minmax(0, 1fr); }
}
.ascioflow-np-column > h3 {
  margin: 0 0 0.3rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.ascioflow-np-shown-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.ascioflow-np-search { flex: 1 1 auto; min-width: 6rem; }
.ascioflow-np-count { font-size: 0.74rem; color: var(--text-dim); white-space: nowrap; }
.ascioflow-np-shown-list { display: block; }
.ascioflow-np-shown {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.1rem 0;
  cursor: pointer;
}
.ascioflow-np-shown input { width: auto; margin: 0; }
.ascioflow-np-shown code {
  font-size: 0.72rem;
  color: var(--text);
  overflow-wrap: anywhere;
}
/* The value box used to compete with a fixed 9rem column for the type hint, and
   in a panel this wide there was nothing left of it. The hint now sits on its own
   line under the row, where a sentence like "30m, 2h, 1d, or a date" is readable
   anyway, and the value gets a real minimum width. */
.ascioflow-np-row {
  display: grid;
  grid-template-columns: auto minmax(7rem, 11rem) minmax(9rem, 13rem) minmax(12rem, 1fr);
  gap: 0.4rem 0.5rem;
  align-items: center;
  padding: 0.3rem 0;
  opacity: 0.6;
}
/* An unticked parameter is not sent, so it reads as switched off until it is. */
.ascioflow-np-row.on { opacity: 1; }
.ascioflow-np-on { width: auto; margin: 0; }
.ascioflow-np-name {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}
.ascioflow-np-detail { display: block; min-width: 0; }
.ascioflow-np-detail > * { width: 100%; min-width: 0; }
.ascioflow-np-type {
  grid-column: 2 / -1;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: -0.1rem;
  overflow-wrap: anywhere;
}
/* A parameter that is switched off does not need its explanation taking up room. */
.ascioflow-np-row:not(.on) .ascioflow-np-type { display: none; }

/* Extra sources under a parameter, tried in order when the first has nothing. */
.ascioflow-np-alts { grid-column: 2 / -1; }
.ascioflow-np-alt-lines { display: block; }
.ascioflow-np-alt {
  display: grid;
  grid-template-columns: 4.2rem minmax(9rem, 13rem) minmax(12rem, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.15rem 0;
}
.ascioflow-np-or { font-size: 0.74rem; color: var(--text-dim); text-align: right; }
.ascioflow-np-add-or,
.ascioflow-np-drop {
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  padding: 0 0.2rem;
}
.ascioflow-np-add-or:hover,
.ascioflow-np-drop:hover { color: var(--text); }
.ascioflow-np-drop { font-size: 0.9rem; line-height: 1; }
/* Nothing to add a fallback to while the parameter itself is off. */
.ascioflow-np-row:not(.on) .ascioflow-np-add-or { visibility: hidden; }
.ascioflow-np-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
}
.ascioflow-np-newname { min-width: 16rem; }
.ascioflow-np-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.ascioflow-np-status { font-size: 0.78rem; color: var(--text-dim); }
.ascioflow-np-status.ok { color: #0f6b4d; }
.ascioflow-np-status.warn { color: var(--danger); }
.ascioflow-dark .ascioflow-np-status.ok { color: #79e0a8; }

/* The toggle itself, sitting in the nav or the page header. */
.ascioflow-theme-toggle {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}
.ascioflow-theme-toggle:hover { border-color: var(--accent); }

/* Connections in the type editor, coloured by the outcome they carry. React
   Flow has no way to select on a label, so markCodedEdges() tags the <g>. */
.react-flow__edge.taskflow-edge-ok .react-flow__edge-path { stroke: #12805c; stroke-width: 2; }
.react-flow__edge.taskflow-edge-ok .react-flow__edge-text { fill: #12805c; font-weight: 600; }
.react-flow__edge.taskflow-edge-bad .react-flow__edge-path { stroke: var(--danger); stroke-width: 2; }
.react-flow__edge.taskflow-edge-bad .react-flow__edge-text { fill: var(--danger); font-weight: 600; }
/* Re-stated after the two above so clicking a connection still shows it is
   selected - that is how you label or delete one. */
.react-flow__edge.selected .react-flow__edge-path { stroke: #555; stroke-width: 2; }

/* Only the picker modal, tagged by the script below: the plain .modal has
   no height limit, so a long code block list runs off both ends of the
   screen with nothing to scroll. */
.modal.taskflow-picker {
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  max-width: 520px;
}
.modal.taskflow-picker .card-list {
  overflow-y: auto;
  gap: 0.4rem;
  padding-right: 0.25rem;
}
.modal.taskflow-picker .name-card { padding: 0.6rem 0.85rem; }
.modal.taskflow-picker .name-card .meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 26rem;
}
.taskflow-filter {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.7rem;
  margin: 0.25rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
.taskflow-count {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0 0 0.5rem;
}
.taskflow-empty { font-size: 0.9rem; color: var(--text-dim); padding: 0.5rem 0; }

/* Backoffice nav as pills instead of bare links, with the current page
   marked - react-router renders plain Links here, so nothing indicated
   where you were. */
.backoffice-nav { flex-wrap: wrap; gap: 0.75rem; }
.backoffice-nav .links { gap: 0.35rem; flex-wrap: wrap; }
.backoffice-nav .links strong {
  margin-right: 0.6rem;
  padding-right: 0.85rem;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.backoffice-nav .links a {
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.backoffice-nav .links a:hover {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}
.backoffice-nav .links a.taskflow-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.backoffice-nav .links a.taskflow-current:hover { color: #fff; opacity: 0.92; }

/* A cancelled task is finished, so the API reports status "done" and the
   badge comes out green. Three classes, so this beats .badge.done. */
.badge.done.taskflow-cancelled {
  background: #fce8e8;
  color: var(--danger);
}

/* Tabs over the front page task list. */
.taskflow-tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--border);
}
.taskflow-tabs button {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.9rem;
  margin-bottom: -1px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 0;
}
.taskflow-tabs button:hover { color: var(--text); }
.taskflow-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
