<?php

namespace App\Filament\Widgets;

use App\Models\ContactMessage;
use App\Models\Pengaduan;
use App\Models\PengajuanSurat;
use Filament\Widgets\StatsOverviewWidget\Stat;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;

class StatsOverview extends BaseWidget
{
    protected function getStats(): array
    {
        return [
            // PENGADUAN MASUK
            Stat::make('Pengaduan Masuk', Pengaduan::where('status', 'Pending')->where('jenis', 'pengaduan')->count())
                ->description('Jumlah Pengaduan yang Masuk ')
                ->descriptionIcon('heroicon-m-clipboard-document-list')
                ->color('danger')
                ->extraAttributes([
                    'class' => 'h-full flex flex-col justify-between'
                ]),

            // PENGADUAN DIPROSES
            Stat::make('Pengaduan Diproses', Pengaduan::where('status', 'Diproses')->where('jenis', 'pengaduan')->count())
                ->description('Pengaduan yang sedang diproses')
                ->descriptionIcon('heroicon-m-exclamation-triangle')
                ->color('warning')
                ->extraAttributes([
                    'class' => 'h-full flex flex-col justify-between'
                ]),

            // PENGADUAN SELESAI
            Stat::make('Pengaduan Selesai', Pengaduan::where('status', 'selesai')->where('jenis', 'pengaduan')->count())
                ->description('Pengaduan yang sudah ditangani')
                ->descriptionIcon('heroicon-m-check-circle')
                ->color('success')
                ->extraAttributes([
                    'class' => 'h-full flex flex-col justify-between'
                ]),

            // TOTAL PENGADUAN
            Stat::make('Total Pengaduan', Pengaduan::where('jenis', 'pengaduan')->count())
                ->description('Jumlah total semua pengaduan')
                ->descriptionIcon('heroicon-m-clipboard-document-list')
                ->color('primary')
                ->extraAttributes([
                    'class' => 'h-full flex flex-col justify-between'
                ]),

            // PENGAJUAN SURAT
            Stat::make('Pengajuan Surat', PengajuanSurat::count())
                ->description('Total pengajuan surat masuk')
                ->descriptionIcon('heroicon-m-document-text')
                ->color('info')
                ->extraAttributes([
                    'class' => 'h-full flex flex-col justify-between'
                ]),

            // PESAN KONTAK
            Stat::make('Pesan Masuk', ContactMessage::count())
                ->description('Pesan dari masyarakat')
                ->descriptionIcon('heroicon-m-envelope')
                ->color('gray')
                ->extraAttributes([
                    'class' => 'h-full flex flex-col justify-between'
                ]),
        ];
    }

    // Jumlah kolom grid
    protected function getColumns(): int
    {
        return 3; // 3 kolom (2 baris x 3)
    }

    protected int|string|array $columnSpan = 'full'; // biar lebarnya penuh ke kanan
}

