<?php

return [
    'name' => 'SaasSwitcher',

    /*
    |--------------------------------------------------------------------------
    | Projects (tenants)
    |--------------------------------------------------------------------------
    | Each project is a separate database reached via its own connection. The
    | connection is registered automatically by SaasSwitcherServiceProvider by
    | cloning the host's default `mysql` connection and swapping the database,
    | so deploying to the cloud only needs these env vars set — no edits to
    | config/database.php.
    |
    | The super-admin lives in the project whose `is_host` is true (its DB is the
    | host's default `mysql` connection).
    */
    'session_key'        => 'saas_project',
    'impersonating_key'  => 'saas_impersonating',
    'admin_key'          => 'saas_admin_id',

    'projects' => [
        'static' => [
            'key'        => 'static',
            'label'      => 'Static — ERP / Purchase',
            'tagline'    => 'Base ERP without the clinic verticals',
            'connection' => 'proj_static',
            'database'   => env('PROJ_STATIC_DB', 'static_test09022026'),
            'vertical'   => 'erp',
            'icon'       => 'fas fa-boxes-stacked',
            'color'      => '#6366f1',
            'is_host'    => true,
        ],
        'shifa' => [
            'key'        => 'shifa',
            'label'      => 'Shifa One — Human Clinics',
            'tagline'    => 'ClinicCore + specialties, staff PWA & website',
            'connection' => 'proj_shifa',
            'database'   => env('PROJ_SHIFA_DB', 'shifa_one_demo'),
            'vertical'   => 'clinic',
            'icon'       => 'fas fa-user-doctor',
            'color'      => '#0ea5e9',
            'is_host'    => false,
        ],
        'vet' => [
            'key'        => 'vet',
            'label'      => 'Vet One — Veterinary Clinics',
            'tagline'    => 'VetClinic + admissions, vet portal & site',
            'connection' => 'proj_vet',
            'database'   => env('PROJ_VET_DB', 'vet_one_demo'),
            'vertical'   => 'vet',
            'icon'       => 'fas fa-paw',
            'color'      => '#16a34a',
            'is_host'    => false,
        ],
        'vrc' => [
            'key'        => 'vrc',
            'label'      => 'VRC One — Vehicle Repair Centers',
            'tagline'    => 'Job cards, inspections, estimates, technicians & insurance',
            'connection' => 'proj_vrc',
            'database'   => env('PROJ_VRC_DB', 'vrc_one_demo'),
            'vertical'   => 'vrc',
            'icon'       => 'fas fa-car',
            'color'      => '#f97316',
            'is_host'    => false,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Per-project module verticals (used by ProjectActivator)
    |--------------------------------------------------------------------------
    | A module that belongs to a "vertical" is only booted when the active
    | project includes that vertical. Modules in no vertical (Essentials,
    | Accounting, Bms, …) are never constrained and follow modules_statuses.json.
    |
    | Classification: a module matches a vertical if its name is in `modules`,
    | or (checked after the explicit lists) ends with one of `suffix`. So
    | "VetClinic" → vet (explicit), "CardiologyClinic" → clinic (suffix).
    */
    'verticals' => [
        'vet' => [
            // Clinical + portal + lab-analyzer integrations specific to the vet stack.
            'modules' => ['VetClinic', 'VetAdmission', 'VetAI', 'VetPortal', 'VetSite', 'VetStaffPortal',
                          'IdexxLab', 'AbaxisLab', 'NX600Lab'],
        ],
        'clinic' => [
            'modules' => ['ClinicCore', 'ClinicSite', 'ClinicStaffPortal', 'ClinicLab', 'ClinicWhatsApp'],
            'suffix'  => ['Clinic'], // specialty modules: CardiologyClinic, DermatologyClinic, …
        ],
        'vrc' => [
            // Vehicle Repair Center — one self-contained domain module on the ERP core.
            'modules' => ['Vrc'],
        ],
    ],

    // Which verticals each project shows. Static carries all (as static-purchase did).
    'project_verticals' => [
        'static' => ['vet', 'clinic', 'vrc'],
        'shifa'  => ['clinic'],
        'vet'    => ['vet'],
        'vrc'    => ['vrc'],
    ],

    // When no project is active (super-admin on the host, or CLI) hide nothing.
    'default_verticals' => ['vet', 'clinic', 'vrc'],

    /*
    |--------------------------------------------------------------------------
    | Per-business module entitlements (the replacement for the old cookie)
    |--------------------------------------------------------------------------
    | Single source of truth for which modules are "gateable" — their menu and/or
    | routes show only when the active business is entitled (business.module_entitlements).
    | Used by Modules\SaasSwitcher\Support\ModuleEntitlementService, the
    | `module:` route guard, the entitlements admin page, and entitlements:seed.
    |
    | The ~50 specialty *Clinic modules are NOT listed — they are plugins to
    | ClinicCore (no own menu/routes) and ride on the ClinicCore entitlement.
    | role: hub = builds the vertical's menu; satellite = injects into the hub;
    | standalone = its own menu.
    */
    'gateable_modules' => [
        'VetClinic'         => ['vertical' => 'vet',    'label' => 'Vet Clinic',          'role' => 'hub'],
        'VetAdmission'      => ['vertical' => 'vet',    'label' => 'Vet Admission',       'role' => 'satellite'],
        'VetAI'             => ['vertical' => 'vet',    'label' => 'Vet AI',              'role' => 'satellite'],
        'VetPortal'         => ['vertical' => 'vet',    'label' => 'Vet Owner Portal',    'role' => 'satellite'],
        'VetSite'           => ['vertical' => 'vet',    'label' => 'Vet Website',         'role' => 'satellite'],
        'VetStaffPortal'    => ['vertical' => 'vet',    'label' => 'Vet Staff Portal',    'role' => 'satellite'],
        'NX600Lab'          => ['vertical' => 'vet',    'label' => 'NX600 Lab',           'role' => 'standalone'],
        'IdexxLab'          => ['vertical' => 'vet',    'label' => 'IDEXX Lab',           'role' => 'standalone'],
        'AbaxisLab'         => ['vertical' => 'vet',    'label' => 'Abaxis Lab',          'role' => 'standalone'],

        'Vrc'               => ['vertical' => 'vrc',    'label' => 'Vehicle Repair Center', 'role' => 'standalone'],

        'ClinicCore'        => ['vertical' => 'clinic', 'label' => 'Clinic Core',         'role' => 'hub'],
        'ClinicSite'        => ['vertical' => 'clinic', 'label' => 'Clinic Website',      'role' => 'satellite'],
        'ClinicStaffPortal' => ['vertical' => 'clinic', 'label' => 'Clinic Staff Portal', 'role' => 'satellite'],
        'ClinicLab'         => ['vertical' => 'clinic', 'label' => 'Clinic Lab',          'role' => 'satellite'],
        'ClinicWhatsApp'    => ['vertical' => 'clinic', 'label' => 'Clinic WhatsApp',     'role' => 'satellite'],
    ],

    /*
    | Default entitlement set per project key (consumed by entitlements:seed).
    | null = leave unset = fail-open (fully entitled).
    | []   = entitled to nothing (no vet/clinic verticals — clean base ERP).
    | [..] = restrict to exactly those (+ shared/plugin modules, never gated).
    */
    'project_modules' => [
        'static' => [], // host / base ERP — no vet, medical (clinic) or vrc modules
        'shifa'  => ['ClinicCore', 'ClinicSite', 'ClinicStaffPortal', 'ClinicLab', 'ClinicWhatsApp'],
        'vet'    => ['VetClinic', 'VetAdmission', 'VetAI', 'VetPortal', 'VetSite', 'VetStaffPortal', 'NX600Lab', 'IdexxLab', 'AbaxisLab'],
        'vrc'    => ['Vrc'], // Vehicle Repair Center (shared modules — Accounting, AdvancedTransfer, WhatsApp, AI — ride along, never gated)
    ],
];
