<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\ProfileController;

Route::get('/', fn() => redirect()->route('dashboard'));

Route::middleware(['auth', 'verified'])->group(function () {

    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');

    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
    Route::patch('/profile', [ProfileController::class, 'update'])->name('profile.update');
    Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');

    Route::resource('banners',    \App\Http\Controllers\BannerController::class);
    Route::resource('galleries',  \App\Http\Controllers\GalleryController::class);
    Route::resource('services',   \App\Http\Controllers\ServiceController::class);
    Route::resource('products',   \App\Http\Controllers\ProductController::class);
    Route::resource('categories', \App\Http\Controllers\CategoryController::class);
    Route::resource('types',      \App\Http\Controllers\TypeController::class);
    Route::resource('careers',    \App\Http\Controllers\CareerController::class);

    Route::get('inquiries', [\App\Http\Controllers\InquiryController::class, 'index'])->name('inquiries.index');
    Route::get('messages', [\App\Http\Controllers\InquiryController::class, 'messages'])->name('inquiries.messages');
    Route::get('product-inquiries', [\App\Http\Controllers\InquiryController::class, 'productInquiries'])->name('inquiries.products');
    Route::get('quotes', [\App\Http\Controllers\InquiryController::class, 'quotes'])->name('inquiries.quotes');
    Route::get('career-applications', [\App\Http\Controllers\InquiryController::class, 'careers'])->name('inquiries.careers');
    
    Route::get('inquiries/{inquiry}', [\App\Http\Controllers\InquiryController::class, 'show'])->name('inquiries.show');
    Route::delete('inquiries/{inquiry}', [\App\Http\Controllers\InquiryController::class, 'destroy'])->name('inquiries.destroy');
    Route::patch('inquiries/{inquiry}/mark-read', [\App\Http\Controllers\InquiryController::class, 'markAsRead'])->name('inquiries.mark-read');
    Route::patch('inquiries/{inquiry}/mark-unread', [\App\Http\Controllers\InquiryController::class, 'markAsUnread'])->name('inquiries.mark-unread');

    // Admin only
    Route::middleware('admin')->group(function () {
        Route::resource('users', UserController::class);
    });
});

require __DIR__.'/auth.php';
