<?php

namespace App\Constants;

class Permissions
{
    // Section: System
    public const SECTION_SYSTEM = 'system_section';

    public const DASHBOARD_VIEW = 'dashboard_view';

    // Section: Logs
    public const SECTION_LOGS = 'logs_section';

    public const ACTIVITY_LOG = 'activity_log';

    // Section: Account
    public const SECTION_ACCOUNT = 'account_section';

    public const MEMBER_DIRECTORY = 'member_directory';

    public const ACCESS_ROLES = 'access_roles';

    // Section: Business
    public const SECTION_BUSINESS = 'business_settings';

    public const BUSINESS_BRANDING = 'business_branding';

    public const LEGAL_MANAGEMENT = 'legal_management';

    public const BUSINESS_LOGIC = 'business_logic';

    // Section: HRM (Human Resource Management)
    public const SECTION_HRM = 'hrm_section';

    public const EMPLOYEE_DIRECTORY = 'employee_directory';

    public const DEPARTMENTS = 'departments';

    // Section: Attendance
    public const SECTION_ATTENDANCE = 'attendance_section';

    public const ATTENDANCE_VIEW = 'attendance_view';

    public const ATTENDANCE_MANAGE = 'attendance_manage';

    public const ATTENDANCE_SETTINGS = 'attendance_settings';

    public const ATTENDANCE_APPROVALS = 'attendance_approvals';

    // Section: Leave
    public const SECTION_LEAVE = 'leave_section';

    public const LEAVE_VIEW = 'leave_view';

    public const LEAVE_MANAGE = 'leave_manage';

    public const LEAVE_TYPE_MANAGE = 'leave_type_manage';

    public const LEAVE_APPROVALS = 'leave_approvals';

    // Section: Assets
    public const SECTION_ASSETS = 'asset_section';

    public const ASSET_VIEW = 'asset_view';

    public const ASSET_MANAGE = 'asset_manage';

    public const ASSET_CATEGORY_MANAGE = 'asset_category_manage';

    // Section: Communication
    public const SECTION_COMMUNICATION = 'communication_section';

    public const ANNOUNCEMENT_VIEW = 'announcement_view';

    public const ANNOUNCEMENT_MANAGE = 'announcement_manage';

    // Section: Payroll
    public const SECTION_PAYROLL = 'payroll_section';

    public const PAYROLL_VIEW = 'payroll_view';

    public const PAYROLL_MANAGE = 'payroll_manage';

    public const PAYROLL_APPROVE = 'payroll_approve';

    public const PAYROLL_APPROVALS_MANAGE = 'payroll_approvals_manage';

    public const SALARY_COMPONENT_MANAGE = 'salary_component_manage';

    public const BONUS_MANAGE = 'bonus_manage';

    public const BONUS_GENERATION_MANAGE = 'bonus_generation_manage';

    public const SALARY_INCREMENT_MANAGE = 'salary_increment_manage';

    public const TAX_MANAGE = 'tax_manage';

    public const LOAN_MANAGE = 'loan_manage';

    public const SALARY_CERTIFICATE_MANAGE = 'salary_certificate_manage';

