<!DOCTYPE html>
<html>
<head>
    <title>Injury Criteria Summary</title>
    <style>
        @page { size: portrait; margin: 20mm; }
        body { font-family: Arial, Helvetica, sans-serif; margin: 0; padding: 20px; color: #333; }
        h1 { color: #2c3e50; font-size: 22px; border-bottom: 2px solid #2c3e50; padding-bottom: 10px; }
        .test-info { background: #f8f9fa; padding: 15px; border-radius: 5px; margin: 15px 0; font-size: 13px; }
        table { border-collapse: collapse; width: 100%; margin-top: 20px; }
        th { background-color: #2c3e50; color: white; padding: 10px; text-align: left; font-size: 12px; }
        td { border: 1px solid #ddd; padding: 8px; font-size: 12px; }
        tr:nth-child(even) { background-color: #f8f9fa; }
        .value { font-weight: bold; font-family: 'Courier New', monospace; }
        .footer { margin-top: 30px; padding-top: 8px; border-top: 1px solid #ddd; font-size: 9px; color: #999; }
    </style>
</head>
<body>
    <h1>Injury Criteria Summary</h1>

    {% if metadata %}
    <div class="test-info">
        {% if metadata.test_number %}<p><strong>Test:</strong> {{ metadata.test_number }}</p>{% endif %}
        {% if metadata.vehicle.make %}<p><strong>Vehicle:</strong> {{ metadata.vehicle.year }} {{ metadata.vehicle.make }} {{ metadata.vehicle.model }}</p>{% endif %}
        {% if metadata.dummy.dummy_type %}<p><strong>Dummy:</strong> {{ metadata.dummy.dummy_type }} ({{ metadata.dummy.position }})</p>{% endif %}
        {% if metadata.impact.test_type %}<p><strong>Test Type:</strong> {{ metadata.impact.test_type }} @ {{ metadata.impact.speed_kmh }} km/h</p>{% endif %}
    </div>
    {% endif %}

    <table>
        <thead>
            <tr>
                <th>Criterion</th>
                <th>Body Region</th>
                <th>Value</th>
                <th>Unit</th>
                <th>Time of Peak</th>
            </tr>
        </thead>
        <tbody>
            {% for name, result in criteria.items() %}
            <tr>
                <td>{{ result.criterion }}</td>
                <td>{{ result.body_region }}</td>
                <td class="value">{{ "%.2f"|format(result.value) }}</td>
                <td>{{ result.unit }}</td>
                <td>{% if result.time_of_peak is not none %}{{ "%.4f"|format(result.time_of_peak) }}s{% endif %}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

    <div class="footer">
        Generated by Impakt
    </div>
</body>
</html>
