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

{% block title %}{% trans "Hospitals" %} - PX360{% endblock %}

{% block extra_css %}
<style>
    /* Page Header Gradient */
    .page-header-gradient {
        background: linear-gradient(135deg, #005696 0%, #0069a8 50%, #007bbd 100%);
        color: white;
        padding: 1.5rem 2rem;
        border-radius: 1rem;
        margin-bottom: 1.5rem;
        box-shadow: 0 10px 15px -3px rgba(0, 86, 150, 0.2);
    }

    /* Section Cards */
    .section-card {
        background: white;
        border-radius: 1rem;
        border: 2px solid #e2e8f0;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        transition: all 0.3s ease;
    }
    .section-card:hover {
        border-color: #005696;
        box-shadow: 0 10px 25px -5px rgba(0, 86, 150, 0.15);
    }

    .section-header {
        padding: 1rem 1.5rem;
        border-bottom: 2px solid #e2e8f0;
        background: linear-gradient(to right, #f8fafc, #f1f5f9);
        display: flex;
        align-items: center;
        gap: 0.75rem;
    }

    .section-icon {
        width: 40px;
        height: 40px;
        border-radius: 0.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Stats Cards */
    .stat-card {
        background: white;
        border-radius: 1rem;
        border: 2px solid #e2e8f0;
        padding: 1.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        transition: all 0.3s ease;
    }
    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        border-color: #005696;
    }

    /* Table Row Hover */
    .table-row-hover {
        transition: all 0.2s ease;
        border-left: 3px solid transparent;
    }
    .table-row-hover:hover {
        background: #f8fafc;
        border-left-color: #007bbd;
    }

    /* Status Badge */
    .status-badge {
        display: inline-flex;
        align-items: center;
        padding: 0.375rem 0.75rem;
        border-radius: 9999px;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.025em;
    }
</style>
{% endblock %}

{% block content %}
<div class="p-6">
    <!-- Page Header -->
    <div class="page-header-gradient">
        <div class="flex justify-between items-center">
            <div>
                <h1 class="text-2xl font-bold mb-1">{% trans "Hospitals" %}</h1>
                <p class="text-blue-100 text-sm">{% trans "Manage hospital locations and facilities" %}</p>
            </div>
            <div class="flex gap-2">
                <a href="{% url 'organizations:hospital_create' %}" class="inline-flex items-center px-4 py-2.5 bg-white text-navy font-medium rounded-xl hover:bg-blue-50 transition">
                    <i data-lucide="plus" class="w-4 h-4 me-2"></i>{% trans "Add Hospital" %}
                </a>
            </div>
        </div>
    </div>

    <!-- Statistics Cards -->
    <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6">
        <div class="stat-card">
            <div class="flex items-center">
                <div class="flex-shrink-0">
                    <div class="w-14 h-14 bg-navy/10 rounded-xl flex items-center justify-center">
                        <i data-lucide="building-2" class="w-7 h-7 text-navy"></i>
                    </div>
                </div>
                <div class="ml-4">
                    <h6 class="text-slate-500 text-sm font-medium mb-1">{% trans "Total Hospitals" %}</h6>
                    <h2 class="text-3xl font-bold text-gray-800">{{ hospitals|length }}</h2>
                </div>
            </div>
        </div>
        <div class="stat-card">
            <div class="flex items-center">
                <div class="flex-shrink-0">
                    <div class="w-14 h-14 bg-green-500/10 rounded-xl flex items-center justify-center">
                        <i data-lucide="check-circle" class="w-7 h-7 text-green-600"></i>
                    </div>
                </div>
                <div class="ml-4">
                    <h6 class="text-slate-500 text-sm font-medium mb-1">{% trans "Active" %}</h6>
                    <h2 class="text-3xl font-bold text-gray-800">{{ hospitals|length }}</h2>
                </div>
            </div>
        </div>
        <div class="stat-card">
            <div class="flex items-center">
                <div class="flex-shrink-0">
                    <div class="w-14 h-14 bg-blue-500/10 rounded-xl flex items-center justify-center">
                        <i data-lucide="map-pin" class="w-7 h-7 text-blue"></i>
                    </div>
                </div>
                <div class="ml-4">
                    <h6 class="text-slate-500 text-sm font-medium mb-1">{% trans "Cities" %}</h6>
                    <h2 class="text-3xl font-bold text-gray-800">{{ hospitals|length }}</h2>
                </div>
            </div>
        </div>
    </div>

    <!-- Hospitals Table Section -->
    <div class="section-card">
        <div class="section-header">
            <div class="section-icon bg-navy/10">
                <i data-lucide="hospital" class="w-5 h-5 text-navy"></i>
            </div>
            <h5 class="text-lg font-semibold text-gray-800">{% trans "Hospital List" %}</h5>
        </div>
        <div class="overflow-x-auto">
            <table class="w-full">
                <thead class="bg-gray-50 border-b border-gray-200">
                    <tr>
                        <th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Name" %}</th>
                        <th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Code" %}</th>
                        <th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "City" %}</th>
                        <th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Phone" %}</th>
                        <th class="px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider">{% trans "Status" %}</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-100">
                    {% for hospital in hospitals %}
                    <tr class="table-row-hover">
                        <td class="px-6 py-4">
                            <div class="flex items-center gap-3">
                                <div class="w-10 h-10 bg-blue/10 rounded-lg flex items-center justify-center">
                                    <i data-lucide="hospital" class="w-5 h-5 text-blue"></i>
                                </div>
                                <span class="font-bold text-gray-800">{{ hospital.name }}</span>
                            </div>
                        </td>
                        <td class="px-6 py-4">
                            <span class="text-xs font-mono bg-slate-100 px-2 py-1 rounded">{{ hospital.code }}</span>
                        </td>
                        <td class="px-6 py-4">
                            <div class="flex items-center gap-2 text-gray-600">
                                <i data-lucide="map-pin" class="w-4 h-4 text-slate"></i>
                                {{ hospital.city }}
                            </div>
                        </td>
                        <td class="px-6 py-4">
                            <div class="flex items-center gap-2 text-gray-600">
                                <i data-lucide="phone" class="w-4 h-4 text-slate"></i>
                                {{ hospital.phone }}
                            </div>
                        </td>
                        <td class="px-6 py-4">
                            <span class="status-badge bg-green-100 text-green-700">
                                {{ hospital.get_status_display }}
                            </span>
                        </td>
                    </tr>
                    {% empty %}
                    <tr>
                        <td colspan="5" class="px-6 py-12 text-center">
                            <div class="flex flex-col items-center justify-center">
                                <div class="w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mb-4">
                                    <i data-lucide="hospital" class="w-8 h-8 text-slate-300"></i>
                                </div>
                                <p class="text-slate font-medium mb-2">{% trans "No hospitals found" %}</p>
                                <p class="text-slate text-sm mb-4">{% trans "Add your first hospital to get started" %}</p>
                                <a href="{% url 'organizations:hospital_create' %}" 
                                   class="inline-flex items-center px-4 py-2 bg-navy text-white font-medium rounded-lg hover:bg-blue transition">
                                    <i data-lucide="plus" class="w-4 h-4 me-2"></i>{% trans "Add Hospital" %}
                                </a>
                            </div>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script>
    lucide.createIcons();
</script>
{% endblock %}