    public static function getAll(): array
    {
        return [
            self::SECTION_SYSTEM => [
                'label' => 'system_section',
                'icon' => 'LayoutDashboard',
                'sub_modules' => [
                    self::DASHBOARD_VIEW => [
                        'label' => 'dashboard',
                        'description' => 'View system health and metrics',
                        'route' => 'admin.dashboard',
                        'icon' => 'Activity',
                    ],
                ],
            ],
            self::SECTION_ACCOUNT => [
                'label' => 'account', // Using 'account' as section label key, or management_section? Sidebar uses management_section for title, but account for rail tooltip.
                // Sidebar uses 'account' for rail tooltip, 'management_section' for Tier 2 title.
                // Permissions structure has label 'account'. I'll stick to 'account' and handle Tier 2 title logic in frontend or mapping.
                'icon' => 'Users',
                'sub_modules' => [
                    self::MEMBER_DIRECTORY => [
                        'label' => 'member_directory',
                        'description' => 'Manage member identities and access levels',
                        'route' => 'admin.users.index',
                        'icon' => 'Users',
                    ],
                    self::ACCESS_ROLES => [
                        'label' => 'access_roles',
                        'description' => 'Configure roles and security boundaries',
                        'route' => 'admin.roles.index',
                        'icon' => 'ShieldCheck',
                    ],
                ],
            ],
            self::SECTION_BUSINESS => [
                'label' => 'business_settings',
                'icon' => 'Briefcase',
                'sub_modules' => [
                    self::BUSINESS_BRANDING => [
                        'label' => 'business_branding',
                        'description' => 'Manage organization visual identity',
                        'route' => 'admin.business.branding', // Check route name
                        'icon' => 'Palette',
                    ],
                    self::LEGAL_MANAGEMENT => [
                        'label' => 'legal_management',
                        'description' => 'Manage legal documents (Privacy, Terms, etc.)',
                        'route' => 'admin.legal.index',
                        'icon' => 'Scale',
                    ],
                    self::BUSINESS_LOGIC => [
                        'label' => 'business_logic',
                        'description' => 'Manage business settings (Currency, Timezone, Country)',
                        'route' => 'admin.business.settings.index',
                        'icon' => 'Settings',
                    ],

                ],
            ],
            self::SECTION_HRM => [
                'label' => 'human_resource_management',
                'icon' => 'UserCheck',
                'sub_modules' => [
                    self::DEPARTMENTS => [
                        'label' => 'departments',
                        'description' => 'Manage company departments',
                        'route' => 'admin.departments.index',
                        'url' => '/admin/departments', // Hardcoded fallback
                        'icon' => 'Building', // Using Building icon, need to ensure it's imported in sidebar or mapped
                    ],
                    self::EMPLOYEE_DIRECTORY => [
                        'label' => 'employee_directory',
                        'description' => 'Manage employee records and profiles',
                        'route' => 'admin.employees.index',
                        'icon' => 'UserCheck',
                    ],
                ],
            ],
            self::SECTION_ATTENDANCE => [
                'label' => 'attendance',
                'icon' => 'Clock',
                'sub_modules' => [
                    self::ATTENDANCE_MANAGE => [
                        'label' => 'employee_attendance',
                        'description' => 'View and manage employee attendance records',
                        'route' => 'admin.attendance.index',
                        'icon' => 'ClipboardCheck',
                    ],
                    self::ATTENDANCE_APPROVALS => [
                        'label' => 'attendance_approvals',
                        'description' => 'Review and approve attendance anomalies',
                        'route' => 'admin.attendance.approvals',
                        'icon' => 'CheckCircle',
                    ],
                    self::ATTENDANCE_SETTINGS => [
                        'label' => 'attendance_settings',
                        'description' => 'Configure attendance rules and manual entry',
                        'route' => 'admin.attendance.settings',
                        'icon' => 'Settings2',
                    ],

                ],
            ],
            self::SECTION_LEAVE => [
                'label' => 'leave_management',
                'icon' => 'CalendarRange',
                'sub_modules' => [
                    self::LEAVE_MANAGE => [
                        'label' => 'all_leave_requests',
                        'description' => 'Manage all employee leave requests',
                        'route' => 'admin.leave.index',
                        'icon' => 'Files',
                    ],
                    self::LEAVE_APPROVALS => [
                        'label' => 'leave_approvals',
                        'description' => 'Review and approve leave requests',
                        'route' => 'admin.leave.approvals',
                        'icon' => 'CheckSquare',
                    ],
                    self::LEAVE_TYPE_MANAGE => [
                        'label' => 'leave_types',
                        'description' => 'Configure leave types and allowances',
                        'route' => 'admin.leave.types.index',
                        'icon' => 'ListTodo',
                    ],
                ],
            ],
            self::SECTION_LOGS => [
                'label' => 'logs',
                'icon' => 'FileClock',
                'sub_modules' => [
                    self::ACTIVITY_LOG => [
                        'label' => 'activity_log',
                        'description' => 'View system activity logs and audit trail',
                        'route' => 'admin.activity_logs.index',
                        'icon' => 'FileClock',
                    ],
                ],
            ],
            self::SECTION_ASSETS => [
                'label' => 'asset_management',
                'icon' => 'Package',
                'sub_modules' => [
                    self::ASSET_MANAGE => [
                        'label' => 'asset_inventory',
                        'description' => 'Manage company assets and inventory',
                        'route' => 'admin.assets.index',
                        'icon' => 'HardDrive',
                    ],
                    self::ASSET_CATEGORY_MANAGE => [
                        'label' => 'asset_categories',
                        'description' => 'Manage asset categories',
                        'route' => 'admin.assets.categories.index',
                        'icon' => 'Tags',
                    ],
                ],
            ],
            self::SECTION_COMMUNICATION => [
                'label' => 'communication',
                'icon' => 'Megaphone',
                'sub_modules' => [
                    self::ANNOUNCEMENT_MANAGE => [
                        'label' => 'announcement',
                        'description' => 'Broadcast updates to the entire team',
                        'route' => 'admin.announcements.index',
                        'icon' => 'Megaphone',
                    ],
                ],
            ],
            self::SECTION_PAYROLL => [
                'label' => 'payroll_management',
                'icon' => 'BadgeDollarSign',
                'sub_modules' => [
                    self::SALARY_COMPONENT_MANAGE => [
                        'label' => 'salary_components',
                        'description' => 'Manage salary earning and deduction components',
                        'route' => 'admin.payroll.components.index',
                        'url' => '/admin/payroll/salary-components',
                        'icon' => 'Layers',
                    ],
                    self::PAYROLL_MANAGE => [
                        'label' => 'payroll_structures',
                        'description' => 'Define payroll structures and component mappings',
                        'route' => 'admin.payroll.structures.index',
                        'url' => '/admin/payroll/structures',
                        'icon' => 'LayoutList',
                    ],
                    self::PAYROLL_VIEW => [
                        'label' => 'salary_assignments',
                        'description' => 'Assign salary structures to employees',
                        'route' => 'admin.payroll.assignments.index',
                        'url' => '/admin/payroll/salary-assignments',
                        'icon' => 'UserCheck',
                    ],
                    self::PAYROLL_APPROVE => [
                        'label' => 'payroll',
                        'description' => 'Generate, review and approve monthly payrolls',
                        'route' => 'admin.payroll.index',
                        'url' => '/admin/payroll',
                        'icon' => 'Banknote',
                    ],
                    self::BONUS_MANAGE => [
                        'label' => 'bonus_setup',
                        'description' => 'Manage bonuses and eligibility rules',
                        'route' => 'admin.bonuses.index',
                        'url' => '/admin/bonuses',
                        'icon' => 'Gift',
                    ],
                    self::BONUS_GENERATION_MANAGE => [
                        'label' => 'bonus_generate',
                        'description' => 'Generate bonuses and view generations',
                        'route' => 'admin.bonuses.generations.index',
                        'url' => '/admin/bonuses/generations',
                        'icon' => 'Files',
                    ],
                    self::SALARY_INCREMENT_MANAGE => [
                        'label' => 'salary_increments',
                        'description' => 'Track and apply salary increments',
                        'route' => 'admin.salary.increments.index',
                        'url' => '/admin/salary-increments',
                        'icon' => 'TrendingUp',
                    ],
                    self::TAX_MANAGE => [
                        'label' => 'income_taxes',
                        'description' => 'Manage income taxes and employee assignments',
                        'route' => 'admin.taxes.index',
                        'url' => '/admin/taxes',
                        'icon' => 'Landmark',
                    ],
                    self::LOAN_MANAGE => [
                        'label' => 'loans',
                        'description' => 'Manage employee loan requests and ledgers',
                        'route' => 'admin.loans.index',
                        'url' => '/admin/loans',
                        'icon' => 'Wallet',
                    ],
                    self::SALARY_CERTIFICATE_MANAGE => [
                        'label' => 'salary_certificates',
                        'description' => 'Manage and approve employee salary certificate requests',
                        'route' => 'admin.payroll.certificate.index',
                        'url' => '/admin/salary-certificates',
                        'icon' => 'FileText',
                    ],
                    self::PAYROLL_APPROVALS_MANAGE => [
                        'label' => 'approvals',
                        'description' => 'Approve or reject payroll, bonus, and increment requests',
                        'route' => 'admin.payroll.approvals.index',
                        'url' => '/admin/payroll/approvals',
                        'icon' => 'ShieldCheck',
                    ],
                ],
            ],
        ];
    }
}
