{{template "head" "Golden Set"}}
{{template "nav" "golden-set"}}

<h2 class="section-title">LEM Golden Set Explorer</h2>

{{if not .GoldenSet.Available}}
<div class="card"><div class="empty">No golden set data available. Run <code>pipeline.py metrics</code> to push stats to InfluxDB.</div></div>
{{else}}

<div class="grid">
  <div class="card">
    <h3>Progress</h3>
    <div class="value">{{fmtInt .GoldenSet.TotalExamples}} / {{fmtInt .GoldenSet.TargetTotal}}</div>
    <div class="progress-bar"><div class="fill" style="width:{{pct .GoldenSet.CompletionPct}}%"></div></div>
    <div class="sub">{{pct .GoldenSet.CompletionPct}}% complete</div>
  </div>

  <div class="card">
    <h3>Domains</h3>
    <div class="value">{{.GoldenSet.Domains}}</div>
    <div class="sub">Unique topic domains</div>
  </div>

  <div class="card">
    <h3>Voices</h3>
    <div class="value">{{.GoldenSet.Voices}}</div>
    <div class="sub">Persona voice types</div>
  </div>

  <div class="card">
    <h3>Avg Generation</h3>
    <div class="value">{{pct .GoldenSet.AvgGenTime}}s</div>
    <div class="sub">{{pct .GoldenSet.AvgResponseChars}} avg chars per response</div>
  </div>
</div>

{{if .GoldenSet.Workers}}
<h2 class="section-title">Workers</h2>
<div class="card">
  <table>
    <thead><tr><th>Worker</th><th style="text-align:right">Generations</th></tr></thead>
    <tbody>
    {{range .GoldenSet.Workers}}
    <tr>
      <td><code>{{.Worker}}</code></td>
      <td style="text-align:right">{{.Count}}</td>
    </tr>
    {{end}}
    </tbody>
  </table>
</div>
{{end}}

{{if .GoldenSet.VoiceStats}}
<h2 class="section-title">Voice Distribution</h2>
<div class="card" style="overflow-x:auto;padding:1rem">
  {{voiceChart .GoldenSet.VoiceStats}}
</div>
{{end}}

{{if .GoldenSet.DomainStats}}
<h2 class="section-title">Domain Breakdown (top 25)</h2>
<div class="card" style="overflow-x:auto;padding:1rem">
  {{domainChart .GoldenSet.DomainStats}}
</div>

<h2 class="section-title">All Domains</h2>
<div class="card">
  <table>
    <thead><tr><th>Domain</th><th style="text-align:right">Count</th><th style="text-align:right">Avg Gen Time</th><th style="width:40%">Coverage</th></tr></thead>
    <tbody>
    {{range .GoldenSet.DomainStats}}
    <tr>
      <td><code>{{.Domain}}</code></td>
      <td style="text-align:right">{{.Count}}</td>
      <td style="text-align:right">{{pct .AvgGenTime}}s</td>
      <td>
        <div class="progress-bar" style="height:6px"><div class="fill" style="width:{{pct (pctOf .Count $.GoldenSet.TotalExamples)}}%"></div></div>
      </td>
    </tr>
    {{end}}
    </tbody>
  </table>
</div>
{{end}}

{{if .GoldenSet.VoiceStats}}
<h2 class="section-title">Voice Details</h2>
<div class="card">
  <table>
    <thead><tr><th>Voice</th><th style="text-align:right">Count</th><th style="text-align:right">Avg Chars</th><th style="text-align:right">Avg Gen Time</th></tr></thead>
    <tbody>
    {{range .GoldenSet.VoiceStats}}
    <tr>
      <td><code>{{.Voice}}</code></td>
      <td style="text-align:right">{{.Count}}</td>
      <td style="text-align:right">{{pct .AvgChars}}</td>
      <td style="text-align:right">{{pct .AvgGenTime}}s</td>
    </tr>
    {{end}}
    </tbody>
  </table>
</div>
{{end}}

{{end}}

{{template "footer"}}
