<?php

declare(strict_types=1);

namespace Database\Seeders;

use App\Models\Menu;
use Illuminate\Database\Seeder;

class MenuSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        // Truncate menus table first
        Menu::truncate();

        $menus = [
            [
                'group_name' => 'Main Menu',
                'title' => 'Dashboard',
                'href' => '/admin/dashboard',
                'icon' => 'LayoutDashboard',
                'roles' => null,
                'permissions' => null,
            ],
            [
                'group_name' => 'Main Menu',
                'title' => 'Panduan Sistem',
                'href' => '/admin/guide',
                'icon' => 'BookOpen',
                'roles' => null,
                'permissions' => null,
            ],
            [
                'group_name' => 'CafePOS',
                'title' => 'POS Cashier',
                'href' => '/admin/pos',
                'icon' => 'ShoppingCart',
                'roles' => null,
                'permissions' => ['pos.create'],
            ],
            [
                'group_name' => 'CafePOS',
                'title' => 'Transactions',
                'href' => '/admin/transactions',
                'icon' => 'Receipt',
                'roles' => null,
                'permissions' => ['pos.view'],
            ],
            [
                'group_name' => 'CafePOS',
                'title' => 'Kitchen Display (KDS)',
                'href' => '/admin/kds',
                'icon' => 'Tv',
                'roles' => null,
                'permissions' => ['pos.view'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Product Catalog',
                'href' => '/admin/products',
                'icon' => 'Coffee',
                'roles' => null,
                'permissions' => ['products.manage'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Add-ons Manager',
                'href' => '/admin/modifiers',
                'icon' => 'PlusSquare',
                'roles' => null,
                'permissions' => ['products.manage'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Stock Inventory',
                'href' => '/admin/ingredients',
                'icon' => 'Package',
                'roles' => null,
                'permissions' => ['inventory.manage'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Stock Opname',
                'href' => '/admin/opnames',
                'icon' => 'ClipboardList',
                'roles' => null,
                'permissions' => ['inventory.manage'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Waste Logs',
                'href' => '/admin/wastes',
                'icon' => 'Trash2',
                'roles' => null,
                'permissions' => ['inventory.manage'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Supplier Manager',
                'href' => '/admin/suppliers',
                'icon' => 'Truck',
                'roles' => null,
                'permissions' => ['inventory.manage'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Table Manager',
                'href' => '/admin/tables',
                'icon' => 'Grid',
                'roles' => null,
                'permissions' => ['pos.view'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'CRM & Membership',
                'href' => '/admin/customers',
                'icon' => 'Users',
                'roles' => null,
                'permissions' => ['pos.view'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Table Reservations',
                'href' => '/admin/reservations',
                'icon' => 'CalendarDays',
                'roles' => null,
                'permissions' => ['pos.view'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Courier Manager',
                'href' => '/admin/couriers',
                'icon' => 'Truck',
                'roles' => null,
                'permissions' => ['pos.view'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Promo Engine',
                'href' => '/admin/promos',
                'icon' => 'Tag',
                'roles' => null,
                'permissions' => ['pos.view'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Voucher Engine',
                'href' => '/admin/vouchers',
                'icon' => 'Tag',
                'roles' => null,
                'permissions' => ['pos.view'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Purchase Orders',
                'href' => '/admin/purchase-orders',
                'icon' => 'FileText',
                'roles' => null,
                'permissions' => ['inventory.manage'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Outlet Manager',
                'href' => '/admin/outlets',
                'icon' => 'Store',
                'roles' => null,
                'permissions' => ['outlets.manage'],
            ],
            [
                'group_name' => 'CafePOS Management',
                'title' => 'Reports & Analytics',
                'href' => '/admin/reports',
                'icon' => 'BarChart3',
                'roles' => null,
                'permissions' => ['report.view'],
            ],
            [
                'group_name' => 'Settings',
                'title' => 'System Settings',
                'href' => '/admin/settings',
                'icon' => 'Settings',
                'roles' => [],
                'permissions' => ['manage settings'],
            ],
            [
                'group_name' => 'Settings',
                'title' => 'QZ Tray Printer',
                'href' => '/admin/settings/qz-tray',
                'icon' => 'Printer',
                'roles' => [],
                'permissions' => ['manage settings'],
            ],
            [
                'group_name' => 'Settings',
                'title' => 'User Management',
                'href' => '/admin/users',
                'icon' => 'Users',
                'roles' => [],
                'permissions' => ['manage users'],
            ],
            [
                'group_name' => 'Settings',
                'title' => 'Roles & Permissions',
                'href' => '/admin/rbac',
                'icon' => 'ShieldCheck',
                'roles' => [],
                'permissions' => ['manage users'],
            ],
            [
                'group_name' => 'Settings',
                'title' => 'Menu Manager',
                'href' => '/admin/menus',
                'icon' => 'Menu',
                'roles' => [],
                'permissions' => ['manage settings'],
            ],
            [
                'group_name' => 'Other',
                'title' => 'Activity Logs',
                'href' => '/admin/logs',
                'icon' => 'History',
                'roles' => [],
                'permissions' => ['view logs'],
            ],
        ];

        foreach ($menus as $index => $menu) {
            $menu['sort_order'] = $index + 1;
            Menu::create($menu);
        }
    }
}
