@extends('coach.layouts.app')

@section('title', 'نظرات ورزشکاران')

@section('content')
    <h1 class="text-xl font-bold mb-6">نظرات درباره‌ی من</h1>

    <div class="space-y-3">
        @forelse($reviews as $review)
            <div class="bg-white rounded-xl shadow-sm p-4">
                <div class="flex items-center justify-between">
                    <span class="font-medium text-sm">{{ $review->coachRequest->athlete->user->fullName() }}</span>
                    <span class="text-amber-500">{{ str_repeat('★', $review->rating) }}{{ str_repeat('☆', 5 - $review->rating) }}</span>
                </div>
                @if($review->comment)<p class="text-sm text-gray-600 mt-2">{{ $review->comment }}</p>@endif
                <div class="text-xs text-gray-400 mt-2">{{ $review->status->label() }}</div>

                @if($review->status->value === 'pending_coach')
                    <div class="flex items-center gap-2 mt-3">
                        <form method="POST" action="{{ route('coach.reviews.approve', $review) }}">
                            @csrf
                            <button class="bg-green-600 text-white text-sm px-4 py-2 rounded-lg">تأیید و ارسال به مدیریت</button>
                        </form>
                        <button type="button" onclick="document.getElementById('reject-{{ $review->id }}').classList.toggle('hidden')"
                                class="bg-red-50 text-red-600 text-sm px-4 py-2 rounded-lg">رد</button>
                    </div>
                    <form id="reject-{{ $review->id }}" method="POST" action="{{ route('coach.reviews.reject', $review) }}" class="hidden mt-2">
                        @csrf
                        <textarea name="reason" rows="2" placeholder="دلیل رد..." class="w-full border rounded-lg px-3 py-2 text-sm" required></textarea>
                        <button class="bg-red-600 text-white text-sm px-4 py-2 rounded-lg mt-2">ثبت رد</button>
                    </form>
                @endif
            </div>
        @empty
            <p class="text-gray-400 text-center py-10">نظری ثبت نشده است.</p>
        @endforelse
    </div>
@endsection
