@extends('coach.layouts.app')

@section('title', 'ویرایش برنامه')

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

    <form method="POST" action="{{ route('coach.workout-plans.update', $plan) }}" class="bg-white rounded-xl shadow-sm p-6 max-w-lg space-y-4">
        @csrf
        @method('PUT')

        <div>
            <label class="block text-sm mb-1">نام برنامه *</label>
            <input type="text" name="name" value="{{ old('name', $plan->name) }}" class="w-full border rounded-lg px-3 py-2" required>
        </div>

        <div>
            <label class="block text-sm mb-1">هدف</label>
            <select name="goal_id" class="w-full border rounded-lg px-3 py-2">
                <option value="">—</option>
                @foreach($goals as $goal)
                    <option value="{{ $goal->id }}" @selected(old('goal_id', $plan->goal_id) == $goal->id)>{{ $goal->title }}</option>
                @endforeach
            </select>
        </div>

        <div class="grid grid-cols-2 gap-4">
            <div>
                <label class="block text-sm mb-1">مدت برنامه (هفته)</label>
                <input type="number" name="duration_weeks" value="{{ old('duration_weeks', $plan->duration_weeks) }}" class="w-full border rounded-lg px-3 py-2">
            </div>
            <div>
                <label class="block text-sm mb-1">جلسات در هفته</label>
                <input type="number" name="sessions_per_week" value="{{ old('sessions_per_week', $plan->sessions_per_week) }}" class="w-full border rounded-lg px-3 py-2">
            </div>
        </div>

        <div>
            <label class="block text-sm mb-1">توضیحات</label>
            <textarea name="description" rows="3" class="w-full border rounded-lg px-3 py-2">{{ old('description', $plan->description) }}</textarea>
        </div>

        <div>
            <label class="block text-sm mb-1">وضعیت</label>
            <select name="status" class="w-full border rounded-lg px-3 py-2">
                <option value="draft" @selected($plan->status->value === 'draft')>پیش‌نویس</option>
                <option value="active" @selected($plan->status->value === 'active')>فعال (قابل مشاهده برای ورزشکار)</option>
                <option value="archived" @selected($plan->status->value === 'archived')>بایگانی‌شده</option>
            </select>
        </div>

        <button class="bg-gray-900 text-white px-5 py-2 rounded-lg text-sm">ذخیره</button>
    </form>
@endsection
