<?php

declare(strict_types=1);

namespace PpPhp\Core\Designer\Presets;

use PpPhp\Core\Designer\DesignerComponent as C;

class SalesDashboardPreset implements DesignerPresetInterface
{
    public static function id(): string
    {
        return 'sales';
    }

    public static function name(): string
    {
        return 'Sales Dashboard';
    }

    public static function description(): string
    {
        return 'Sales dashboard for revenue, leads, conversions, and sales pipeline monitoring.';
    }

    public static function icon(): string
    {
        return 'graph-up-arrow';
    }

    public static function category(): string
    {
        return 'Business';
    }

    public static function type(): string
    {
        return 'dashboard';
    }


    public static function components(): array
    {
        return [
            C::breadcrumb('breadcrumb_main', ['Home', 'Sales Dashboard']),

            C::heading(
                'page_heading',
                'Sales Dashboard',
                'Track sales revenue, customers, conversions, and pipeline activity.'
            ),

            C::make('sales_kpi_section', 'section', 'Sales KPIs', [
                'title' => 'Sales KPIs',
                'collapsible' => true,
                'collapsed' => false,
            ], [
                C::make('sales_kpi_row', 'row', 'Sales KPI Row', [
                    'columns' => 4,
                    'cells' => [
                        self::kpiCell('sales_revenue_kpi', 'Sales Revenue', '$84,500', '12%', 'up', 'vs last month', 'cash-stack'),
                        self::kpiCell('new_leads_kpi', 'New Leads', '246', '18%', 'up', 'this month', 'person-plus'),
                        self::kpiCell('conversion_kpi', 'Conversion', '28%', '4%', 'up', 'improved rate', 'graph-up-arrow'),
                        self::kpiCell('lost_deals_kpi', 'Lost Deals', '14', '6%', 'down', 'lower loss rate', 'x-circle'),
                    ],
                ]),
            ]),
        ];
    }

    private static function kpiCell(
        string $id,
        string $label,
        string $value,
        string $trend,
        string $direction,
        string $subtitle,
        string $icon,
        int $span = 3
    ): array {
        return [
            'id' => $id . '_cell',
            'span' => $span,
            'components' => [
                C::make($id, 'kpi-trend-card', $label, [
                    'label' => $label,
                    'value' => $value,
                    'trend' => $trend,
                    'trendDirection' => $direction,
                    'subtitle' => $subtitle,
                    'icon' => $icon,
                ]),
            ],
            'style' => C::style(),
        ];
    }
}
