<?php

namespace App\Filament\Admin\Widgets;

use App\Models\Wallet;
use Filament\Widgets\StatsOverviewWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class AdminWalletsOverview extends StatsOverviewWidget
{
     protected function getStats(): array
    {
        $totalBalance = Wallet::sum('balance');
        $activeWallets = Wallet::where('is_active', true)->count();
        $inactiveWallets = Wallet::where('is_active', false)->count();
        $totalWallets = Wallet::count();

        return [
            Stat::make('Total Wallet Balance', number_format($totalBalance, 2) . ' USD')
                ->description('Sum of all user wallets')
                ->descriptionIcon('heroicon-o-banknotes')
                ->color('success'),

            Stat::make('Active Wallets', $activeWallets)
                ->description('Wallets currently active')
                ->descriptionIcon('heroicon-o-check-circle')
                ->color('primary'),

            Stat::make('Inactive Wallets', $inactiveWallets)
                ->description('Disabled wallets')
                ->descriptionIcon('heroicon-o-x-circle')
                ->color('danger'),

            Stat::make('Total Wallets', $totalWallets)
                ->description('All wallets in system')
                ->descriptionIcon('heroicon-o-wallet')
                ->color('gray'),
        ];
    }

}
