# Screens Audit

## Audit Session - 2026-05-29 11:38:13 +03:00

Browser audit performed as admin before the local SQLite database was reset by the current test configuration. See `phase_1_analysis.md` for the critical test-database warning.

## Sidebar Menu Audit

| Sidebar Item | Route | Component/File | Current Status | Expected Purpose | Allowed Roles | Problems Found |
|---|---|---|---|---|---|---|
| Dashboard / لوحة التحكم | `/admin` | `app/Filament/Pages/Dashboard.php`; `resources/views/filament/pages/chat-workspace.blade.php` | Working | Main operational workspace with stats, chat list, active chat, queue, and activity | Admin, Supervisor, Employee | Role selector is local-only and uses `manager/support/supervisor`, not backend `admin/supervisor/agent`. |
| Conversations / المحادثات | `/admin/conversations` | `app/Filament/Resources/ConversationResource.php` | Working but isolated | List/search/filter all conversations in user's scope; transfer/close/view | Admin, Supervisor, Employee | Full page reload from dashboard; no visible sidebar/topbar on resource page. |
| Waiting List / قائمة الانتظار | `/admin/conversations?tableFilters[status][value]=pending` | `ConversationResource` filtered by status | Incomplete | Queue of unassigned or pending WhatsApp conversations waiting for assignment | Admin, Supervisor, Employee for own/team scope | It is only a filtered conversation table; incoming workflow does not currently create pending/unassigned conversations. |
| Contacts / جهات الاتصال | `/admin/contacts` | `app/Filament/Resources/ContactResource.php` | Working for admin; role mismatch | Customer/contact directory with WhatsApp ID, profile, dedicated agent | Admin, Supervisor read-only/team scope, Employee own assigned contacts | Dashboard allows supervisor, but resource allows admin only. |
| Assignment Log / سجل التكليفات | `/admin/assignments` | `app/Filament/Resources/AssignmentResource.php` | Working but permission gap | Audit trail of conversation assignment/transfers | Admin, Supervisor team scope; Employee ideally no access or own audit only | `AssignmentPolicy::viewAny()` allows everyone and resource query does not filter agents. |
| Team / الفريق | `/admin/teams` | `app/Filament/Resources/TeamResource.php` | Working for admin; role mismatch | Team and supervisor structure | Admin; Supervisor own team read-only if needed | Dashboard allows supervisor, but TeamResource allows admin only. Employee management is actually in Users. |
| Reports / التقارير | `/admin/webhook-events` | `app/Filament/Resources/WebhookEventResource.php` | Opens, but wrong purpose | Business reports and analytics | Admin, Supervisor team reports | Currently shows technical webhook logs; supervisor is allowed in dashboard but blocked by resource. |
| Permissions / الصلاحيات | `/admin/users` | `app/Filament/Resources/UserResource.php` | Opens Users, not permissions | Role/permission matrix and per-role access settings | Admin | No real permissions screen; permissions table is empty. |
| Settings / الإعدادات | `/admin/users` | `app/Filament/Resources/UserResource.php` | Opens Users, not settings | WhatsApp/API/system settings | Admin | No settings screen exists; duplicate route with Permissions. |

## Screen Audit

| Screen | Route | Current Purpose | Recommended Purpose | Working Status | Design Status | Logic Status | Notes |
|---|---|---|---|---|---|---|---|
| Dashboard / Chat Workspace | `/admin` | Custom operational chat dashboard | Keep as main workspace; make it role-aware and connected to real routes | Working | Custom dark WhatsApp-style UI | Partly real, partly simulated | Loads chats from `/api/workspace/data`; role switcher is debug/local-only; sidebar is only present here. |
| Conversations List | `/admin/conversations` | Filament conversation table | Scoped conversation management list | Working | Filament table, but no visible nav shell | Mostly working | Browser load about 2985 ms; table polls every 3 seconds. |
| Conversation View | `/admin/conversations/{record}` | Filament read-only conversation details | Full conversation detail or redirect to chat workspace active conversation | Incomplete | Filament form-like view | Transfer/close actions exist | Does not show message thread; chat happens on dashboard, causing split workflow. |
| Waiting List | `/admin/conversations?tableFilters[status][value]=pending` | Filtered conversations table | Dedicated queue for unassigned/pending conversations | Incomplete | Empty Filament table when no pending rows | Weak | No incoming workflow creates pending waiting-list items. |
| Contacts | `/admin/contacts` | Contacts table and edit/create | Contact/customer directory and dedicated agent management | Working for admin | Filament table without visible nav shell | Partly working | Supervisor access expected but blocked; dedicated agent is not used by router. |
| Assignment Log | `/admin/assignments` | Assignment audit table | Scoped transfer/assignment history | Working but unsafe | Filament table without visible nav shell | Permission gap | Agent resource query can expose all assignment rows. |
| Team | `/admin/teams` | Team list/create/edit | Team/supervisor structure | Working for admin | Filament table without visible nav shell | Partial | Supervisor nav mismatch; employees are managed elsewhere. |
| Users / Employees | `/admin/users` | Employee CRUD and role assignment | Team / Employees screen | Working for admin | Filament table without visible nav shell | Partial | Can create employees and assign role/team, but no guided permission workflow. |
| Create Employee | `/admin/users/create` | Create user form | Employee creation wizard | Working | Filament form | Partial | Fields: name, email, password, roles, WABA phone ID, team, active. |
| Edit Employee | `/admin/users/{record}/edit` | Edit user | Employee profile/settings | Working | Filament form | Partial | Can edit role/team/phone/active; no profile history or assigned conversations panel. |
| Webhook Events | `/admin/webhook-events` | Technical webhook event log | Internal diagnostics only, not Reports | Working for admin | Filament table without visible nav shell | Working for admin | Should move under technical/admin diagnostics, not business Reports. |
| Login | `/admin/login` | Filament login | Authentication | Working | Filament default | Working | Login as seeded admin worked before test DB reset. |

