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

{% block title %}{% trans "URGENT - Second SLA Reminder" %}{% endblock %}
{% block preheader %}{% trans "FINAL REMINDER: A complaint is about to breach its SLA. Immediate action required." %}{% 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 "CRITICAL: This is an URGENT reminder about an UNASSIGNED complaint that requires IMMEDIATE attention. This complaint has NOT been assigned to anyone and is about to breach its SLA deadline. This is the FINAL reminder before automatic escalation." %}
</p>
{% else %}
<p style="margin: 0 0 20px;">
    {% trans "This is the second and final reminder that you have an assigned complaint approaching its SLA deadline. Immediate action is required to avoid escalation." %}
</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 critical deadline" %}</p>
<p style="margin: 0 0 5px;">- {% trans "MONITOR progress continuously until resolved" %}</p>
<p style="margin: 0 0 25px;">{% trans "Failure to assign and address this complaint may result in automatic escalation to higher management." %}</p>
{% else %}
<p style="margin: 0 0 5px;">- {% trans "Update the complaint status to reflect current progress" %}</p>
<p style="margin: 0 0 5px;">- {% trans "Add a timeline update explaining the delay" %}</p>
<p style="margin: 0 0 25px;">- {% trans "Contact your department manager if additional resources are needed" %}</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 Now" %}
            </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:"d F Y H:i" }} - الوقت المتبقي: {{ hours_remaining }} ساعة<br>
    {% if not is_unassigned %}
    يرجى المراجعة واتخاذ إجراء فوري لتجنب التصعيد وعواقب تجاوز الموعد.
    {% endif %}
</p>
{% endblock %}
