<?php

/*
|--------------------------------------------------------------------------
| ROUTES MODULARI NETGESCON - ADMIN
|--------------------------------------------------------------------------
| 
| Tutte le route per il pannello amministratore.
| Ogni sezione è organizzata in gruppi logici e commentata.
|
| Autore: NetGesCon Development Team
| Data: 2024
|
*/

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Admin\DashboardController as AdminDashboardController;
use App\Http\Controllers\Admin\StabileController;
use App\Http\Controllers\Admin\CondominiController;
use App\Http\Controllers\Admin\TicketsController;
use App\Http\Controllers\Admin\ContabilitaController;
use App\Http\Controllers\Admin\FiscaleController;
use App\Http\Controllers\Admin\AssembleeController;
use App\Http\Controllers\Admin\ComunicazioniController;
use App\Http\Controllers\Admin\DocumentiController;
use App\Http\Controllers\Admin\FornitoriController;
use App\Http\Controllers\Admin\ManutentoriController;
use App\Http\Controllers\Admin\SettingsController as AdminSettingsController;
use App\Http\Controllers\Admin\UsersController as AdminUsersController;
use App\Http\Controllers\Admin\RegistrazioniController;
use App\Http\Controllers\Admin\RiconciliazioniController;
use App\Http\Controllers\Admin\MillesimiController;
use App\Http\Controllers\Admin\RiconciliazioniController;
use App\Http\Controllers\Admin\MillesimiController;
use App\Http\Controllers\Admin\LibroGiornaleController;
use App\Http\Controllers\Admin\PianoContiController;
use App\Http\Controllers\Admin\ProtocolliController;
use App\Http\Controllers\Admin\ScadenzarioController;
use App\Http\Controllers\Admin\BackupContabileController;
use App\Http\Controllers\Admin\AuditController;
use App\Http\Controllers\Admin\ImportazioniController;

