<?php

declare(strict_types=1);

namespace WorkforceOS\Services;

final class OrganizationService
{
    public function structure(array $tenant): array
    {
        return [
            'tenant_id' => $tenant['id'],
            'branches' => [
                ['name' => 'Head Office', 'code' => 'HO', 'employees' => 164, 'devices' => 4, 'timezone' => 'Asia/Dhaka', 'status' => 'active'],
                ['name' => 'Gazipur Plant', 'code' => 'GZP', 'employees' => 528, 'devices' => 8, 'timezone' => 'Asia/Dhaka', 'status' => 'active'],
                ['name' => 'Chattogram Depot', 'code' => 'CTG', 'employees' => 150, 'devices' => 2, 'timezone' => 'Asia/Dhaka', 'status' => 'active'],
            ],
            'departments' => [
                ['name' => 'Human Resources', 'parent' => '-', 'employees' => 24, 'head' => 'EMP-1001'],
                ['name' => 'Production', 'parent' => '-', 'employees' => 520, 'head' => 'EMP-1007'],
                ['name' => 'Quality Control', 'parent' => 'Production', 'employees' => 96, 'head' => 'EMP-1022'],
                ['name' => 'Finance', 'parent' => '-', 'employees' => 18, 'head' => 'EMP-1030'],
            ],
            'designations' => [
                ['name' => 'CEO', 'grade' => 'EX-1', 'level' => 1],
                ['name' => 'Director', 'grade' => 'EX-2', 'level' => 2],
                ['name' => 'HR Manager', 'grade' => 'M-2', 'level' => 4],
                ['name' => 'Line Manager', 'grade' => 'M-3', 'level' => 5],
                ['name' => 'Employee', 'grade' => 'S-1', 'level' => 7],
            ],
        ];
    }

    public function schedules(array $tenant): array
    {
        return [
            'tenant_id' => $tenant['id'],
            'shifts' => [
                ['name' => 'General Shift', 'type' => 'fixed', 'start' => '09:00', 'end' => '18:00', 'grace' => 10, 'weekly_off' => 'Friday'],
                ['name' => 'Night Shift', 'type' => 'night', 'start' => '22:00', 'end' => '06:00', 'grace' => 15, 'weekly_off' => 'Friday'],
                ['name' => 'Production Rotation A', 'type' => 'rotational', 'start' => '06:00', 'end' => '14:00', 'grace' => 5, 'weekly_off' => 'Roster'],
                ['name' => 'Flexible Admin', 'type' => 'flexible', 'start' => '08:00', 'end' => '19:00', 'grace' => 0, 'weekly_off' => 'Friday'],
            ],
            'rosters' => [
                ['team' => 'Production Team A', 'branch' => 'Gazipur Plant', 'shift' => 'Production Rotation A', 'employees' => 160, 'date_range' => '2026-05-26 to 2026-06-01'],
                ['team' => 'Security Night Team', 'branch' => 'Head Office', 'shift' => 'Night Shift', 'employees' => 18, 'date_range' => '2026-05-26 to 2026-06-01'],
                ['team' => 'Admin Team', 'branch' => 'Head Office', 'shift' => 'General Shift', 'employees' => 74, 'date_range' => '2026-05-26 to 2026-06-01'],
            ],
            'auto_shift_detection' => true,
        ];
    }
}
