<?php

namespace App\Enums;

enum TreatmentPlanStatus: string
{
    case Draft = 'draft';
    case Proposed = 'proposed';
    case Accepted = 'accepted';
    case InProgress = 'in_progress';
    case Completed = 'completed';
    case Cancelled = 'cancelled';

    public function canTransitionTo(self $to): bool
    {
        return match ($this) {
            self::Draft => in_array($to, [self::Proposed, self::Accepted, self::Cancelled], true),
            self::Proposed => in_array($to, [self::Accepted, self::Draft, self::Cancelled], true),
            self::Accepted => in_array($to, [self::InProgress, self::Cancelled], true),
            self::InProgress => in_array($to, [self::Completed, self::Cancelled], true),
            self::Completed, self::Cancelled => false,
        };
    }

    public function label(): string
    {
        return __(match ($this) {
            self::Draft => 'Draft',
            self::Proposed => 'Proposed',
            self::Accepted => 'Accepted',
            self::InProgress => 'In progress',
            self::Completed => 'Completed',
            self::Cancelled => 'Cancelled',
        });
    }

    public function color(): string
    {
        return match ($this) {
            self::Draft => '#94A3B8',
            self::Proposed => '#F5A524',
            self::Accepted => '#0EA5E9',
            self::InProgress => '#8B5CF6',
            self::Completed => '#22C55E',
            self::Cancelled => '#EF4444',
        };
    }
}
