<div x-data="{ open: {{ request()->routeIs('einvoices.*') || request()->routeIs('zatca.*') ? 'true' : 'false' }} }" class="mb-1">
    @permission('einvoices.view')
    <button @click="open = !open" class="group flex items-center p-3 py-2 text-base font-medium rounded-md
        {{ request()->routeIs('einvoices.*') || request()->routeIs('zatca.*') ? '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('einvoices.*') || request()->routeIs('zatca.*') ? '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 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
        </svg>
        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('E-Invoices System', __('E-Invoices 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">
        <!-- 🔗 ربط ZATCA - خطوة البداية الأساسية -->
        @permission('zatca.settings.view')
        <a href="{{ route('zatca.simple-binding.show') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('zatca.simple-binding.*') ? 'text-red-800 bg-red-100' : 'text-gray-700 hover:text-red-800 hover:bg-red-50' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('zatca.simple-binding.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>
                <i class="fas fa-link text-red-700 ml-1"></i>
                {{ \App\Helpers\TranslationHelper::transFromDatabase('Connect ZATCA', __('Connect ZATCA')) }}
            </span>
        </a>
        @endpermission

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

        <!-- ➕ إنشاء فاتورة إلكترونية جديدة -->
        @permission('einvoices.create')
        <a href="{{ route('einvoices.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('einvoices.create') ? 'text-red-800 bg-red-100' : 'text-gray-700 hover:text-red-800 hover:bg-red-50' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('einvoices.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Create E-Invoice', __('Create E-Invoice')) }}</span>
        </a>
        @endpermission
    </div>
    @endpermission
</div>
