<?php

namespace PloverCRM\Core\Services;

/**
 * Shared starter pipeline templates for first-run workspace setup.
 */
class PipelineTemplateRegistry
{
    public const TEMPLATE_SIMPLE_SALES = 'simple_sales';
    public const TEMPLATE_LEAD_QUALIFICATION = 'lead_qualification';
    public const TEMPLATE_CUSTOMER_LIFECYCLE = 'customer_lifecycle';

    public static function getTemplates(): array
    {
        return [
            self::simpleSalesTemplate(),
            self::leadQualificationTemplate(),
            self::customerLifecycleTemplate(),
        ];
    }

    private static function simpleSalesTemplate(): array
    {
        return [
            'key' => self::TEMPLATE_SIMPLE_SALES,
            'label' => 'Simple sales',
            'description' => 'A straightforward pipeline for new leads, conversations, proposals, and final outcomes.',
            'stages' => [
                ['name' => 'New', 'color' => '#10b981'],
                ['name' => 'Contacted', 'color' => '#3b82f6'],
                ['name' => 'Qualified', 'color' => '#8b5cf6'],
                ['name' => 'Proposal Sent', 'color' => '#f59e0b'],
                ['name' => 'Won', 'color' => '#16a34a'],
                ['name' => 'Lost', 'color' => '#ef4444'],
            ],
        ];
    }

    private static function leadQualificationTemplate(): array
    {
        return [
            'key' => self::TEMPLATE_LEAD_QUALIFICATION,
            'label' => 'Lead qualification',
            'description' => 'Ideal when your team wants to qualify or disqualify leads before they enter the main sales cycle.',
            'stages' => [
                ['name' => 'New', 'color' => '#10b981'],
                ['name' => 'Attempting Contact', 'color' => '#3b82f6'],
                ['name' => 'Qualified', 'color' => '#8b5cf6'],
                ['name' => 'Unqualified', 'color' => '#ef4444'],
            ],
        ];
    }

    private static function customerLifecycleTemplate(): array
    {
        return [
            'key' => self::TEMPLATE_CUSTOMER_LIFECYCLE,
            'label' => 'Customer lifecycle',
            'description' => 'Useful for onboarding, retained customers, renewal risk, and churn monitoring.',
            'stages' => [
                ['name' => 'New', 'color' => '#10b981'],
                ['name' => 'Onboarding', 'color' => '#3b82f6'],
                ['name' => 'Active', 'color' => '#16a34a'],
                ['name' => 'At Risk', 'color' => '#f59e0b'],
                ['name' => 'Renewed', 'color' => '#14b8a6'],
                ['name' => 'Churned', 'color' => '#ef4444'],
            ],
        ];
    }
}
