<?php

use App\Http\Controllers\EventWebController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;

// Homepage
Route::get('/', [EventWebController::class, 'index'])->name('home');

// Event Routes
Route::get('/events', [EventWebController::class, 'index'])->name('events');
Route::get('/events/{event}', [EventWebController::class, 'show'])->name('event.detail');

// Auth Routes
Route::get('/login', function () {
    return view('auth.login');
})->name('login')->middleware('guest');

Route::post('/login', [\App\Http\Controllers\AuthController::class, 'webLogin'])->name('login.post')->middleware('guest');

Route::get('/register', function () {
    return view('auth.register');
})->name('register')->middleware('guest');

Route::post('/register', [\App\Http\Controllers\AuthController::class, 'webRegister'])->name('register.post')->middleware('guest');

Route::post('/logout', [\App\Http\Controllers\AuthController::class, 'webLogout'])->name('logout');

Route::get('/forgot-password', function () {
    return view('auth.forgot-password');
})->name('forgot-password');

Route::get('/reset-password', function () {
    return view('auth.reset-password');
})->name('reset-password');

// Protected Routes
Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'show'])->name('profile');
    Route::put('/profile/info', [ProfileController::class, 'updateInfo'])->name('profile.update.info');
    Route::put('/profile/password', [ProfileController::class, 'updatePassword'])->name('profile.update.password');
});

// Swagger API Documentation Routes
require __DIR__ . '/swagger.php';

// Legal pages
Route::view('/datenschutz', 'legal.privacy')->name('privacy');
Route::view('/impressum', 'legal.impressum')->name('impressum');
Route::view('/agb', 'legal.agb')->name('agb');
