<?php

namespace App\Enums;

enum RoleEnum: string
{
    case CUSTOMER = 'customer';
    case SUPER_ADMIN = 'super_admin';
    case ADMINISTRATION = 'administration';
    case SALES_MANAGER = 'sales_manager';

    /**
     * Get all role values as array
     */
    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }

    /**
     * Check if a role slug is a valid system role
     */
    public static function isValid(string $slug): bool
    {
        return in_array($slug, self::values());
    }

    /**
     * Get role display name
     */
    public function displayName(): string
    {
        return match ($this) {
            self::CUSTOMER => 'Customer',
            self::SUPER_ADMIN => 'Super Admin',
            self::ADMINISTRATION => 'Administration',
            self::SALES_MANAGER => 'Sales Manager',
        };
    }

    /**
     * Get role description
     */
    public function description(): string
    {
        return match ($this) {
            self::CUSTOMER => 'Can view own invoices and make payments. Cannot access admin panel.',
            self::SUPER_ADMIN => 'Full system control. Manages SaaS subscription plans and global settings when SaaS plugin is active.',
            self::ADMINISTRATION => 'Full control of system settings, company details, user management, and invoices.',
            self::SALES_MANAGER => 'Can create invoices, manage customers, and view sales reports. Cannot access system settings.',
        };
    }
}
