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

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

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h2 class="mb-1">
                <i class="bi bi-clock-history text-warning me-2"></i>
                SLA Configurations
            </h2>
            <p class="text-muted mb-0">Manage SLA deadlines for PX actions</p>
        </div>
        <a href="{% url 'config:dashboard' %}" class="btn btn-outline-secondary">
            <i class="bi bi-arrow-left me-1"></i> Back to Config
        </a>
    </div>

    <div class="card">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover mb-0">
                    <thead class="table-light">
                        <tr>
                            <th>{% trans "Name" %}</th>
                            <th>{% trans "Hospital" %}</th>
                            <th>{% trans "Critical (hrs)" %}</th>
                            <th>{% trans "High (hrs)" %}</th>
                            <th>{% trans "Medium (hrs)" %}</th>
                            <th>{% trans "Low (hrs)" %}</th>
                            <th>{% trans "Auto Escalate" %}</th>
                            <th>{% trans "Status" %}</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for config in sla_configs %}
                        <tr>
                            <td><strong>{{ config.name }}</strong></td>
                            <td>
                                {% if config.hospital %}
                                <small>{{ config.hospital.name_en }}</small>
                                {% else %}
                                <span class="badge bg-primary">Global</span>
                                {% endif %}
                            </td>
                            <td><span class="badge bg-danger">{{ config.critical_hours }}</span></td>
                            <td><span class="badge bg-warning">{{ config.high_hours }}</span></td>
                            <td><span class="badge bg-info">{{ config.medium_hours }}</span></td>
                            <td><span class="badge bg-secondary">{{ config.low_hours }}</span></td>
                            <td>
                                {% if config.auto_escalate %}
                                <i class="bi bi-check-circle text-success"></i>
                                {% else %}
                                <i class="bi bi-x-circle text-muted"></i>
                                {% endif %}
                            </td>
                            <td>
                                {% if config.is_active %}
                                <span class="badge bg-success">Active</span>
                                {% else %}
                                <span class="badge bg-secondary">Inactive</span>
                                {% endif %}
                            </td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="8" class="text-center py-5">
                                <i class="bi bi-clock-history" style="font-size: 3rem; color: #ccc;"></i>
                                <p class="text-muted mt-3">No SLA configurations found</p>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}
