@extends('layouts.app')

@section('content')

<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; margin-top: 15px;">
    <h2 style="color: #d4af37; font-size: 1.5rem; font-weight: bold;">
        {{ app()->getLocale() == 'ar' ? 'تسجيل حادث / مطالبة تأمينية' : 'Record Accident / Insurance Claim' }}
    </h2>
    <a href="{{ route('admin.insurance-claims.index') }}" style="background: #666; color: white; padding: 0.5rem 1rem; border-radius: 0.5rem; text-decoration: none;">
        {{ app()->getLocale() == 'ar' ? 'عودة' : 'Back' }}
    </a>
</div>

<div style="background: #111; border: 1px solid #333; border-radius: 1rem; padding: 2rem; max-width: 700px; margin: 0 auto;">
                <form action="{{ route('admin.insurance-claims.store') }}" method="POST">
                    @csrf
                    
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
                        <div>
                            <label class="block text-xs text-gray-500 mb-2 uppercase tracking-wider text-right">{{ app()->getLocale() == 'ar' ? 'السيارة' : 'Vehicle' }}</label>
                            <select name="car_id" required class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-[#d4af37] outline-none text-sm text-right">
                                <option value="">{{ app()->getLocale() == 'ar' ? 'اختر السيارة' : 'Select Car' }}</option>
                                @foreach($cars as $car)
                                    <option value="{{ $car->id }}" {{ (old('car_id') == $car->id || (isset($selected_car) && $selected_car->id == $car->id)) ? 'selected' : '' }}>{{ $car->brand?->name }} {{ $car->carModel?->name }} ({{ $car->plate_number }})</option>
                                @endforeach
                            </select>
                        </div>
                        <div>
                            <label class="block text-xs text-gray-500 mb-2 uppercase tracking-wider text-right">{{ app()->getLocale() == 'ar' ? 'العقد المرتبط (اختياري)' : 'Linked Contract (Optional)' }}</label>
                            <select name="rental_id" class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-[#d4af37] outline-none text-sm text-right">
                                <option value="">{{ app()->getLocale() == 'ar' ? 'اختر العقد' : 'Select Contract' }}</option>
                                @foreach($rentals as $rental)
                                    <option value="{{ $rental->id }}" {{ old('rental_id') == $rental->id ? 'selected' : '' }}>#{{ $rental->contract_number }} - {{ $rental->customer->name }}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
                        <div>
                            <label class="block text-xs text-gray-500 mb-2 uppercase tracking-wider text-right">{{ app()->getLocale() == 'ar' ? 'رقم المطالبة' : 'Claim Number' }}</label>
                            <input type="text" name="claim_number" value="{{ old('claim_number') }}" required class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-[#d4af37] outline-none text-sm font-mono text-left">
                        </div>
                        <div>
                            <label class="block text-xs text-gray-500 mb-2 uppercase tracking-wider text-right">{{ app()->getLocale() == 'ar' ? 'تاريخ الحادث' : 'Accident Date' }}</label>
                            <input type="date" name="accident_date" value="{{ old('accident_date', date('Y-m-d')) }}" required class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-[#d4af37] outline-none text-sm">
                        </div>
                    </div>

                    <div class="mb-8">
                        <label class="block text-xs text-gray-500 mb-2 uppercase tracking-wider text-right">{{ app()->getLocale() == 'ar' ? 'وصف الحادث والأضرار' : 'Accident Description' }}</label>
                        <textarea name="description" required class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-[#d4af37] outline-none text-sm text-right h-24">{{ old('description') }}</textarea>
                    </div>

                    <div class="grid grid-cols-1 md:grid-cols-3 gap-8 mb-8">
                        <div>
                            <label class="block text-xs text-gray-500 mb-2 uppercase tracking-wider text-right">{{ app()->getLocale() == 'ar' ? 'التكلفة التقديرية' : 'Est. Damage Cost' }}</label>
                            <input type="number" step="0.01" name="estimated_damage_cost" value="{{ old('estimated_damage_cost') }}" class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-[#d4af37] outline-none text-sm text-right" placeholder="0.00">
                        </div>
                        <div>
                            <label class="block text-xs text-gray-500 mb-2 uppercase tracking-wider text-right">{{ app()->getLocale() == 'ar' ? 'نسبة التحمل المدفوعة' : 'Deductible Paid' }}</label>
                            <input type="number" step="0.01" name="deductible_paid" value="{{ old('deductible_paid', 0) }}" required class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-[#d4af37] outline-none text-sm text-right" placeholder="0.00">
                        </div>
                        <div>
                            <label class="block text-xs text-gray-500 mb-2 uppercase tracking-wider text-right">{{ app()->getLocale() == 'ar' ? 'حالة المطالبة' : 'Claim Status' }}</label>
                            <select name="claim_status" required class="w-full bg-black border-gray-800 rounded-lg px-4 py-2.5 text-white focus:border-[#d4af37] outline-none text-sm text-right">
                                <option value="pending" {{ old('claim_status') == 'pending' ? 'selected' : '' }}>{{ app()->getLocale() == 'ar' ? 'قيد المراجعة' : 'Pending' }}</option>
                                <option value="accepted" {{ old('claim_status') == 'accepted' ? 'selected' : '' }}>{{ app()->getLocale() == 'ar' ? 'مقبولة' : 'Accepted' }}</option>
                                <option value="rejected" {{ old('claim_status') == 'rejected' ? 'selected' : '' }}>{{ app()->getLocale() == 'ar' ? 'مرفوضة' : 'Rejected' }}</option>
                                <option value="closed" {{ old('claim_status') == 'closed' ? 'selected' : '' }}>{{ app()->getLocale() == 'ar' ? 'مغلقة' : 'Closed' }}</option>
                            </select>
                        </div>
                    </div>

    <div style="display: flex; gap: 1rem; margin-top: 2rem;">
        <button type="submit" class="flex-1 bg-[#d4af37] text-black font-bold py-3 rounded-lg hover:bg-[#b08d2a] transition-colors">
            {{ app()->getLocale() == 'ar' ? 'حفظ المطالبة' : 'Save Claim' }}
        </button>
        <a href="{{ route('admin.insurance-claims.index') }}" style="flex: 1; background: #666; color: white; padding: 0.75rem 1rem; border-radius: 0.5rem; text-decoration: none; text-align: center; font-weight: bold;">
            {{ app()->getLocale() == 'ar' ? 'إلغاء' : 'Cancel' }}
        </a>
    </div>
</form>
</div>

@endsection