/*
|--------------------------------------------------------------------------
| GRUPPO ADMIN - Middleware e Prefix
|--------------------------------------------------------------------------
*/
Route::middleware(['auth', 'verified', 'role:admin|amministratore|super-admin'])
    ->prefix('admin')
    ->name('admin.')
    ->group(function () {

    /*
    |--------------------------------------------------------------------------
    | DASHBOARD ADMIN
    |--------------------------------------------------------------------------
    */
    Route::get('/', [AdminDashboardController::class, 'index'])->name('dashboard');
    Route::get('/dashboard', [AdminDashboardController::class, 'index'])->name('dashboard.main');
    
    // API per dashboard (stats, grafici, etc.)
    Route::prefix('api/dashboard')->name('dashboard.api.')->group(function () {
        Route::get('/stats', [AdminDashboardController::class, 'getStats'])->name('stats');
        Route::get('/charts', [AdminDashboardController::class, 'getCharts'])->name('charts');
        Route::get('/recent-activity', [AdminDashboardController::class, 'getRecentActivity'])->name('activity');
    });

    /*
    |--------------------------------------------------------------------------
    | GESTIONE STABILI
    |--------------------------------------------------------------------------
    */
    Route::prefix('stabili')->name('stabili.')->group(function () {
        Route::get('/', [StabileController::class, 'index'])->name('index');
        Route::get('/create', [StabileController::class, 'create'])->name('create');
        Route::post('/', [StabileController::class, 'store'])->name('store');
        Route::get('/{stabile}', [StabileController::class, 'show'])->name('show');
        Route::get('/{stabile}/edit', [StabileController::class, 'edit'])->name('edit');
        Route::put('/{stabile}', [StabileController::class, 'update'])->name('update');
        Route::delete('/{stabile}', [StabileController::class, 'destroy'])->name('destroy');
        
        // Route secondarie per stabili
        Route::get('/{stabile}/unita', [StabileController::class, 'unita'])->name('unita');
        Route::get('/{stabile}/documenti', [StabileController::class, 'documenti'])->name('documenti');
        Route::get('/{stabile}/contabilita', [StabileController::class, 'contabilita'])->name('contabilita');
        Route::get('/{stabile}/manutentori', [StabileController::class, 'manutentori'])->name('manutentori');
        
        // Azioni bulk
        Route::post('/bulk/delete', [StabileController::class, 'bulkDelete'])->name('bulk.delete');
        Route::post('/bulk/export', [StabileController::class, 'bulkExport'])->name('bulk.export');
    });

    /*
    |--------------------------------------------------------------------------
    | GESTIONE CONDOMINI
    |--------------------------------------------------------------------------
    */
    Route::prefix('condomini')->name('condomini.')->group(function () {
        Route::get('/', [CondominiController::class, 'index'])->name('index');
        Route::get('/create', [CondominiController::class, 'create'])->name('create');
        Route::post('/', [CondominiController::class, 'store'])->name('store');
        Route::get('/{condomino}', [CondominiController::class, 'show'])->name('show');
        Route::get('/{condomino}/edit', [CondominiController::class, 'edit'])->name('edit');
        Route::put('/{condomino}', [CondominiController::class, 'update'])->name('update');
        Route::delete('/{condomino}', [CondominiController::class, 'destroy'])->name('destroy');
        
        // Gestione documenti e comunicazioni
        Route::get('/{condomino}/documenti', [CondominiController::class, 'documenti'])->name('documenti');
        Route::get('/{condomino}/comunicazioni', [CondominiController::class, 'comunicazioni'])->name('comunicazioni');
        Route::get('/{condomino}/contabilita', [CondominiController::class, 'contabilita'])->name('contabilita');
        
        // Import/Export
        Route::get('/import', [CondominiController::class, 'importForm'])->name('import.form');
        Route::post('/import', [CondominiController::class, 'import'])->name('import');
        Route::get('/export', [CondominiController::class, 'export'])->name('export');
    });

    /*
    |--------------------------------------------------------------------------
    | SISTEMA TICKETS
    |--------------------------------------------------------------------------
    */
    Route::prefix('tickets')->name('tickets.')->group(function () {
        Route::get('/', [TicketsController::class, 'index'])->name('index');
        Route::get('/create', [TicketsController::class, 'create'])->name('create');
        Route::post('/', [TicketsController::class, 'store'])->name('store');
        Route::get('/{ticket}', [TicketsController::class, 'show'])->name('show');
        Route::get('/{ticket}/edit', [TicketsController::class, 'edit'])->name('edit');
        Route::put('/{ticket}', [TicketsController::class, 'update'])->name('update');
        Route::delete('/{ticket}', [TicketsController::class, 'destroy'])->name('destroy');
        
        // Azioni sui tickets
        Route::post('/{ticket}/assign', [TicketsController::class, 'assign'])->name('assign');
        Route::post('/{ticket}/close', [TicketsController::class, 'close'])->name('close');
        Route::post('/{ticket}/reopen', [TicketsController::class, 'reopen'])->name('reopen');
        Route::post('/{ticket}/comment', [TicketsController::class, 'addComment'])->name('comment');
        
        // Allegati
        Route::post('/{ticket}/attachments', [TicketsController::class, 'uploadAttachment'])->name('attachments.upload');
        Route::delete('/attachments/{attachment}', [TicketsController::class, 'deleteAttachment'])->name('attachments.delete');
    });

    /*
    |--------------------------------------------------------------------------
    | CONTABILITÀ
    |--------------------------------------------------------------------------
    */
    Route::prefix('contabilita')->name('contabilita.')->group(function () {
        Route::get('/', [ContabilitaController::class, 'index'])->name('index');
        
        // Gestione Rate
        Route::prefix('rate')->name('rate.')->group(function () {
            Route::get('/', [ContabilitaController::class, 'rateIndex'])->name('index');
            Route::get('/create', [ContabilitaController::class, 'rateCreate'])->name('create');
            Route::post('/', [ContabilitaController::class, 'rateStore'])->name('store');
            Route::get('/{rata}', [ContabilitaController::class, 'rateShow'])->name('show');
            Route::get('/{rata}/edit', [ContabilitaController::class, 'rateEdit'])->name('edit');
            Route::put('/{rata}', [ContabilitaController::class, 'rateUpdate'])->name('update');
            Route::delete('/{rata}', [ContabilitaController::class, 'rateDestroy'])->name('destroy');
            
            // Azioni specifiche rate
            Route::post('/{rata}/pagamento', [ContabilitaController::class, 'registraPagamento'])->name('pagamento');
            Route::post('/bulk/solleciti', [ContabilitaController::class, 'inviaSolleciti'])->name('solleciti');
        });
        
        // Bilanci e rendiconti
        Route::prefix('bilanci')->name('bilanci.')->group(function () {
            Route::get('/', [ContabilitaController::class, 'bilanciIndex'])->name('index');
            Route::get('/create', [ContabilitaController::class, 'bilanciCreate'])->name('create');
            Route::post('/', [ContabilitaController::class, 'bilanciStore'])->name('store');
            Route::get('/{bilancio}', [ContabilitaController::class, 'bilanciShow'])->name('show');
            Route::get('/{bilancio}/export', [ContabilitaController::class, 'exportBilancio'])->name('export');
        });
        
        // Spese e fornitori
        Route::prefix('spese')->name('spese.')->group(function () {
            Route::get('/', [ContabilitaController::class, 'speseIndex'])->name('index');
            Route::get('/create', [ContabilitaController::class, 'speseCreate'])->name('create');
            Route::post('/', [ContabilitaController::class, 'speseStore'])->name('store');
            Route::get('/{spesa}', [ContabilitaController::class, 'speseShow'])->name('show');
            Route::put('/{spesa}', [ContabilitaController::class, 'speseUpdate'])->name('update');
            Route::delete('/{spesa}', [ContabilitaController::class, 'speseDestroy'])->name('destroy');
        });
        
        // Registrazioni contabili
        Route::prefix('registrazioni')->name('registrazioni.')->group(function () {
            Route::get('/', [RegistrazioniController::class, 'index'])->name('index');
            Route::get('/create', [RegistrazioniController::class, 'create'])->name('create');
            Route::post('/', [RegistrazioniController::class, 'store'])->name('store');
            Route::get('/{registrazione}', [RegistrazioniController::class, 'show'])->name('show');
            Route::get('/{registrazione}/edit', [RegistrazioniController::class, 'edit'])->name('edit');
            Route::put('/{registrazione}', [RegistrazioniController::class, 'update'])->name('update');
            Route::delete('/{registrazione}', [RegistrazioniController::class, 'destroy'])->name('destroy');
        });
        
        // Riconciliazioni
        Route::prefix('riconciliazioni')->name('riconciliazioni.')->group(function () {
            Route::get('/', [RiconciliazioniController::class, 'index'])->name('index');
            Route::get('/create', [RiconciliazioniController::class, 'create'])->name('create');
            Route::post('/', [RiconciliazioniController::class, 'store'])->name('store');
            Route::get('/{riconciliazione}', [RiconciliazioniController::class, 'show'])->name('show');
            Route::get('/{riconciliazione}/edit', [RiconciliazioniController::class, 'edit'])->name('edit');
            Route::put('/{riconciliazione}', [RiconciliazioniController::class, 'update'])->name('update');
            Route::delete('/{riconciliazione}', [RiconciliazioniController::class, 'destroy'])->name('destroy');
        });
        
        // Millesimi
        Route::prefix('millesimi')->name('millesimi.')->group(function () {
            Route::get('/', [MillesimiController::class, 'index'])->name('index');
            Route::get('/create', [MillesimiController::class, 'create'])->name('create');
            Route::post('/', [MillesimiController::class, 'store'])->name('store');
            Route::get('/{millesimo}', [MillesimiController::class, 'show'])->name('show');
            Route::get('/{millesimo}/edit', [MillesimiController::class, 'edit'])->name('edit');
            Route::put('/{millesimo}', [MillesimiController::class, 'update'])->name('update');
            Route::delete('/{millesimo}', [MillesimiController::class, 'destroy'])->name('destroy');
        });
        
        // Libro giornale
        Route::prefix('libro-giornale')->name('libro-giornale.')->group(function () {
            Route::get('/', [LibroGiornaleController::class, 'index'])->name('index');
            Route::get('/create', [LibroGiornaleController::class, 'create'])->name('create');
            Route::post('/', [LibroGiornaleController::class, 'store'])->name('store');
            Route::get('/{voce}', [LibroGiornaleController::class, 'show'])->name('show');
            Route::get('/{voce}/edit', [LibroGiornaleController::class, 'edit'])->name('edit');
            Route::put('/{voce}', [LibroGiornaleController::class, 'update'])->name('update');
            Route::delete('/{voce}', [LibroGiornaleController::class, 'destroy'])->name('destroy');
        });
        
        // Piano dei conti
        Route::prefix('piano-conti')->name('piano-conti.')->group(function () {
            Route::get('/', [PianoContiController::class, 'index'])->name('index');
            Route::get('/create', [PianoContiController::class, 'create'])->name('create');
            Route::post('/', [PianoContiController::class, 'store'])->name('store');
            Route::get('/{conto}', [PianoContiController::class, 'show'])->name('show');
            Route::get('/{conto}/edit', [PianoContiController::class, 'edit'])->name('edit');
            Route::put('/{conto}', [PianoContiController::class, 'update'])->name('update');
            Route::delete('/{conto}', [PianoContiController::class, 'destroy'])->name('destroy');
        });
        
        // Protocolli
        Route::prefix('protocolli')->name('protocolli.')->group(function () {
            Route::get('/', [ProtocolliController::class, 'index'])->name('index');
            Route::get('/create', [ProtocolliController::class, 'create'])->name('create');
            Route::post('/', [ProtocolliController::class, 'store'])->name('store');
            Route::get('/{protocollo}', [ProtocolliController::class, 'show'])->name('show');
            Route::get('/{protocollo}/edit', [ProtocolliController::class, 'edit'])->name('edit');
            Route::put('/{protocollo}', [ProtocolliController::class, 'update'])->name('update');
            Route::delete('/{protocollo}', [ProtocolliController::class, 'destroy'])->name('destroy');
        });
        
        // Scadenzario
        Route::prefix('scadenzario')->name('scadenzario.')->group(function () {
            Route::get('/', [ScadenzarioController::class, 'index'])->name('index');
            Route::get('/create', [ScadenzarioController::class, 'create'])->name('create');
            Route::post('/', [ScadenzarioController::class, 'store'])->name('store');
            Route::get('/{scadenza}', [ScadenzarioController::class, 'show'])->name('show');
            Route::get('/{scadenza}/edit', [ScadenzarioController::class, 'edit'])->name('edit');
            Route::put('/{scadenza}', [ScadenzarioController::class, 'update'])->name('update');
            Route::delete('/{scadenza}', [ScadenzarioController::class, 'destroy'])->name('destroy');
        });
        
        // Backup contabile
        Route::prefix('backup-contabile')->name('backup-contabile.')->group(function () {
            Route::get('/', [BackupContabileController::class, 'index'])->name('index');
            Route::post('/create', [BackupContabileController::class, 'create'])->name('create');
            Route::get('/{backup}/download', [BackupContabileController::class, 'download'])->name('download');
            Route::delete('/{backup}', [BackupContabileController::class, 'destroy'])->name('destroy');
        });
        
        // Audit
        Route::prefix('audit')->name('audit.')->group(function () {
            Route::get('/', [AuditController::class, 'index'])->name('index');
            Route::get('/{audit}', [AuditController::class, 'show'])->name('show');
        });
        
        // Importazioni
        Route::prefix('importazioni')->name('importazioni.')->group(function () {
            Route::get('/', [ImportazioniController::class, 'index'])->name('index');
            Route::get('/create', [ImportazioniController::class, 'create'])->name('create');
            Route::post('/', [ImportazioniController::class, 'store'])->name('store');
            Route::get('/{importazione}', [ImportazioniController::class, 'show'])->name('show');
            Route::get('/{importazione}/edit', [ImportazioniController::class, 'edit'])->name('edit');
            Route::put('/{importazione}', [ImportazioniController::class, 'update'])->name('update');
            Route::delete('/{importazione}', [ImportazioniController::class, 'destroy'])->name('destroy');
        });
    });

    /*
    |--------------------------------------------------------------------------
    | GESTIONE FISCALE
    |--------------------------------------------------------------------------
    */
    Route::prefix('fiscale')->name('fiscale.')->group(function () {
        Route::get('/', [FiscaleController::class, 'index'])->name('index');
        
        // Dichiarazioni e adempimenti
        Route::get('/dichiarazioni', [FiscaleController::class, 'dichiarazioni'])->name('dichiarazioni');
        Route::get('/f24', [FiscaleController::class, 'f24'])->name('f24');
        Route::get('/iva', [FiscaleController::class, 'iva'])->name('iva');
        Route::get('/730', [FiscaleController::class, 'modello730'])->name('730');
        
        // Scadenze fiscali
        Route::get('/scadenze', [FiscaleController::class, 'scadenze'])->name('scadenze');
        Route::post('/scadenze/reminder', [FiscaleController::class, 'impostaPromemoria'])->name('scadenze.reminder');
    });

    /*
    |--------------------------------------------------------------------------
    | ASSEMBLEE
    |--------------------------------------------------------------------------
    */
    Route::prefix('assemblee')->name('assemblee.')->group(function () {
        Route::get('/', [AssembleeController::class, 'index'])->name('index');
        Route::get('/create', [AssembleeController::class, 'create'])->name('create');
        Route::post('/', [AssembleeController::class, 'store'])->name('store');
        Route::get('/{assemblea}', [AssembleeController::class, 'show'])->name('show');
        Route::get('/{assemblea}/edit', [AssembleeController::class, 'edit'])->name('edit');
        Route::put('/{assemblea}', [AssembleeController::class, 'update'])->name('update');
        Route::delete('/{assemblea}', [AssembleeController::class, 'destroy'])->name('destroy');
        
        // Gestione verbali e convocazioni
        Route::get('/{assemblea}/convocazione', [AssembleeController::class, 'convocazione'])->name('convocazione');
        Route::post('/{assemblea}/invia-convocazione', [AssembleeController::class, 'inviaConvocazione'])->name('invia-convocazione');
        Route::get('/{assemblea}/verbale', [AssembleeController::class, 'verbale'])->name('verbale');
        Route::post('/{assemblea}/verbale', [AssembleeController::class, 'salvaVerbale'])->name('salva-verbale');
        
        // Presenze e votazioni
        Route::post('/{assemblea}/presenze', [AssembleeController::class, 'registraPresenze'])->name('presenze');
        Route::post('/{assemblea}/votazioni', [AssembleeController::class, 'registraVotazioni'])->name('votazioni');
    });

    /*
    |--------------------------------------------------------------------------
    | COMUNICAZIONI
    |--------------------------------------------------------------------------
    */
    Route::prefix('comunicazioni')->name('comunicazioni.')->group(function () {
        Route::get('/', [ComunicazioniController::class, 'index'])->name('index');
        Route::get('/create', [ComunicazioniController::class, 'create'])->name('create');
        Route::post('/', [ComunicazioniController::class, 'store'])->name('store');
        Route::get('/{comunicazione}', [ComunicazioniController::class, 'show'])->name('show');
        Route::get('/{comunicazione}/edit', [ComunicazioniController::class, 'edit'])->name('edit');
        Route::put('/{comunicazione}', [ComunicazioniController::class, 'update'])->name('update');
        Route::delete('/{comunicazione}', [ComunicazioniController::class, 'destroy'])->name('destroy');
        
        // Invio comunicazioni
        Route::post('/{comunicazione}/invia', [ComunicazioniController::class, 'invia'])->name('invia');
        Route::get('/{comunicazione}/preview', [ComunicazioniController::class, 'preview'])->name('preview');
        
        // Template comunicazioni
        Route::prefix('template')->name('template.')->group(function () {
            Route::get('/', [ComunicazioniController::class, 'templateIndex'])->name('index');
            Route::get('/create', [ComunicazioniController::class, 'templateCreate'])->name('create');
            Route::post('/', [ComunicazioniController::class, 'templateStore'])->name('store');
            Route::get('/{template}/edit', [ComunicazioniController::class, 'templateEdit'])->name('edit');
            Route::put('/{template}', [ComunicazioniController::class, 'templateUpdate'])->name('update');
            Route::delete('/{template}', [ComunicazioniController::class, 'templateDestroy'])->name('destroy');
        });
    });

    /*
    |--------------------------------------------------------------------------
    | GESTIONE DOCUMENTI
    |--------------------------------------------------------------------------
    */
    Route::prefix('documenti')->name('documenti.')->group(function () {
        Route::get('/', [DocumentiController::class, 'index'])->name('index');
        Route::get('/create', [DocumentiController::class, 'create'])->name('create');
        Route::post('/', [DocumentiController::class, 'store'])->name('store');
        Route::get('/{documento}', [DocumentiController::class, 'show'])->name('show');
        Route::get('/{documento}/download', [DocumentiController::class, 'download'])->name('download');
        Route::delete('/{documento}', [DocumentiController::class, 'destroy'])->name('destroy');
        
        // Gestione categorie
        Route::prefix('categorie')->name('categorie.')->group(function () {
            Route::get('/', [DocumentiController::class, 'categorieIndex'])->name('index');
            Route::post('/', [DocumentiController::class, 'categorieStore'])->name('store');
            Route::put('/{categoria}', [DocumentiController::class, 'categorieUpdate'])->name('update');
            Route::delete('/{categoria}', [DocumentiController::class, 'categorieDestroy'])->name('destroy');
        });
        
        // Upload multiplo e archivio
        Route::post('/bulk-upload', [DocumentiController::class, 'bulkUpload'])->name('bulk-upload');
        Route::get('/archivio', [DocumentiController::class, 'archivio'])->name('archivio');
    });

    /*
    |--------------------------------------------------------------------------
    | FORNITORI
    |--------------------------------------------------------------------------
    */
    Route::prefix('fornitori')->name('fornitori.')->group(function () {
        Route::get('/', [FornitoriController::class, 'index'])->name('index');
        Route::get('/create', [FornitoriController::class, 'create'])->name('create');
        Route::post('/', [FornitoriController::class, 'store'])->name('store');
        Route::get('/{fornitore}', [FornitoriController::class, 'show'])->name('show');
        Route::get('/{fornitore}/edit', [FornitoriController::class, 'edit'])->name('edit');
        Route::put('/{fornitore}', [FornitoriController::class, 'update'])->name('update');
        Route::delete('/{fornitore}', [FornitoriController::class, 'destroy'])->name('destroy');
        
        // Valutazioni e contratti
        Route::post('/{fornitore}/valutazioni', [FornitoriController::class, 'addValutazione'])->name('valutazioni');
        Route::get('/{fornitore}/contratti', [FornitoriController::class, 'contratti'])->name('contratti');
    });

    /*
    |--------------------------------------------------------------------------
    | MANUTENTORI
    |--------------------------------------------------------------------------
    */
    Route::prefix('manutentori')->name('manutentori.')->group(function () {
        Route::get('/', [ManutentoriController::class, 'index'])->name('index');
        Route::get('/create', [ManutentoriController::class, 'create'])->name('create');
        Route::post('/', [ManutentoriController::class, 'store'])->name('store');
        Route::get('/{manutentore}', [ManutentoriController::class, 'show'])->name('show');
        Route::get('/{manutentore}/edit', [ManutentoriController::class, 'edit'])->name('edit');
        Route::put('/{manutentore}', [ManutentoriController::class, 'update'])->name('update');
        Route::delete('/{manutentore}', [ManutentoriController::class, 'destroy'])->name('destroy');
        
        // Interventi e pianificazione
        Route::get('/{manutentore}/interventi', [ManutentoriController::class, 'interventi'])->name('interventi');
        Route::post('/{manutentore}/pianifica', [ManutentoriController::class, 'pianificaIntervento'])->name('pianifica');
    });

    /*
    |--------------------------------------------------------------------------
    | GESTIONE UTENTI ADMIN
    |--------------------------------------------------------------------------
    */
    Route::prefix('users')->name('users.')->group(function () {
        Route::get('/', [AdminUsersController::class, 'index'])->name('index');
        Route::get('/create', [AdminUsersController::class, 'create'])->name('create');
        Route::post('/', [AdminUsersController::class, 'store'])->name('store');
        Route::get('/{user}', [AdminUsersController::class, 'show'])->name('show');
        Route::get('/{user}/edit', [AdminUsersController::class, 'edit'])->name('edit');
        Route::put('/{user}', [AdminUsersController::class, 'update'])->name('update');
        Route::delete('/{user}', [AdminUsersController::class, 'destroy'])->name('destroy');
        
        // Gestione ruoli e permessi
        Route::post('/{user}/roles', [AdminUsersController::class, 'assignRole'])->name('assign-role');
        Route::delete('/{user}/roles/{role}', [AdminUsersController::class, 'removeRole'])->name('remove-role');
        Route::post('/{user}/impersonate', [AdminUsersController::class, 'impersonate'])->name('impersonate');
    });

    /*
    |--------------------------------------------------------------------------
    | IMPOSTAZIONI ADMIN
    |--------------------------------------------------------------------------
    */
    Route::prefix('settings')->name('settings.')->group(function () {
        Route::get('/', [AdminSettingsController::class, 'index'])->name('index');
        Route::post('/', [AdminSettingsController::class, 'update'])->name('update');
        
        // Sezioni specifiche
        Route::get('/general', [AdminSettingsController::class, 'general'])->name('general');
        Route::get('/email', [AdminSettingsController::class, 'email'])->name('email');
        Route::get('/backup', [AdminSettingsController::class, 'backup'])->name('backup');
        Route::get('/logs', [AdminSettingsController::class, 'logs'])->name('logs');
        
        // Backup e manutenzione
        Route::post('/backup/create', [AdminSettingsController::class, 'createBackup'])->name('backup.create');
        Route::get('/backup/{backup}/download', [AdminSettingsController::class, 'downloadBackup'])->name('backup.download');
        Route::delete('/backup/{backup}', [AdminSettingsController::class, 'deleteBackup'])->name('backup.delete');
        
        // Cache e ottimizzazione
        Route::post('/cache/clear', [AdminSettingsController::class, 'clearCache'])->name('cache.clear');
        Route::post('/optimize', [AdminSettingsController::class, 'optimize'])->name('optimize');
    });

}); // Fine gruppo admin
