<?php

namespace App\Http\Requests\Athlete;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreAssessmentRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->isAthlete();
    }

    public function rules(): array
    {
        return [
            // اطلاعات بدنی — بند ۹
            'weight_kg' => ['required', 'numeric', 'min:20', 'max:300'],
            'height_cm' => ['required', 'integer', 'min:100', 'max:250'],
            'athlete_level' => ['nullable', Rule::in(['beginner', 'intermediate', 'advanced'])],
            'training_history' => ['nullable', 'string', 'max:2000'],
            'goal_id' => ['nullable', 'integer', 'exists:goals,id'],
            // body_fat_percentage عمداً اینجا نیست — طبق بند ۹ فقط توسط مربی وارد می‌شود (Phase 5+)

            // اندازه‌گیری‌ها — بند ۱۳
            'waist_cm' => ['nullable', 'numeric', 'min:0', 'max:300'],
            'arm_cm' => ['nullable', 'numeric', 'min:0', 'max:100'],
            'thigh_cm' => ['nullable', 'numeric', 'min:0', 'max:150'],
            'chest_cm' => ['nullable', 'numeric', 'min:0', 'max:300'],

            // سبک زندگی — بند ۱۱
            'occupation' => ['nullable', 'string', 'max:150'],
            'job_type' => ['nullable', Rule::in(['physical', 'mental', 'mixed'])],
            'avg_sleep_hours' => ['nullable', 'numeric', 'min:0', 'max:24'],
            'stress_level' => ['nullable', Rule::in(['low', 'medium', 'high'])],
            'smokes' => ['sometimes', 'boolean'],
            'drinks_alcohol' => ['sometimes', 'boolean'],
            'can_eat_regularly' => ['sometimes', 'boolean'],
            'can_eat_healthy' => ['sometimes', 'boolean'],
            'lifestyle_notes' => ['nullable', 'string', 'max:1000'],

            // مشکلات جسمی و پزشکی — بند ۱۰ (حساس‌ترین بخش فرم)
            'physical_problems' => ['nullable', 'string', 'max:2000'],
            'movement_disorders' => ['nullable', 'string', 'max:2000'],
            'skeletal_problems' => ['nullable', 'string', 'max:2000'],
            'current_medications' => ['nullable', 'string', 'max:2000'],
            'lab_tests' => ['nullable', 'string', 'max:2000'],
            'medical_notes' => ['nullable', 'string', 'max:2000'],
        ];
    }
}
