{% extends "base.html" %}

{% block title %}Daily briefing - {{ clinic_name }}{% endblock %}

{% block content %}
<h2>Briefing for {{ today }}</h2>

{% if appointments is not none %}
<h3>Today's appointments ({{ appointments | length }})</h3>
{% if appointments %}
<div class="info-box">
    {% for a in appointments %}
    <div class="info-row">
        <div style="flex: 1;">
            <div class="label">{{ a.start_time[11:16] if a.start_time else '' }}</div>
            <div class="value">{{ a.patient_name or '—' }}</div>
        </div>
        <div style="flex: 1;">
            <div class="label">Status</div>
            <div class="value">{{ a.status }}</div>
        </div>
    </div>
    {% endfor %}
</div>
{% else %}
<p>No appointments scheduled for today.</p>
{% endif %}
{% endif %}

{% if recalls is not none %}
<h3>Overdue recalls ({{ recalls | length }})</h3>
{% if recalls %}
<div class="info-box">
    {% for r in recalls %}
    <div class="info-row">
        <div style="flex: 1;">
            <div class="label">{{ r.reason }}</div>
            <div class="value">{{ r.patient_name or '—' }}{% if r.phone %} · {{ r.phone }}{% endif %}</div>
        </div>
        <div style="flex: 1;">
            <div class="label">Priority</div>
            <div class="value">{{ r.priority }}</div>
        </div>
    </div>
    {% endfor %}
</div>
{% else %}
<p>No overdue recalls.</p>
{% endif %}
{% endif %}

{% if budgets is not none %}
<h3>Unanswered budgets ({{ budgets | length }})</h3>
{% if budgets %}
<div class="info-box">
    {% for b in budgets %}
    <div class="info-row">
        <div style="flex: 1;">
            <div class="label">{{ b.number }}</div>
            <div class="value">{{ b.patient_name or '—' }}</div>
        </div>
        <div style="flex: 1;">
            <div class="label">Amount</div>
            <div class="value">{{ b.total }}</div>
        </div>
    </div>
    {% endfor %}
</div>
{% else %}
<p>No budgets awaiting a response.</p>
{% endif %}
{% endif %}

<p style="color: #71717a; font-size: 14px;">
    Automatic summary generated by the DentalPin copilot. You can turn
    it off or change the hour in Settings → Copilot.
</p>
{% endblock %}
