/* agent-workspace.css — Phase 3UX.
 *
 * Die linke Spalte war ein klassischer Chat: jede Meldung in einer eigenen
 * Blase mit Hintergrund, Rand und Radius. Das erzeugte die Box-in-Box-Optik
 * und liess 12px-Text auf 320px Breite laufen — eine endlose vertikale Wand.
 *
 * Diese Datei ersetzt das durch eine Arbeitsflaeche: Fliesstext traegt die
 * Erzaehlung, Typografie erzeugt die Hierarchie, Rahmen gibt es nur dort, wo
 * sie semantisch etwas bedeuten (Entscheidung, Fehler, Composer).
 *
 * REGELN: keine Emojis, keine Unicode-Statuszeichen (Status kommt als SVG),
 * kein Glow, keine Verlaufsflaechen, keine Neonfarben. Zurueckhaltend und
 * neutral — der Agent Workspace soll nicht mit der Vorschau konkurrieren.
 */

/* -- Breite ---------------------------------------------------------------
 * Statt einer festen Zahl eine Spanne: mindestens 380px (darunter wird
 * Fliesstext unlesbar), hoechstens 560px (darueber leidet die Vorschau),
 * dazwischen 30vw. Auf 1366px ergibt das 410px und laesst der Vorschau ~950px;
 * auf 1440px sind es 432px; auf 1920px greift der Deckel bei 560px, sodass die
 * Vorschau immer den groesseren Teil behaelt.
 */
#leftPanel.aw-panel {
  width: clamp(380px, 30vw, 560px);
  min-width: 380px;
}
@media (max-width: 1100px) {
  #leftPanel.aw-panel { width: clamp(320px, 38vw, 420px); min-width: 320px; }
}

/* -- Grundflaeche --------------------------------------------------------- */
.aw {
  --aw-ink: #1C0C26;
  --aw-ink-soft: #4A4152;
  --aw-muted: #767085;
  --aw-line: #E7E4EA;
  --aw-line-soft: #F0EEF2;
  --aw-surface: #FFFFFF;
  --aw-raise: #FAF9FB;
  --aw-accent: #3D2B55;
  --aw-run: #6B5B8A;
  --aw-ok: #2F6B4F;
  --aw-fail: #A3302B;
  --aw-radius: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--aw-surface);
  color: var(--aw-ink);
  font-size: 14px;
  line-height: 1.62;
}

.aw-stream {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 26px 26px 8px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  scrollbar-width: thin;
  scrollbar-color: #D8D4DE transparent;
}
.aw-stream::-webkit-scrollbar { width: 10px; }
.aw-stream::-webkit-scrollbar-thumb { background: #DDD9E3; border-radius: 99px; border: 3px solid var(--aw-surface); }
.aw-stream::-webkit-scrollbar-track { background: transparent; }

/* -- Nutzernachricht: klar erkennbar, aber ohne Ballon ------------------- */
.aw-user {
  align-self: flex-end;
  max-width: 84%;
  background: var(--aw-raise);
  border: 1px solid var(--aw-line);
  border-radius: var(--aw-radius);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--aw-ink);
  white-space: pre-wrap;
  word-break: break-word;
}

