<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\EventController;
use App\Http\Controllers\GalleryController;
use App\Http\Controllers\ImpactController;
use App\Http\Controllers\PageController;
use App\Http\Controllers\PostController;
use App\Http\Controllers\SliderController;

Route::get('/', [PageController::class, 'home'])->name('home');
Route::get('/about', [PageController::class, 'about'])->name('about');
Route::get('/gallery', [GalleryController::class, 'index'])->name('gallery');
Route::get('/events', [EventController::class, 'index'])->name('events');

// Auth Routes
Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
Route::post('/login', [AuthController::class, 'login']);
Route::post('/logout', [AuthController::class, 'logout'])->name('logout');

// Protected Routes
Route::middleware('auth')->group(function () {
    // Admin Settings
    Route::get('/admin/settings', [AdminController::class, 'editSettings'])->name('admin.settings');
    Route::post('/admin/settings', [AdminController::class, 'updateSettings']);
    Route::get('/admin/page-content/{page_slug}', [AdminController::class, 'editPageContent'])->name('admin.page-content.edit');
    Route::put('/admin/page-content/{page_slug}', [AdminController::class, 'updatePageContent'])->name('admin.page-content.update');

    Route::get('/gallery/upload', [GalleryController::class, 'create'])->name('gallery.upload');
    Route::post('/gallery/upload', [GalleryController::class, 'store'])->name('gallery.upload.store');
    Route::delete('/gallery/bulk-delete', [GalleryController::class, 'bulkDestroy'])->name('gallery.bulk-destroy');
    Route::delete('/gallery/{item}', [GalleryController::class, 'destroy'])->name('gallery.destroy');
    
    Route::get('/blog/create', [PostController::class, 'create'])->name('blog.create');
    Route::post('/blog/create', [PostController::class, 'store'])->name('blog.store');
    Route::delete('/blog/{post}', [PostController::class, 'destroy'])->name('blog.destroy');
    
    Route::get('/events/create', [EventController::class, 'create'])->name('events.create');
    Route::post('/events/create', [EventController::class, 'store'])->name('events.store');
    Route::delete('/events/{event}', [EventController::class, 'destroy'])->name('events.destroy');

    Route::get('/impact/edit', [ImpactController::class, 'edit'])->name('impact.edit');
    Route::put('/impact/edit', [ImpactController::class, 'update'])->name('impact.update');

    Route::get('/slider', [SliderController::class, 'index'])->name('slider.index');
    Route::get('/slider/create', [SliderController::class, 'create'])->name('slider.create');
    Route::post('/slider/create', [SliderController::class, 'store'])->name('slider.store');
    Route::get('/slider/{slider}/edit', [SliderController::class, 'edit'])->name('slider.edit');
    Route::put('/slider/{slider}/edit', [SliderController::class, 'update'])->name('slider.update');
    Route::delete('/slider/{slider}', [SliderController::class, 'destroy'])->name('slider.destroy');
});

Route::get('/blog', [PostController::class, 'index'])->name('blog');
Route::get('/blog/{post}', [PostController::class, 'show'])->name('blog.show');
Route::get('/join', [PageController::class, 'join'])->name('join');
Route::get('/sponsors', [PageController::class, 'sponsors'])->name('sponsors');
