/* =====================================================================
   demo-workflow.css – Zusatz-Styles NUR für die Workflow-Engine-Demo.
   Baut auf demo.css (CI-Tokens, Buttons, Badges) auf; ergänzt nur, was
   die Pipeline-Visualisierung braucht. Kein Framework, keine CDN.
   ===================================================================== */

/* ---- Grund-Layout: Workflow-Liste + Arbeitsbereich ----------------- */
.wf-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 2.5rem;
}

/* ---- Sidebar: Workflow-Auswahl ------------------------------------ */
.wf-list { display: flex; flex-direction: column; gap: .8rem; }
.wf-list__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .1rem;
}
.wf-list__head h2 { font-size: 1.1rem; font-weight: 700; margin: 0; }

.wf-item {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform .18s var(--ease-out), border-color .2s var(--ease-out), background .2s var(--ease-out);
  display: flex; flex-direction: column; gap: .6rem;
}
.wf-item:hover { transform: translateY(-2px); border-color: var(--border-strong); background: var(--card-hover); }
.wf-item.is-selected {
  border-color: rgba(255,109,0,.55);
  background: var(--card-hover);
  box-shadow: 0 0 0 1px rgba(255,109,0,.35), var(--shadow-card);
}
.wf-item.is-inactive { opacity: .62; }

.wf-item__top { display: flex; align-items: flex-start; gap: .7rem; }
.wf-item__icon {
  flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--gradient); color: #fff;
}
.wf-item__icon svg { width: 18px; height: 18px; }
.wf-item__name { font-weight: 700; font-size: .96rem; letter-spacing: -.01em; line-height: 1.25; }
.wf-item__trigger { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }

.wf-item__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding-top: .1rem;
}
.wf-item__state { font-size: .74rem; font-weight: 600; color: var(--text-dim); }
.wf-item__state.is-on { color: var(--green); }

/* ---- Toggle-Schalter (aktiv/inaktiv) ------------------------------ */
.wf-switch {
  position: relative;
  width: 42px; height: 24px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s var(--ease-out), border-color .2s var(--ease-out);
  padding: 0;
}
.wf-switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #cfd3dd;
  transition: transform .2s var(--ease-out), background .2s var(--ease-out);
}
.wf-switch.is-on { background: rgba(255,109,0,.25); border-color: rgba(255,109,0,.55); }
.wf-switch.is-on::after { transform: translateX(18px); background: var(--accent); }
.wf-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Arbeitsbereich ----------------------------------------------- */
.wf-main { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }

/* Konfigurations-Übersicht des gewählten Workflows */
.wf-config {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow-card);
}
.wf-config__title { font-size: 1.15rem; font-weight: 800; margin: 0 0 .25rem; letter-spacing: -.01em; }
.wf-config__desc { color: var(--text-muted); font-size: .9rem; margin: 0 0 1.1rem; max-width: 66ch; }

.wf-flow {
  display: flex; flex-wrap: wrap; align-items: stretch; gap: .5rem;
  margin-bottom: 1.1rem;
}
.wf-flow__node {
  display: flex; align-items: center; gap: .45rem;
  font-size: .8rem; font-weight: 600; color: var(--text-muted);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: .4rem .7rem;
}
.wf-flow__arrow { align-self: center; color: var(--text-dim); }
.wf-flow__arrow svg { width: 15px; height: 15px; display: block; }

/* WENN / SONST-Übersicht */
.wf-branches { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.wf-branch {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .8rem .9rem;
  background: rgba(255,255,255,.02);
}
.wf-branch__label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 700; margin-bottom: .35rem;
}
.wf-branch--then .wf-branch__label { color: var(--accent); }
.wf-branch--else .wf-branch__label { color: var(--blue); }
.wf-branch__text { font-size: .84rem; color: var(--text); margin-bottom: .5rem; }
.wf-branch__acts { display: flex; flex-wrap: wrap; gap: .35rem; }
.wf-actchip {
  font-size: .72rem; font-weight: 600; color: var(--text-muted);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 7px; padding: .22rem .5rem;
  display: inline-flex; align-items: center; gap: .3rem;
}
.wf-actchip svg { width: 12px; height: 12px; }

