<?php $__env->startSection('title', 'درخواست‌های من'); ?>

<?php $__env->startSection('content'); ?>
    <h1 class="text-xl font-bold mb-6">درخواست‌های من</h1>

    <div class="space-y-3">
        <?php $__empty_1 = true; $__currentLoopData = $requests; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $req): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <div class="bg-white rounded-xl shadow-sm p-4">
                <div class="flex items-center justify-between">
                    <div class="font-medium"><?php echo e($req->coach->user->fullName()); ?></div>
                    <span class="text-xs px-2 py-1 rounded-full
                        <?php echo e($req->status->value === 'accepted' ? 'bg-green-50 text-green-700' :
                           ($req->status->value === 'rejected' ? 'bg-red-50 text-red-600' : 'bg-amber-50 text-amber-600')); ?>">
                        <?php echo e($req->status->label()); ?>

                    </span>
                </div>
                <div class="text-xs text-gray-400 mt-1"><?php echo e(verta($req->created_at)->format('Y/m/d H:i')); ?></div>

                <?php if($req->status->value === 'rejected' && $req->coach_response_note): ?>
                    <p class="text-sm text-gray-500 mt-2">دلیل رد: <?php echo e($req->coach_response_note); ?></p>
                <?php endif; ?>

                <?php if($req->status->value === 'accepted'): ?>
                    <div class="mt-2">
                        <a href="<?php echo e(route('chat.show', $req)); ?>" class="text-blue-600 text-sm hover:underline">
                            💬 گفتگو
                            <?php if($req->unreadCountFor(auth()->user()) > 0): ?>
                                <span class="bg-red-500 text-white text-[10px] rounded-full px-1.5"><?php echo e($req->unreadCountFor(auth()->user())); ?></span>
                            <?php endif; ?>
                        </a>
                    </div>

                    <?php if($req->price): ?>
                        <p class="text-sm mt-2">قیمت تعیین‌شده: <span class="font-bold"><?php echo e(number_format($req->price)); ?> تومان</span></p>

                        <?php if($req->coach->bankAccount): ?>
                            <div class="bg-gray-50 rounded-lg p-3 mt-2 text-sm">
                                <div>صاحب حساب: <?php echo e($req->coach->bankAccount->account_holder_name); ?></div>
                                <div dir="ltr">شماره کارت: <?php echo e($req->coach->bankAccount->card_number); ?></div>
                                <?php if($req->coach->bankAccount->bank_name): ?>
                                    <div>بانک: <?php echo e($req->coach->bankAccount->bank_name); ?></div>
                                <?php endif; ?>
                            </div>
                        <?php endif; ?>

                        <?php $payment = $req->payment; ?>
                        <?php if(! $payment): ?>
                            <form method="POST" action="<?php echo e(route('athlete.coach-requests.payments.store', $req)); ?>" enctype="multipart/form-data" class="mt-3 flex flex-wrap gap-2">
                                <?php echo csrf_field(); ?>
                                <input type="number" name="amount" placeholder="مبلغ واریزی (تومان)" value="<?php echo e($req->price); ?>" class="border rounded-lg px-3 py-2 text-sm w-40">
                                <input type="file" name="receipt" accept=".jpg,.jpeg,.png,.pdf" required class="text-sm">
                                <button class="bg-gray-900 text-white text-sm px-4 py-2 rounded-lg">ثبت رسید پرداخت</button>
                            </form>
                        <?php elseif($payment->status->value === 'pending_review'): ?>
                            <div class="bg-amber-50 text-amber-700 text-sm rounded-lg px-3 py-2 mt-3">رسید شما در انتظار بررسی مربی است.</div>
                        <?php elseif($payment->status->value === 'approved'): ?>
                            <div class="bg-green-50 text-green-700 text-sm rounded-lg px-3 py-2 mt-3">✅ پرداخت شما تأیید شد.</div>
                        <?php elseif($payment->status->value === 'rejected'): ?>
                            <div class="bg-red-50 text-red-700 text-sm rounded-lg px-3 py-2 mt-3">رسید قبلی رد شد. دلیل: <?php echo e($payment->rejection_reason); ?></div>
                            <form method="POST" action="<?php echo e(route('athlete.coach-requests.payments.store', $req)); ?>" enctype="multipart/form-data" class="mt-2 flex flex-wrap gap-2">
                                <?php echo csrf_field(); ?>
                                <input type="number" name="amount" placeholder="مبلغ واریزی (تومان)" value="<?php echo e($req->price); ?>" class="border rounded-lg px-3 py-2 text-sm w-40">
                                <input type="file" name="receipt" accept=".jpg,.jpeg,.png,.pdf" required class="text-sm">
                                <button class="bg-gray-900 text-white text-sm px-4 py-2 rounded-lg">ارسال رسید جدید</button>
                            </form>
                        <?php endif; ?>
                        <?php $__errorArgs = ['receipt'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <p class="text-red-600 text-xs mt-1"><?php echo e($message); ?></p> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    <?php else: ?>
                        <p class="text-sm text-gray-400 mt-2">در انتظار تعیین قیمت توسط مربی...</p>
                    <?php endif; ?>

                    
                    <?php if($req->review): ?>
                        <div class="bg-gray-50 rounded-lg p-3 mt-3 text-sm">
                            <div class="text-amber-500"><?php echo e(str_repeat('★', $req->review->rating)); ?><?php echo e(str_repeat('☆', 5 - $req->review->rating)); ?></div>
                            <?php if($req->review->comment): ?><p class="text-gray-600 mt-1"><?php echo e($req->review->comment); ?></p><?php endif; ?>
                            <div class="text-xs text-gray-400 mt-1"><?php echo e($req->review->status->label()); ?></div>
                        </div>
                    <?php else: ?>
                        <details class="mt-3">
                            <summary class="text-sm text-blue-600 cursor-pointer">ثبت نظر درباره‌ی این مربی</summary>
                            <form method="POST" action="<?php echo e(route('athlete.coach-requests.reviews.store', $req)); ?>" class="mt-2 space-y-2">
                                <?php echo csrf_field(); ?>
                                <select name="rating" class="border rounded-lg px-3 py-2 text-sm" required>
                                    <option value="">امتیاز...</option>
                                    <?php for($i = 5; $i >= 1; $i--): ?>
                                        <option value="<?php echo e($i); ?>"><?php echo e(str_repeat('★', $i)); ?> (<?php echo e($i); ?>)</option>
                                    <?php endfor; ?>
                                </select>
                                <textarea name="comment" rows="2" placeholder="نظر شما (اختیاری)..." class="w-full border rounded-lg px-3 py-2 text-sm"></textarea>
                                <button class="bg-gray-900 text-white text-sm px-4 py-2 rounded-lg">ثبت نظر</button>
                            </form>
                            <?php $__errorArgs = ['review'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <p class="text-red-600 text-xs mt-1"><?php echo e($message); ?></p> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </details>
                    <?php endif; ?>
                <?php endif; ?>
            </div>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <p class="text-gray-400 text-center py-10">هنوز درخواستی ارسال نکرده‌اید.</p>
        <?php endif; ?>
    </div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('athlete.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\paradox\Desktop\fresh\abtin-sport-platform\resources\views/athlete/requests/index.blade.php ENDPATH**/ ?>