<?php

use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\SuperAdmin;
use Illuminate\Support\Facades\Route;

// Auth routes
Route::middleware('guest')->group(function () {
    Route::get('/login', [LoginController::class, 'show'])->name('login');
    Route::post('/login', [LoginController::class, 'store'])->name('login.store');
});

Route::middleware('auth')->group(function () {
    Route::post('/logout', [LoginController::class, 'destroy'])->name('logout');
});

// Super Admin routes
Route::prefix('super-admin')
    ->name('super-admin.')
    ->middleware(['auth', 'super-admin'])
    ->group(function () {
        Route::get('/dashboard', [SuperAdmin\DashboardController::class, 'index'])->name('dashboard');
        Route::resource('tenants', SuperAdmin\TenantController::class);
    });

// Tenant routes (authenticated users with tenant)
Route::middleware(['auth', 'tenant-auth'])->group(function () {
    Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
    Route::get('/dashboard', [DashboardController::class, 'index']);
});
