<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\RoomController;
use App\Http\Controllers\ServiceController;
use App\Http\Controllers\GalleryController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\BookingController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

Route::get('/', [HomeController::class, 'index'])->name('home');
Route::get('/about', [HomeController::class, 'about'])->name('about');

Route::prefix('rooms')->name('rooms.')->group(function () {
    Route::get('/', [RoomController::class, 'index'])->name('index');
    Route::get('/{slug}', [RoomController::class, 'show'])->name('show');
});

Route::get('/services', [ServiceController::class, 'index'])->name('services');
Route::get('/gallery', [GalleryController::class, 'index'])->name('gallery');

Route::prefix('contact')->name('contact.')->group(function () {
    Route::get('/', [ContactController::class, 'index'])->name('index');
    Route::post('/', [ContactController::class, 'submit'])->name('submit');
});

Route::prefix('booking')->name('booking.')->group(function () {
    Route::get('/check-availability', [BookingController::class, 'checkAvailability'])->name('check-availability');
    Route::post('/reserve', [BookingController::class, 'reserve'])->name('reserve');
});

Route::get('/pashupatinath', [HomeController::class, 'pashupatinath'])->name('pashupatinath');
Route::get('/boudhanath', [HomeController::class, 'boudhanath'])->name('boudhanath');
Route::get('/kathmandu-durbar-square', [HomeController::class, 'kathmanduDurbarSquare'])->name('kathmandu-durbar-square');

/*
|--------------------------------------------------------------------------
| Admin Routes
|--------------------------------------------------------------------------
*/

use App\Http\Controllers\Admin\AuthController as AdminAuthController;
use App\Http\Controllers\Admin\AdminController;

// Admin Authentication
Route::prefix('admin')->name('admin.')->group(function () {
    // Redirect /admin to /admin/login
    Route::get('/', function () {
        return redirect()->route('admin.login');
    });
    
    Route::get('/login', [AdminAuthController::class, 'showLoginForm'])->name('login');
    Route::post('/login', [AdminAuthController::class, 'login'])->name('login.post');
    Route::post('/logout', [AdminAuthController::class, 'logout'])->name('logout');
});

// Admin Panel (Protected)
Route::prefix('admin')->name('admin.')->middleware('admin')->group(function () {
    Route::get('/dashboard', [AdminController::class, 'dashboard'])->name('dashboard');
    
    // Bookings Management
    Route::get('/bookings', [AdminController::class, 'bookings'])->name('bookings');
    Route::get('/bookings/{id}', [AdminController::class, 'bookingShow'])->name('bookings.show');
    Route::post('/bookings/{id}/status', [AdminController::class, 'bookingUpdateStatus'])->name('bookings.update-status');
    Route::delete('/bookings/{id}', [AdminController::class, 'bookingDelete'])->name('bookings.delete');
    
    // Contact Messages
    Route::get('/contacts', [AdminController::class, 'contacts'])->name('contacts');
    Route::get('/contacts/{id}', [AdminController::class, 'contactShow'])->name('contacts.show');
    Route::delete('/contacts/{id}', [AdminController::class, 'contactDelete'])->name('contacts.delete');
});

