@extends('admin.layouts.app')

@section('title', 'جزئیات ورزشکار')

@section('content')
    <a href="{{ route('admin.athletes.index') }}" class="text-sm text-blue-600 hover:underline mb-4 inline-block">← بازگشت به لیست ورزشکاران</a>

    <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
        <div class="md:col-span-1 bg-white rounded-xl shadow-sm p-6 text-center">
            @if($athlete->photo_path)
                <img src="{{ Storage::disk('public')->url($athlete->photo_path) }}" class="w-24 h-24 rounded-full object-cover mx-auto mb-3">
            @else
                <div class="w-24 h-24 rounded-full bg-gray-200 mx-auto mb-3"></div>
            @endif
            <h1 class="font-bold">{{ $athlete->user->fullName() }}</h1>
            <p class="text-gray-400 text-sm" dir="ltr">{{ $athlete->user->mobile }}</p>
            <p class="text-sm mt-2">کد ملی: {{ $athlete->national_code ?? '—' }}</p>
            <p class="text-sm">قد/وزن فعلی: {{ $athlete->height_cm ?? '—' }} cm / {{ $athlete->weight_kg ?? '—' }} kg</p>
        </div>

        <div class="md:col-span-2 bg-white rounded-xl shadow-sm p-6">
            <h2 class="font-semibold mb-4">تاریخچه ارزیابی‌ها ({{ $athlete->assessments->count() }})</h2>

            <div class="space-y-2">
                @forelse($athlete->assessments as $assessment)
                    <div class="border rounded-lg p-3 flex items-center justify-between text-sm">
                        <div>
                            <span class="font-medium">
                                {{ $assessment->is_initial ? 'ارزیابی اولیه' : 'ارزیابی' }}
                                — {{ verta($assessment->assessment_date)->format('Y/m/d') }}
                            </span>
                            <span class="text-gray-400"> · وزن {{ $assessment->weight_kg }} · BMI {{ $assessment->bmi }}</span>
                        </div>
                        <a href="{{ route('admin.assessments.show', $assessment) }}" class="text-blue-600 hover:underline">مشاهده کامل</a>
                    </div>
                @empty
                    <p class="text-gray-400 text-sm">هنوز ارزیابی‌ای ثبت نشده است.</p>
                @endforelse
            </div>
        </div>
    </div>
@endsection