/* -- Agenten-Fliesstext: KEINE Blase ------------------------------------- */
.aw-say {
  max-width: 62ch;
  color: var(--aw-ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.aw-say strong { color: var(--aw-ink); font-weight: 600; }

/* -- Milestone ----------------------------------------------------------- */
.aw-block { display: flex; flex-direction: column; gap: 10px; }
.aw-head { display: flex; align-items: baseline; gap: 10px; }
.aw-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.011em;
  color: var(--aw-ink);
  margin: 0;
}
.aw-detail {
  max-width: 62ch;
  color: var(--aw-ink-soft);
  font-size: 14px;
}

/* Aktivitaetszeilen: zwei Spalten, Label links, Status rechts. Keine Pills. */
.aw-acts { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.aw-act {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--aw-ink-soft);
  border-top: 1px solid var(--aw-line-soft);
}
.aw-act:first-child { border-top: 0; }
.aw-act-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aw-act-status { font-size: 12.5px; color: var(--aw-muted); font-variant-numeric: tabular-nums; }
.aw-act[data-status="complete"] .aw-act-status { color: var(--aw-ok); }
.aw-act[data-status="failed"] .aw-act-status { color: var(--aw-fail); }

/* -- Entscheidung: staerker, aber nicht dramatisch ----------------------- */
.aw-block[data-kind="decision"] {
  border-left: 2px solid var(--aw-accent);
  padding: 2px 0 2px 18px;
}
.aw-block[data-kind="decision"] .aw-title { color: var(--aw-accent); }

/* -- Fehler -------------------------------------------------------------- */
.aw-block[data-status="failed"] {
  border-left: 2px solid var(--aw-fail);
  padding: 2px 0 2px 18px;
}
.aw-block[data-status="failed"] .aw-title { color: var(--aw-fail); }

/* -- Statusikonen (SVG, nie Zeichen) ------------------------------------- */
.aw-ico { width: 15px; height: 15px; flex-shrink: 0; display: block; }
.aw-ico circle, .aw-ico path, .aw-ico polyline {
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.aw-ico-run { color: var(--aw-run); animation: aw-spin 1.15s linear infinite; }
.aw-ico-ok { color: var(--aw-ok); }
.aw-ico-fail { color: var(--aw-fail); }
.aw-ico-wait { color: #C6C1CE; }
@keyframes aw-spin { to { transform: rotate(360deg); } }

.aw-block-ico { width: 17px; height: 17px; margin-top: 3px; }
.aw-head { display: grid; grid-template-columns: 17px 1fr; gap: 11px; align-items: start; }
.aw-head-text { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

/* -- Rueckfrage ----------------------------------------------------------
 * Eine Rueckfrage ist ein bewusster Arbeitsschritt, kein Chatbeitrag. Sie
 * bekommt deshalb dieselbe Form wie ein Milestone: Titel, kurze Einleitung,
 * darunter die Fragen als eigene Zeilen mit Haarlinien - keine Bubble, keine
 * Kaesten, keine zweite Gestaltungssprache.
 */
.aw-ask { display: flex; flex-direction: column; gap: 0; margin-top: 4px; }
.aw-ask-item {
  display: grid; grid-template-columns: 20px 1fr; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--aw-line-soft);
  font-size: 14px; color: var(--aw-ink); line-height: 1.55;
}
.aw-ask-item:first-child { border-top: 0; }
.aw-ask-n { color: var(--aw-muted); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.aw-ask-hint { font-size: 13px; color: var(--aw-muted); margin-top: 10px; }
.aw-block[data-kind="ask"] .aw-title { color: var(--aw-accent); }

/* -- Abschluss-Aktionen -------------------------------------------------- */
.aw-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 4px; }
.aw-action {
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 8px 15px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--aw-line); background: var(--aw-surface); color: var(--aw-ink);
  transition: background .16s ease, border-color .16s ease;
}
.aw-action:hover { background: var(--aw-raise); border-color: #D9D5DF; }
.aw-action--primary { background: var(--aw-ink); border-color: var(--aw-ink); color: #fff; }
.aw-action--primary:hover { background: #2A1638; border-color: #2A1638; }

/* -- Zur aktuellen Aktivitaet -------------------------------------------- */
.aw-jump {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 14px; z-index: 4;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: 99px; cursor: pointer;
  background: var(--aw-surface); border: 1px solid var(--aw-line);
  box-shadow: 0 4px 16px rgba(28, 12, 38, .10);
  font: inherit; font-size: 12.5px; color: var(--aw-ink);
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.aw-jump[data-visible="1"] { opacity: 1; pointer-events: auto; }
.aw-jump svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* -- Composer ------------------------------------------------------------ */
.aw-foot { position: relative; flex-shrink: 0; padding: 14px 20px 18px; }
.aw-composer {
  border: 1px solid var(--aw-line);
  border-radius: 18px;
  background: var(--aw-surface);
  box-shadow: 0 1px 2px rgba(28, 12, 38, .04), 0 6px 20px rgba(28, 12, 38, .05);
  transition: border-color .16s ease, box-shadow .16s ease;
  display: flex; flex-direction: column;
}
.aw-composer:focus-within {
  border-color: #C9C2D4;
  box-shadow: 0 1px 2px rgba(28, 12, 38, .05), 0 8px 26px rgba(28, 12, 38, .09);
}
.aw-input {
  width: 100%; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--aw-ink);
  font: inherit; font-size: 14.5px; line-height: 1.55;
  padding: 16px 18px 6px;
  min-height: 56px; max-height: 190px; overflow-y: auto;
}
.aw-input::placeholder { color: var(--aw-muted); }
.aw-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px 10px 12px;
}
.aw-tool {
  width: 32px; height: 32px; border-radius: 9px; border: 0;
  background: transparent; color: var(--aw-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .14s ease, color .14s ease;
}
.aw-tool:hover { background: var(--aw-raise); color: var(--aw-ink); }
.aw-tool[aria-pressed="true"] { background: #F1EEF6; color: var(--aw-accent); }
.aw-tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.aw-spacer { flex: 1; }
.aw-send {
  width: 34px; height: 34px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--aw-ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .14s ease, opacity .14s ease;
}
.aw-send:hover:not(:disabled) { background: #2A1638; }
.aw-send:disabled { opacity: .38; cursor: not-allowed; }
.aw-send svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.aw-send[data-sending="1"] svg { animation: aw-spin 1.15s linear infinite; }

.aw-hint { font-size: 11.5px; color: var(--aw-muted); padding: 8px 4px 0; }

/* Sichtbarer Fokus ueberall — Tastaturbedienung darf nie unsichtbar sein. */
.aw :focus-visible,
.aw-composer:focus-within .aw-input:focus-visible { outline: 2px solid #6B5B8A; outline-offset: 2px; border-radius: 6px; }

/* -- Kompakter Buildstatus (ersetzt die zweite Fortschritts-Wahrheit) ---- */
.aw-progress { display: flex; align-items: center; gap: 10px; padding: 0 4px 10px; font-size: 12.5px; color: var(--aw-muted); }
.aw-progress-track { flex: 1; height: 3px; border-radius: 99px; background: var(--aw-line-soft); overflow: hidden; }
.aw-progress-fill { height: 100%; background: var(--aw-run); border-radius: 99px; transition: width .5s cubic-bezier(.2,.7,.2,1); }

@media (prefers-reduced-motion: reduce) {
  .aw-ico-run, .aw-send[data-sending="1"] svg { animation: none; }
  .aw-progress-fill, .aw-jump, .aw-composer, .aw-action { transition: none; }
}
