﻿<div x-data="{ open: {{ request()->routeIs('suppliers.*') || request()->routeIs('supplier-invoices.*') || request()->routeIs('supplier-payments.*') || request()->routeIs('reports.purchase.*') ? 'true' : 'false' }} }" class="mb-1">
    @permission('suppliers.view')
    <button @click="open = !open" class="group flex items-center p-3 py-2 text-base font-medium rounded-md
        {{ request()->routeIs('suppliers.*') || request()->routeIs('supplier-invoices.*') || request()->routeIs('supplier-payments.*') || request()->routeIs('reports.purchase.*') ? '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('suppliers.*') || request()->routeIs('supplier-invoices.*') || request()->routeIs('supplier-payments.*') || request()->routeIs('reports.purchase.*') ? '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="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4" />
        </svg>
        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Suppliers System', __('Suppliers 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('suppliers.view')
        <a href="{{ route('suppliers.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('suppliers.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('suppliers.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Suppliers List', __('Suppliers List')) }}</span>
        </a>
        @endpermission

        <!-- إضافة مورد جديد -->
        @permission('suppliers.create')
        <a href="{{ route('suppliers.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('suppliers.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('suppliers.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Supplier', __('Add New Supplier')) }}</span>
        </a>
        @endpermission

        <!-- فواتير الموردين -->
        @permission('supplier-invoices.view')
        <a href="{{ route('supplier-invoices.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('supplier-invoices.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('supplier-invoices.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Supplier Invoices', __('Supplier Invoices')) }}</span>
        </a>
        @endpermission

        <!-- إضافة فاتورة جديدة -->
        @permission('supplier-invoices.create')
        <a href="{{ route('supplier-invoices.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('supplier-invoices.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('supplier-invoices.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Invoice', __('Add New Invoice')) }}</span>
        </a>
        @endpermission

        <!-- دفعات الموردين -->
        @permission('supplier-payments.view')
        <a href="{{ route('supplier-payments.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('supplier-payments.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('supplier-payments.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Supplier Payments', __('Supplier Payments')) }}</span>
        </a>
        @endpermission

        <!-- إضافة دفعة جديدة -->
        @permission('supplier-payments.create')
        <a href="{{ route('supplier-payments.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('supplier-payments.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('supplier-payments.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Payment', __('Add New Payment')) }}</span>
        </a>
        @endpermission

        <!-- تقارير الموردين -->
        @permission('supplier-reports.view')
        <a href="{{ route('reports.purchase.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('reports.purchase.*') ? '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('reports.purchase.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Supplier Reports', __('Supplier Reports')) }}</span>
        </a>
        @endpermission
    </div>
    @endpermission
</div>
