<!DOCTYPE html>
<html>
<head>
    <title>{{ title }}</title>
    <meta charset="utf-8">
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            max-width: 900px;
            margin: 0 auto;
            padding: 20px;
            color: #333;
            line-height: 1.6;
        }
        h1 {
            color: #2E86AB;
            border-bottom: 3px solid #2E86AB;
            padding-bottom: 10px;
        }
        h2 {
            color: #A23B72;
            margin-top: 30px;
            border-bottom: 1px solid #eee;
            padding-bottom: 5px;
        }
        h3 { color: #F18F01; }
        table {
            border-collapse: collapse;
            width: 100%;
            margin: 15px 0;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 10px;
            text-align: left;
        }
        th {
            background-color: #A23B72;
            color: white;
            font-weight: 600;
        }
        tr:nth-child(even) { background-color: #f8f9fa; }
        tr:hover { background-color: #e9ecef; }
        .figure {
            text-align: center;
            margin: 25px 0;
            padding: 15px;
            background: #f8f9fa;
            border-radius: 8px;
        }
        .figure img { max-width: 100%; border-radius: 4px; }
        .figure .caption {
            font-style: italic;
            color: #666;
            margin-top: 8px;
        }
        .meta {
            color: #666;
            font-size: 0.9em;
            margin-bottom: 25px;
            padding: 10px;
            background: #f8f9fa;
            border-radius: 4px;
        }
        .convergence-box {
            padding: 15px;
            border-radius: 8px;
            margin: 15px 0;
        }
        .convergence-ok {
            background: #d4edda;
            border: 1px solid #c3e6cb;
        }
        .convergence-warn {
            background: #fff3cd;
            border: 1px solid #ffeaa7;
        }
        .convergence-fail {
            background: #f8d7da;
            border: 1px solid #f5c6cb;
        }
        .param-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 15px;
            margin: 15px 0;
        }
        .param-card {
            padding: 15px;
            background: #f8f9fa;
            border-radius: 8px;
            border: 1px solid #eee;
        }
        footer {
            margin-top: 40px;
            padding-top: 15px;
            border-top: 1px solid #eee;
            color: #999;
            font-size: 0.8em;
        }
    </style>
</head>
<body>
    <h1>{{ title }}</h1>
    <div class="meta">
        <strong>Author:</strong> {{ author }} |
        <strong>Date:</strong> {{ date }} |
        <strong>Generated by:</strong> particlefilterbox PMCMC
    </div>

    {% for section in sections %}
    <h{{ section.level }}>{{ section.title }}</h{{ section.level }}>
    {% if section.content %}
    <p>{{ section.content }}</p>
    {% endif %}
    {% for table in section.tables %}
    <table>
        {% if table.caption %}<caption>{{ table.caption }}</caption>{% endif %}
        <thead><tr>
            {% for h in table.headers %}<th>{{ h }}</th>{% endfor %}
        </tr></thead>
        <tbody>
            {% for row in table.rows %}
            <tr>{% for cell in row %}<td>{{ cell }}</td>{% endfor %}</tr>
            {% endfor %}
        </tbody>
    </table>
    {% endfor %}
    {% for fig in section.figures %}
    <div class="figure">
        <img src="{{ fig.path }}" />
        {% if fig.caption %}<div class="caption">{{ fig.caption }}</div>{% endif %}
    </div>
    {% endfor %}
    {% endfor %}

    <footer>
        Generated by particlefilterbox - Particle Markov Chain Monte Carlo Analysis
    </footer>
</body>
</html>
