<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="UTF-8">
<title>Kontrola stavu pojištění</title>

<style>
@font-face {
    font-family: 'DejaVu';
    src: url('{{ font_regular }}');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'DejaVu';
    src: url('{{ font_bold }}');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'DejaVu';
    src: url('{{ font_italic }}');
    font-weight: normal;
    font-style: italic;
}

@page {
    size: A4;
    margin: 1.5cm;
    @bottom-right {
        content: "Strana " counter(page) " z " counter(pages);
        font-size: 9pt;
    }
}

body {
    font-family: 'DejaVu', sans-serif;
    font-size: 10pt;
    color: #333;
}

h1 {
    font-size: 16pt;
    border-bottom: 2px solid #2c3e50;
    padding-bottom: 5px;
}

.meta {
    font-size: 9pt;
    margin-bottom: 15px;
    color: #666;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border: 1px solid #ccc;
    padding: 6px 8px;
    vertical-align: top;
}

th {
    background-color: #f2f2f2;
}

tr {
    page-break-inside: avoid;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

.status-bad {
    color: #d9534f;
    font-weight: bold;
}

.date-info {
    font-size: 9pt;
    color: #555;
}
</style>
</head>

<body>

<h1>Kontrola stavu pojištění (VZP)</h1>

<div class="meta">
    Vygenerováno: {{ generated_at }}
</div>

{% if patients %}
<table>
<thead>
<tr>
    <th>Rodné číslo</th>
    <th>Příjmení a jméno</th>
    <th>Pojišťovna</th>
    <th>Stav</th>
    <th>Platnost pojištění</th>
</tr>
</thead>
<tbody>
{% for p in patients %}
<tr>
    <td>{{ p.rc }}</td>
    <td><strong>{{ p.prijmeni }}</strong> {{ p.jmeno }}</td>
    <td>{{ p.poj }}</td>
    <td class="status-bad">{{ p.stav }}</td>
    <td class="date-info">
        {% if p.insured_to %}
            pojištěn do {{ p.insured_to.strftime("%d.%m.%Y") }}<br>
            nepojištěn od {{ p.uninsured_from.strftime("%d.%m.%Y") }}
        {% else %}
            nelze určit
        {% endif %}
    </td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p style="color: green; font-weight: bold;">
&#10004; Vše v pořádku – žádné neshody nenalezeny.
</p>
{% endif %}

</body>
</html>
