<div class="row">
    <div class="col-md-6">
        <h6 class="fw-bold">معلومات الدفع</h6>
        <table class="table table-sm">
            <tr>
                <td><strong>رقم الدفع:</strong></td>
                <td>#{{ $payment->id }}</td>
            </tr>
            <tr>
                <td><strong>المبلغ:</strong></td>
                <td class="text-success fw-bold">{{ number_format($payment->amount, 2) }} ريال</td>
            </tr>
            @if($payment->subscription_fee > 0)
                <tr>
                    <td><strong>رسوم الاشتراك:</strong></td>
                    <td>{{ number_format($payment->subscription_fee, 2) }} ريال</td>
                </tr>
            @endif
            @if($payment->total_amount > $payment->amount)
                <tr>
                    <td><strong>المجموع:</strong></td>
                    <td class="text-primary fw-bold">{{ number_format($payment->total_amount, 2) }} ريال</td>
                </tr>
            @endif
            <tr>
                <td><strong>طريقة الدفع:</strong></td>
                <td>
                    @switch($payment->payment_method)
                        @case('cash')
                            <span class="badge bg-success">
                                <i class="fas fa-money-bill-wave"></i> نقداً
                            </span>
                            @break
                        @case('credit_card')
                            <span class="badge bg-primary">
                                <i class="fas fa-credit-card"></i> بطاقة ائتمان
                            </span>
                            @break
                        @case('debit_card')
                            <span class="badge bg-info">
                                <i class="fas fa-credit-card"></i> بطاقة مدى
                            </span>
                            @break
                        @case('bank_transfer')
                            <span class="badge bg-warning">
                                <i class="fas fa-university"></i> تحويل بنكي
                            </span>
                            @break
                        @case('digital_wallet')
                            <span class="badge bg-secondary">
                                <i class="fas fa-mobile-alt"></i> محفظة رقمية
                            </span>
                            @break
                        @default
                            <span class="badge bg-secondary">{{ $payment->payment_method }}</span>
                    @endswitch
                </td>
            </tr>
            <tr>
                <td><strong>الحالة:</strong></td>
                <td>
                    @switch($payment->status)
                        @case('pending')
                            <span class="badge bg-warning">في الانتظار</span>
                            @break
                        @case('processing')
                            <span class="badge bg-info">قيد المعالجة</span>
                            @break
                        @case('completed')
                            <span class="badge bg-success">مكتمل</span>
                            @break
                        @case('cancelled')
                            <span class="badge bg-danger">ملغي</span>
                            @break
                        @case('failed')
                            <span class="badge bg-danger">فشل</span>
                            @break
                        @case('refund_requested')
                            <span class="badge bg-warning">طلب استرداد</span>
                            @break
                        @default
                            <span class="badge bg-secondary">{{ $payment->status }}</span>
                    @endswitch
                </td>
            </tr>
        </table>
    </div>
    <div class="col-md-6">
        <h6 class="fw-bold">معلومات إضافية</h6>
        <table class="table table-sm">
            <tr>
                <td><strong>تاريخ الإنشاء:</strong></td>
                <td>{{ $payment->created_at->format('Y-m-d H:i') }}</td>
            </tr>
            @if($payment->completed_at)
                <tr>
                    <td><strong>تاريخ الإكمال:</strong></td>
                    <td class="text-success">{{ $payment->completed_at->format('Y-m-d H:i') }}</td>
                </tr>
            @endif
            @if($payment->cancelled_at)
                <tr>
                    <td><strong>تاريخ الإلغاء:</strong></td>
                    <td class="text-danger">{{ $payment->cancelled_at->format('Y-m-d H:i') }}</td>
                </tr>
            @endif
            @if($payment->refund_requested_at)
                <tr>
                    <td><strong>تاريخ طلب الاسترداد:</strong></td>
                    <td class="text-warning">{{ $payment->refund_requested_at->format('Y-m-d H:i') }}</td>
                </tr>
            @endif
            @if($payment->transaction_id)
                <tr>
                    <td><strong>رقم المعاملة:</strong></td>
                    <td><code>{{ $payment->transaction_id }}</code></td>
                </tr>
            @endif
            @if($payment->refund_amount > 0)
                <tr>
                    <td><strong>مبلغ الاسترداد:</strong></td>
                    <td class="text-warning">{{ number_format($payment->refund_amount, 2) }} ريال</td>
                </tr>
            @endif
        </table>
    </div>
</div>

@if($payment->notes)
    <div class="row mt-3">
        <div class="col-12">
            <h6 class="fw-bold">الملاحظات</h6>
            <p class="mb-0">{{ $payment->notes }}</p>
        </div>
    </div>
@endif

@if($payment->refund_reason)
    <div class="row mt-3">
        <div class="col-12">
            <h6 class="fw-bold">سبب الاسترداد</h6>
            <p class="mb-0 text-warning">{{ $payment->refund_reason }}</p>
        </div>
    </div>
@endif

<div class="row mt-3">
    <div class="col-12">
        <h6 class="fw-bold">نوع الدفع</h6>
        @if($payment->paymentable_type)
            @switch($payment->paymentable_type)
                @case('App\Models\Trip')
                    <span class="badge bg-primary">
                        <i class="fas fa-route"></i> رحلة
                    </span>
                    @if($payment->trip)
                        <div class="mt-2">
                            <strong>تفاصيل الرحلة:</strong><br>
                            <small class="text-muted">
                                من: {{ $payment->trip->pickup_location }}<br>
                                إلى: {{ $payment->trip->dropoff_location }}<br>
                                المسافة: {{ $payment->trip->distance ?? 'غير محدد' }} كم
                            </small>
                        </div>
                    @endif
                    @break
                @case('App\Models\FoodOrder')
                    <span class="badge bg-success">
                        <i class="fas fa-utensils"></i> طلب طعام
                    </span>
                    @break
                @case('App\Models\GasOrder')
                    <span class="badge bg-warning">
                        <i class="fas fa-fire"></i> طلب غاز
                    </span>
                    @break
                @default
                    <span class="badge bg-secondary">{{ class_basename($payment->paymentable_type) }}</span>
            @endswitch
        @else
            <span class="text-muted">غير محدد</span>
        @endif
    </div>
</div>
