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

{% block title %}{% trans "Select Hospital" %} - PX360{% endblock %}

{% block content %}
<div class="container mt-5">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card shadow">
                <div class="card-header bg-primary text-white">
                    <h4 class="mb-0">
                        <i class="fas fa-hospital me-2"></i>
                        {% trans "Select Hospital" %}
                    </h4>
                </div>
                <div class="card-body">
                    <p class="text-muted mb-4">
                        {% trans "As a PX Admin, you can view and manage data for any hospital. Please select the hospital you want to work with:" %}
                    </p>

                    <form method="post">
                        {% csrf_token %}
                        <input type="hidden" name="next" value="{{ next }}">

                        <div class="list-group mb-4">
                            {% for hospital in hospitals %}
                            <label class="list-group-item list-group-item-action">
                                <input class="form-check-input me-3" type="radio"
                                       name="hospital_id"
                                       value="{{ hospital.id }}"
                                       {% if hospital.id == selected_hospital_id %}checked{% endif %}>

                                <div class="d-flex w-100 justify-content-between">
                                    <h5 class="mb-1">{{ hospital.name }}</h5>
                                    <small class="text-muted">
                                        {% if hospital.id == selected_hospital_id %}
                                        <span class="badge bg-success">
                                            {% trans "Selected" %}
                                        </span>
                                        {% endif %}
                                    </small>
                                </div>
                                {% if hospital.city %}
                                <p class="mb-1 text-muted small">
                                    <i class="fas fa-map-marker-alt me-1"></i>
                                    {{ hospital.city }}
                                    {% if hospital.country %}, {{ hospital.country }}{% endif %}
                                </p>
                                {% endif %}
                            </label>
                            {% empty %}
                            <div class="alert alert-warning">
                                <i class="fas fa-exclamation-triangle me-2"></i>
                                {% trans "No hospitals found in the system." %}
                            </div>
                            {% endfor %}
                        </div>

                        <div class="d-flex justify-content-between">
                            <a href="/" class="btn btn-outline-secondary">
                                <i class="fas fa-arrow-left me-2"></i>
                                {% trans "Back to Dashboard" %}
                            </a>
                            <button type="submit" class="btn btn-primary btn-lg">
                                <i class="fas fa-check me-2"></i>
                                {% trans "Continue" %}
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
