<?php

use Illuminate\Support\Facades\Route;
use Modules\VetOneDemo\Http\Controllers\RegisterController;
use Modules\VetOneDemo\Http\Controllers\OnboardingController;
use Modules\VetOneDemo\Http\Controllers\DemoExpiredController;

/*
|--------------------------------------------------------------------------
| VetOne self-service demo routes
|--------------------------------------------------------------------------
| Public registration (guest), the post-registration onboarding gate
| (auth, but exempt from the demo-active guard so an expired tenant can
| never loop here), and the expired-demo landing.
*/

Route::middleware(['web'])->group(function () {

    // ── Public registration wizard ──────────────────────────────────────
    Route::prefix('vetone')->group(function () {
        Route::get('/register',  [RegisterController::class, 'create'])->name('vetone.register');
        Route::post('/register', [RegisterController::class, 'store'])->name('vetone.register.store');
        Route::post('/register/check-slug', [RegisterController::class, 'checkSlug'])->name('vetone.register.check_slug');
    });

    // ── Onboarding gate (WhatsApp QR + Groq key, both skippable) ─────────
    Route::prefix('vetone/onboarding')->middleware('auth')->group(function () {
        Route::get('/',            [OnboardingController::class, 'index'])->name('vetone.onboarding');
        Route::post('/groq',       [OnboardingController::class, 'saveGroq'])->name('vetone.onboarding.groq');
        Route::post('/skip',       [OnboardingController::class, 'skip'])->name('vetone.onboarding.skip');
        Route::post('/finish',     [OnboardingController::class, 'finish'])->name('vetone.onboarding.finish');
    });

    // ── Expired-demo landing (contact TPS) ──────────────────────────────
    Route::get('/demo-expired', [DemoExpiredController::class, 'show'])->name('vetone.demo_expired');
});