/* ---- Run-Leiste (Beispiel wählen + ausführen) --------------------- */
.wf-run {
  display: flex; align-items: center; flex-wrap: wrap; gap: .75rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
.wf-run__label { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.wf-select {
  font: inherit; font-size: .86rem; font-weight: 600;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: .55rem .8rem;
  cursor: pointer;
  min-width: 220px;
  flex: 1 1 220px;
}
.wf-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.wf-run__spacer { flex: 1; }
.wf-run__hint {
  font-size: .78rem; color: var(--amber);
  display: inline-flex; align-items: center; gap: .35rem;
}
.wf-run__hint svg { width: 15px; height: 15px; }

/* ---- Pipeline (Stationen) ----------------------------------------- */
.wf-pipeline { display: flex; flex-direction: column; gap: 0; }

.wf-pipeline__placeholder {
  text-align: center; padding: 2.6rem 1rem;
  color: var(--text-dim);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.wf-pipeline__placeholder svg { width: 30px; height: 30px; opacity: .6; margin-bottom: .6rem; }

.wf-station {
  position: relative;
  display: flex; gap: .9rem;
  padding: 0 0 1.1rem;
  opacity: .4;
  transition: opacity .35s var(--ease-out), transform .35s var(--ease-out);
  transform: translateY(6px);
}
.wf-station.is-visible { opacity: 1; transform: translateY(0); }
.wf-station.is-pending { opacity: .32; }

/* vertikale Verbindungslinie */
.wf-station:not(:last-child) .wf-station__rail::after {
  content: "";
  position: absolute; top: 34px; bottom: -6px; left: 50%;
  width: 2px; transform: translateX(-50%);
  background: var(--border-strong);
}
.wf-station.is-done .wf-station__rail::after { background: rgba(255,109,0,.4); }

.wf-station__rail { position: relative; flex-shrink: 0; width: 34px; }
.wf-station__num {
  position: relative; z-index: 1;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .85rem; font-weight: 800;
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  transition: all .25s var(--ease-out);
}
.wf-station.is-active .wf-station__num {
  border-color: var(--accent); color: #fff;
  background: rgba(255,109,0,.18);
  box-shadow: 0 0 0 4px rgba(255,109,0,.12);
}
.wf-station.is-done .wf-station__num {
  border-color: rgba(255,109,0,.5);
  background: var(--gradient); color: #fff;
}
.wf-station__num svg { width: 16px; height: 16px; }

.wf-station__body {
  flex: 1; min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.05rem;
  box-shadow: var(--shadow-card);
  transition: border-color .25s var(--ease-out);
}
.wf-station.is-active .wf-station__body { border-color: rgba(255,109,0,.4); }

.wf-station__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
}
.wf-station__title { font-weight: 700; font-size: .95rem; }
.wf-station__summary { font-size: .8rem; color: var(--text-muted); }
.wf-station__status {
  font-size: .72rem; font-weight: 700; color: var(--text-dim);
  display: inline-flex; align-items: center; gap: .35rem;
}
.wf-station.is-active .wf-station__status { color: var(--accent); }
.wf-station.is-done .wf-station__status { color: var(--green); }
.wf-station__status .spinner { width: 13px; height: 13px; }

.wf-station__detail {
  margin-top: .75rem; padding-top: .75rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
}

/* Detail: normalisierte Felder */
.wf-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .5rem .9rem; }
.wf-kv__row { min-width: 0; }
.wf-kv__k { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); font-weight: 600; }
.wf-kv__v { font-size: .85rem; word-break: break-word; white-space: pre-wrap; }
.wf-notes { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.wf-note {
  font-size: .72rem; color: var(--text-muted);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 7px; padding: .22rem .5rem;
}

/* Detail: KI-Analyse (kompakter Score-Balken) */
.wf-ai { display: flex; flex-direction: column; gap: .7rem; }
.wf-ai__scoreline { display: flex; align-items: center; gap: 1rem; }
.wf-ai__num { font-size: 1.9rem; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.wf-ai__num small { font-size: .85rem; color: var(--text-dim); font-weight: 600; }
.wf-ai__meter { flex: 1; }
.wf-ai__track { height: 8px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.wf-ai__fill { height: 100%; border-radius: 999px; background: var(--gradient); width: 0; transition: width .7s var(--ease-out); }
.wf-ai__labels { display: flex; justify-content: space-between; font-size: .7rem; color: var(--text-dim); margin-top: .3rem; }
.wf-ai__rationale {
  font-size: .84rem; color: #d7dae2;
  background: rgba(255,255,255,.03);
  border-left: 3px solid var(--accent-2);
  padding: .55rem .8rem; border-radius: 0 8px 8px 0;
}
.wf-ai__facts { display: flex; flex-wrap: wrap; gap: .4rem; }
.wf-ai__fact {
  font-size: .72rem; color: var(--text-muted);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 7px; padding: .25rem .55rem;
}
.wf-ai__fact b { color: var(--text); }

/* Prioritäts-Badges (hoch / mittel / niedrig) – analog zu score-badges */
.prio-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .74rem; font-weight: 700;
  padding: .24rem .6rem; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.prio-hoch    { background: rgba(255,109,0,.16);  border-color: rgba(255,109,0,.5);  color: #ffcba4; }
.prio-mittel  { background: rgba(157,78,221,.16); border-color: rgba(157,78,221,.5); color: #d9b8ff; }
.prio-niedrig { background: rgba(96,165,250,.14); border-color: rgba(96,165,250,.4); color: #bcd7ff; }

/* Detail: Bedingung */
.wf-cond__expr {
  font-family: 'Inter', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .9rem; font-weight: 700;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 8px; padding: .5rem .75rem;
  display: inline-block; margin-bottom: .75rem;
}
.wf-cond__branches { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.wf-cond__opt {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .8rem;
  font-size: .83rem;
  opacity: .5;
  transition: all .25s var(--ease-out);
}
.wf-cond__opt.is-chosen { opacity: 1; }
.wf-cond__opt--then.is-chosen { border-color: rgba(255,109,0,.5); background: rgba(255,109,0,.07); }
.wf-cond__opt--else.is-chosen { border-color: rgba(96,165,250,.5); background: rgba(96,165,250,.07); }
.wf-cond__opt .tag {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
  font-weight: 800; display: block; margin-bottom: .25rem;
}
.wf-cond__opt--then .tag { color: var(--accent); }
.wf-cond__opt--else .tag { color: var(--blue); }

/* Detail: Aktionen (simuliert) */
.wf-actions { display: flex; flex-direction: column; gap: .7rem; }
.action-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.02);
  overflow: hidden;
}
.action-card__head {
  display: flex; align-items: center; gap: .55rem;
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--border);
}
.action-card__ico {
  width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center; flex-shrink: 0;
  background: rgba(255,109,0,.12); color: var(--accent);
  border: 1px solid rgba(255,109,0,.3);
}
.action-card__ico svg { width: 15px; height: 15px; }
.action-card__title { font-weight: 700; font-size: .86rem; flex: 1; }
.action-card__sim {
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--amber);
  background: rgba(251,191,36,.1);
  border: 1px solid rgba(251,191,36,.3);
  border-radius: 999px; padding: .15rem .5rem;
}
.action-card__body { padding: .7rem .8rem; font-size: .83rem; }

/* E-Mail-Vorschau */
.mail-prev { display: flex; flex-direction: column; gap: .4rem; }
.mail-prev__row { display: flex; gap: .5rem; font-size: .8rem; }
.mail-prev__k { color: var(--text-dim); min-width: 3.2rem; font-weight: 600; }
.mail-prev__v { color: var(--text); word-break: break-word; }
.mail-prev__body {
  margin-top: .3rem; padding: .6rem .75rem;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap; color: #d7dae2; font-size: .82rem;
}

/* Statuswechsel */
.status-change { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.status-change__ent { font-size: .8rem; color: var(--text-muted); width: 100%; margin-bottom: .1rem; }
.status-pill {
  font-size: .76rem; font-weight: 700;
  padding: .24rem .6rem; border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(255,255,255,.04); color: var(--text-muted);
}
.status-pill--new { border-color: rgba(255,109,0,.5); background: rgba(255,109,0,.12); color: #ffcba4; }
.status-change__arrow { color: var(--text-dim); display: inline-flex; }
.status-change__arrow svg { width: 16px; height: 16px; }

/* Webhook / JSON */
.wf-json {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem; line-height: 1.5;
  color: #cdd3e0;
  background: #0c0c14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .7rem .8rem;
  overflow-x: auto;
  white-space: pre;
}
.wf-json .jk { color: #ffb27a; }
.wf-json .js { color: #9fe0b0; }
.webhook-meta { display: flex; gap: .5rem; align-items: center; margin-bottom: .55rem; flex-wrap: wrap; }
.webhook-method {
  font-size: .7rem; font-weight: 800; letter-spacing: .04em;
  color: var(--green);
  background: rgba(74,222,128,.12);
  border: 1px solid rgba(74,222,128,.3);
  border-radius: 6px; padding: .18rem .45rem;
}
.webhook-url { font-family: ui-monospace, monospace; font-size: .78rem; color: var(--text-muted); word-break: break-all; }

/* Benachrichtigung */
.notify-prev { display: flex; align-items: flex-start; gap: .6rem; }
.notify-prev__ch {
  font-size: .74rem; font-weight: 700; color: var(--accent-2);
  background: rgba(157,78,221,.12);
  border: 1px solid rgba(157,78,221,.3);
  border-radius: 7px; padding: .25rem .55rem; white-space: nowrap; flex-shrink: 0;
}
.notify-prev__msg { font-size: .84rem; color: #d7dae2; }

/* ---- Protokoll / Historie ----------------------------------------- */
.wf-protocol { margin-top: .5rem; }
.wf-log { display: flex; flex-direction: column; gap: .5rem; }
.wf-log__empty {
  text-align: center; padding: 2rem 1rem;
  color: var(--text-dim);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: .88rem;
}
.log-entry {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: .65rem .9rem;
  font-size: .84rem;
  animation: logIn .35s var(--ease-out);
}
.log-entry--then { border-left-color: var(--accent); }
.log-entry--else { border-left-color: var(--blue); }
@keyframes logIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.log-entry__time { font-variant-numeric: tabular-nums; color: var(--text-dim); font-size: .78rem; white-space: nowrap; }
.log-entry__wf { font-weight: 700; }
.log-entry__branch { color: var(--text-muted); flex: 1; min-width: 140px; }
.log-entry__meta { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.log-entry__id { font-family: ui-monospace, monospace; font-size: .72rem; color: var(--text-dim); }

/* ---- Responsive --------------------------------------------------- */
@media (max-width: 900px) {
  .wf-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wf-branches, .wf-cond__branches { grid-template-columns: 1fr; }
  .wf-flow { gap: .35rem; }
  .wf-flow__node { font-size: .74rem; padding: .35rem .55rem; }
  .wf-run__spacer { display: none; }
  .wf-select { min-width: 0; }
  .log-entry__meta { margin-left: 0; width: 100%; }
}
