<?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>
                        <div class="font-medium"><?php echo e($req->athlete->user->fullName()); ?></div>
                        <div class="text-xs text-gray-400"><?php echo e(verta($req->created_at)->format('Y/m/d H:i')); ?> · <?php echo e($req->status->label()); ?></div>
                        <?php if($req->athlete_message): ?>
                            <p class="text-sm text-gray-600 mt-1">«<?php echo e($req->athlete_message); ?>»</p>
                        <?php endif; ?>
                    </div>

                    <?php if($req->status->value === 'pending'): ?>
                        <div class="flex items-center gap-2">
                            <form method="POST" action="<?php echo e(route('coach.requests.accept', $req)); ?>">
                                <?php echo csrf_field(); ?>
                                <button class="bg-green-600 text-white text-sm px-3 py-1.5 rounded-lg">قبول</button>
                            </form>
                            <button type="button" onclick="document.getElementById('reject-<?php echo e($req->id); ?>').classList.toggle('hidden')"
                                    class="bg-red-50 text-red-600 text-sm px-3 py-1.5 rounded-lg">رد</button>
                        </div>
                    <?php endif; ?>
                </div>

                <?php if($req->status->value === 'pending'): ?>
                    <form id="reject-<?php echo e($req->id); ?>" method="POST" action="<?php echo e(route('coach.requests.reject', $req)); ?>" class="hidden mt-3">
                        <?php echo csrf_field(); ?>
                        <textarea name="note" rows="2" placeholder="دلیل رد (اختیاری)..." class="w-full border rounded-lg px-3 py-2 text-sm"></textarea>
                        <button class="bg-red-600 text-white text-sm px-4 py-2 rounded-lg mt-2">ثبت رد درخواست</button>
                    </form>
                <?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>
                    <form method="POST" action="<?php echo e(route('coach.requests.price', $req)); ?>" class="flex items-center gap-2 mt-3">
                        <?php echo csrf_field(); ?>
                        <input type="number" name="price" value="<?php echo e($req->price); ?>" placeholder="قیمت برنامه (تومان)"
                               class="border rounded-lg px-3 py-2 text-sm flex-1">
                        <button class="bg-gray-900 text-white text-sm px-4 py-2 rounded-lg">ذخیره قیمت</button>
                    </form>
                <?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('coach.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/coach/requests/index.blade.php ENDPATH**/ ?>