<?php $__env->startSection('title', 'طلب دفع #'.$submission->id); ?>
<?php $__env->startSection('heading', 'طلب دفع #'.$submission->id); ?>
<?php $__env->startSection('subheading', $submission->paymentMethod?->name_ar.' — '.$submission->user?->username); ?>

<?php $__env->startSection('content'); ?>
    <div class="mb-6">
        <a href="<?php echo e(route('admin.payments.reviews')); ?>" class="text-sm font-medium text-teal-700 hover:underline">← العودة للقائمة</a>
    </div>

    <div class="grid gap-6 lg:grid-cols-2">
        <div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm">
            <h3 class="mb-4 font-bold text-zinc-900">تفاصيل الطلب</h3>
            <dl class="space-y-3 text-sm">
                <div class="flex justify-between gap-4"><dt class="text-zinc-500">المستخدم</dt><dd class="font-medium"><?php echo e($submission->user?->full_name); ?> (<?php echo e($submission->user?->username); ?>)</dd></div>
                <div class="flex justify-between gap-4"><dt class="text-zinc-500">وسيلة الدفع</dt><dd><?php echo e($submission->paymentMethod?->name_ar); ?></dd></div>
                <div class="flex justify-between gap-4"><dt class="text-zinc-500">الغرض</dt><dd><?php echo e($submission->purpose === 'subscription' ? 'اشتراك' : 'شحن محفظة'); ?></dd></div>
                <?php if($submission->subscriptionPlan): ?>
                    <div class="flex justify-between gap-4"><dt class="text-zinc-500">الخطة</dt><dd><?php echo e($submission->subscriptionPlan->name); ?> (<?php echo e($submission->subscriptionPlan->slug); ?>)</dd></div>
                <?php endif; ?>
                <div class="flex justify-between gap-4"><dt class="text-zinc-500">المبلغ</dt><dd class="font-mono font-bold text-lg"><?php echo e(number_format((float) $submission->amount, 2)); ?></dd></div>
                <div class="flex justify-between gap-4"><dt class="text-zinc-500">مرجع الدفع</dt><dd class="font-mono"><?php echo e($submission->payer_reference); ?></dd></div>
                <?php if($submission->payer_note): ?>
                    <div><dt class="text-zinc-500 mb-1">ملاحظة المستخدم</dt><dd class="rounded-lg bg-zinc-50 p-3"><?php echo e($submission->payer_note); ?></dd></div>
                <?php endif; ?>
                <div class="flex justify-between gap-4"><dt class="text-zinc-500">الحالة</dt><dd class="font-bold"><?php echo e($submission->status); ?></dd></div>
                <div class="flex justify-between gap-4"><dt class="text-zinc-500">تاريخ الإرسال</dt><dd><?php echo e($submission->created_at?->format('Y-m-d H:i')); ?></dd></div>
                <?php if($submission->reviewed_at): ?>
                    <div class="flex justify-between gap-4"><dt class="text-zinc-500">رُاجع بواسطة</dt><dd><?php echo e($submission->reviewer?->full_name ?? '—'); ?> · <?php echo e($submission->reviewed_at->format('Y-m-d H:i')); ?></dd></div>
                <?php endif; ?>
                <?php if($submission->admin_note): ?>
                    <div><dt class="text-zinc-500 mb-1">ملاحظة المدير</dt><dd class="rounded-lg bg-amber-50 p-3 text-amber-900"><?php echo e($submission->admin_note); ?></dd></div>
                <?php endif; ?>
            </dl>
        </div>

        <div class="space-y-6">
            <?php if($submission->proof_path): ?>
                <div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm">
                    <h3 class="mb-3 font-bold text-zinc-900">إثبات الدفع</h3>
                    <?php $ext = strtolower(pathinfo($submission->proof_path, PATHINFO_EXTENSION)); ?>
                    <?php if(in_array($ext, ['jpg', 'jpeg', 'png'], true)): ?>
                        <img src="<?php echo e(route('admin.payments.proof', $submission)); ?>" alt="إثبات" class="max-h-80 w-full rounded-xl border object-contain">
                    <?php else: ?>
                        <a href="<?php echo e(route('admin.payments.proof', $submission)); ?>" class="text-teal-700 font-medium hover:underline" target="_blank">فتح الملف (PDF)</a>
                    <?php endif; ?>
                </div>
            <?php endif; ?>

            <?php if($submission->status === 'pending'): ?>
                <div class="rounded-2xl border border-zinc-200 bg-white p-6 shadow-sm">
                    <h3 class="mb-4 font-bold text-zinc-900">قرار المراجعة</h3>
                    <form method="post" action="<?php echo e(route('admin.payments.reviews.approve', $submission)); ?>" class="mb-4 space-y-3">
                        <?php echo csrf_field(); ?>
                        <textarea name="admin_note" rows="2" placeholder="ملاحظة اختيارية للموافقة…" class="w-full rounded-xl border border-zinc-300 px-3 py-2 text-sm"></textarea>
                        <button type="submit" class="w-full rounded-xl bg-emerald-600 px-4 py-3 text-sm font-bold text-white hover:bg-emerald-700">موافقة وتفعيل</button>
                    </form>
                    <form method="post" action="<?php echo e(route('admin.payments.reviews.reject', $submission)); ?>" class="space-y-3">
                        <?php echo csrf_field(); ?>
                        <textarea name="admin_note" rows="2" placeholder="سبب الرفض (يظهر للمستخدم)…" class="w-full rounded-xl border border-zinc-300 px-3 py-2 text-sm"></textarea>
                        <button type="submit" class="w-full rounded-xl border border-red-300 bg-red-50 px-4 py-3 text-sm font-bold text-red-800 hover:bg-red-100">رفض الطلب</button>
                    </form>
                </div>
            <?php endif; ?>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\madar-backend\resources\views\admin\payments\show.blade.php ENDPATH**/ ?>