<x-layouts.admin title="Admin Dashboard | {{ config('app.name') }}" activePage="admin-dashboard">
<!-- Summary Stats -->
<section class="grid grid-cols-1 md:grid-cols-4 gap-8 mb-12">
    <div class="bg-surface-container-lowest p-8 border-l-4 border-primary">
        <p class="text-xs font-label uppercase tracking-widest text-on-surface-variant mb-2">Total Managed Users</p>
        <h3 class="font-serif text-4xl text-on-surface">{{ number_format($totalUsers) }}</h3>
        <p class="text-xs text-secondary mt-2 font-medium">{{ $pendingVerifications }} pending verification</p>
    </div>
    <div class="bg-surface-container-lowest p-8 border-l-4 border-secondary">
        <p class="text-xs font-label uppercase tracking-widest text-on-surface-variant mb-2">Transaction Volume</p>
        <h3 class="font-serif text-4xl text-on-surface">${{ number_format($transactionVolume, 0) }}</h3>
        <p class="text-xs text-secondary mt-2 font-medium">All-time total</p>
    </div>
    <div class="bg-surface-container-lowest p-8 border-l-4 border-on-surface">
        <p class="text-xs font-label uppercase tracking-widest text-on-surface-variant mb-2">Active Accounts</p>
        <h3 class="font-serif text-4xl text-on-surface">{{ number_format($activeAccounts) }}</h3>
        <p class="text-xs text-primary mt-2 font-medium">Verified accounts</p>
    </div>
    <div class="bg-surface-container-lowest p-8 border-l-4 border-outline-variant">
        <p class="text-xs font-label uppercase tracking-widest text-on-surface-variant mb-2">Pending Requests</p>
        <h3 class="font-serif text-4xl text-on-surface">{{ $pendingDeposits + $pendingWithdrawals }}</h3>
        <p class="text-xs text-primary mt-2 font-medium">{{ $pendingDeposits }} deposits / {{ $pendingWithdrawals }} withdrawals</p>
    </div>
</section>

