<?php

namespace App\Filament\Widgets;

use App\Models\OrdenProduccion;
use App\Models\Tela;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;

class TelasStatsOverview extends BaseWidget
{
        protected static ?int $sort = 1;

    protected function getStats(): array
    {
        return [
            Stat::make('Total de Telas', Tela::count())
                ->description('Telas registradas')
                ->descriptionIcon('heroicon-m-archive-box')
                ->color('success'),

            Stat::make('Metros Disponibles', number_format(Tela::sum('metros_disponibles'), 2) . ' m')
                ->description('Total en stock')
                ->descriptionIcon('heroicon-m-bolt')
                ->color('warning'),

            Stat::make('Valor Total Inventario', '$' . number_format(Tela::sum('valor_total'), 2))
                ->description('Inversión total')
                ->descriptionIcon('heroicon-m-currency-dollar')
                ->color('primary'),

            Stat::make('Órdenes Activas', OrdenProduccion::whereNotIn('estado', ['finalizada'])->count())
                ->description('En proceso')
                ->descriptionIcon('heroicon-m-clipboard-document-list')
                ->color('info'),
        ];
    }
}