## Console and Loading States

| Check | Result |
|---|---|
| Console errors during audited page loads | None observed in browser logs. |
| Empty states | Filament empty state appears for Waiting List when no pending rows. |
| Loading states | Mostly Filament/Livewire defaults; dashboard has no explicit full-page error state for failed workspace fetch beyond console error. |
| API error display | Chat actions show toasts on failure; workspace fetch only logs to console. |
| Search/filter | Filament search/filter controls present; dashboard chat search and filter tabs present. |
| Forms | Employee, team, and contact forms load; not submitted during audit. |

## Sidebar and Navigation Problems

| Problem | Evidence | Recommended Fix |
|---|---|---|
| Custom sidebar exists only in dashboard. | `NAV_ITEMS` is defined inside `resources/views/filament/pages/chat-workspace.blade.php`. | Move navigation to shared layout or restore Filament navigation consistently. |
| Filament sidebar/topbar hidden globally. | `public/css/chat-workspace.css` hides `.fi-topbar`, `.fi-sidebar`, `.fi-sidebar-close-overlay`. | Scope these rules only to the chat workspace page. |
| Full reload navigation. | `selectView()` uses `window.location.href`. | Use Filament navigation or an SPA-like shell only after screen structure is finalized. |
| Screens route to misleading pages. | Reports -> Webhook Events; Permissions/Settings -> Users. | Create real pages or label routes honestly until implemented. |

## Phase 2 Update - 2026-05-29 12:09:31 +03:00

| Sidebar Item | Route | Component/File | Current Status | Expected Purpose | Allowed Roles | Problems Found |
|---|---|---|---|---|---|---|
| Dashboard | `/admin` | `app/Filament/Pages/Dashboard.php`, `resources/views/filament/pages/chat-workspace.blade.php` | Working with scoped chat shell | WhatsApp workspace and quick operational overview | Admin, Supervisor, Employee | Still a custom dashboard shell; uses normal page navigation rather than SPA navigation. |
| Conversations | `/admin/conversations` | `app/Filament/Resources/ConversationResource.php` | Working | Conversation list and transfer/close actions | Admin, Supervisor, Employee scoped | Polling remains every 3s; deeper performance work deferred. |
| Waiting List | `/admin/waiting-list` | `app/Filament/Pages/WaitingList.php` | Placeholder working | Pending/unassigned queue | Admin, Supervisor, Employee scoped | True unassigned workflow still incomplete. |
| Contacts | `/admin/contacts` | `app/Filament/Resources/ContactResource.php` | Working with role scope | Customer/contact list | Admin, Supervisor scoped to team, Employee scoped to assigned contacts | Contact ViewAction still needs a dedicated view page later. |
| Assignment Log | `/admin/assignments` | `app/Filament/Resources/AssignmentResource.php` | Working and protected | Assignment audit trail | Admin, Supervisor scoped | Employee direct access now blocked. |
| Team / Employees | `/admin/users` | `app/Filament/Resources/UserResource.php` | Working, clearer label | Create/manage employees and assign role/team/status | Admin full, Supervisor scoped view | Full employee profile panels still pending. |
| Reports | `/admin/reports` | `app/Filament/Pages/Reports.php` | Placeholder working | Business reports and analytics | Admin, Supervisor later/team-scoped | Report widgets/data not implemented yet. |
| Permissions | `/admin/permissions` | `app/Filament/Pages/Permissions.php` | Placeholder working | Role permission matrix | Admin | Configurable permission matrix not implemented yet. |
| Settings | `/admin/settings` | `app/Filament/Pages/Settings.php` | Placeholder working | System and WhatsApp settings | Admin | Real settings forms not implemented yet. |

## Phase 3A Waiting List Screen Update - 2026-05-29 12:30:00 +03:00

| Screen | Route | Current Purpose | Recommended Purpose | Working Status | Design Status | Logic Status | Notes |
|---|---|---|---|---|---|---|---|
| Waiting List | `/admin/waiting-list` | Operational queue for pending/unassigned WhatsApp conversations. | Daily triage screen where admin/supervisor assigns waiting conversations to employees. | Working | Filament table matching current admin style | Working with role-scoped query and assign action | Employees are blocked. Supervisors see only team-scoped pending rows. Global unscoped rows are admin-only. |

