{% extends "layouts/base.html" %}
{% load i18n %}
{% load static %}

{% block title %}SLA Configurations - PX360{% endblock %}

{% block content %}
<!-- Header -->
<header class="mb-6">
    <div class="flex justify-between items-start">
        <div>
            <h1 class="text-2xl font-bold text-navy">
                <i data-lucide="clock" class="w-6 h-6 inline-block mr-2"></i>
                {% trans "SLA Configurations" %}
            </h1>
            <p class="text-sm text-slate mt-1">{% trans "Manage Service Level Agreement configurations by complaint source" %}</p>
        </div>
        <a href="{% url 'config:dashboard' %}" class="inline-flex items-center gap-2 px-4 py-2 border border-slate-200 rounded-xl text-sm font-semibold text-slate hover:bg-light transition">
            <i data-lucide="arrow-left" class="w-4 h-4"></i>
            {% trans "Back to Config" %}
        </a>
    </div>
</header>

<!-- SLA Configs Table -->
<div class="bg-white rounded-2xl shadow-sm border border-slate-100 overflow-hidden">
    <div class="flex justify-between items-center p-5 border-b border-slate-100">
        <h3 class="font-bold text-navy flex items-center gap-2 text-sm">
            <i data-lucide="list" class="w-4 h-4"></i>
            {% trans "SLA Configurations List" %}
        </h3>
        <div class="text-xs text-slate font-medium">
            {% trans "Total" %}: <span class="font-bold text-navy">{{ sla_configs.count }}</span> {% trans "configs" %}
        </div>
    </div>
    <div class="overflow-x-auto">
        <table class="w-full">
            <thead class="bg-slate-50 border-b border-slate-100">
                <tr class="text-xs font-bold text-slate uppercase tracking-wider">
                    <th class="px-5 py-3 text-left">{% trans "Source Type" %}</th>
                    <th class="px-5 py-3 text-left">{% trans "Hospital" %}</th>
                    <th class="px-5 py-3 text-left">{% trans "Acknowledgement (hrs)" %}</th>
                    <th class="px-5 py-3 text-left">{% trans "Resolution (hrs)" %}</th>
                    <th class="px-5 py-3 text-left">{% trans "Escalation (hrs)" %}</th>
                    <th class="px-5 py-3 text-left">{% trans "Status" %}</th>
                </tr>
            </thead>
            <tbody class="text-sm divide-y divide-slate-100">
                {% for config in sla_configs %}
                <tr class="hover:bg-light/30 transition">
                    <td class="px-5 py-4">
                        {% if config.source_type %}
                        <span class="px-2 py-1 rounded-lg text-xs font-bold bg-blue-100 text-blue-600">{{ config.get_source_type_display }}</span>
                        {% else %}
                        <span class="px-2 py-1 rounded-lg text-xs font-bold bg-slate-100 text-slate-600">{% trans "Default" %}</span>
                        {% endif %}
                    </td>
                    <td class="px-5 py-4">
                        {% if config.hospital %}
                        <span class="text-slate-800 text-xs">{{ config.hospital.get_localized_name }}</span>
                        {% else %}
                        <span class="px-2 py-1 rounded-lg text-xs font-bold bg-slate-100 text-slate-600">{% trans "All Hospitals" %}</span>
                        {% endif %}
                    </td>
                    <td class="px-5 py-4">
                        <span class="px-2 py-1 rounded-lg text-xs font-bold bg-yellow-100 text-yellow-700">{{ config.acknowledgement_hours }}h</span>
                    </td>
                    <td class="px-5 py-4">
                        <span class="px-2 py-1 rounded-lg text-xs font-bold bg-red-100 text-red-600">{{ config.resolution_hours }}h</span>
                    </td>
                    <td class="px-5 py-4">
                        <span class="px-2 py-1 rounded-lg text-xs font-bold bg-orange-100 text-orange-600">{{ config.escalation_hours }}h</span>
                    </td>
                    <td class="px-5 py-4">
                        {% if config.is_active %}
                        <span class="px-2 py-1 rounded-lg text-xs font-bold bg-green-100 text-green-600">{% trans "Active" %}</span>
                        {% else %}
                        <span class="px-2 py-1 rounded-lg text-xs font-bold bg-slate-100 text-slate-500">{% trans "Inactive" %}</span>
                        {% endif %}
                    </td>
                </tr>
                {% empty %}
                <tr>
                    <td colspan="6" class="px-5 py-12 text-center">
                        <div class="w-16 h-16 mx-auto mb-3 bg-slate-100 rounded-2xl flex items-center justify-center">
                            <i data-lucide="clock" class="w-8 h-8 text-slate-300"></i>
                        </div>
                        <p class="text-slate font-medium">{% trans "No SLA configurations found" %}</p>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}