# Sidebar Unification Fix — 2026-05-30

## Strategy
Replace two separate sidebar systems with Filament's native NavigationBuilder defined centrally in AdminPanelProvider. Remove the custom sidebar from the Dashboard. Filament's sidebar (already styled by crm-theme.css) becomes the single source of truth on all pages.

## New Source of Truth
`app/Providers/Filament/AdminPanelProvider.php` — `->navigation()` callback

### Navigation Items (in order)
| Label | Route Name | Icon | Roles |
|-------|-----------|------|-------|
| لوحة التحكم | filament.admin.pages.dashboard | heroicon-o-home | all |
| المحادثات | filament.admin.resources.conversations.index | heroicon-o-chat-bubble-left-right | all |
| قائمة الانتظار | filament.admin.pages.waiting-list | heroicon-o-clock | admin, supervisor |
| جهات الاتصال | filament.admin.resources.contacts.index | heroicon-o-user-group | admin, supervisor |
| سجل التكليفات | filament.admin.resources.assignments.index | heroicon-o-clipboard-document-list | admin, supervisor |
| الفريق / الموظفون | filament.admin.resources.users.index | heroicon-o-users | admin, supervisor |
| التقارير | filament.admin.pages.reports | heroicon-o-chart-bar | admin, supervisor |
| الصلاحيات | filament.admin.pages.permissions | heroicon-o-shield-check | admin only |
| الردود التلقائية | filament.admin.resources.auto-replies.index | heroicon-o-arrow-path-rounded-square | admin only |
| الإعدادات | filament.admin.pages.settings | heroicon-o-cog-6-tooth | admin only |
| ملفي الشخصي | filament.admin.pages.my-profile | heroicon-o-user-circle | all |

## Files Changed

### AdminPanelProvider.php
- Added `NavigationBuilder` and `NavigationItem` imports
- Added `->navigation()` callback with all 11 items
- Role-based visibility via `$user->hasRole()` / `$user->hasAnyRole()`
- Active state via `isActiveWhen(fn() => request()->routeIs(...))`

### chat-workspace.blade.php (Dashboard view)
- Removed `<aside class="sidebar" id="sidebar">` HTML block
- Removed `const NAV_ITEMS = [...]` array
- Removed `renderSidebar()` function and its call from `renderAll()`
- Removed `selectView()` function
- Removed `initSidebarToggle()` function and call
- Removed `state.activeView` property

### crm-theme.css (section 15)
- Removed: `body.fi-body:has(.app) .fi-sidebar { display: none }`
- Removed: `body.fi-body:has(.app) .fi-sidebar-close-overlay { display: none }`
- Removed: `body.fi-body:has(.app) .fi-layout { display: block }` (restore Filament flex layout)
- Kept: `body.fi-body:has(.app) .fi-topbar { display: none }` (custom topbar inside page)
- Kept: padding-0 rules for `.fi-main` and `.fi-main-ctn`

### chat-workspace.css
- Removed: `.fi-sidebar` and `.fi-sidebar-close-overlay` from display:none rule
- Changed: `.app { grid-template-columns: 270px 1fr }` → `.app { display: block }`
- Removed: `.app:has(.sidebar.collapsed)` rule

### All Filament Pages (navigationGroup set to null, labels fixed to Arabic)
- WaitingList.php: "WhatsApp" → null, "Waiting List" → "قائمة الانتظار"
- Settings.php: "Management" → null, "Settings" → "الإعدادات"
- Reports.php: "Management" → null, "Reports" → "التقارير"
- Permissions.php: "Management" → null, "Permissions" → "الصلاحيات"
- MyProfile.php: "Management" → null, "My Profile" → "ملفي الشخصي"

### All Filament Resources (navigationGroup set to null)
- UserResource.php: "Management" → null, "Team / Employees" → "الفريق / الموظفون"
- AutoReplyResource.php: "Management" → null, "Auto Replies" → "الردود التلقائية"
- ContactResource.php: "واتساب" → null (label already Arabic)
- ConversationResource.php: "واتساب" → null (label already Arabic)
- AssignmentResource.php: "واتساب" → null (label already Arabic)
- TeamResource.php: "الإدارة" → null (label already Arabic)
- WebhookEventResource.php: "النظام" → null (label already Arabic)

## Sidebar Styling
The Filament sidebar was already styled correctly by `crm-theme.css` (sections starting line ~141):
- Dark background (`--crm-bg`)
- Correct active state with `--crm-accent-soft` background and `--crm-accent` color
- Hover effects, proper fonts, RTL direction

## Result
- One sidebar source of truth: AdminPanelProvider NavigationBuilder
- Same Filament sidebar on ALL pages (Dashboard, WaitingList, Settings, etc.)
- Sidebar always on the right (RTL via Filament's native RTL support)
- No duplicate sidebar
- No legacy sidebar conflicts
- Role-based visibility enforced at navigation level
- All 25 admin routes return 302 (no 404/500)
