<?php

use App\Http\Controllers\ProfileController;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;

use App\Http\Controllers\DashboardController;

Route::get('/', function () {
    return Inertia::render('Welcome', [
        'canLogin' => Route::has('login'),
        'canRegister' => Route::has('register'),
        'laravelVersion' => Application::VERSION,
        'phpVersion' => PHP_VERSION,
    ]);
});

Route::get('/dashboard', [DashboardController::class, 'index'])
    ->middleware(['auth', 'verified'])
    ->name('dashboard');

use App\Http\Controllers\CoursePlayerController;

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');

    // Course Routes
    Route::get('/courses', [App\Http\Controllers\CourseLibraryController::class, 'index'])->name('courses.index');
    Route::post('/courses/{course:slug}/enroll', [App\Http\Controllers\CourseLibraryController::class, 'enroll'])->name('courses.enroll');
    Route::get('/courses/{course:slug}/learn/{lesson:slug?}', [CoursePlayerController::class, 'show'])->name('courses.learn');
    Route::post('/lessons/{lesson}/complete', [CoursePlayerController::class, 'complete'])->name('lessons.complete');

    // SRS / Flashcards Routes
    Route::get('/srs', [App\Http\Controllers\SrsController::class, 'index'])->name('srs.index');
    Route::get('/srs/practice', [App\Http\Controllers\SrsController::class, 'practice'])->name('srs.practice');
    Route::post('/srs/reviews', [App\Http\Controllers\SrsController::class, 'store'])->name('srs.store');
});

require __DIR__.'/auth.php';
