{% extends "superadmin/base_superadmin.html" %}

{% block title %}Backup & Export - Superadmin{% endblock %}

{% block content %}
<div class="space-y-6">
    <!-- Page Header -->
    <div class="border-b border-gray-200 pb-4">
        <h1 class="text-2xl font-bold text-gray-900">Backup & Export</h1>
        <p class="text-gray-600 mt-1">Data backup and export management</p>
    </div>

    <!-- System Statistics -->
    <div class="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-6 gap-4">
        <div class="bg-white overflow-hidden shadow rounded-lg border-l-4 border-blue-500">
            <div class="p-4">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-users text-2xl text-blue-600"></i>
                    </div>
                    <div class="ml-3">
                        <p class="text-sm font-medium text-gray-500">Members</p>
                        <p class="text-lg font-bold text-blue-600">{{ db_stats.members }}</p>
                    </div>
                </div>
            </div>
        </div>

        <div class="bg-white overflow-hidden shadow rounded-lg border-l-4 border-green-500">
            <div class="p-4">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-building text-2xl text-green-600"></i>
                    </div>
                    <div class="ml-3">
                        <p class="text-sm font-medium text-gray-500">Groups</p>
                        <p class="text-lg font-bold text-green-600">{{ db_stats.groups }}</p>
                    </div>
                </div>
            </div>
        </div>

        <div class="bg-white overflow-hidden shadow rounded-lg border-l-4 border-purple-500">
            <div class="p-4">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-coins text-2xl text-purple-600"></i>
                    </div>
                    <div class="ml-3">
                        <p class="text-sm font-medium text-gray-500">Contributions</p>
                        <p class="text-lg font-bold text-purple-600">{{ db_stats.contributions }}</p>
                    </div>
                </div>
            </div>
        </div>

        <div class="bg-white overflow-hidden shadow rounded-lg border-l-4 border-orange-500">
            <div class="p-4">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-calendar-alt text-2xl text-orange-600"></i>
                    </div>
                    <div class="ml-3">
                        <p class="text-sm font-medium text-gray-500">Events</p>
                        <p class="text-lg font-bold text-orange-600">{{ db_stats.events }}</p>
                    </div>
                </div>
            </div>
        </div>

        <div class="bg-white overflow-hidden shadow rounded-lg border-l-4 border-red-500">
            <div class="p-4">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-hand-holding-usd text-2xl text-red-600"></i>
                    </div>
                    <div class="ml-3">
                        <p class="text-sm font-medium text-gray-500">Loan Requests</p>
                        <p class="text-lg font-bold text-red-600">{{ db_stats.loan_requests }}</p>
                    </div>
                </div>
            </div>
        </div>

        <div class="bg-white overflow-hidden shadow rounded-lg border-l-4 border-indigo-500">
            <div class="p-4">
                <div class="flex items-center">
                    <div class="flex-shrink-0">
                        <i class="fas fa-clipboard-list text-2xl text-indigo-600"></i>
                    </div>
                    <div class="ml-3">
                        <p class="text-sm font-medium text-gray-500">Requests</p>
                        <p class="text-lg font-bold text-indigo-600">{{ db_stats.contribution_requests }}</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Backup Actions -->
    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
        <!-- Database Backup -->
        <div class="bg-white shadow rounded-lg">
            <div class="px-6 py-4 border-b border-gray-200">
                <h3 class="text-lg font-medium text-gray-900">
                    <i class="fas fa-database text-blue-600 mr-2"></i>Database Backup
                </h3>
            </div>
            <div class="p-6">
                <div class="space-y-4">
                    <div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
                        <div class="flex items-center">
                            <i class="fas fa-info-circle text-blue-600 mr-3"></i>
                            <div>
                                <h4 class="text-sm font-medium text-blue-900">Full Database Backup</h4>
                                <p class="text-sm text-blue-700 mt-1">Export complete database with all tables and data</p>
                            </div>
                        </div>
                    </div>
                    
                    <button class="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
                        <i class="fas fa-download mr-2"></i>Export Full Database
                    </button>
                    
                    <div class="border-t pt-4">
                        <h4 class="text-sm font-medium text-gray-900 mb-3">Quick Export Options</h4>
                        <div class="grid grid-cols-2 gap-3">
                            <button class="bg-gray-100 hover:bg-gray-200 text-gray-800 font-medium py-2 px-3 rounded text-sm transition-colors">
                                <i class="fas fa-users mr-1"></i>Members
                            </button>
                            <button class="bg-gray-100 hover:bg-gray-200 text-gray-800 font-medium py-2 px-3 rounded text-sm transition-colors">
                                <i class="fas fa-building mr-1"></i>Groups
                            </button>
                            <button class="bg-gray-100 hover:bg-gray-200 text-gray-800 font-medium py-2 px-3 rounded text-sm transition-colors">
                                <i class="fas fa-coins mr-1"></i>Contributions
                            </button>
                            <button class="bg-gray-100 hover:bg-gray-200 text-gray-800 font-medium py-2 px-3 rounded text-sm transition-colors">
                                <i class="fas fa-hand-holding-usd mr-1"></i>Loans
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Report Generation -->
        <div class="bg-white shadow rounded-lg">
            <div class="px-6 py-4 border-b border-gray-200">
                <h3 class="text-lg font-medium text-gray-900">
                    <i class="fas fa-file-alt text-green-600 mr-2"></i>Report Generation
                </h3>
            </div>
            <div class="p-6">
                <div class="space-y-4">
                    <div class="bg-green-50 border border-green-200 rounded-lg p-4">
                        <div class="flex items-center">
                            <i class="fas fa-chart-bar text-green-600 mr-3"></i>
                            <div>
                                <h4 class="text-sm font-medium text-green-900">Financial Reports</h4>
                                <p class="text-sm text-green-700 mt-1">Generate comprehensive financial summaries</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="space-y-3">
                        <button class="w-full bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
                            <i class="fas fa-chart-line mr-2"></i>Financial Summary Report
                        </button>
                        
                        <button class="w-full bg-purple-600 hover:bg-purple-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
                            <i class="fas fa-users mr-2"></i>Member Activity Report
                        </button>
                        
                        <button class="w-full bg-orange-600 hover:bg-orange-700 text-white font-medium py-2 px-4 rounded-lg transition-colors">
                            <i class="fas fa-building mr-2"></i>Group Performance Report
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Backup Schedule -->
    <div class="bg-white shadow rounded-lg">
        <div class="px-6 py-4 border-b border-gray-200">
            <h3 class="text-lg font-medium text-gray-900">
                <i class="fas fa-clock text-purple-600 mr-2"></i>Backup Schedule
            </h3>
        </div>
        <div class="p-6">
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                <div class="text-center p-4 bg-gray-50 rounded-lg">
                    <div class="w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-3">
                        <i class="fas fa-calendar-day text-2xl text-blue-600"></i>
                    </div>
                    <h4 class="text-sm font-medium text-gray-900">Daily Backup</h4>
                    <p class="text-xs text-gray-500 mt-1">Last: Today 2:00 AM</p>
                    <p class="text-xs text-green-600 mt-1">Status: Completed</p>
                </div>
                
                <div class="text-center p-4 bg-gray-50 rounded-lg">
                    <div class="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-3">
                        <i class="fas fa-calendar-week text-2xl text-green-600"></i>
                    </div>
                    <h4 class="text-sm font-medium text-gray-900">Weekly Backup</h4>
                    <p class="text-xs text-gray-500 mt-1">Last: Sunday 3:00 AM</p>
                    <p class="text-xs text-green-600 mt-1">Status: Completed</p>
                </div>
                
                <div class="text-center p-4 bg-gray-50 rounded-lg">
                    <div class="w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-3">
                        <i class="fas fa-calendar-alt text-2xl text-purple-600"></i>
                    </div>
                    <h4 class="text-sm font-medium text-gray-900">Monthly Backup</h4>
                    <p class="text-xs text-gray-500 mt-1">Last: 1st of Month</p>
                    <p class="text-xs text-green-600 mt-1">Status: Completed</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Export Notice -->
    <div class="bg-yellow-50 border border-yellow-200 rounded-lg p-4">
        <div class="flex items-center">
            <i class="fas fa-exclamation-triangle text-yellow-600 mr-3"></i>
            <div>
                <h4 class="text-sm font-medium text-yellow-900">Export Notice</h4>
                <p class="text-sm text-yellow-700 mt-1">
                    All exported data contains sensitive information. Please ensure proper security measures when handling backup files.
                    Regular backups are recommended for data protection.
                </p>
            </div>
        </div>
    </div>
</div>
{% endblock %}