<div x-data="{
    sidebarOpen: () => { try { return $store.sidebar.open } catch { return true } },
    toggleSidebar: () => { try { $store.sidebar.toggle() } catch { console.log('Sidebar store not available yet') } }
}" class="sidebar bg-white shadow-lg" :class="{ 'hidden': !sidebarOpen() }">
    <!-- رأس القائمة الجانبية -->
    <div class="flex items-center justify-between p-4 border-b border-gray-200 flex-shrink-0 h-auto bg-white">
        <div class="flex items-center">
            <x-application-logo class="h-8 w-auto" style="max-height: 32px;" />
            <h2 class="text-sm font-bold text-red-800 mr-2">
                {{ \App\Models\SystemSetting::get('system_name', \App\Helpers\TranslationHelper::transFromDatabase('Sales and Service Management System', __('Sales and Service Management System'))) }}
            </h2>
        </div>
        <button @click="toggleSidebar()"
            class="text-gray-700 hover:text-red-700 focus:outline-none p-2 rounded-md hover:bg-gray-100">
            <svg xxmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24"
                stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
            </svg>
        </button>
    </div>

    <!-- قائمة العناصر -->
    <nav class="p-2">
        @php
            // جلب إعدادات الرؤية من قاعدة البيانات بشكل عام (لجميع الشركات)
            $sidebarVisibilityMap = \App\Models\SidebarVisibility::pluck('is_visible', 'module_name')
                ->map(fn($visible) => (bool) $visible)
                ->toArray();
            
            $isSidebarVisible = function (string $module) use ($sidebarVisibilityMap) {
                return $sidebarVisibilityMap[$module] ?? true;
            };

            $userHasAnyPermission = function (array $permissions) {
                if (!auth()->check()) return false;
                $user = auth()->user();
                foreach ($permissions as $perm) {
                    if ($user->hasPermission($perm)) return true;
                }
                return false;
            };
        @endphp
        @if ($isSidebarVisible('dashboard'))
            <!-- لوحة التحكم -->
            <a href="{{ route('dashboard') }}"
                class="group flex items-center p-3 py-2 text-base font-medium rounded-md mb-1
            {{ request()->routeIs('dashboard') ? 'bg-red-100 text-red-800' : 'text-gray-800 hover:bg-red-50 hover:text-red-800' }}">
                <svg xmlns="http://www.w3.org/2000/svg"
                    class="ml-3 flex-shrink-0 h-6 w-6
                {{ request()->routeIs('dashboard') ? 'text-red-700' : 'text-gray-700 group-hover:text-red-700' }}"
                    fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                        d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
                </svg>
                <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Dashboard', __('Dashboard')) }}</span>
            </a>
        @endif


        @if ($isSidebarVisible('accounting') && $userHasAnyPermission(['accounting.chart-of-accounts.view', 'accounting.chart-of-accounts.tree', 'accounting.chart-of-accounts.create', 'accounting.account-categories.view', 'accounting.fiscal-years.view', 'accounting.accounting-periods.view', 'accounting.journal-entries.view', 'accounting.ledger.view', 'accounting.ledger.account-balances', 'accounting.ledger.trial-balance', 'accounting.ledger.income-statement', 'accounting.ledger.balance-sheet']))
            <!-- نظام الحسابات -->
            <div x-data="{ open: {{ request()->routeIs('accounting.*') ? 'true' : 'false' }} }" class="mb-1">
                <button @click="open = !open"
                    class="group flex items-center p-3 py-2 text-base font-medium rounded-md
                {{ request()->routeIs('accounting.*') ? 'bg-red-100 text-red-800' : 'text-gray-700 hover:bg-red-50 hover:text-red-800' }}">
                    <svg xxmlns="http://www.w3.org/2000/svg"
                        class="ml-3 flex-shrink-0 h-6 w-6
                    {{ request()->routeIs('accounting.*') ? 'text-red-700' : 'text-gray-500 group-hover:text-red-700' }}"
                        fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                    </svg>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Accounting System', __('Accounting System')) }}</span>
                    <svg :class="{ 'rotate-180': open, 'rotate-0': !open }"
                        class="mr-auto h-5 w-5 transform transition-transform duration-200"
                        xxmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                        <path fill-rule="evenodd"
                            d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
                            clip-rule="evenodd" />
                    </svg>
                </button>
                <div x-show="open" x-transition class="pr-4 mr-4 border-r border-gray-200">
                    <!-- دليل الحسابات -->
                    @permission('accounting.chart-of-accounts.view')
                        <a href="{{ route('accounting.chart-of-accounts.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.chart-of-accounts.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.chart-of-accounts.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Chart of Accounts', __('Chart of Accounts')) }}</span>
                        </a>
                    @endpermission

                    <!-- شجرة الحسابات -->
                    @permission('accounting.chart-of-accounts.tree')
                        <a href="{{ route('accounting.chart-of-accounts.tree') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.chart-of-accounts.tree') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.chart-of-accounts.tree') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Accounts Tree', __('Accounts Tree')) }}</span>
                        </a>
                    @endpermission

                    <!-- إنشاء حساب جديد -->
                    @permission('accounting.chart-of-accounts.create')
                        <a href="{{ route('accounting.chart-of-accounts.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.chart-of-accounts.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.chart-of-accounts.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Create New Account', __('Create New Account')) }}</span>
                        </a>
                    @endpermission

                    <!-- فئات الحسابات -->
                    @permission('accounting.account-categories.view')
                        <a href="{{ route('accounting.account-categories.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.account-categories.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.account-categories.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Account Categories', __('Account Categories')) }}</span>
                        </a>
                    @endpermission

                    <!-- السنوات المالية -->
                    @permission('accounting.fiscal-years.view')
                        <a href="{{ route('accounting.fiscal-years.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.fiscal-years.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.fiscal-years.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Fiscal Years', __('Fiscal Years')) }}</span>
                        </a>
                    @endpermission

                    <!-- الفترات المحاسبية -->
                    @permission('accounting.accounting-periods.view')
                        <a href="{{ route('accounting.accounting-periods.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.accounting-periods.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.accounting-periods.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Accounting Periods', __('Accounting Periods')) }}</span>
                        </a>
                    @endpermission

                    <!-- قيود اليومية -->
                    @permission('accounting.journal-entries.view')
                        <a href="{{ route('accounting.journal-entries.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.journal-entries.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.journal-entries.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Journal Entries', __('Journal Entries')) }}</span>
                        </a>
                    @endpermission

                    <!-- دفتر الأستاذ -->
                    @permission('accounting.ledger.view')
                        <a href="{{ route('accounting.ledger.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.ledger.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.ledger.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Ledger', __('Ledger')) }}</span>
                        </a>
                    @endpermission

                    <!-- أرصدة الحسابات -->
                    @permission('accounting.ledger.account-balances')
                        <a href="{{ route('accounting.ledger.account-balances') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.ledger.account-balances') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.ledger.account-balances') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Account Balances', __('Account Balances')) }}</span>
                        </a>
                    @endpermission

                    <!-- ميزان المراجعة -->
                    @permission('accounting.ledger.trial-balance')
                        <a href="{{ route('accounting.ledger.trial-balance') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.ledger.trial-balance') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.ledger.trial-balance') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Trial Balance', __('Trial Balance')) }}</span>
                        </a>
                    @endpermission

                    <!-- قائمة الدخل -->
                    @permission('accounting.ledger.income-statement')
                        <a href="{{ route('accounting.ledger.income-statement') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.ledger.income-statement') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.ledger.income-statement') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Income Statement', __('Income Statement')) }}</span>
                        </a>
                    @endpermission

                    <!-- الميزانية العمومية -->
                    @permission('accounting.ledger.balance-sheet')
                        <a href="{{ route('accounting.ledger.balance-sheet') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.ledger.balance-sheet') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.ledger.balance-sheet') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Balance Sheet', __('Balance Sheet')) }}</span>
                        </a>
                    @endpermission
                </div>
            </div>
        @endif

        @if ($isSidebarVisible('cost_centers') && $userHasAnyPermission(['accounting.cost-center-types.view', 'accounting.cost-center-types.create', 'accounting.cost-center-categories.view', 'accounting.cost-center-categories.create', 'accounting.cost-centers.view', 'accounting.cost-centers.create', 'reports.cost-center.view']))
            <!-- نظام مراكز التكاليف -->
            <div x-data="{ open: {{ request()->routeIs('accounting.cost-center-types.*', 'accounting.cost-center-categories.*', 'accounting.cost-centers.*', 'accounting.cost-centers.tree') ? 'true' : 'false' }} }" class="mb-1">
                <button @click="open = !open"
                    class="group flex items-center p-3 py-2 text-base font-medium rounded-md
                {{ request()->routeIs('accounting.cost-center-types.*', 'accounting.cost-center-categories.*', 'accounting.cost-centers.*', 'accounting.cost-centers.tree') ? 'bg-red-100 text-red-800' : 'text-gray-700 hover:bg-red-50 hover:text-red-800' }}">
                    <svg xxmlns="http://www.w3.org/2000/svg"
                        class="ml-3 flex-shrink-0 h-6 w-6
                    {{ request()->routeIs('accounting.cost-center-types.*', 'accounting.cost-center-categories.*', 'accounting.cost-centers.*', 'accounting.cost-centers.tree') ? 'text-red-700' : 'text-gray-500 group-hover:text-red-700' }}"
                        fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z" />
                    </svg>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Cost Centers System', __('Cost Centers System')) }}</span>
                    <svg :class="{ 'rotate-180': open, 'rotate-0': !open }"
                        class="mr-auto h-5 w-5 transform transition-transform duration-200"
                        xxmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                        <path fill-rule="evenodd"
                            d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
                            clip-rule="evenodd" />
                    </svg>
                </button>
                <div x-show="open" x-transition class="pr-4 mr-4 border-r border-gray-200">
                    <!-- قائمة أنواع مراكز التكاليف -->
                    @permission('accounting.cost-center-types.view')
                        <a href="{{ route('accounting.cost-center-types.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.cost-center-types.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.cost-center-types.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Cost Center Types', __('Cost Center Types')) }}</span>
                        </a>
                    @endpermission

                    <!-- إضافة نوع مركز تكاليف جديد -->
                    @permission('accounting.cost-center-types.create')
                        <a href="{{ route('accounting.cost-center-types.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.cost-center-types.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.cost-center-types.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Type', __('Add New Type')) }}</span>
                        </a>
                    @endpermission

                    <!-- قائمة فئات مراكز التكاليف -->
                    @permission('accounting.cost-center-categories.view')
                        <a href="{{ route('accounting.cost-center-categories.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.cost-center-categories.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.cost-center-categories.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Cost Center Categories', __('Cost Center Categories')) }}</span>
                        </a>
                    @endpermission

                    <!-- إضافة فئة مركز تكاليف جديدة -->
                    @permission('accounting.cost-center-categories.create')
                        <a href="{{ route('accounting.cost-center-categories.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.cost-center-categories.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.cost-center-categories.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Category', __('Add New Category')) }}</span>
                        </a>
                    @endpermission

                    <!-- قائمة مراكز التكاليف -->
                    @permission('accounting.cost-centers.view')
                        <a href="{{ route('accounting.cost-centers.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.cost-centers.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.cost-centers.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Cost Centers List', __('قائمة مراكز التكلفة')) }}</span>
                        </a>
                    @endpermission

                    <!-- شجرة مراكز التكاليف -->
                    @permission('accounting.cost-centers.view')
                        <a href="{{ route('accounting.cost-centers.tree') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.cost-centers.tree') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.cost-centers.tree') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Cost Centers Tree', __('شجرة مراكز التكلفة')) }}</span>
                        </a>
                    @endpermission

                    <!-- إضافة مركز تكاليف جديد -->
                    @permission('accounting.cost-centers.create')
                        <a href="{{ route('accounting.cost-centers.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('accounting.cost-centers.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('accounting.cost-centers.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Cost Center', __('إضافة مركز تكلفة جديد')) }}</span>
                        </a>
                    @endpermission
                    @permission('reports.cost-center.view')
                        <a href="{{ route('reports.cost-center') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('reports.cost-center*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('reports.cost-center*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span class="text-sm">@lang('Reports')</span>

                        </a>
                    @endpermission
                </div>
            </div>
        @endif



        @if ($isSidebarVisible('banking') && $userHasAnyPermission(['banking.view', 'banking.create', 'banking.accounts.view', 'banking.deposits.view', 'banking.withdrawals.view', 'banking.checks.view', 'banking.reconciliations.view', 'banking.reports.view']))
            <!-- نظام البنوك -->
            @include('layouts.sidebar-banking')
        @endif

        @if ($isSidebarVisible('inventory') && $userHasAnyPermission(['inventory.warehouses.view', 'inventory.units.view', 'inventory.items.view', 'inventory.issues.view', 'inventory.raw_materials.issue.view', 'inventory.finished_goods.issue.view', 'inventory.receipts.view', 'inventory.transfers.view', 'inventory.counts.view', 'inventory.reports.view']))
            <!-- نظام المخازن -->
            @include('layouts.sidebar-inventory')
        @endif

        @if ($isSidebarVisible('hr') && $userHasAnyPermission(['hr.employees.view', 'hr.employees.create', 'hr.contracts.view', 'hr.contracts.create', 'hr.leaves.view', 'hr.leaves.create', 'hr.attendance.view', 'hr.attendance.create', 'hr.attendance.bulk-create', 'hr.attendance.report', 'hr.payrolls.view', 'hr.payrolls.create']))
            <!-- نظام شؤون الموظفين -->
            @include('layouts.sidebar-hr')
        @endif

        @if ($isSidebarVisible('suppliers') && $userHasAnyPermission(['suppliers.view', 'suppliers.create', 'supplier-invoices.view', 'supplier-invoices.create', 'supplier-payments.view', 'supplier-payments.create', 'supplier-reports.view']))
            <!-- نظام الموردين -->
            @include('layouts.sidebar-suppliers')
        @endif
        @if ($isSidebarVisible('purchasing') && $userHasAnyPermission(['purchasing.requisitions.view', 'purchasing.requisitions.create', 'purchasing.orders.view', 'purchasing.orders.create', 'purchasing.quotations.view', 'purchasing.quotations.create', 'purchasing.quotations.compare', 'purchasing.quotation-requests.view', 'purchasing.quotation-requests.create', 'purchasing.grn.view', 'purchasing.grn.create']))
            <!-- نظام المشتريات -->
            @include('layouts.sidebar-purchasing')
        @endif

        @if ($isSidebarVisible('customers') && $userHasAnyPermission(['customers.view', 'customers.create', 'customer-invoices.view', 'customer-invoices.create', 'customer-payments.view', 'customer-payments.create', 'customer-invoice-returns.view', 'customer-invoice-returns.create']))
            <!-- نظام العملاء -->
            @include('layouts.sidebar-customers')
        @endif

        @if ($isSidebarVisible('sales') && $userHasAnyPermission(['sales.requisitions.view', 'sales.quotations.view', 'sales.orders.view', 'sales.delivery_notes.view', 'sales.representatives.view', 'sales.commissions.view', 'sales.targets.view']))
            <!-- نظام المبيعات -->
            @include('layouts.sidebar-sales')
        @endif

        @if ($isSidebarVisible('einvoices') && $userHasAnyPermission(['einvoices.view', 'einvoices.create', 'zatca.settings.view']))
            <!-- نظام الفواتير الإلكترونية -->
            @include('layouts.sidebar-einvoices')
        @endif

        @if ($isSidebarVisible('assets') && $userHasAnyPermission(['assets.view', 'assets.create', 'asset_categories.view', 'asset_depreciations.view', 'asset_maintenance.view', 'asset_disposals.view', 'reports.view']))
            <!-- نظام إدارة الأصول -->
            @include('layouts.sidebar-assets')
        @endif

        @if ($isSidebarVisible('treasury') && $userHasAnyPermission(['treasury.view', 'treasury.create', 'treasury.deposit.view', 'treasury.deposit.create', 'treasury.payment.view', 'treasury.payment.create', 'treasury.transfer.view', 'treasury.transfer.create', 'treasury.report.view']))
            <!-- نظام الخزائن -->
            <div x-data="{ open: {{ request()->routeIs('treasury.*') ? 'true' : 'false' }} }" class="mb-1">
                <button @click="open = !open"
                    class="group flex items-center p-3 py-2 text-base font-medium rounded-md
                {{ request()->routeIs('treasury.*') ? 'bg-red-100 text-red-800' : 'text-gray-700 hover:bg-red-50 hover:text-red-800' }}">
                    <svg xxmlns="http://www.w3.org/2000/svg"
                        class="ml-3 flex-shrink-0 h-6 w-6
                    {{ request()->routeIs('treasury.*') ? 'text-red-700' : 'text-gray-500 group-hover:text-red-700' }}"
                        fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M17 9V7a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2m2 4h10a2 2 0 002-2v-6a2 2 0 00-2-2H9a2 2 0 00-2 2v6a2 2 0 002 2zm7-5a2 2 0 11-4 0 2 2 0 014 0z" />
                    </svg>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Treasury System', __('Treasury System')) }}</span>
                    <svg :class="{ 'rotate-180': open, 'rotate-0': !open }"
                        class="mr-auto h-5 w-5 transform transition-transform duration-200"
                        xxmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                        <path fill-rule="evenodd"
                            d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
                            clip-rule="evenodd" />
                    </svg>
                </button>
                <div x-show="open" x-transition class="pr-4 mr-4 border-r border-gray-200">
                    <!-- قائمة الخزائن -->
                    @permission('treasury.view')
                        <a href="{{ route('treasury.treasuries.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('treasury.treasuries.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('treasury.treasuries.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Treasuries List', __('Treasuries List')) }}</span>
                        </a>
                    @endpermission

                    <!-- إضافة خزينة جديدة -->
                    @permission('treasury.create')
                        <a href="{{ route('treasury.treasuries.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('treasury.treasuries.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('treasury.treasuries.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Treasury', __('Add New Treasury')) }}</span>
                        </a>
                    @endpermission

                    <!-- قائمة الإيداعات -->
                    @permission('treasury.deposit.view')
                        <a href="{{ route('treasury.deposits.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('treasury.deposits.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('treasury.deposits.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Deposits List', __('Deposits List')) }}</span>
                        </a>
                    @endpermission

                    <!-- إضافة إيداع جديد -->
                    @permission('treasury.deposit.create')
                        <a href="{{ route('treasury.deposits.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('treasury.deposits.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('treasury.deposits.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Deposit', __('Add New Deposit')) }}</span>
                        </a>
                    @endpermission

                    <!-- قائمة سندات الصرف -->
                    @permission('treasury.payment.view')
                        <a href="{{ route('treasury.payments.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('treasury.payments.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('treasury.payments.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Payment Vouchers List', __('Payment Vouchers List')) }}</span>
                        </a>
                    @endpermission

                    <!-- إضافة سند صرف جديد -->
                    @permission('treasury.payment.create')
                        <a href="{{ route('treasury.payments.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('treasury.payments.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('treasury.payments.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Payment Voucher', __('Add New Payment Voucher')) }}</span>
                        </a>
                    @endpermission

                    <!-- قائمة التحويلات -->
                    @permission('treasury.transfer.view')
                        <a href="{{ route('treasury.transfers.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('treasury.transfers.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('treasury.transfers.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Transfers List', __('Transfers List')) }}</span>
                        </a>
                    @endpermission

                    <!-- إضافة تحويل جديد -->
                    @permission('treasury.transfer.create')
                        <a href="{{ route('treasury.transfers.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('treasury.transfers.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('treasury.transfers.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Transfer', __('Add New Transfer')) }}</span>
                        </a>
                    @endpermission

                    <!-- تقارير الخزينة -->
                    @permission('treasury.report.view')
                        <a href="{{ route('treasury.reports.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('treasury.reports.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('treasury.reports.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Treasury Reports', __('Treasury Reports')) }}</span>
                        </a>
                    @endpermission
                </div>
            </div>
        @endif



        @if ($isSidebarVisible('reports') && $userHasAnyPermission(['purchasing.reports.view', 'customer-invoices.view', 'reports.cost-center.view', 'inventory.reports.view', 'hr.attendance.report', 'hr.payrolls.view', 'treasury.report.view']))
            <!-- التقارير -->
            @include('layouts.sidebar-reports')
        @endif
        @if ($isSidebarVisible('companies') && $userHasAnyPermission(['companies.view', 'companies.create', 'branches.view', 'branches.create']))
            @include('layouts.sidebar-companies')
        @endif

        @if ($isSidebarVisible('subscriptions'))
            <!-- نظام الاشتراكات - للعضو رقم 1 فقط -->
            @auth
                @if (auth()->id() == 1)
                    <div x-data="{ open: {{ request()->routeIs('subscriptions.*') ? 'true' : 'false' }} }" class="mb-1">
                        <button @click="open = !open"
                            class="group flex items-center p-3 py-2 text-base font-medium rounded-md
                    {{ request()->routeIs('subscriptions.*') ? 'bg-red-100 text-red-800' : 'text-gray-700 hover:bg-red-50 hover:text-red-800' }}">
                            <svg xxmlns="http://www.w3.org/2000/svg"
                                class="ml-3 flex-shrink-0 h-6 w-6
                        {{ request()->routeIs('subscriptions.*') ? 'text-red-700' : 'text-gray-500 group-hover:text-red-700' }}"
                                fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                    d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
                            </svg>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Manage Subscriptions', __('Manage Subscriptions')) }}</span>
                            <svg :class="{ 'rotate-180': open, 'rotate-0': !open }"
                                class="mr-auto h-5 w-5 transform transition-transform duration-200"
                                xxmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                                <path fill-rule="evenodd"
                                    d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
                                    clip-rule="evenodd" />
                            </svg>
                        </button>
                        <div x-show="open" x-transition class="pr-4 mr-4 border-r border-gray-200">
                            <a href="{{ route('subscriptions.index') }}"
                                class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                        {{ request()->routeIs('subscriptions.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                                <span
                                    class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('subscriptions.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                                <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Subscriptions List', __('Subscriptions List')) }}</span>
                            </a>
                            <a href="{{ route('subscriptions.create') }}"
                                class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                        {{ request()->routeIs('subscriptions.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                                <span
                                    class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('subscriptions.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                                <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Create New Subscription', __('Create New Subscription')) }}</span>
                            </a>
                        </div>
                    </div>
                @endif
            @endauth
        @endif

        <!-- الإعدادات العامة -->
        @if ($userHasAnyPermission(['countries.view', 'cities.view', 'regions.view']))
        <div x-data="{ open: {{ request()->routeIs('countries.*', 'cities.*', 'regions.*') ? 'true' : 'false' }} }" class="mb-1">
            <button @click="open = !open"
                class="group flex items-center p-3 py-2 text-base font-medium rounded-md
            {{ request()->routeIs('countries.*', 'cities.*', 'regions.*') ? 'bg-red-100 text-red-800' : 'text-gray-700 hover:bg-red-50 hover:text-red-800' }}">
                <svg xmlns="http://www.w3.org/2000/svg"
                    class="ml-3 flex-shrink-0 h-6 w-6
                {{ request()->routeIs('countries.*', 'cities.*', 'regions.*') ? 'text-red-700' : 'text-gray-500 group-hover:text-red-700' }}"
                    fill="none" viewBox="0 0 24 24" stroke="currentColor">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                        d="M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
                </svg>
                <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('General Settings', __('General Settings')) }}</span>
                <svg :class="{ 'rotate-180': open, 'rotate-0': !open }"
                    class="mr-auto h-5 w-5 transform transition-transform duration-200"
                    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                    <path fill-rule="evenodd"
                        d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
                        clip-rule="evenodd" />
                </svg>
            </button>
            <div x-show="open" x-transition class="pr-4 mr-4 border-r border-gray-200">
                <!-- الدول -->
                @permission('countries.view')
                    <a href="{{ route('countries.index') }}"
                        class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                {{ request()->routeIs('countries.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                        <span
                            class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('countries.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Countries', __('Countries')) }}</span>
                    </a>
                @endpermission

                <!-- المدن -->
                @permission('cities.view')
                    <a href="{{ route('cities.index') }}"
                        class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                {{ request()->routeIs('cities.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                        <span
                            class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('cities.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Cities', __('Cities')) }}</span>
                    </a>
                @endpermission

                <!-- المناطق -->
                @permission('regions.view')
                    <a href="{{ route('regions.index') }}"
                        class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                {{ request()->routeIs('regions.*') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                        <span
                            class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('regions.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Regions', __('Regions')) }}</span>
                    </a>
                @endpermission
            </div>
        </div>
        @endif

        @if ($isSidebarVisible('users'))
            <!-- إدارة المستخدمين -->

            <div x-data="{ open: false }" class="mb-1">
                <button @click="open = !open"
                    class="group flex items-center p-3 py-2 text-base font-medium rounded-md
                {{ request()->routeIs('users.*') || request()->routeIs('roles.*') ? 'bg-red-100 text-red-800' : 'text-gray-700 hover:bg-red-50 hover:text-red-800' }}">
                    <svg xxmlns="http://www.w3.org/2000/svg"
                        class="ml-3 flex-shrink-0 h-6 w-6
                    {{ request()->routeIs('users.*') || request()->routeIs('roles.*') ? 'text-red-700' : 'text-gray-500 group-hover:text-red-700' }}"
                        fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
                    </svg>
                    <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('User Management', __('User Management')) }}</span>
                    <svg :class="{ 'rotate-180': open, 'rotate-0': !open }"
                        class="mr-auto h-5 w-5 transform transition-transform duration-200"
                        xxmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
                        <path fill-rule="evenodd"
                            d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
                            clip-rule="evenodd" />
                    </svg>
                </button>
                <div x-show="open" x-transition class="pr-4 mr-4 border-r border-gray-200">
                    <a href="{{ route('users.index') }}"
                        class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('users.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                        <span
                            class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('users.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Users List', __('Users List')) }}</span>
                    </a>
                    @permission('users.create')
                        <a href="{{ route('users.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('users.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('users.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New User', __('Add New User')) }}</span>
                        </a>
                    @endpermission
                    <a href="{{ route('roles.index') }}"
                        class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('roles.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                        <span
                            class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('roles.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Roles List', __('Roles List')) }}</span>
                    </a>
                    @permission('roles.create')
                        <a href="{{ route('roles.create') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('roles.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('roles.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Role', __('Add New Role')) }}</span>
                        </a>
                    @endpermission
                    @role('super_admin')
                        <a href="{{ route('module-visibility.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('module-visibility.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('module-visibility.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Module Visibility Settings', __('Module Visibility Settings')) }}</span>
                        </a>
                        <a href="{{ route('sidebar-visibility.index') }}"
                            class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
                    {{ request()->routeIs('sidebar-visibility.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
                            <span
                                class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('sidebar-visibility.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
                            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Sidebar Visibility Settings', __('Sidebar Visibility Settings')) }}</span>
                        </a>
                    @endrole
                </div>
            </div>
        @endif



        @if ($isSidebarVisible('zakat_taxes') && $userHasAnyPermission(['taxes.view', 'taxes.manage']))
            <!-- نظام الزكاة والضرائب -->
            @include('layouts.sidebar-zakat-taxes')
        @endif

        @if ($isSidebarVisible('government_integrations') && $userHasAnyPermission(['government_integrations.view', 'qowa.view', 'baladi.view', 'sadad.view', 'zatca.settings.view', 'einvoices.view']))
            <!-- التكامل مع الأنظمة الحكومية -->
            @include('layouts.sidebar-government-integrations')
        @endif

        @if ($isSidebarVisible('translations'))
            <!-- إدارة الترجمات -->
            @include('layouts.sidebar-translations')
        @endif


        @if(auth()->user()->is_system_owner)
            <!-- إعدادات النظام (سوبر أدمن) -->
            <div class="mt-4 pt-4 border-t border-gray-200">
                <a href="{{ route('system-admin.settings.index') }}"
                    class="group flex items-center p-3 py-2 text-base font-medium rounded-md mb-1
                {{ request()->routeIs('system-admin.settings.*') ? 'bg-red-100 text-red-800' : 'text-gray-800 hover:bg-red-50 hover:text-red-800' }}">
                    <svg xxmlns="http://www.w3.org/2000/svg"
                        class="ml-3 flex-shrink-0 h-6 w-6
                    {{ request()->routeIs('system-admin.settings.*') ? 'text-red-700' : 'text-gray-700 group-hover:text-red-700' }}"
                        fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
                    </svg>
                    <span>إعدادات النظام</span>
                </a>

                <a href="{{ route('system-admin.business-activities.index') }}"
                    class="group flex items-center p-3 py-2 text-base font-medium rounded-md mb-1
                {{ request()->routeIs('system-admin.business-activities.*') ? 'bg-red-100 text-red-800' : 'text-gray-800 hover:bg-red-50 hover:text-red-800' }}">
                    <svg xmlns="http://www.w3.org/2000/svg"
                        class="ml-3 flex-shrink-0 h-6 w-6
                    {{ request()->routeIs('system-admin.business-activities.*') ? 'text-red-700' : 'text-gray-700 group-hover:text-red-700' }}"
                        fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
                    </svg>
                    <span>الأنشطة التجارية (الأنظمة)</span>
                </a>
            </div>
        @endif

    </nav>
</div>
