/* ekte web UI v2 — form field components: model picker + secret key field.
 *
 * Link after ekte.css on pages that use them:
 *   <link rel="stylesheet" href="/static/fields.css" />
 * The model picker is built by relaycfg.js with the .zmp classes below.
 * Colours only through the ekte.css tokens, so light and dark both work.
 */

/* ---------- model picker (built by relaycfg.js) ---------- */
.zmp { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.zmp-sels { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.zmp .zmp-sel {
  width: 100%; min-width: 0; max-width: 100%; cursor: pointer;
  border: 1.5px solid var(--border); background-color: var(--surface); color: var(--ink);
  border-radius: var(--r-sm); font-family: var(--sans); font-weight: 500; font-size: var(--t-md);
  padding: 12px 36px 12px 14px; outline: none;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: right 19px center, right 14px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background-color var(--dur-fast), color var(--dur-fast);
}
.zmp .zmp-sel:hover:not(:disabled) { border-color: var(--ink-muted); }
.zmp .zmp-sel:focus,
.zmp .zmp-sel:focus-visible {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-tint); background-color: var(--surface);
}
/* placeholder ("Select provider…") reads as unfilled, like an input placeholder */
.zmp .zmp-sel.is-empty { color: var(--ink-muted); font-weight: 400; font-style: italic; }
.zmp .zmp-sel option { color: var(--ink); background: var(--surface); font-style: normal; font-weight: 500; }
.zmp .zmp-sel option[value=""] { color: var(--ink-muted); }
/* disabled (no provider chosen yet): dashed, flat, no chevron */
.zmp .zmp-sel:disabled {
  cursor: not-allowed; border-style: dashed; border-color: var(--line);
  background-color: var(--sunken); background-image: none; color: var(--ink-muted);
}

/* "Custom (from relay)": fetch button + status line */
.zmp-fetch { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; min-width: 0; }
.zmp-fetch-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.zmp-status { font-size: var(--t-sm); line-height: 1.45; color: var(--ink-muted); overflow-wrap: anywhere; min-width: 0; }
.zmp-status.is-ok { color: var(--success); }
.zmp-status.is-warn { color: var(--warning); }
.zmp-status.is-error { color: var(--danger); }

/* the free-text input (moved inside .zmp) and the mode toggle */
.zmp > input { min-width: 0; }
.zmp-custom {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 2px; margin: -1px 0 0; border-radius: var(--r-xs); line-height: 1.3;
}
.zmp-custom:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; text-decoration: underline; }

/* ---------- secret key field (/secretfield.js) ---------- */
.zsf { min-width: 0; }
.zsf > input { min-width: 0; }
.zsf .zsf-toggle {
  --zsf-color: var(--ink-muted);
  --zsf-color-on: var(--ink);
  --zsf-focus: var(--primary);
  width: 38px; height: 34px; right: 5px; border-radius: var(--r-sm);
  transition: color var(--dur-fast), background-color var(--dur-fast);
}
.zsf .zsf-toggle:hover { background-color: var(--sunken); }
.zsf .zsf-toggle[aria-pressed="true"] { color: var(--primary); }
.zsf .zsf-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; box-shadow: 0 0 0 3px var(--primary-tint); }
.zsf .zsf-toggle svg,
.zsf .zsf-toggle .zicon { width: 18px; height: 18px; }

/* ---------- monitors' master key (/static/masterkey.js) ---------- */
/* the bar is the page-size Callout (.znote success / warning / critical in
   ekte.css: unlocked, locked, no key or wrong key); its lines stack */
.zmk-bar { display: block; }
.zmk-line { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.zmk-ico { display: inline-flex; color: var(--ink-muted); }
.zmk-ico .zicon { width: 18px; height: 18px; }
.zmk-text { flex: 1 1 260px; min-width: 0; font-size: var(--t-base); line-height: 1.45; color: var(--ink); }
.zmk-meta { color: var(--ink-muted); }
.zmk-text code {
  font-size: var(--t-xs); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xs); padding: 0 5px;
}
.zmk-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.zmk-btns .btn.link { border-color: transparent; background: none; text-decoration: underline; }
.zmk-warn { margin: 10px 0 0; font-size: var(--t-sm); font-weight: 600; color: var(--warning); line-height: 1.45; }
.zmk-msg { margin: 8px 0 0; font-size: var(--t-sm); font-weight: 600; color: var(--ink-muted); }
.zmk-msg:empty { display: none; }
.zmk-reset { margin-top: 10px; }
.zmk-reset p { margin: 0 0 8px; font-size: var(--t-sm); color: var(--danger); font-weight: 600; line-height: 1.45; }
.zmk-row { display: flex; gap: 6px 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.zmk-row .in { flex: 1 1 160px; min-width: 0; font-size: var(--t-sm); padding: 7px 10px; border-radius: var(--r-sm); }

.zmk-dlg {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
}
.zmk-dlg::backdrop { background: var(--backdrop); }
.zmk-body { padding: 22px 22px 20px; }
@media (max-width: 520px) { .zmk-body { padding: 18px 16px 16px; } }
.zmk-body h2 {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  font-family: var(--disp); font-size: var(--t-xl); font-weight: 600; letter-spacing: var(--track-heading);
}
.zmk-body h2 .zicon { width: 20px; height: 20px; }
.zmk-body p { margin: 0 0 12px; font-size: var(--t-base); line-height: 1.55; color: var(--ink-muted); }
.zmk-body .in { width: 100%; box-sizing: border-box; }
.zmk-body #zmk-key { font-size: var(--t-base); letter-spacing: var(--track-label); }
.zmk-check { display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 0; font-size: var(--t-base); line-height: 1.45; cursor: pointer; }
.zmk-check input { margin-top: 3px; }
/* .zmk-act: the dialog's actions, the shared .actions row (ekte.css) */
.zmk-err { margin: 8px 0 0; font-size: var(--t-sm); font-weight: 600; color: var(--danger); }
.zmk-err[hidden] { display: none; }

/* field-level error message, linked to its field with aria-describedby (BITV 9.3.3.1) */
.ferr { margin: 6px 0 0; font-size: var(--t-sm); font-weight: 600; color: var(--danger); line-height: 1.45; }
.ferr[hidden] { display: none; }

/* ---------- relay configuration (/static/relaycfg.js) ---------- */
/* the select / text input pairs reuse the model picker's .zmp styles */
.rc-choice [hidden], .rc-save [hidden], .rc-save[hidden] { display: none; }
.rc-match { margin: 6px 0 0; overflow-wrap: anywhere; }
.rc-match:empty { display: none; }
/* "Save to knowledge base" under the URL field */
.rc-save { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rc-save-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rc-save-body .lab { margin: 0; }
.rc-save-row { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; min-width: 0; }
.rc-save-row .in { flex: 1 1 200px; min-width: 0; }
