<?php

declare(strict_types=1);

/**
 * The module list here matches the Roles & Permissions page exactly
 * (Leads & Customers, Appointments & Scheduling, Email & Campaigns,
 * AI & Automation, Reports & Analytics, User Management,
 * Billing & Integrations). Each module gets a standard set of actions;
 * PermissionSeeder expands this into one `permissions` row per
 * module.action pair (see database/seeders/PermissionSeeder.php).
 *
 * The frontend's permission matrix renders one checkbox per
 * (module, role) cell. That checkbox maps to the 'manage' action for
 * that module — checking it grants every action in the module for that
 * role in one step. Individual actions remain available for finer
 * control from the API/CLI even though the current UI only exposes the
 * simple per-module toggle.
 */
return [
    'modules' => [
        'leads_customers' => [
            'label' => 'Leads & Customers',
            'actions' => ['view', 'create', 'update', 'delete', 'export', 'manage'],
        ],
        'scheduling' => [
            'label' => 'Appointments & Scheduling',
            'actions' => ['view', 'create', 'update', 'delete', 'manage'],
        ],
        'email_campaigns' => [
            'label' => 'Email & Campaigns',
            'actions' => ['view', 'create', 'update', 'delete', 'send', 'manage'],
        ],
        'ai_automation' => [
            'label' => 'AI & Automation',
            'actions' => ['view', 'update', 'manage'],
        ],
        'reports_analytics' => [
            'label' => 'Reports & Analytics',
            'actions' => ['view', 'export', 'manage'],
        ],
        'user_management' => [
            'label' => 'User Management',
            'actions' => ['view', 'create', 'update', 'delete', 'manage'],
        ],
        'billing_integrations' => [
            'label' => 'Billing & Integrations',
            'actions' => ['view', 'update', 'manage'],
        ],
    ],

    // System roles seeded on install, matching the four roles already
    // shown in the User Management / Roles & Permissions pages.
    // 'full' = every action in the module, 'view' = view-only,
    // 'none' = no access (module hidden from nav + blocked server-side).
    'default_role_matrix' => [
        'operations_admin' => [
            'leads_customers'      => 'full',
            'scheduling'           => 'full',
            'email_campaigns'      => 'full',
            'ai_automation'        => 'full',
            'reports_analytics'    => 'full',
            'user_management'      => 'full',
            'billing_integrations' => 'full',
        ],
        'sales_rep' => [
            'leads_customers'      => 'full',
            'scheduling'           => 'full',
            'email_campaigns'      => 'full',
            'ai_automation'        => 'none',
            'reports_analytics'    => 'full',
            'user_management'      => 'none',
            'billing_integrations' => 'none',
        ],
        'field_staff' => [
            'leads_customers'      => 'none',
            'scheduling'           => 'full',
            'email_campaigns'      => 'none',
            'ai_automation'        => 'none',
            'reports_analytics'    => 'none',
            'user_management'      => 'none',
            'billing_integrations' => 'none',
        ],
        'read_only' => [
            'leads_customers'      => 'view',
            'scheduling'           => 'view',
            'email_campaigns'      => 'none',
            'ai_automation'        => 'none',
            'reports_analytics'    => 'view',
            'user_management'      => 'none',
            'billing_integrations' => 'none',
        ],
    ],
];
