<?php

namespace App\Filament\Widgets;

use App\Models\Customer;
use Filament\Widgets\ChartWidget;

class CustomerStatsOverview extends ChartWidget
{
    protected ?string $heading = 'Customers vs Tour Guides';
    
    protected static ?int $sort = 1;

    protected function getData(): array
    {
        $loyaltyCount = Customer::where('type', 'loyalty')->count();
        $guideCount = Customer::where('type', 'guide')->count();

        return [
            'datasets' => [
                [
                    'label' => 'Customers',
                    'data' => [$loyaltyCount, $guideCount],
                    'backgroundColor' => [
                        '#007A5E', // Teal for Loyalty
                        '#F59E0B', // Amber/Orange for Guides
                    ],
                    'hoverOffset' => 4,
                ],
            ],
            'labels' => ['Loyalty Customers', 'Tour Guides'],
        ];
    }

    protected function getType(): string
    {
        return 'pie';
    }
}