<!-- Quick Actions & Recent Transactions -->
<div class="grid grid-cols-12 gap-8">
    <!-- Recent Transactions -->
    <section class="col-span-12 lg:col-span-8 space-y-6">
        <div class="flex justify-between items-end">
            <div>
                <h2 class="font-serif text-3xl text-on-surface">Transaction Oversight</h2>
                <p class="text-on-surface-variant text-sm mt-1">Live activity monitoring</p>
            </div>
            <a href="{{ route('admin.transactions') }}" class="text-primary text-xs font-bold uppercase tracking-widest">View All</a>
        </div>
        <div class="bg-surface-container-lowest overflow-x-auto">
            <table class="w-full text-left border-collapse min-w-[600px]">
                <thead>
                    <tr class="bg-surface-container-low text-on-surface-variant uppercase text-[10px] tracking-widest font-bold">
                        <th class="px-6 py-4">Timestamp</th>
                        <th class="px-6 py-4">User</th>
                        <th class="px-6 py-4">Amount</th>
                        <th class="px-6 py-4">Type</th>
                        <th class="px-6 py-4">Status</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-surface-container">
                    @foreach($recentTransactions as $txn)
                    <tr class="hover:bg-surface-container-low transition-colors">
                        <td class="px-6 py-4 text-xs font-mono">{{ $txn->created_at->format('H:i:s') }}</td>
                        <td class="px-6 py-4">
                            <div class="text-sm font-semibold">{{ $txn->account?->user?->first_name }} {{ $txn->account?->user?->last_name }}</div>
                            <div class="text-[10px] text-on-surface-variant">{{ $txn->account?->account_number }}</div>
                        </td>
                        <td class="px-6 py-4 font-serif {{ $txn->type->value === 'credit' ? 'text-primary' : 'text-on-surface' }} font-semibold">{{ $txn->account?->currency?->symbol() ?? '$' }}{{ number_format($txn->amount, 2) }}</td>
                        <td class="px-6 py-4">
                            <span class="text-[10px] font-bold uppercase {{ $txn->type->value === 'credit' ? 'text-secondary' : 'text-on-surface-variant' }}">{{ $txn->type->value }}</span>
                        </td>
                        <td class="px-6 py-4">
                            <span class="inline-flex items-center px-2 py-1 rounded-full text-[10px] font-bold uppercase tracking-tighter
                                @if($txn->status->value === 'completed') bg-secondary-container text-secondary
                                @elseif($txn->status->value === 'pending') bg-surface-container-highest text-on-surface-variant
                                @elseif($txn->status->value === 'failed') bg-error-container text-on-error-container
                                @else bg-surface-container text-on-surface-variant @endif
                            ">{{ $txn->status->value }}</span>
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </section>

    <!-- Quick Navigation -->
    <section class="col-span-12 lg:col-span-4 space-y-6">
        <h2 class="font-serif text-3xl text-on-surface">Quick Actions</h2>
        <div class="bg-surface-container-lowest p-8 space-y-6 shadow-sm">
            <a href="{{ route('admin.users.index') }}" class="flex items-center gap-4 p-4 hover:bg-surface-container-high transition-colors rounded-sm group">
                <span class="material-symbols-outlined text-secondary">group</span>
                <div>
                    <h4 class="font-label text-sm font-bold text-on-surface group-hover:text-primary">Manage Users</h4>
                    <p class="text-xs text-on-surface-variant">View, edit and manage user accounts</p>
                </div>
            </a>
            <a href="{{ route('admin.deposits') }}" class="flex items-center gap-4 p-4 hover:bg-surface-container-high transition-colors rounded-sm group">
                <span class="material-symbols-outlined text-secondary">savings</span>
                <div>
                    <h4 class="font-label text-sm font-bold text-on-surface group-hover:text-primary">Review Deposits</h4>
                    <p class="text-xs text-on-surface-variant">{{ $pendingDeposits }} pending approval</p>
                </div>
            </a>
            <a href="{{ route('admin.withdrawals') }}" class="flex items-center gap-4 p-4 hover:bg-surface-container-high transition-colors rounded-sm group">
                <span class="material-symbols-outlined text-secondary">account_balance_wallet</span>
                <div>
                    <h4 class="font-label text-sm font-bold text-on-surface group-hover:text-primary">Review Withdrawals</h4>
                    <p class="text-xs text-on-surface-variant">{{ $pendingWithdrawals }} pending approval</p>
                </div>
            </a>
            <a href="{{ route('admin.settings') }}" class="flex items-center gap-4 p-4 hover:bg-surface-container-high transition-colors rounded-sm group">
                <span class="material-symbols-outlined text-secondary">settings</span>
                <div>
                    <h4 class="font-label text-sm font-bold text-on-surface group-hover:text-primary">System Settings</h4>
                    <p class="text-xs text-on-surface-variant">OTP, maintenance, thresholds</p>
                </div>
            </a>
        </div>

        <div class="bg-secondary-container p-8 flex flex-col relative overflow-hidden">
            <div class="absolute inset-0 opacity-10 pointer-events-none" style="background-image: radial-gradient(circle at 2px 2px, #765a25 1px, transparent 0); background-size: 20px 20px;"></div>
            <div class="relative z-10">
                <h3 class="font-serif text-2xl text-secondary leading-tight mb-4">System Health</h3>
                <p class="text-sm text-on-secondary-container leading-relaxed">All systems operational. Mainframe is running at full capacity.</p>
                <div class="mt-4 flex items-center gap-2">
                    <span class="h-2 w-2 bg-secondary rounded-full animate-pulse"></span>
                    <span class="text-[10px] font-label font-bold uppercase tracking-widest text-secondary">Online</span>
                </div>
            </div>
        </div>
    </section>
</div>
</x-layouts.admin>