## Phase 3B Team / Employees Screen Update - 2026-05-29 12:45:48 +03:00

| Screen | Route | Current Purpose | Recommended Purpose | Working Status | Design Status | Logic Status | Notes |
|---|---|---|---|---|---|---|---|
| Team / Employees | `/admin/users` | Employee list/create/edit and profile entry point. | Manage employees and inspect workload/profile details. | Working | Filament resource style | Working with admin/supervisor scopes | Added `View` action and `/admin/users/{record}` profile. |
| Employee Profile | `/admin/users/{record}` | Employee details, workload, assignments, and conversations. | Clear employee profile for admin/supervisor review. | Working | Filament section layout | Backend scoped by `UserPolicy` and `UserResource::getEloquentQuery()` | Employee self-view not implemented. |

## Phase 3C Reports Dashboard Update - 2026-05-29

| Screen | Route | Current Purpose | Recommended Purpose | Working Status | Design Status | Logic Status | Notes |
|---|---|---|---|---|---|---|---|
| Reports | `/admin/reports` | Real business reports and analytics with KPI cards, tables, and filters. | Business reporting for WhatsApp operations. | Working | Filament page with custom RTL cards/tables | Working with role-scoped queries | Admin sees global data; supervisor sees team-only data; employee blocked. |

## Phase 3D Settings & WhatsApp Health Update - 2026-05-29

| Screen | Route | Current Purpose | Recommended Purpose | Working Status | Design Status | Logic Status | Notes |
|---|---|---|---|---|---|---|---|
| Settings | `/admin/settings` | Real admin settings dashboard with WhatsApp health, webhook status, routing rules, notifications, and chat behavior. | System configuration and WhatsApp health checks. | Working | Filament page with custom RTL sections/status cards | Working with config/env reads | Admin-only; supervisor/employee blocked. Read-only status dashboard — no editable forms yet. |

## Global Theme Mode Update - 2026-05-29

### Theme Support Per Screen

| Screen | Route | Dark Mode | Light Mode | RTL Status | Sidebar Right |
|--------|-------|-----------|------------|------------|---------------|
| Dashboard (Workspace) | `/admin` | ✅ Workspace dark vars | ✅ Via `html.crm-theme-light` | ✅ RTL | ✅ Right side |
| Conversations | `/admin/conversations` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |
| Conversation View | `/admin/conversations/{record}` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |
| Waiting List | `/admin/waiting-list` | ✅ Tailwind dark classes | ✅ Tailwind light | ✅ RTL | ✅ Right side |
| Contacts | `/admin/contacts` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |
| Contact Create | `/admin/contacts/create` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |
| Assignment Log | `/admin/assignments` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |
| Team | `/admin/teams` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |
| Users | `/admin/users` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |
| User Create | `/admin/users/create` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |
| User Edit | `/admin/users/{record}/edit` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |
| Reports | `/admin/reports` | ✅ Tailwind dark classes | ✅ Tailwind light | ✅ RTL | ✅ Right side |
| Permissions | `/admin/permissions` | ✅ Tailwind dark classes | ✅ Tailwind light | ✅ RTL | ✅ Right side |
| Settings | `/admin/settings` | ✅ Tailwind dark classes | ✅ Tailwind light | ✅ RTL | ✅ Right side |
| My Profile | `/admin/my-profile` | ✅ Tailwind dark classes | ✅ Tailwind light | ✅ RTL | ✅ Right side |
| Auto Replies | `/admin/auto-replies` | ✅ Global CSS vars | ✅ Global CSS vars | ✅ RTL | ✅ Right side |

All screens pass: Dark mode works, Light mode works, Sidebar stays on right in both modes, RTL is correct in both modes.

## Primary Color Change Update — 2026-05-30

### Primary Color Support Per Screen

| Screen | Route | Color Picker | Primary Color Applied | Notes |
|--------|-------|--------------|-----------------------|-------|
| Dashboard (Workspace) | `/admin` | ✅ In topbar | ✅ Via `--wa: var(--crm-primary)` | Inline picker + reset button |
| Settings | `/admin/settings` | ✅ Section 7 | ✅ Via `--crm-accent: var(--crm-primary)` | Full picker with hex input + mode buttons + reset |
| Conversations | `/admin/conversations` | — | ✅ `--crm-accent: var(--crm-primary)` | Buttons, badges, active states |
| Waiting List | `/admin/waiting-list` | — | ✅ Global CSS vars cascade | Assign buttons |
| Contacts | `/admin/contacts` | — | ✅ Global CSS vars cascade | Action buttons |
| Users / Employees | `/admin/users` | — | ✅ Global CSS vars cascade | Table actions |
| Reports | `/admin/reports` | — | ✅ Global CSS vars cascade | KPI accents |
| Permissions | `/admin/permissions` | — | ✅ Global CSS vars cascade | All primary accents |
| All other admin pages | — | — | ✅ Global CSS vars cascade | Primary color change applies everywhere |

Primary color persists across refresh and navigation via `localStorage['crm-primary-color']`.
Reset to default (#16a34a) available from Dashboard topbar or Settings page.
