<div x-data="{ open: {{ request()->routeIs('customers.*') || request()->routeIs('customer-invoices.*') || request()->routeIs('customer-payments.*') || request()->routeIs('customer-invoice-returns.*') ? 'true' : 'false' }} }" class="mb-1">
    @permission('customers.view')
    <button @click="open = !open" class="group flex items-center p-3 py-2 text-base font-medium rounded-md
        {{ request()->routeIs('customers.*') || request()->routeIs('customer-invoices.*') || request()->routeIs('customer-payments.*') || request()->routeIs('customer-invoice-returns.*') ? '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('customers.*') || request()->routeIs('customer-invoices.*') || request()->routeIs('customer-payments.*') || request()->routeIs('customer-invoice-returns.*') ? '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 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
        </svg>
        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Customers System', __('Customers 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('customers.view')
        <a href="{{ route('customers.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('customers.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customers.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Customers List', __('Customers List')) }}</span>
        </a>
        @endpermission

        @permission('customers.create')
        <a href="{{ route('customers.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('customers.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customers.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Customer', __('Add New Customer')) }}</span>
        </a>
        @endpermission

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

        @permission('customer-invoices.create')
        <a href="{{ route('customer-invoices.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('customer-invoices.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-invoices.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Invoice', __('Add New Invoice')) }}</span>
        </a>
        @endpermission

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

        @permission('customer-payments.create')
        <a href="{{ route('customer-payments.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('customer-payments.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-payments.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Payment', __('Add New Payment')) }}</span>
        </a>
        @endpermission

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

        @permission('customer-invoice-returns.create')
        <a href="{{ route('customer-invoice-returns.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('customer-invoice-returns.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-invoice-returns.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Return', __('Add New Return')) }}</span>
        </a>
        @endpermission

        <div class="my-2 border-t border-gray-200"></div>

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