{% extends 'base.html' %}

{% block title %}Confirm Delete Client - HAVEN GRAZURI ADVANCE{% endblock %}

{% block content %}
<div class="min-h-screen bg-gray-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8">
    <div class="sm:mx-auto sm:w-full sm:max-w-md">
        <div class="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
            <div class="text-center">
                <span>⚠️</span>
                <h2 class="text-lg font-medium text-gray-900 mb-4">
                    Client Action Options
                </h2>
                <p class="text-sm text-gray-600 mb-6">
                    Choose an action for <strong>{{ client.get_full_name }}</strong>:
                </p>
                
                <div class="bg-gray-50 p-4 rounded-md mb-6">
                    <h3 class="text-sm font-medium text-gray-900 mb-2">Client Details</h3>
                    <div class="text-sm text-gray-600">
                        <p><strong>Name:</strong> {{ client.get_full_name }}</p>
                        <p><strong>Email:</strong> {{ client.email }}</p>
                        <p><strong>Phone:</strong> {{ client.phone_number }}</p>
                        <p><strong>Status:</strong> <span class="text-green-600">{{ client.get_status_display }}</span></p>
                    </div>
                </div>
                
                {% if dependencies %}
                <div class="bg-blue-50 p-4 rounded-md mb-6">
                    <h3 class="text-sm font-medium text-blue-900 mb-2">
                        <span>ℹ️</span>
                        Related Data Summary
                    </h3>
                    <div class="text-sm text-blue-700 grid grid-cols-2 gap-2">
                        {% if dependencies.loans %}<p><strong>Loans:</strong> {{ dependencies.loans }}</p>{% endif %}
                        {% if dependencies.applications %}<p><strong>Applications:</strong> {{ dependencies.applications }}</p>{% endif %}
                        {% if dependencies.repayments %}<p><strong>Repayments:</strong> {{ dependencies.repayments }}</p>{% endif %}
                        {% if dependencies.offers %}<p><strong>Loan Offers:</strong> {{ dependencies.offers }}</p>{% endif %}
                        {% if dependencies.receipts %}<p><strong>Receipts:</strong> {{ dependencies.receipts }}</p>{% endif %}
                        {% if dependencies.statements %}<p><strong>Statements:</strong> {{ dependencies.statements }}</p>{% endif %}
                        {% if dependencies.documents %}<p><strong>Documents:</strong> {{ dependencies.documents }}</p>{% endif %}
                        {% if dependencies.notifications %}<p><strong>Notifications:</strong> {{ dependencies.notifications }}</p>{% endif %}
                        {% if dependencies.rollover_requests %}<p><strong>Rollover Requests:</strong> {{ dependencies.rollover_requests }}</p>{% endif %}
                        {% if dependencies.scoring_records %}<p><strong>Credit Records:</strong> {{ dependencies.scoring_records }}</p>{% endif %}
                        {% if dependencies.audit_logs %}<p><strong>Audit Logs:</strong> {{ dependencies.audit_logs }}</p>{% endif %}
                    </div>
                    <div class="mt-3 pt-3 border-t border-blue-200">
                        <p class="text-sm font-medium text-blue-900">
                            <strong>Total Related Records:</strong> {{ dependencies.total }}
                        </p>
                    </div>
                </div>
                {% endif %}
                
                {% if error %}
                <div class="bg-red-50 border border-red-200 rounded-md p-4 mb-6">
                    <h3 class="text-sm font-medium text-red-800 mb-2">
                        <span>⚠️</span>
                        Error
                    </h3>
                    <p class="text-sm text-red-700">{{ error }}</p>
                </div>
                {% endif %}
                
                <div class="space-y-4">
                    <!-- Blacklist Option -->
                    <div class="bg-yellow-50 border border-yellow-200 rounded-md p-4">
                        <h3 class="text-sm font-medium text-yellow-800 mb-2">
                            <i class="fas fa-ban text-yellow-600 mr-2"></i>
                            Blacklist Client
                        </h3>
                        <p class="text-sm text-yellow-700 mb-3">
                            Mark the client as blacklisted. They will no longer be able to access the system, but their data will be preserved for audit purposes. This is the <strong>recommended option</strong> for most cases.
                        </p>
                        <form method="post" class="inline">
                            {% csrf_token %}
                            <input type="hidden" name="action" value="blacklist">
                            <button type="submit" 
                                    class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-yellow-600 hover:bg-yellow-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-yellow-500">
                                <i class="fas fa-ban mr-2"></i>
                                Blacklist Client
                            </button>
                        </form>
                    </div>
                    
                    <!-- Permanent Delete Option -->
                    <div class="bg-red-50 border border-red-200 rounded-md p-4">
                        <h3 class="text-sm font-medium text-red-800 mb-2">
                            <i class="fas fa-trash-alt text-red-600 mr-2"></i>
                            Permanently Delete Client
                        </h3>
                        <p class="text-sm text-red-700 mb-3">
                            <strong class="font-semibold">⚠️ WARNING:</strong> This action will permanently delete the client and all their associated data ({{ dependencies.total|default:"unknown number of" }} related records). This action cannot be undone and may take a few moments to complete.
                        </p>
                        <form method="post" class="inline">
                            {% csrf_token %}
                            <input type="hidden" name="action" value="delete">
                            <button type="submit" 
                                    class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"
                                    onclick="return confirm('Are you absolutely sure you want to permanently delete this client? This action cannot be undone.')">
                                <i class="fas fa-trash-alt mr-2"></i>
                                Permanently Delete
                            </button>
                        </form>
                    </div>
                    
                    <!-- Cancel Button -->
                    <div class="text-center pt-4">
                        <a href="{% url 'users:client_list' %}" 
                           class="inline-flex justify-center py-2 px-4 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">
                            <span>✕</span>
                            Cancel
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 