<?php

declare(strict_types=1);

use App\Http\Controllers\Marketing\ContactController;
use App\Models\Plan;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;

Route::get('/', fn () => Inertia::render('Marketing/Home'))->name('home');
Route::redirect('/products', '/', 301);
Route::get('/vps-hosting', function () {
    $plans = Plan::query()
        ->where('service_type', 'vps')
        ->where('status', 'active')
        ->orderBy('sort_order')
        ->orderBy('price')
        ->get();

    return Inertia::render('Marketing/VpsHosting', [
        'plans' => $plans,
    ]);
})->name('vps-hosting');
Route::get('/dedicated-servers', function () {
    $plans = Plan::query()
        ->where('service_type', 'dedicated')
        ->where('status', 'active')
        ->orderBy('sort_order')
        ->orderBy('price')
        ->get();

    return Inertia::render('Marketing/DedicatedServers', [
        'plans' => $plans,
    ]);
})->name('dedicated-servers');
Route::get('/web-hosting', function () {
    $plans = Plan::query()
        ->where('service_type', 'hosting')
        ->where('status', 'active')
        ->orderBy('sort_order')
        ->orderBy('price')
        ->get();

    return Inertia::render('Marketing/WebHosting', [
        'plans' => $plans,
    ]);
})->name('web-hosting');
Route::get('/game-servers', function () {
    $plans = Plan::query()
        ->where('service_type', 'game')
        ->where('status', 'active')
        ->orderBy('sort_order')
        ->orderBy('price')
        ->get();

    return Inertia::render('Marketing/GameServers', [
        'plans' => $plans,
    ]);
})->name('game-servers');
Route::redirect('/battlefield-acp', '/game-servers', 301);
Route::get('/pricing', function () {
    $plans = Plan::query()
        ->where('status', 'active')
        ->orderBy('sort_order')
        ->orderBy('price')
        ->get();

    return Inertia::render('Marketing/Pricing', [
        'plans' => $plans,
    ]);
})->name('pricing');
Route::get('/about', fn () => Inertia::render('Marketing/About'))->name('about');
Route::get('/contact', fn () => Inertia::render('Marketing/Contact'))->name('contact');
Route::post('/contact', [ContactController::class, 'store'])->name('contact.store');

Route::get('/api-docs', fn () => Inertia::render('Marketing/ApiDocs'))->name('api-docs');

// Legal pages
Route::get('/terms-of-service', fn () => Inertia::render('Marketing/TermsOfService'))->name('terms');
Route::get('/privacy-policy', fn () => Inertia::render('Marketing/PrivacyPolicy'))->name('privacy');
Route::get('/acceptable-use', fn () => Inertia::render('Marketing/AcceptableUse'))->name('aup');
Route::get('/sla', fn () => Inertia::render('Marketing/Sla'))->name('sla');
