{% extends 'emails/base_email_template.html' %}
{% load i18n %}

{% block title %}{% trans "SLA Reminder - Complaint" %}{% endblock %}
{% block preheader %}{% trans "A complaint is approaching its SLA deadline. Please take action." %}{% endblock %}

{% block content %}
<p style="margin: 0 0 15px;">
    {% trans "Dear" %} <strong>{{ recipient.get_full_name }}</strong>,
</p>

{% if is_unassigned %}
<p style="margin: 0 0 20px;">
    {% trans "This is a reminder about an UNASSIGNED complaint that needs your attention. This complaint has not yet been assigned to anyone. Please assign it to an appropriate team member as soon as possible." %}
</p>
{% else %}
<p style="margin: 0 0 20px;">
    {% trans "This is an automated reminder that you have an assigned complaint approaching its SLA deadline. Please review and take appropriate action." %}
</p>
{% endif %}

<p style="margin: 0 0 5px;"><strong>{% trans "Reference:" %}</strong> #{{ complaint.id|slice:":8" }}</p>
<p style="margin: 0 0 5px;"><strong>{% trans "Title:" %}</strong> {{ complaint.title }}</p>
<p style="margin: 0 0 5px;"><strong>{% trans "Severity:" %}</strong> {{ complaint.get_severity_display }}</p>
<p style="margin: 0 0 5px;"><strong>{% trans "Priority:" %}</strong> {{ complaint.get_priority_display }}</p>
<p style="margin: 0 0 5px;"><strong>{% trans "Category:" %}</strong> {% if complaint.category %}{{ complaint.category.get_localized_name }}{% else %}N/A{% endif %}</p>
<p style="margin: 0 0 5px;"><strong>{% trans "Department:" %}</strong> {% if complaint.department %}{{ complaint.department.get_localized_name }}{% else %}N/A{% endif %}</p>
<p style="margin: 0 0 5px;"><strong>{% trans "Patient:" %}</strong> {% if complaint.patient %}{{ complaint.patient.get_full_name }} (MRN: {{ complaint.patient.mrn }}){% else %}N/A{% endif %}</p>
<p style="margin: 0 0 5px;"><strong>{% trans "Due Date:" %}</strong> {{ due_date|date:"F d, Y H:i" }}</p>
<p style="margin: 0 0 5px;"><strong>{% trans "Time Remaining:" %}</strong> {{ hours_remaining }} {% trans "hours" %}</p>
<p style="margin: 0 0 20px;"><strong>{% trans "Status:" %}</strong> {{ complaint.get_status_display }}</p>

{% if is_unassigned %}
<p style="margin: 0 0 5px;">- {% trans "Assign this complaint to an appropriate staff member immediately" %}</p>
<p style="margin: 0 0 5px;">- {% trans "Ensure the assigned person is aware of the approaching SLA deadline" %}</p>
<p style="margin: 0 0 25px;">- {% trans "Monitor progress to ensure timely resolution" %}</p>
{% else %}
<p style="margin: 0 0 25px;">
    {% trans "Please review this complaint and take appropriate action before the SLA deadline to avoid breach." %}
</p>
{% endif %}

<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
    <tr>
        <td align="center">
            <a href="{{ site_url }}/complaints/{{ complaint.id }}/"
               style="display: inline-block; padding: 12px 32px; font-size: 16px; font-weight: 600; color: #ffffff; text-decoration: none; border-radius: 6px; background-color: #005696;">
                {% trans "View Complaint" %}
            </a>
        </td>
    </tr>
</table>

<p style="margin: 25px 0 5px; font-size: 13px; color: #666666; direction: rtl; text-align: right;">
    تذكير اتفاقية مستوى الخدمة - شكوى #{{ complaint.id|slice:":8" }}
</p>
<p style="margin: 0; font-size: 12px; color: #999999; direction: rtl; text-align: right; line-height: 1.8;">
    {% if is_unassigned %}
    هام: هذا تذكير بشكوى غير معينة تحتاج إلى اهتمامكم. يرجى تعيينها لأحد أعضاء الفريق المناسبين في أقرب وقت ممكن.<br>
    {% endif %}
    معلومات اتفاقية مستوى الخدمة: تاريخ الاستحقاق {{ due_date|date:"Y F d H:i" }} - الوقت المتبقي: {{ hours_remaining }} ساعة<br>
    {% if not is_unassigned %}
    يرجى مراجعة هذه الشكوى واتخاذ الإجراء المناسب قبل الموعد النهائي لتجنب تجاوزها.
    {% endif %}
</p>
{% endblock %}
