<?php

use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\LaporanController;
use App\Http\Controllers\AlurKasusController;
use App\Http\Controllers\ProfilController;
use Illuminate\Support\Facades\Route;

// Public landing page
Route::get('/home', function () {
    return view('welcome');
})->name('home');

Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login');
Route::post('/login', [LoginController::class, 'login'])->name('login.perform');
Route::post('/register', [RegisterController::class, 'register'])->name('register.perform');
Route::post('/logout', [LoginController::class, 'logout'])->name('logout');

Route::middleware(['auth'])->group(function () {
    Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
    Route::get('admin/rekap-pdf', [DashboardController::class, 'cetakRekap'])->name('admin.rekap.pdf');
    
    // Laporan / Aduan
    Route::get('laporan', [LaporanController::class, 'index'])->name('laporan.index');
    Route::get('laporan/create', [LaporanController::class, 'create'])->name('laporan.create');
    Route::post('laporan', [LaporanController::class, 'store'])->name('laporan.store');
    Route::get('laporan/export', [LaporanController::class, 'export'])->name('laporan.export');
    Route::get('laporan/{laporan}', [LaporanController::class, 'show'])->name('laporan.show');
    Route::get('laporan/{laporan}/edit', [LaporanController::class, 'edit'])->name('laporan.edit');
    Route::put('laporan/{laporan}', [LaporanController::class, 'update'])->name('laporan.update');
    Route::post('laporan/{laporan}/toggle-pantau', [LaporanController::class, 'togglePantauLldikti'])->name('laporan.toggle_pantau');
    
    // Alur Kasus / Tindakan Roles
    Route::post('laporan/{laporan}/admin-keputusan', [AlurKasusController::class, 'adminKeputusanStore'])->name('laporan.admin_keputusan');
    Route::post('laporan/{laporan}/satgas', [AlurKasusController::class, 'satgasStore'])->name('laporan.satgas');
    Route::post('laporan/{laporan}/penilai', [AlurKasusController::class, 'penilaiStore'])->name('laporan.penilai');
    Route::post('laporan/{laporan}/psikolog', [AlurKasusController::class, 'psikologStore'])->name('laporan.psikolog');
    Route::post('laporan/{laporan}/psikolog-selesai', [AlurKasusController::class, 'psikologSelesai'])->name('laporan.psikolog_selesai');
    Route::post('laporan/{laporan}/rektor', [AlurKasusController::class, 'rektorStore'])->name('laporan.rektor');
    
    Route::get('profil', [ProfilController::class, 'index'])->name('profil.index');
});
