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

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

{% block content %}
<div class="container-fluid">
    <!-- Page Header -->
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb mb-2">
                    <li class="breadcrumb-item">
                        <a href="{% url 'px_sources:source_list' %}">{% trans "PX Sources" %}</a>
                    </li>
                    <li class="breadcrumb-item">
                        <a href="{% url 'px_sources:source_detail' source.pk %}">{{ source.name_en }}</a>
                    </li>
                    <li class="breadcrumb-item active" aria-current="page">
                        {% trans "Delete Source User" %}
                    </li>
                </ol>
            </nav>
            <h2 class="mb-1">
                <i class="bi bi-exclamation-triangle text-danger me-2"></i>
                {% trans "Delete Source User" %}
            </h2>
            <p class="text-muted mb-0">
                {{ source.name_en }}
            </p>
        </div>
        <div>
            <a href="{% url 'px_sources:source_detail' source.pk %}" class="btn btn-outline-secondary">
                <i class="bi bi-arrow-left me-1"></i> {% trans "Back to Source" %}
            </a>
        </div>
    </div>

    <!-- Confirmation Card -->
    <div class="row">
        <div class="col-12">
            <div class="card border-danger">
                <div class="card-header bg-danger text-white">
                    <h5 class="card-title mb-0">
                        <i class="bi bi-exclamation-triangle me-2"></i>
                        {% trans "Confirm Deletion" %}
                    </h5>
                </div>
                <div class="card-body">
                    <div class="alert alert-danger">
                        <i class="bi bi-exclamation-triangle-fill me-2"></i>
                        <strong>{% trans "Warning:" %}</strong> {% trans "This action cannot be undone!" %}
                    </div>

                    <div class="mb-4">
                        <p>{% trans "Are you sure you want to remove the following source user?" %}</p>
                        
                        <div class="card bg-light">
                            <div class="card-body">
                                <dl class="row mb-0">
                                    <dt class="col-sm-3">{% trans "User" %}:</dt>
                                    <dd class="col-sm-9">
                                        <strong>{{ source_user.user.email }}</strong>
                                        {% if source_user.user.get_full_name %}
                                            <br><small class="text-muted">{{ source_user.user.get_full_name }}</small>
                                        {% endif %}
                                    </dd>
                                    
                                    <dt class="col-sm-3">{% trans "Source" %}:</dt>
                                    <dd class="col-sm-9">{{ source.name_en }}</dd>
                                    
                                    <dt class="col-sm-3">{% trans "Status" %}:</dt>
                                    <dd class="col-sm-9">
                                        {% if source_user.is_active %}
                                            <span class="badge bg-success">{% trans "Active" %}</span>
                                        {% else %}
                                            <span class="badge bg-secondary">{% trans "Inactive" %}</span>
                                        {% endif %}
                                    </dd>
                                    
                                    <dt class="col-sm-3">{% trans "Permissions" %}:</dt>
                                    <dd class="col-sm-9">
                                        {% if source_user.can_create_complaints %}
                                            <span class="badge bg-primary">{% trans "Complaints" %}</span>
                                        {% endif %}
                                        {% if source_user.can_create_inquiries %}
                                            <span class="badge bg-info">{% trans "Inquiries" %}</span>
                                        {% endif %}
                                        {% if not source_user.can_create_complaints and not source_user.can_create_inquiries %}
                                            <span class="text-muted">{% trans "None" %}</span>
                                        {% endif %}
                                    </dd>
                                </dl>
                            </div>
                        </div>
                    </div>

                    <div class="alert alert-info">
                        <i class="bi bi-info-circle me-2"></i>
                        {% trans "The user will lose access to the source dashboard and will not be able to create complaints or inquiries from this source." %}
                    </div>

                    <form method="POST" novalidate>
                        {% csrf_token %}
                        
                        <div class="d-flex gap-2">
                            <button type="submit" class="btn btn-danger">
                                <i class="bi bi-trash me-1"></i> {% trans "Yes, Delete" %}
                            </button>
                            <a href="{% url 'px_sources:source_detail' source.pk %}" class="btn btn-outline-secondary">
                                <i class="bi bi-x-lg me-1"></i> {% trans "Cancel" %}
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}