@extends('layouts.app')

@section('content')
<div class="container mx-auto px-4 py-6">
    <div class="flex justify-between items-center mb-6">
        <h1 class="text-3xl font-bold text-gray-800">التقارير المخصصة</h1>
        @can('create', App\Models\CustomReport::class)
        <a href="{{ route('reports.custom.create') }}" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
            <i class="fas fa-plus ml-1"></i> إنشاء تقرير جديد
        </a>
        @endcan
    </div>

    @if($reports->isEmpty())
    <div class="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4">
        <p>لا توجد تقارير حتى الآن</p>
    </div>
    @else
    <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
        @foreach($reports as $report)
        <div class="bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition">
            <h3 class="text-lg font-semibold mb-2">{{ $report->name }}</h3>
            <p class="text-gray-600 text-sm mb-4">{{ $report->description }}</p>
            
            <div class="flex gap-2">
                <a href="{{ route('reports.custom.show', $report) }}" class="flex-1 bg-blue-500 hover:bg-blue-600 text-white py-2 px-3 rounded text-center text-sm">
                    عرض
                </a>
                @can('update', $report)
                <a href="{{ route('reports.custom.edit', $report) }}" class="flex-1 bg-yellow-500 hover:bg-yellow-600 text-white py-2 px-3 rounded text-center text-sm">
                    تعديل
                </a>
                @endcan
                @can('delete', $report)
                <form method="POST" action="{{ route('reports.custom.destroy', $report) }}" class="flex-1" onsubmit="return confirm('هل أنت متأكد؟');">
                    @csrf
                    @method('DELETE')
                    <button type="submit" class="w-full bg-red-500 hover:bg-red-600 text-white py-2 px-3 rounded text-sm">
                        حذف
                    </button>
                </form>
                @endcan
            </div>
        </div>
        @endforeach
    </div>

    <div class="mt-6">
        {{ $reports->links() }}
    </div>
    @endif
</div>
@endsection
