{% extends 'layouts/public_base.html' %}
{% load i18n %}

{% block title %}{% trans "Submit Complaint" %} - PX360{% endblock %}

{% block extra_css %}
<style>
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.025em;
}
.type-badge.ed { background: #fef3c7; color: #92400e; }
.type-badge.ip { background: #dbeafe; color: #1e40af; }
.type-badge.op { background: #d1fae5; color: #065f46; }
.type-badge.daycase { background: #f3e8ff; color: #6b21a8; }
.type-badge.appointment { background: #fce7f3; color: #9d174d; }
</style>
{% endblock %}

{% block content %}
<div class="max-w-2xl mx-auto px-4 py-8 md:py-12">
    <a href="/" class="inline-flex items-center gap-2 text-navy/70 hover:text-navy mb-6 transition-all font-medium group">
        <div class="p-2 rounded-full group-hover:bg-navy/5 transition-colors">
            <i data-lucide="arrow-left" class="w-5 h-5 group-hover:-translate-x-1 transition-transform"></i>
        </div>
        {% trans "Home" %}
    </a>

    <!-- Header Card -->
    <div class="glass-card rounded-2xl shadow-xl overflow-hidden mb-8 animate-fade-in">
        <div class="bg-gradient-to-r from-navy to-blue p-8 text-white text-center">
            <div class="w-16 h-16 bg-white/20 rounded-2xl flex items-center justify-center mx-auto mb-4 shadow-lg">
                <i data-lucide="message-circle" class="w-8 h-8"></i>
            </div>
            <h1 class="text-2xl font-bold mb-2">{% trans "Submit a Complaint" %}</h1>
            <p class="text-blue-100 text-sm max-w-md mx-auto">{% trans "We're sorry to hear about your experience. Please select the hospital where the incident occurred." %}</p>
        </div>
        <div class="p-6">
            <div class="flex items-center gap-3">
                <div class="w-10 h-10 bg-navy/10 rounded-xl flex items-center justify-center">
                    <i data-lucide="user" class="w-5 h-5 text-navy"></i>
                </div>
                <div>
                    <p class="text-xs text-slate font-semibold uppercase tracking-wider">{% trans "Patient" %}</p>
                    <p class="font-bold text-gray-800">{{ patient.get_full_name }}</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Hospital Selection -->
    <div class="space-y-3 animate-slide-up" style="animation-delay: 0.1s">
        <h2 class="text-lg font-bold text-gray-800 mb-4 flex items-center gap-2">
            <i data-lucide="building-2" class="w-5 h-5 text-navy"></i>
            {% trans "Select Hospital" %}
        </h2>

        {% if hospitals %}
            {% for h in hospitals %}
            <a href="{% url 'complaints:patient_complaint_hospital_visits' session.token h.hospital__id %}"
               class="glass-card block p-5 rounded-2xl border border-white/50 hover:border-navy hover:shadow-xl transition-all duration-300 group -translate-y-0 hover:-translate-y-0.5">
                <div class="flex items-center justify-between">
                    <div class="flex items-center gap-4">
                        <div class="w-12 h-12 bg-navy/10 rounded-xl flex items-center justify-center group-hover:bg-navy/20 transition-colors">
                            <i data-lucide="building-2" class="w-6 h-6 text-navy"></i>
                        </div>
                        <div>
                            <h3 class="font-bold text-gray-800 group-hover:text-navy transition">{{ h.hospital__name }}</h3>
                            {% if h.hospital__name_ar %}
                            <p class="text-sm text-slate" dir="rtl">{{ h.hospital__name_ar }}</p>
                            {% endif %}
                        </div>
                    </div>
                    <div class="flex items-center gap-3">
                        <span class="inline-flex items-center gap-1.5 px-3 py-1.5 bg-navy/10 text-navy text-sm font-bold rounded-lg">
                            {{ h.visit_count }}
                            <span class="text-xs font-medium text-navy/70">{% trans "visits" %}</span>
                        </span>
                        <i data-lucide="chevron-right" class="w-5 h-5 text-slate-300 group-hover:text-navy group-hover:translate-x-1 transition-all"></i>
                    </div>
                </div>
            </a>
            {% endfor %}
        {% else %}
            <div class="glass-card rounded-2xl p-12 text-center">
                <div class="w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4">
                    <i data-lucide="building" class="w-8 h-8 text-slate-300"></i>
                </div>
                <p class="text-slate font-medium">{% trans "No visits found for this patient" %}</p>
            </div>
        {% endif %}
    </div>
</div>
{% endblock %}

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