﻿﻿<div x-data="{ open: {{ request()->routeIs('customers.*') || request()->routeIs('customer-contracts.*') || request()->routeIs('customer-invoices.*') || request()->routeIs('customer-payments.*') || request()->routeIs('customer-invoice-returns.*') ? 'true' : 'false' }} }" class="mb-1">
    @can('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-contracts.*') || request()->routeIs('customer-invoices.*') || request()->routeIs('customer-payments.*') || request()->routeIs('customer-invoice-returns.*') ? 'bg-primary-100 text-primary-900' : 'text-gray-700 hover:bg-primary-50 hover:text-primary-900' }}">
        <svg xxmlns="http://www.w3.org/2000/svg" class="ml-3 flex-shrink-0 h-6 w-6 
            {{ request()->routeIs('customers.*') || request()->routeIs('customer-contracts.*') || request()->routeIs('customer-invoices.*') || request()->routeIs('customer-payments.*') || request()->routeIs('customer-invoice-returns.*') ? 'text-primary-600' : 'text-gray-500 group-hover:text-primary-600' }}" 
            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>نظام العملاء</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">
        <!-- قائمة العملاء -->
        @can('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-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customers.index') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>قائمة العملاء</span>
        </a>
        @endcan

        <!-- إضافة عميل جديد -->
        @can('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-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customers.create') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>إضافة عميل جديد</span>
        </a>
        @endcan

        <!-- عقود العملاء -->
        @can('customer-contracts.view')
        <a href="{{ route('customer-contracts.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('customer-contracts.index') ? 'text-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-contracts.index') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>عقود العملاء</span>
        </a>
        @endcan

        <!-- إضافة عقد جديد -->
        @can('customer-contracts.create')
        <a href="{{ route('customer-contracts.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('customer-contracts.create') ? 'text-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-contracts.create') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>إضافة عقد جديد</span>
        </a>
        @endcan

        <!-- فواتير العملاء -->
        @can('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-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-invoices.index') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>فواتير العملاء</span>
        </a>
        @endcan

        <!-- إضافة فاتورة جديدة -->
        @can('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-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-invoices.create') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>إضافة فاتورة جديدة</span>
        </a>
        @endcan

        <!-- دفعات العملاء -->
        @can('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-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-payments.index') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>دفعات العملاء</span>
        </a>
        @endcan

        <!-- إضافة دفعة جديدة -->
        @can('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-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-payments.create') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>إضافة دفعة جديدة</span>
        </a>
        @endcan

        <!-- مرتجعات فواتير العملاء -->
        @can('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-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-invoice-returns.index') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>مرتجعات الفواتير</span>
        </a>
        @endcan

        <!-- إضافة مرتجع جديد -->
        @can('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-primary-900' : 'text-gray-700 hover:text-primary-900' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('customer-invoice-returns.create') ? 'bg-primary-600' : 'bg-gray-500' }}"></span>
            <span>إضافة مرتجع جديد</span>
        </a>
        @endcan

        <!-- تقارير العملاء -->
        @can('customer-reports.view')
        <a href="#" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            text-gray-700 hover:text-primary-900">
            <span class="ml-2 w-1 h-1 rounded-full bg-gray-500"></span>
            <span>تقارير العملاء</span>
        </a>
        @endcan
    </div>
    @endcan
</div>
