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

{% block title %}{% trans "Delete Source User" %} - {{ source.get_localized_name }}{% endblock %}

{% block content %}
<div class="p-6">
    <!-- Breadcrumb -->
    <nav class="mb-4">
        <ol class="flex items-center gap-2 text-sm text-slate">
            <li><a href="{% url 'px_sources:source_list' %}" class="text-blue hover:text-navy">{% trans "PX Sources" %}</a></li>
            <li><i data-lucide="chevron-right" class="w-4 h-4"></i></li>
            <li><a href="{% url 'px_sources:source_detail' source.pk %}" class="text-blue hover:text-navy">{{ source.get_localized_name }}</a></li>
            <li><i data-lucide="chevron-right" class="w-4 h-4"></i></li>
            <li class="text-navy font-semibold">{% trans "Delete Source User" %}</li>
        </ol>
    </nav>

    <!-- Page Header -->
    <div class="flex flex-wrap justify-between items-center gap-4 mb-6">
        <div>
            <h1 class="text-2xl font-bold text-navy flex items-center gap-3">
                <i data-lucide="alert-triangle" class="w-8 h-8 text-red-500"></i>
                {% trans "Delete Source User" %}
            </h1>
            <p class="text-slate mt-1">{{ source.get_localized_name }}</p>
        </div>
        <div>
            <a href="{% url 'px_sources:source_detail' source.pk %}" 
               class="inline-flex items-center gap-2 px-4 py-2 border border-slate-200 text-slate-700 rounded-lg hover:bg-slate-50 transition">
                <i data-lucide="arrow-left" class="w-4 h-4"></i> {% trans "Back to Source" %}
            </a>
        </div>
    </div>

    <!-- Confirmation Card -->
    <div class="bg-white rounded-xl shadow-sm border border-red-200">
        <div class="p-4 border-b border-red-200 bg-red-500 rounded-t-xl">
            <h2 class="text-lg font-semibold text-white flex items-center gap-2">
                <i data-lucide="alert-triangle" class="w-5 h-5"></i>
                {% trans "Confirm Deletion" %}
            </h2>
        </div>
        <div class="p-6">
            <!-- Warning Alert -->
            <div class="bg-red-50 border border-red-200 rounded-lg p-4 mb-6">
                <div class="flex items-center gap-3">
                    <i data-lucide="alert-triangle" class="w-5 h-5 text-red-600"></i>
                    <strong class="text-red-800">{% trans "Warning:" %}</strong>
                    <span class="text-red-700">{% trans "This action cannot be undone!" %}</span>
                </div>
            </div>

            <!-- User Details -->
            <div class="mb-6">
                <p class="text-navy mb-4">{% trans "Are you sure you want to remove the following source user?" %}</p>
                
                <div class="bg-slate-50 rounded-xl border border-slate-200 p-4">
                    <dl class="space-y-3 mb-0">
                        <div class="flex">
                            <dt class="w-32 text-sm font-semibold text-navy">{% trans "User" %}:</dt>
                            <dd class="flex-1">
                                <strong class="text-navy">{{ source_user.user.email }}</strong>
                                {% if source_user.user.get_full_name %}
                                    <br><small class="text-slate">{{ source_user.user.get_full_name }}</small>
                                {% endif %}
                            </dd>
                        </div>
                        
                        <div class="flex">
                            <dt class="w-32 text-sm font-semibold text-navy">{% trans "Source" %}:</dt>
                            <dd class="flex-1 text-navy">{{ source.get_localized_name }}</dd>
                        </div>
                        
                        <div class="flex">
                            <dt class="w-32 text-sm font-semibold text-navy">{% trans "Status" %}:</dt>
                            <dd class="flex-1">
                                {% if source_user.is_active %}
                                    <span class="inline-flex items-center gap-1 px-2.5 py-1 bg-green-100 text-green-700 rounded-full text-xs font-semibold">
                                        <i data-lucide="check-circle" class="w-3 h-3"></i>
                                        {% trans "Active" %}
                                    </span>
                                {% else %}
                                    <span class="inline-flex items-center gap-1 px-2.5 py-1 bg-slate-100 text-slate-600 rounded-full text-xs font-semibold">
                                        <i data-lucide="x-circle" class="w-3 h-3"></i>
                                        {% trans "Inactive" %}
                                    </span>
                                {% endif %}
                            </dd>
                        </div>
                        
                        <div class="flex">
                            <dt class="w-32 text-sm font-semibold text-navy">{% trans "Permissions" %}:</dt>
                            <dd class="flex-1">
                                {% if source_user.can_create_complaints %}
                                    <span class="inline-flex items-center px-2 py-1 bg-blue-100 text-blue-700 rounded text-xs font-medium mr-1">{% trans "Complaints" %}</span>
                                {% endif %}
                                {% if source_user.can_create_inquiries %}
                                    <span class="inline-flex items-center px-2 py-1 bg-cyan-100 text-cyan-700 rounded text-xs font-medium">{% trans "Inquiries" %}</span>
                                {% endif %}
                                {% if not source_user.can_create_complaints and not source_user.can_create_inquiries %}
                                    <span class="text-slate text-sm">{% trans "None" %}</span>
                                {% endif %}
                            </dd>
                        </div>
                    </dl>
                </div>
            </div>

            <!-- Info Alert -->
            <div class="bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6">
                <div class="flex items-center gap-3">
                    <i data-lucide="info" class="w-5 h-5 text-blue-600"></i>
                    <span class="text-blue-700 text-sm">{% trans "The user will lose access to the source dashboard and will not be able to create complaints or inquiries from this source." %}</span>
                </div>
            </div>

            <!-- Action Buttons -->
            <form method="POST" novalidate>
                {% csrf_token %}
                
                <div class="flex gap-3">
                    <button type="submit" 
                            class="inline-flex items-center gap-2 px-6 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600 transition shadow-lg shadow-red-500/20">
                        <i data-lucide="trash-2" class="w-4 h-4"></i> {% trans "Yes, Delete" %}
                    </button>
                    <a href="{% url 'px_sources:source_detail' source.pk %}" 
                       class="inline-flex items-center gap-2 px-6 py-2 border border-slate-200 text-slate-700 rounded-lg hover:bg-slate-50 transition">
                        <i data-lucide="x" class="w-4 h-4"></i> {% trans "Cancel" %}
                    </a>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function() {
    lucide.createIcons();
});
</script>
{% endblock %}
