<?php

use App\Http\Controllers\PublicController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\ExportController;
use App\Http\Controllers\Admin\AnswerOptionController;
use App\Http\Controllers\Admin\QuestionController;
use App\Http\Controllers\Admin\OPDController;
use Illuminate\Support\Facades\Route;

Route::get('/', [PublicController::class, 'index'])->name('public.index');
Route::get('/survey/{opd}', [PublicController::class, 'survey'])->name('public.survey');
Route::post('/survey/{opd}/submit', [PublicController::class, 'submit'])->name('public.submit');
Route::get('/thankyou', [PublicController::class, 'thankyou'])->name('public.thankyou');

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

Route::middleware('auth')->prefix('admin')->name('admin.')->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
    Route::get('/opd/{opd}/results', [DashboardController::class, 'opdResults'])->name('opd.results');
    Route::get('/opd/{opd}/export/excel', [ExportController::class, 'exportExcel'])->name('opd.export.excel');
    Route::get('/opd/{opd}/export/pdf', [ExportController::class, 'exportPdf'])->name('opd.export.pdf');
    
    // OPD Management (Kelola OPD)
    Route::resource('opds', OPDController::class);
    
    // Question Configuration (Konfigurasi Soal)
    Route::resource('questions', QuestionController::class);
    
    // Answer Options Management (Legacy - kept for backward compatibility)
    Route::resource('answer-options', AnswerOptionController::class);
});

