<?php

namespace App\Filament\Widgets;

use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
use App\Repositories\EtablissementRepository;

class EtablissementsKPI extends BaseWidget
{
    protected ?string $pollingInterval = '15s';
    
    protected function getStats(): array
    {
        $repository = app(EtablissementRepository::class);
        $stats = $repository->getStatistics();
        
        return [
            Stat::make('Total Établissements', $stats['total'])
                ->description('Nombre total d\'établissements')
                ->descriptionIcon('heroicon-o-building-office')
                ->color('primary'),
            Stat::make('Par Cycle', count($stats['by_cycle'] ?? []))
                ->description('Nombre de cycles')
                ->descriptionIcon('heroicon-o-academic-cap')
                ->color('success'),
            Stat::make('Par Commune', count($stats['by_commune'] ?? []))
                ->description('Nombre de communes')
                ->descriptionIcon('heroicon-o-map')
                ->color('warning'),
        ];
    }
}
