<div x-data="{ open: {{ request()->routeIs('sales-requisitions.*', 'sales-orders.*', 'sales-quotations.*', 'delivery-notes.*', 'sales.representatives.*', 'sales.commissions.*', 'sales.targets.*') ? 'true' : 'false' }} }" class="mb-1">
    @permission(['sales.requisitions.view', 'sales.representatives.view'])
    <button @click="open = !open" class="group flex items-center p-3 py-2 text-base font-medium rounded-md
        {{ request()->routeIs('sales-requisitions.*', 'sales-orders.*', 'sales-quotations.*', 'delivery-notes.*', 'sales.representatives.*', 'sales.commissions.*', 'sales.targets.*') ? '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('sales-requisitions.*', 'sales-orders.*', 'sales-quotations.*', 'delivery-notes.*') ? '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('Sales Representatives', __('مندوبي المبيعات')) }}</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('sales.requisitions.view')
        <a href="{{ route('sales-requisitions.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('sales-requisitions.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('sales-requisitions.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Sales Requests', __('Sales Requests')) }}</span>
        </a>
        @endpermission

        @permission('sales.quotations.view')
        <a href="{{ route('sales-quotations.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('sales-quotations.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('sales-quotations.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Customer Quotations', __('Customer Quotations')) }}</span>
        </a>
        @endpermission

        @permission('sales.orders.view')
        <a href="{{ route('sales-orders.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('sales-orders.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('sales-orders.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Sales Orders', __('Sales Orders')) }}</span>
        </a>
        @endpermission

        @permission('sales.delivery_notes.view')
        <a href="{{ route('delivery-notes.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('delivery-notes.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('delivery-notes.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Delivery Notes', __('Delivery Notes')) }}</span>
        </a>
        @endpermission

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

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

        @permission('sales.targets.view')
        <a href="{{ route('sales.targets.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('sales.targets.*') ? '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('sales.targets.*') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Sales Targets', __('المستهدفات البيعية')) }}</span>
        </a>
        @endpermission
    </div>
    @endpermission
</div>
