<?php

use App\Http\Controllers\Admin\AssessmentShowController;
use App\Http\Controllers\Admin\AthleteIndexController;
use App\Http\Controllers\Admin\AthleteShowController;
use App\Http\Controllers\Admin\AuditLogController;
use App\Http\Controllers\Admin\CoachApprovalController;
use App\Http\Controllers\Admin\CoachIndexController;
use App\Http\Controllers\Admin\CoachRequestIndexController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\EquipmentController;
use App\Http\Controllers\Admin\ExerciseController;
use App\Http\Controllers\Admin\GoalController;
use App\Http\Controllers\Admin\MuscleController;
use App\Http\Controllers\Admin\NutritionPlanIndexController;
use App\Http\Controllers\Admin\PaymentIndexController;
use App\Http\Controllers\Admin\ReviewIndexController;
use App\Http\Controllers\Admin\WorkoutPlanIndexController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Admin Routes — تجمیع نهایی همه‌ی فازها (Phase 2, 3, 4, 5, 6, 7, 8, 10, 13)
|--------------------------------------------------------------------------
*/
Route::middleware(['auth', 'active.account', 'role:admin'])
    ->prefix('admin')
    ->name('admin.')
    ->group(function () {
        // Phase 2 — Dashboard
        Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');

        // Phase 2 — Goals
        Route::resource('goals', GoalController::class)->except(['show']);

        // Phase 2 — Coaches / Athletes (لیست + مشاهده)
        Route::get('/coaches', [CoachIndexController::class, 'index'])->name('coaches.index');
        Route::get('/athletes', [AthleteIndexController::class, 'index'])->name('athletes.index');

        // Phase 3 — تأیید/رد/غیرفعال‌سازی مربی
        Route::get('/coaches/{coach}', [CoachApprovalController::class, 'show'])->name('coaches.show');
        Route::post('/coaches/{coach}/approve', [CoachApprovalController::class, 'approve'])->name('coaches.approve');
        Route::post('/coaches/{coach}/reject', [CoachApprovalController::class, 'reject'])->name('coaches.reject');
        Route::post('/coaches/{coach}/disable', [CoachApprovalController::class, 'disable'])->name('coaches.disable');
        Route::post('/coaches/{coach}/enable', [CoachApprovalController::class, 'enable'])->name('coaches.enable');

        // Phase 2 — Audit Log
        Route::get('/audit-logs', [AuditLogController::class, 'index'])->name('audit-logs.index');

        // Phase 4 — مشاهده کامل ورزشکار + یک ارزیابی خاص (Phase 4 + رفع باگ در تجمیع نهایی)
        Route::get('/athletes/{athlete}', [AthleteShowController::class, 'show'])->name('athletes.show');
        Route::get('/assessments/{assessment}', [AssessmentShowController::class, 'show'])->name('assessments.show');

        // Phase 6 — بانک حرکات ورزشی
        Route::resource('exercises', ExerciseController::class)->except(['show']);
        Route::resource('muscles', MuscleController::class)->except(['show']);
        Route::resource('equipment', EquipmentController::class)->except(['show']);

        // Phase 5 — نظارت بر درخواست‌های همکاری
        Route::get('/coach-requests', [CoachRequestIndexController::class, 'index'])->name('coach-requests.index');

        // Phase 7 — نظارت بر برنامه‌های تمرینی
        Route::get('/workout-plans', [WorkoutPlanIndexController::class, 'index'])->name('workout-plans.index');
        Route::get('/workout-plans/{plan}', [WorkoutPlanIndexController::class, 'show'])->name('workout-plans.show');

        // Phase 8 — نظارت بر برنامه‌های غذایی
        Route::get('/nutrition-plans', [NutritionPlanIndexController::class, 'index'])->name('nutrition-plans.index');
        Route::get('/nutrition-plans/{plan}', [NutritionPlanIndexController::class, 'show'])->name('nutrition-plans.show');

        // Phase 10 — نظارت بر پرداخت‌ها
        Route::get('/payments', [PaymentIndexController::class, 'index'])->name('payments.index');

        // Phase 13/15 — Moderation نظرات (مرحله ۲)
        Route::get('/reviews', [ReviewIndexController::class, 'index'])->name('reviews.index');
        Route::post('/reviews/{review}/approve', [ReviewIndexController::class, 'approve'])->name('reviews.approve');
        Route::post('/reviews/{review}/reject', [ReviewIndexController::class, 'reject'])->name('reviews.reject');
    });
