<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>MCP Kit Eval Report</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; padding: 2rem; background: #fafafa; color: #333; }
        h1 { margin-bottom: 0.5rem; }
        .meta { color: #666; margin-bottom: 2rem; }
        .summary { display: flex; gap: 2rem; margin-bottom: 2rem; padding: 1rem; background: white; border-radius: 8px; border: 1px solid #e0e0e0; }
        .summary .stat { text-align: center; }
        .summary .stat .value { font-size: 2rem; font-weight: bold; }
        .summary .stat .label { color: #666; font-size: 0.875rem; }
        .stat .value.green { color: #22863a; }
        .stat .value.red { color: #cb2431; }
        .suite { margin-bottom: 2rem; background: white; border-radius: 8px; border: 1px solid #e0e0e0; padding: 1.5rem; }
        .suite h2 { margin-bottom: 0.25rem; }
        .description { color: #666; margin-bottom: 1rem; }
        table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
        th { text-align: left; padding: 0.5rem; border-bottom: 2px solid #e0e0e0; font-size: 0.875rem; color: #666; }
        td { padding: 0.5rem; border-bottom: 1px solid #f0f0f0; }
        tr.pass td.status { color: #22863a; font-weight: bold; }
        tr.fail td.status { color: #cb2431; font-weight: bold; }
        .center { text-align: center; }
        .right { text-align: right; }
        .details { color: #666; font-size: 0.875rem; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .regressions { margin-bottom: 2rem; background: #fff8e1; border-radius: 8px; border: 1px solid #ffe082; padding: 1.5rem; }
        .regressions h2 { color: #f57f17; margin-bottom: 0.5rem; }
        .regressions li { margin: 0.25rem 0 0.25rem 1.5rem; }
        .footer { color: #999; font-size: 0.75rem; margin-top: 2rem; }
    </style>
</head>
<body>
    <h1>MCP Kit Eval Report</h1>
    <p class="meta">Generated {{ generated_at }}</p>

    <div class="summary">
        <div class="stat">
            <div class="value green">{{ total_passed }}</div>
            <div class="label">Passed</div>
        </div>
        <div class="stat">
            <div class="value {{ 'red' if total_failed else 'green' }}">{{ total_failed }}</div>
            <div class="label">Failed</div>
        </div>
        <div class="stat">
            <div class="value">{{ total_ms }}ms</div>
            <div class="label">Total Time</div>
        </div>
        <div class="stat">
            <div class="value">{{ num_suites }}</div>
            <div class="label">Suites</div>
        </div>
    </div>

    {% if regressions %}
    <div class="regressions">
        <h2>Regressions</h2>
        <ul>
        {% for reg in regressions %}
            <li><strong>{{ reg.eval_name }}</strong> in suite '{{ reg.suite_name }}' — passed previously, now fails</li>
        {% endfor %}
        </ul>
    </div>
    {% endif %}

    {% for suite in suite_data %}
    <div class="suite">
        <h2>{{ suite.name }}</h2>
        {% if suite.description %}<p class="description">{{ suite.description }}</p>{% endif %}
        <table>
            <thead>
                <tr>
                    <th>Eval</th>
                    <th>Status</th>
                    <th>Assertions</th>
                    <th>Latency</th>
                    <th>Details</th>
                </tr>
            </thead>
            <tbody>
            {% for row in suite.rows %}
                <tr class="{{ row.status_class }}">
                    <td>{{ row.eval_name }}</td>
                    <td class="status">{{ row.status_text }}</td>
                    <td class="center">{{ row.passed_assertions }}/{{ row.total_assertions }}</td>
                    <td class="right">{{ row.latency_ms }}ms</td>
                    <td class="details">{{ row.details }}</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
    {% endfor %}

    <p class="footer">Generated by hdx eval</p>
</body>
</html>
