<?php

use App\Http\Controllers\Admin\AuthController as AdminAuthController;
use App\Http\Controllers\Admin\ChatAdminController;
use App\Http\Controllers\Admin\PromptLibraryController;
use App\Http\Controllers\ChatController;
use App\Http\Controllers\LeadController;
use Illuminate\Support\Facades\Route;

Route::get('/', [ChatController::class, 'index'])->name('chat.home');
Route::post('/chat/identify', [ChatController::class, 'identify'])->name('chat.identify');
Route::post('/chat/send', [ChatController::class, 'send'])->name('chat.send');
Route::post('/chat/track', [ChatController::class, 'track'])->name('chat.track');
Route::post('/lead/save', [LeadController::class, 'store'])->name('lead.save');

Route::prefix('admin')->group(function () {
    Route::get('/login', [AdminAuthController::class, 'showLogin'])->name('admin.login');
    Route::post('/login', [AdminAuthController::class, 'login'])->name('admin.login.submit');
    Route::post('/logout', [AdminAuthController::class, 'logout'])->name('admin.logout');

    Route::middleware('admin.auth')->group(function () {
        Route::get('/', [ChatAdminController::class, 'dashboard'])->name('admin.dashboard');
        Route::get('/chats', [ChatAdminController::class, 'sessions'])->name('admin.chats');
        Route::get('/chats/{session}', [ChatAdminController::class, 'show'])->name('admin.chats.show');
        Route::get('/forms', [ChatAdminController::class, 'forms'])->name('admin.forms');
        Route::get('/prompts', [PromptLibraryController::class, 'index'])->name('admin.prompts');
        Route::get('/prompts/create', [PromptLibraryController::class, 'create'])->name('admin.prompts.create');
        Route::post('/prompts', [PromptLibraryController::class, 'store'])->name('admin.prompts.store');
        Route::get('/prompts/{prompt}/edit', [PromptLibraryController::class, 'edit'])->name('admin.prompts.edit');
        Route::put('/prompts/{prompt}', [PromptLibraryController::class, 'update'])->name('admin.prompts.update');
        Route::delete('/prompts/{prompt}', [PromptLibraryController::class, 'destroy'])->name('admin.prompts.delete');
    });
});
