# Sidebar Settings Implementation Plan

**Goal:** Give admins a separate page of sidebar visibility checkboxes.

**Architecture:** A SidebarSettings service owns the core section catalog, business-scoped system-table persistence, and filtering of named menu items. A controller validates and saves choices. Existing sidebar middleware assigns stable names and applies visibility after construction.

**Tech stack:** Existing Laravel, Blade, Nwidart menus, PHPUnit, SQLite tests.

## Constraints
- One checkbox per top-level section, applying to its children.
- Settings link remains available to admins even when every checkbox is cleared.
- Existing roles and module enablement still determine eligibility.
- No migrations, dependencies, or changes to existing saved module configuration.

## Tasks
- [x] Write and run failing tests in tests/Feature/SidebarSettingsTest.php for rendered visibility, persistence, business isolation, admin restrictions and invalid values.
- [x] Create app/Services/SidebarSettings.php with sections(), visibility(int), save(int, array), and apply(MenuBuilder, array). Save explicit booleans; default missing keys to true.
- [x] Add app/Http/Controllers/SidebarSettingsController.php and authenticated GET/POST /sidebar-settings routes. Use authenticated user business_id, validate every section boolean, reject unknown keys, redirect with save feedback.
- [x] Assign stable names to each existing top-level menu in app/Http/Middleware/AdminSidebarMenu.php. Add permanent admin Sidebar Settings entry, then apply saved visibility.
- [x] Create resources/views/sidebar_settings/index.blade.php using the existing layout, native labeled checkboxes, select-all/clear-all buttons and Save Settings. Explain business-wide visibility and retained permissions.
- [x] Run targeted tests, PHP syntax checks and page rendering; inspect final changes and report results.

## Verification results
10 targeted tests passed (83 assertions), including actual Blade page and sidebar rendering, admin authorization, business isolation, all-hidden recovery and restoring visibility. PHP syntax checks passed for all changed PHP source files. No real business preferences were changed. Browser reached the login screen; the isolated local-file preview was blocked by browser URL policy, so interactive visual verification was not completed.
