{{define "settings"}}
<!doctype html>
<html lang="en">
<head>
  <title>{{.Title}}</title>
  {{template "head" .}}
</head>
<body>
  {{template "nav" .}}
  {{if .Msg}}<div class="flash flash-ok">{{.Msg}}</div>{{end}}
  {{if .Err}}<div class="flash flash-err">{{.Err}}</div>{{end}}
  <h1>Settings</h1>
  <p>QC-Settings plus globale Prompt-/Systemsteuerung fuer den spaeteren LLM-Flow.</p>
  <table>
    <tr><th>QC Base URL</th><td class="mono">{{.QCBaseURL}}</td></tr>
    <tr><th>Bearer token configured</th><td>{{if .TokenConfigured}}yes{{else}}no{{end}}</td></tr>
    <tr><th>Poll interval (seconds)</th><td>{{.PollIntervalSeconds}}</td></tr>
    <tr><th>Poll timeout (seconds)</th><td>{{.PollTimeoutSeconds}}</td></tr>
    <tr><th>Poll max concurrent</th><td>{{.PollMaxConcurrent}}</td></tr>
    <tr><th>Language output mode</th><td>{{.LanguageOutputMode}}</td></tr>
  </table>

  <h2>Globaler Master Prompt</h2>
  <p><small>Diese Einstellungen gelten systemweit und werden im normalen Build-/Review-Formular nicht mehr direkt editiert.</small></p>
  <form method="post" action="/settings/prompt">
    <input type="hidden" name="prompt_block_count" value="{{len .PromptBlocks}}">
    <div>
      <label>Master Prompt
        <textarea name="master_prompt">{{.MasterPrompt}}</textarea>
      </label>
    </div>
    <h3>Prompt-Bloecke (Standard)</h3>
    {{range $i, $block := .PromptBlocks}}
    <input type="hidden" name="prompt_block_id_{{$i}}" value="{{$block.ID}}">
    <div>
      <label>
        <input type="checkbox" name="prompt_block_enabled_{{$i}}" {{if $block.Enabled}}checked{{end}}>
        {{$block.Label}}
      </label>
      <input type="hidden" name="prompt_block_label_{{$i}}" value="{{$block.Label}}">
      <textarea name="prompt_block_instruction_{{$i}}">{{$block.Instruction}}</textarea>
    </div>
    {{end}}
    <button type="submit">Prompt-Settings speichern</button>
  </form>
</body>
</html>
{{end}}
