<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\AduanController;
use App\Http\Controllers\Admin\AuthController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\AduanController as AdminAduanController;
use App\Http\Controllers\Admin\EvaluasiController;
use App\Http\Controllers\Admin\ExportController;

Route::get('/', [AduanController::class, 'index'])->name('home');
Route::post('/aduan', [AduanController::class, 'store'])->name('aduan.store');

// Custom Admin Panel Premium Routes
Route::prefix('admin')->name('admin.')->group(function () {
    // Guest Routes
    Route::middleware('guest')->group(function () {
        Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
        Route::post('/login', [AuthController::class, 'login'])->name('login.store');
    });

    // Authenticated Routes
    Route::middleware(['auth', 'ensureIsAdmin'])->group(function () {
        Route::post('/logout', [AuthController::class, 'logout'])->name('logout');
        Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
        
        // CRUD Aduans
        Route::get('/aduan', [AdminAduanController::class, 'index'])->name('aduan.index');
        Route::get('/aduan/selesai', [AdminAduanController::class, 'selesai'])->name('aduan.selesai');
        Route::get('/aduan/{id}/edit', [AdminAduanController::class, 'edit'])->name('aduan.edit');
        Route::put('/aduan/{id}', [AdminAduanController::class, 'update'])->name('aduan.update');
        Route::delete('/aduan/{id}', [AdminAduanController::class, 'destroy'])->name('aduan.destroy');

        // Evaluasi Model ML
        Route::get('/evaluasi', [EvaluasiController::class, 'index'])->name('evaluasi');

        // Export Data Laporan
        Route::get('/aduan/export', [ExportController::class, 'exportCsv'])->name('aduan.export');
        Route::get('/aduan/export-excel', [ExportController::class, 'exportExcel'])->name('aduan.export.excel');
    });
});
