<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PrediksiController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\GoogleAuthController;

// Halaman utama (bebas akses)
Route::get('/', [PrediksiController::class, 'index'])->name('utama');

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

// Register
Route::get('/register',  [AuthController::class, 'showRegister'])->name('register');
Route::post('/register', [AuthController::class, 'register'])->name('register.store');

// Lupa password
Route::get('/lupa-password',  [AuthController::class, 'showLupaPassword'])->name('password.request');
Route::post('/lupa-password', [AuthController::class, 'resetPassword'])->name('password.update');

// Logout
Route::post('/logout', [AuthController::class, 'logout'])->name('logout');

// Google Login
Route::get('/auth/google', [GoogleAuthController::class, 'redirect'])->name('auth.google');
Route::get('/auth/google/callback', [GoogleAuthController::class, 'callback'])->name('auth.google.callback');

// Prediksi (wajib login)
Route::get('/prediksi', function () {
    return view('tampilanutama.prediksi');
})->name('halaman.prediksi');

Route::post('/prediksi', [PrediksiController::class, 'proses'])->name('prediksi.proses');

Route::get('/riwayat', [PrediksiController::class, 'riwayat'])->middleware('auth')->name('riwayat.prediksi');
