<!-- Path: app/Views/admin/dashboard.view.php -->
<div class="bg-slate-50 min-h-[calc(100vh-64px)] py-8">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        
        <div class="mb-8 flex justify-between items-center">
            <div>
                <h1 class="text-3xl font-bold text-navy-900"><i class="fas fa-shield-alt text-brandBlue-500 mr-2"></i> Command Center</h1>
                <p class="text-slate-600 mt-1">Live overview of the Emergency Response Coordination System.</p>
            </div>
            <a href="{{APP_URL}}/admin/incidents/pending" class="bg-alert hover:bg-red-600 text-white px-5 py-2.5 rounded-lg font-bold shadow-md transition-colors pulse-animation">
                <i class="fas fa-exclamation-circle mr-2"></i> View Pending Dispatches
            </a>
        </div>

        <!-- Stats Row -->
        <div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
            <div class="bg-white rounded-xl shadow-sm border border-slate-200 p-6 flex items-center gap-4">
                <div class="w-12 h-12 rounded-full bg-blue-100 text-blue-600 flex items-center justify-center text-xl"><i class="fas fa-clipboard-list"></i></div>
                <div>
                    <div class="text-sm text-slate-500 font-medium">Total Incidents</div>
                    <div class="text-2xl font-bold text-navy-900">{{ $stats['total_incidents'] }}</div>
                </div>
            </div>
            <div class="bg-white rounded-xl shadow-sm border border-slate-200 p-6 flex items-center gap-4">
                <div class="w-12 h-12 rounded-full bg-yellow-100 text-yellow-600 flex items-center justify-center text-xl"><i class="fas fa-clock"></i></div>
                <div>
                    <div class="text-sm text-slate-500 font-medium">Pending Action</div>
                    <div class="text-2xl font-bold text-navy-900">{{ $stats['pending_incidents'] }}</div>
                </div>
            </div>
            <div class="bg-white rounded-xl shadow-sm border border-slate-200 p-6 flex items-center gap-4">
                <div class="w-12 h-12 rounded-full bg-green-100 text-green-600 flex items-center justify-center text-xl"><i class="fas fa-ambulance"></i></div>
                <div>
                    <div class="text-sm text-slate-500 font-medium">Active Responders</div>
                    <div class="text-2xl font-bold text-navy-900">{{ $stats['active_responders'] }}</div>
                </div>
            </div>
            <div class="bg-white rounded-xl shadow-sm border border-slate-200 p-6 flex items-center gap-4">
                <div class="w-12 h-12 rounded-full bg-purple-100 text-purple-600 flex items-center justify-center text-xl"><i class="fas fa-users"></i></div>
                <div>
                    <div class="text-sm text-slate-500 font-medium">Total Users</div>
                    <div class="text-2xl font-bold text-navy-900">{{ $stats['total_users'] }}</div>
                </div>
            </div>
        </div>

        <!-- Recent Incidents -->
        <div class="bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden">
            <div class="p-6 border-b border-slate-200 flex justify-between items-center bg-slate-50">
                <h3 class="font-bold text-navy-900 text-lg">Recent Alerts Needing Attention</h3>
            </div>
            <div class="overflow-x-auto">
                <table class="w-full text-left border-collapse">
                    <thead>
                        <tr class="bg-white text-slate-500 text-sm uppercase tracking-wider border-b border-slate-200">
                            <th class="p-4 font-semibold">ID</th>
                            <th class="p-4 font-semibold">Time</th>
                            <th class="p-4 font-semibold">Victim</th>
                            <th class="p-4 font-semibold">Category</th>
                            <th class="p-4 font-semibold">Status</th>
                            <th class="p-4 font-semibold text-right">Action</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-slate-100 text-sm">
                        @if(empty($recentIncidents))
                            <tr><td colspan="6" class="p-8 text-center text-slate-500">No active incidents at this time.</td></tr>
                        @else
                            @foreach($recentIncidents as $incident)
                                <tr class="hover:bg-slate-50 transition-colors">
                                    <td class="p-4 font-mono font-medium text-navy-900">#{{ str_pad($incident['id'], 5, '0', STR_PAD_LEFT) }}</td>
                                    <td class="p-4 text-slate-600">{{ date('h:i A - M d', strtotime($incident['created_at'])) }}</td>
                                    <td class="p-4 font-medium">{{ $incident['victim_name'] }}</td>
                                    <td class="p-4">{{ $incident['category_name'] }}</td>
                                    <td class="p-4">
                                        <span class="bg-yellow-100 text-yellow-800 text-xs px-2 py-1 rounded-full font-semibold">{{ ucfirst($incident['status']) }}</span>
                                    </td>
                                    <td class="p-4 text-right">
                                        <a href="{{APP_URL}}/admin/incidents/{{ $incident['id'] }}" class="text-white bg-navy-900 hover:bg-navy-800 px-3 py-1.5 rounded transition-colors text-xs font-bold">Review</a>
                                    </td>
                                </tr>
                            @endforeach
                        @endif
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>