{{--
    Dashboard Admin - Layout Unificato con Navigazione AJAX
    Versione ottimizzata per gestione centralizzata e UX migliorata
--}}

<x-layout.universal pageTitle="Dashboard Admin" showBreadcrumb="true" showSidebar="true">

{{-- CSS per la dashboard --}}
@push('styles')
<style>
.dashboard-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.dashboard-card .card-body {
    padding: 1rem;
}

.dashboard-card .card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.widget-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.widget-stats {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
}

.quick-action-btn {
    height: 100px;
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    transition: all 0.3s ease;
    padding: 0.75rem;
}

.quick-action-btn:hover {
    border-color: var(--bs-primary);
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    transform: translateY(-2px);
}

.stats-card {
    height: 120px;
    min-height: 120px;
}

.stats-card .card-body {
    padding: 1rem;
    display: flex;
    align-items: center;
}

.stats-card h3 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.stats-card h6 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.stats-card small {
    font-size: 0.75rem;
    opacity: 0.8;
}

.list-group-item {
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding: 0.75rem 1rem;
}

.list-group-item:last-child {
    border-bottom: none;
}

.list-group-item h6 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.list-group-item small {
    font-size: 0.75rem;
}

.row.g-2 > * {
    padding-right: 0.25rem;
    padding-left: 0.25rem;
}

@media (max-width: 768px) {
    .stats-card {
        height: auto;
        min-height: 100px;
    }
    
    .quick-action-btn {
        height: 80px;
        margin-bottom: 0.5rem;
    }
    
    .dashboard-card .card-body {
        padding: 0.75rem;
    }
}
</style>
@endpush

<div class="container-fluid">
    
    <!-- Header Dashboard - Ottimizzato -->
    <div class="row mb-3">
        <div class="col-12">
            <div class="d-flex align-items-center justify-content-between">
                <div>
                    <h1 class="h4 mb-1 text-primary">
                        <i class="fas fa-user-shield me-2"></i>Dashboard Amministratore
                    </h1>
                    <p class="text-muted mb-0 small">
                        @auth
                            Benvenuto, <strong>{{ Auth::user()->name }}</strong> nel pannello di gestione condominiale
                        @endauth
                    </p>
                </div>
                <div class="text-muted text-end small">
                    <i class="fas fa-clock me-1"></i>{{ date('d/m/Y H:i') }}
                </div>
            </div>
        </div>
    </div>

    <!-- Alert Notifiche -->
    <div class="row mb-4">
        <div class="col-md-6">
            <x-widgets.alert-box 
                type="danger" 
                title="Tickets Urgenti!" 
                message="1 ticket richiede attenzione immediata"
                action-text="Visualizza Urgenti"
                action-url="#"
                dismissible="true"
            />
        </div>
        <div class="col-md-6">
            <x-widgets.alert-box 
                type="info" 
                title="Notifiche Sistema" 
                message="Sistema di backup completato con successo"
                action-text="Visualizza Log"
                action-url="#"
                dismissible="true"
            />
        </div>
    </div>

    <!-- Stats Cards - Cliccabili per navigazione -->
    <div class="row mb-4" id="stats-cards">
        @if(App\Helpers\MenuHelper::canUserAccessMenu('stabili'))
        <div class="col-md-3 mb-3">
            <div class="card bg-primary text-white stats-card dashboard-card clickable-card" 
                 data-section="stabili" style="cursor: pointer;">
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div class="flex-grow-1">
                            <h6 class="card-title mb-1 small">
                                <i class="fas fa-building me-2"></i>Stabili Totali
                            </h6>
                            <h3 class="mb-0">{{ \App\Models\Stabile::count() ?? 0 }}</h3>
                            <small class="opacity-75">Stabili gestiti</small>
                        </div>
                        <div class="ms-3">
                            <i class="fas fa-arrow-right"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @endif
        
        @if(App\Helpers\MenuHelper::canUserAccessMenu('condomini'))
        <div class="col-md-3 mb-3">
            <div class="card bg-success text-white stats-card dashboard-card clickable-card" 
                 data-section="condomini" style="cursor: pointer;">
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div class="flex-grow-1">
                            <h6 class="card-title mb-1 small">
                                <i class="fas fa-users me-2"></i>Condomini
                            </h6>
                            <h3 class="mb-0">0</h3>
                            <small class="opacity-75">Condomini registrati</small>
                        </div>
                        <div class="ms-3">
                            <i class="fas fa-arrow-right"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @endif
        
        @if(App\Helpers\MenuHelper::canUserAccessMenu('tickets'))
        <div class="col-md-3 mb-3">
            <div class="card bg-warning text-white stats-card dashboard-card clickable-card" 
                 data-section="tickets" style="cursor: pointer;">
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div class="flex-grow-1">
                            <h6 class="card-title mb-1 small">
                                <i class="fas fa-ticket-simple me-2"></i>Tickets Aperti
                            </h6>
                            <h3 class="mb-0">{{ isset($stats['tickets_aperti']) ? $stats['tickets_aperti'] : 3 }}</h3>
                            <small class="opacity-75">Richieste in corso</small>
                        </div>
                        <div class="ms-3">
                            <i class="fas fa-arrow-right"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @endif
        
        @if(App\Helpers\MenuHelper::canUserAccessMenu('contabilita'))
        <div class="col-md-3 mb-3">
            <div class="card bg-info text-white stats-card dashboard-card clickable-card" 
                 data-section="contabilita" style="cursor: pointer;">
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div class="flex-grow-1">
                            <h6 class="card-title mb-1 small">
                                <i class="fas fa-calculator me-2"></i>Contabilità
                            </h6>
                            <h3 class="mb-0">{{ isset($stats['bilanci_attivi']) ? $stats['bilanci_attivi'] : 0 }}</h3>
                            <small class="opacity-75">Bilanci attivi</small>
                        </div>
                        <div class="ms-3">
                            <i class="fas fa-arrow-right"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        @endif
    </div>

    <!-- Saldo Bancario Card -->
    <div class="row mb-4">
        <div class="col-12">
            <div class="card bg-gradient-success text-white" style="background: linear-gradient(135deg, #28a745 0%, #20c997 100%);">
                <div class="card-body">
                    <div class="row align-items-center">
                        <div class="col-md-8">
                            <h5 class="card-title mb-2">
                                <i class="fas fa-piggy-bank me-2"></i>Saldo Bancario Condominio
                            </h5>
                            <div class="row">
                                <div class="col-md-6">
                                    <h3 class="mb-1" id="saldo-principale">
                                        € {{ number_format($saldoBancario['principale'] ?? 0, 2, ',', '.') }}
                                    </h3>
                                    <small class="opacity-75">
                                        <i class="fas fa-university me-1"></i>
                                        Conto Principale {{ $bancaPrincipale ?? 'N/D' }}
                                    </small>
                                </div>
                                @if(isset($saldoBancario['secondario']) && $saldoBancario['secondario'] != 0)
                                <div class="col-md-6">
                                    <h4 class="mb-1" id="saldo-secondario">
                                        € {{ number_format($saldoBancario['secondario'], 2, ',', '.') }}
                                    </h4>
                                    <small class="opacity-75">
                                        <i class="fas fa-university me-1"></i>
                                        Conto Secondario {{ $bancaSecondaria ?? 'N/D' }}
                                    </small>
                                </div>
                                @endif
                            </div>
                        </div>
                        <div class="col-md-4 text-end">
                            <div class="mb-2">
                                <small class="opacity-75">Ultimo aggiornamento:</small><br>
                                <strong id="ultimo-aggiornamento-saldo">
                                    {{ isset($ultimoAggiornamentoSaldo) ? $ultimoAggiornamentoSaldo->format('d/m/Y H:i') : 'Mai aggiornato' }}
                                </strong>
                            </div>
                            <div class="btn-group btn-group-sm">
                                <button type="button" class="btn btn-light btn-sm" onclick="aggiornaSaldoBancario()" title="Aggiorna saldo">
                                    <i class="fas fa-sync-alt"></i> Aggiorna
                                </button>
                                <button type="button" class="btn btn-light btn-sm" onclick="visualizzaStoricoSaldi()" title="Storico saldi">
                                    <i class="fas fa-chart-line"></i> Storico
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Quick Actions -->
    <div class="row mb-4">
        <div class="col-12">
            <div class="card dashboard-card">
                <div class="card-header">
                    <h5 class="card-title mb-0">
                        <i class="fas fa-bolt text-warning me-2"></i>Azioni Rapide
                    </h5>
                </div>
                <div class="card-body">
                    <div class="row g-2">
                        @if(App\Helpers\MenuHelper::canUserAccessMenu('stabili'))
                        <div class="col-md-2 col-6">
                            <button class="btn btn-outline-primary w-100 quick-action-btn" onclick="showCreateStabileForm()">
                                <i class="fas fa-plus-circle mb-2"></i>
                                <small>Nuovo Stabile</small>
                            </button>
                        </div>
                        @endif
                        
                        @if(App\Helpers\MenuHelper::canUserAccessMenu('condomini'))
                        <div class="col-md-2 col-6">
                            <button class="btn btn-outline-success w-100 quick-action-btn">
                                <i class="fas fa-plus-circle mb-2"></i>
                                <small>Nuovo Condomino</small>
                            </button>
                        </div>
                        @endif
                        
                        @if(App\Helpers\MenuHelper::canUserAccessMenu('contabilita'))
                        <div class="col-md-2 col-6">
                            <button class="btn btn-outline-warning w-100 quick-action-btn">
                                <i class="fas fa-receipt mb-2"></i>
                                <small>Emetti Rate</small>
                            </button>
                        </div>
                        @endif
                        
                        @if(App\Helpers\MenuHelper::canUserAccessMenu('comunicazioni'))
                        <div class="col-md-2 col-6">
                            <button class="btn btn-outline-info w-100 quick-action-btn">
                                <i class="fas fa-envelope mb-2"></i>
                                <small>Invia Email</small>
                            </button>
                        </div>
                        @endif
                        
                        @if(App\Helpers\MenuHelper::canUserAccessMenu('contabilita'))
                        <div class="col-md-2 col-6">
                            <button class="btn btn-outline-secondary w-100 quick-action-btn">
                                <i class="fas fa-chart-bar mb-2"></i>
                                <small>Report</small>
                            </button>
                        </div>
                        @endif
                        
                        @if(App\Helpers\MenuHelper::canUserAccessMenu('tickets'))
                        <div class="col-md-2 col-6">
                            <button class="btn btn-outline-danger w-100 quick-action-btn">
                                <i class="fas fa-exclamation-triangle mb-2"></i>
                                <small>Urgenze</small>
                            </button>
                        </div>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Sezione Informazioni e Attività -->
    <div class="row">
        <!-- Notifiche Recenti -->
        <div class="col-md-6 mb-4">
            <div class="card dashboard-card">
                <div class="card-header">
                    <h5 class="card-title mb-0">
                        <i class="fas fa-bell text-info me-2"></i>Notifiche Recenti
                    </h5>
                </div>
                <div class="card-body">
                    <div class="list-group list-group-flush">
                        @if(isset($stats['notifiche_recenti']) && count($stats['notifiche_recenti']) > 0)
                            @foreach($stats['notifiche_recenti'] as $notifica)
                            <div class="list-group-item d-flex align-items-center">
                                <i class="fas {{ $notifica['icon'] ?? 'fa-bell' }} {{ $notifica['color'] ?? 'text-info' }} me-3"></i>
                                <div>
                                    <h6 class="mb-1">{{ $notifica['titolo'] }}</h6>
                                    <small class="text-muted">{{ $notifica['descrizione'] }}</small>
                                </div>
                                <small class="text-muted ms-auto">{{ $notifica['tempo'] }}</small>
                            </div>
                            @endforeach
                        @else
                        <div class="list-group-item d-flex align-items-center">
                            <i class="fas fa-exclamation-circle text-danger me-3"></i>
                            <div>
                                <h6 class="mb-1">Ticket Urgente #1234</h6>
                                <small class="text-muted">Ascensore bloccato - Stabile A</small>
                            </div>
                            <small class="text-muted ms-auto">2 min fa</small>
                        </div>
                        <div class="list-group-item d-flex align-items-center">
                            <i class="fas fa-euro-sign text-warning me-3"></i>
                            <div>
                                <h6 class="mb-1">Rata in scadenza</h6>
                                <small class="text-muted">Condomino Rossi - €450</small>
                            </div>
                            <small class="text-muted ms-auto">1 ora fa</small>
                        </div>
                        <div class="list-group-item d-flex align-items-center">
                            <i class="fas fa-check-circle text-success me-3"></i>
                            <div>
                                <h6 class="mb-1">Backup completato</h6>
                                <small class="text-muted">Database salvato con successo</small>
                            </div>
                            <small class="text-muted ms-auto">3 ore fa</small>
                        </div>
                        @endif
                    </div>
                </div>
            </div>
        </div>

        <!-- Ultimi Tickets -->
        <div class="col-md-6 mb-4">
            <div class="card dashboard-card">
                <div class="card-header">
                    <h5 class="card-title mb-0">
                        <i class="fas fa-ticket-simple text-warning me-2"></i>Ultimi Tickets
                    </h5>
                </div>
                <div class="card-body">
                    <div class="list-group list-group-flush">
                        @if(isset($stats['ultimi_tickets']) && count($stats['ultimi_tickets']) > 0)
                            @foreach($stats['ultimi_tickets'] as $ticket)
                            <div class="list-group-item d-flex align-items-center justify-between">
                                <div class="flex-grow-1">
                                    <h6 class="mb-1">Ticket #{{ $ticket['id'] }}</h6>
                                    <small class="text-muted">{{ $ticket['descrizione'] }}</small>
                                </div>
                                <div class="flex-shrink-0 ms-3">
                                    @if($ticket['stato'] == 'Aperto')
                                        <span class="badge bg-warning">{{ $ticket['stato'] }}</span>
                                    @elseif($ticket['stato'] == 'Urgente')
                                        <span class="badge bg-danger">{{ $ticket['stato'] }}</span>
                                    @elseif($ticket['stato'] == 'Risolto')
                                        <span class="badge bg-success">{{ $ticket['stato'] }}</span>
                                    @else
                                        <span class="badge bg-secondary">{{ $ticket['stato'] }}</span>
                                    @endif
                                </div>
                            </div>
                            @endforeach
                        @else
                        <div class="text-center py-4">
                            <i class="fas fa-ticket-simple text-muted fa-2x mb-2"></i>
                            <p class="text-muted mb-0">Nessun ticket recente</p>
                        </div>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Area dinamica per contenuti AJAX (nascosta di default) -->
    <div class="row" id="dynamic-content-area" style="display: none;">
        <div class="col-12">
            <div class="card dashboard-card">
                <div class="card-header">
                    <h5 class="card-title mb-0" id="dynamic-content-title">
                        <i class="fas fa-cog me-2"></i>Contenuto Dinamico
                    </h5>
                    <button type="button" class="btn btn-sm btn-outline-secondary" id="back-to-dashboard">
                        <i class="fas fa-arrow-left me-2"></i>Torna alla Dashboard
                    </button>
                </div>
                <div class="card-body" id="dynamic-content-body">
                    <!-- Il contenuto verrà caricato qui dinamicamente -->
                </div>
            </div>
        </div>
    </div>

</div>

@push('scripts')
<script>
$(document).ready(function() {
    // Gestione click su cards statistiche
    $('.clickable-card').on('click', function() {
        const section = $(this).data('section');
        loadSection(section);
    });

    // Gestione click sui link della sidebar con navigazione AJAX
    $(document).on('click', '.dashboard-nav-link', function(e) {
        e.preventDefault();
        
        const section = $(this).data('section');
        const action = $(this).data('action');
        
        // Debug per capire cosa sta succedendo
        console.log('Sidebar click:', { section, action });
        
        // Gestione azioni specifiche
        if (action === 'create-stabile') {
            showCreateStabileForm();
        } else if (action === 'create' && section === 'condomini') {
            showCreateCondominiForm();
        } else if (action === 'create' && section === 'tickets') {
            showCreateTicketForm();
        } else if (section === 'superadmin') {
            loadSuperAdminSection(action);
        } else if (section) {
            loadSection(section, action);
        }
    });

    // Gestione pulsante "Torna alla Dashboard"
    $('#back-to-dashboard').on('click', function() {
        showDashboard();
    });

    // Funzione per caricare una sezione
    function loadSection(section, action = null) {
        // Assicurati che l'header principale rimanga sempre visibile
        $('#dynamic-content-area').show();
        
        // Nascondi solo le sezioni del contenuto dashboard, NON l'header
        $('.container-fluid > .row').not('#dynamic-content-area').not('.mb-3:first').hide();
        
        // Aggiorna il titolo
        let title = '';
        let icon = '';
        switch(section) {
            case 'stabili':
                title = 'Gestione Stabili';
                icon = 'fas fa-building';
                loadStabiliContent(action);
                break;
            case 'condomini':
                title = 'Gestione Condomini';
                icon = 'fas fa-users';
                loadCondominiContent(action);
                break;
            case 'tickets':
                title = 'Gestione Tickets';
                icon = 'fas fa-ticket-simple';
                loadTicketsContent(action);
                break;
            case 'contabilita':
                title = 'Gestione Contabilità';
                icon = 'fas fa-calculator';
                loadContabilitaContent(action);
                break;
            case 'varie':
                title = 'Varie & Utilità';
                icon = 'fas fa-tools';
                loadVarieContent(action);
                break;
            case 'superadmin':
                title = 'SuperAdmin Dashboard';
                icon = 'fas fa-crown text-danger';
                loadSuperAdminSection(action);
                return; // Esce dalla funzione perché gestisce il caricamento internamente
        }
        
        $('#dynamic-content-title').html(`<i class="${icon} me-2"></i>${title}`);
    }

    // Funzione per tornare alla dashboard
    function showDashboard() {
        $('#dynamic-content-area').hide();
        $('.container-fluid > .row').show();
    }

    // Funzioni per caricare contenuti specifici
    function loadStabiliContent(action = null) {
        let content = '';
        
        if (action === 'list' || action === null) {
            content = `
                <div class="row mb-3">
                    <div class="col-md-6">
                        <h6 class="text-muted">Panoramica Stabili</h6>
                    </div>
                    <div class="col-md-6 text-end">
                        <button type="button" class="btn btn-primary btn-sm" onclick="showCreateStabileForm()">
                            <i class="fas fa-plus me-2"></i>Nuovo Stabile
                        </button>
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-12">
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>Denominazione</th>
                                        <th>Codice</th>
                                        <th>Indirizzo</th>
                                        <th>Condomini</th>
                                        <th>Azioni</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td colspan="5" class="text-center text-muted">
                                            <i class="fas fa-building fa-2x mb-2"></i><br>
                                            Nessuno stabile ancora registrato.<br>
                                            <button type="button" class="btn btn-primary btn-sm mt-2" onclick="showCreateStabileForm()">
                                                Crea il primo stabile
                                            </button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            `;
        }
        
        $('#dynamic-content-body').html(content);
    }

    function loadCondominiContent(action = null) {
        let content = '';
        
        if (action === 'list' || action === null) {
            content = `
                <div class="row mb-3">
                    <div class="col-md-6">
                        <h6 class="text-muted">Panoramica Condomini</h6>
                    </div>
                    <div class="col-md-6 text-end">
                        <button type="button" class="btn btn-success btn-sm" onclick="showCreateCondominiForm()">
                            <i class="fas fa-plus me-2"></i>Nuovo Condomino
                        </button>
                    </div>
                </div>
                
                <div class="alert alert-info">
                    <i class="fas fa-info-circle me-2"></i>
                    Sezione Condomini in sviluppo. Per ora gestisci i condomini tramite la sezione Stabili.
                </div>
                
                <div class="row">
                    <div class="col-md-3 mb-3">
                        <div class="card bg-success text-white">
                            <div class="card-body text-center">
                                <i class="fas fa-users fa-2x mb-2"></i>
                                <h4>0</h4>
                                <small>Condomini Totali</small>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 mb-3">
                        <div class="card bg-info text-white">
                            <div class="card-body text-center">
                                <i class="fas fa-home fa-2x mb-2"></i>
                                <h4>0</h4>
                                <small>Proprietari</small>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 mb-3">
                        <div class="card bg-warning text-white">
                            <div class="card-body text-center">
                                <i class="fas fa-clock fa-2x mb-2"></i>
                                <h4>0</h4>
                                <small>Inquilini</small>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 mb-3">
                        <div class="card bg-secondary text-white">
                            <div class="card-body text-center">
                                <i class="fas fa-envelope fa-2x mb-2"></i>
                                <h4>0</h4>
                                <small>Comunicazioni</small>
                            </div>
                        </div>
                    </div>
                </div>
            `;
        }
        
        $('#dynamic-content-body').html(content);
    }

    function loadTicketsContent(action = null) {
        let content = '';
        
        if (action === 'list' || action === null) {
            content = `
                <div class="row mb-3">
                    <div class="col-md-6">
                        <h6 class="text-muted">Tickets e Richieste</h6>
                    </div>
                    <div class="col-md-6 text-end">
                        <button type="button" class="btn btn-warning btn-sm" onclick="showCreateTicketForm()">
                            <i class="fas fa-plus me-2"></i>Nuovo Ticket
                        </button>
                    </div>
                </div>
                
                <div class="alert alert-warning">
                    <i class="fas fa-exclamation-triangle me-2"></i>
                    3 tickets urgenti richiedono attenzione immediata.
                </div>
                
                <div class="row">
                    <div class="col-md-3 mb-3">
                        <div class="card bg-danger text-white">
                            <div class="card-body text-center">
                                <i class="fas fa-exclamation-triangle fa-2x mb-2"></i>
                                <h4>1</h4>
                                <small>Urgenti</small>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 mb-3">
                        <div class="card bg-warning text-white">
                            <div class="card-body text-center">
                                <i class="fas fa-clock fa-2x mb-2"></i>
                                <h4>2</h4>
                                <small>In Corso</small>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 mb-3">
                        <div class="card bg-success text-white">
                            <div class="card-body text-center">
                                <i class="fas fa-check fa-2x mb-2"></i>
                                <h4>15</h4>
                                <small>Risolti</small>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 mb-3">
                        <div class="card bg-info text-white">
                            <div class="card-body text-center">
                                <i class="fas fa-ticket-simple fa-2x mb-2"></i>
                                <h4>18</h4>
                                <small>Totali</small>
                            </div>
                        </div>
                    </div>
                </div>
            `;
        }
        
        $('#dynamic-content-body').html(content);
    }

    function loadContabilitaContent(action = null) {
        let content = '';
        
        if (action === 'movimenti') {
            content = `
                <div class="row mb-3">
                    <div class="col-md-6">
                        <h6 class="text-muted">Movimenti Bancari e Contabili</h6>
                    </div>
                    <div class="col-md-6 text-end">
                        <button type="button" class="btn btn-info btn-sm">
                            <i class="fas fa-plus me-2"></i>Nuovo Movimento
                        </button>
                    </div>
                </div>
                <div class="alert alert-info">
                    <i class="fas fa-calculator me-2"></i>
                    Gestione Movimenti in sviluppo.
                </div>
            `;
        } else if (action === 'bilanci') {
            content = `
                <div class="row mb-3">
                    <div class="col-md-6">
                        <h6 class="text-muted">Bilanci e Consuntivi</h6>
                    </div>
                    <div class="col-md-6 text-end">
                        <button type="button" class="btn btn-info btn-sm">
                            <i class="fas fa-plus me-2"></i>Nuovo Bilancio
                        </button>
                    </div>
                </div>
                <div class="alert alert-info">
                    <i class="fas fa-chart-bar me-2"></i>
                    Gestione Bilanci in sviluppo.
                </div>
            `;
        } else {
            content = `
                <div class="row mb-3">
                    <div class="col-md-6">
                        <h6 class="text-muted">Gestione Contabilità</h6>
                    </div>
                    <div class="col-md-6 text-end">
                        <button type="button" class="btn btn-info btn-sm">
                            <i class="fas fa-plus me-2"></i>Nuovo Bilancio
                        </button>
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-6 mb-3">
                        <div class="card clickable-card" onclick="loadSection('contabilita', 'movimenti')" style="cursor: pointer;">
                            <div class="card-body text-center">
                                <i class="fas fa-exchange-alt fa-3x text-primary mb-3"></i>
                                <h5>Movimenti</h5>
                                <p class="text-muted">Gestione movimenti bancari e contabili</p>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 mb-3">
                        <div class="card clickable-card" onclick="loadSection('contabilita', 'bilanci')" style="cursor: pointer;">
                            <div class="card-body text-center">
                                <i class="fas fa-chart-bar fa-3x text-success mb-3"></i>
                                <h5>Bilanci</h5>
                                <p class="text-muted">Bilanci preventivi e consuntivi</p>
                            </div>
                        </div>
                    </div>
                </div>
            `;
        }
        
        $('#dynamic-content-body').html(content);
    }

    // Funzione per caricare contenuti Varie
    function loadVarieContent(action = null) {
        let content = '';
        
        if (action === 'etichette-faldoni') {
            content = getEtichetteFaldoniContent();
        } else if (action === 'etichette-chiavi') {
            content = getEtichetteChiaviContent();
        } else if (action === 'backup-dati') {
            content = getBackupDatiContent();
        } else if (action === 'utilita-sistema') {
            content = getUtilitaSistemaContent();
        } else {
            // Vista principale delle utilità
            content = `
                <div class="row mb-3">
                    <div class="col-md-6">
                        <h6 class="text-muted">Utilità e Strumenti Amministrativi</h6>
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-md-6 mb-3">
                        <div class="card clickable-card" onclick="loadSection('varie', 'etichette-faldoni')" style="cursor: pointer;">
                            <div class="card-body text-center">
                                <i class="fas fa-tags fa-3x text-primary mb-3"></i>
                                <h5>Etichette Faldoni</h5>
                                <p class="text-muted">Stampa etichette per l'organizzazione dei faldoni</p>
                                <span class="badge bg-primary">Pronto</span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 mb-3">
                        <div class="card clickable-card" onclick="loadSection('varie', 'etichette-chiavi')" style="cursor: pointer;">
                            <div class="card-body text-center">
                                <i class="fas fa-key fa-3x text-warning mb-3"></i>
                                <h5>Etichette Chiavi</h5>
                                <p class="text-muted">Stampa etichette identificative per le chiavi</p>
                                <span class="badge bg-warning">Pronto</span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 mb-3">
                        <div class="card clickable-card" onclick="loadSection('varie', 'backup-dati')" style="cursor: pointer;">
                            <div class="card-body text-center">
                                <i class="fas fa-download fa-3x text-success mb-3"></i>
                                <h5>Backup Dati</h5>
                                <p class="text-muted">Esporta backup completo del database</p>
                                <span class="badge bg-success">Disponibile</span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 mb-3">
                        <div class="card clickable-card" onclick="loadSection('varie', 'utilita-sistema')" style="cursor: pointer;">
                            <div class="card-body text-center">
                                <i class="fas fa-cogs fa-3x text-info mb-3"></i>
                                <h5>Utilità Sistema</h5>
                                <p class="text-muted">Strumenti di manutenzione e diagnostica</p>
                                <span class="badge bg-info">Avanzato</span>
                            </div>
                        </div>
                    </div>
                </div>
            `;
        }
        
        $('#dynamic-content-body').html(content);
    }

    // Helper functions per sezione Varie
    function getEtichetteFaldoniContent() {
        return `
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">
                        <i class="fas fa-tags me-2"></i>Stampa Etichette Faldoni
                    </h5>
                </div>
                <div class="card-body">
                    <div class="alert alert-info">
                        <i class="fas fa-info-circle me-2"></i>
                        Genera e stampa etichette per l'organizzazione dei faldoni amministrativi.
                    </div>
                    
                    <form id="form-etichette-faldoni">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="mb-3">
                                    <label class="form-label">Seleziona Stabile</label>
                                    <select class="form-select" name="stabile_id" required>
                                        <option value="">Seleziona uno stabile...</option>
                                        <!-- Popolato dinamicamente -->
                                    </select>
                                </div>
                                <div class="mb-3">
                                    <label class="form-label">Anno</label>
                                    <input type="number" class="form-control" name="anno" value="${new Date().getFullYear()}" min="2020" max="2030">
                                </div>
                                <div class="mb-3">
                                    <label class="form-label">Tipo Etichetta</label>
                                    <select class="form-select" name="tipo_etichetta">
                                        <option value="standard">Standard (70x35mm)</option>
                                        <option value="grande">Grande (105x70mm)</option>
                                        <option value="piccola">Piccola (50x25mm)</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="mb-3">
                                    <label class="form-label">Categorie da includere</label>
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="categorie[]" value="contabilita" checked>
                                        <label class="form-check-label">Contabilità</label>
                                    </div>
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="categorie[]" value="amministrativo" checked>
                                        <label class="form-check-label">Amministrativo</label>
                                    </div>
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="categorie[]" value="assemblee" checked>
                                        <label class="form-check-label">Assemblee</label>
                                    </div>
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="categorie[]" value="tecnico" checked>
                                        <label class="form-check-label">Tecnico</label>
                                    </div>
                                </div>
                                <div class="mb-3">
                                    <label class="form-label">Formato Output</label>
                                    <select class="form-select" name="formato">
                                        <option value="pdf">PDF (Stampabile)</option>
                                        <option value="word">Word (Modificabile)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        
                        <div class="text-end">
                            <button type="button" class="btn btn-secondary me-2" onclick="loadSection('varie')">Annulla</button>
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-print me-2"></i>Genera Etichette
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        `;
    }

    function getEtichetteChiaviContent() {
        return `
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">
                        <i class="fas fa-key me-2"></i>Stampa Etichette Chiavi
                    </h5>
                </div>
                <div class="card-body">
                    <div class="alert alert-info">
                        <i class="fas fa-info-circle me-2"></i>
                        Genera etichette identificative per le chiavi degli stabili.
                    </div>
                    
                    <form id="form-etichette-chiavi">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="mb-3">
                                    <label class="form-label">Seleziona Stabile</label>
                                    <select class="form-select" name="stabile_id" required>
                                        <option value="">Seleziona uno stabile...</option>
                                        <!-- Popolato dinamicamente -->
                                    </select>
                                </div>
                                <div class="mb-3">
                                    <label class="form-label">Tipo Chiave</label>
                                    <select class="form-select" name="tipo_chiave">
                                        <option value="tutte">Tutte le chiavi</option>
                                        <option value="portone">Solo Portone</option>
                                        <option value="appartamenti">Solo Appartamenti</option>
                                        <option value="locali">Solo Locali/Garage</option>
                                        <option value="servizi">Solo Locali Servizi</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="mb-3">
                                    <label class="form-label">Dimensione Etichetta</label>
                                    <select class="form-select" name="dimensione">
                                        <option value="piccola">Piccola (25x15mm)</option>
                                        <option value="media" selected>Media (35x20mm)</option>
                                        <option value="grande">Grande (50x30mm)</option>
                                    </select>
                                </div>
                                <div class="mb-3">
                                    <label class="form-label">Informazioni da includere</label>
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="info[]" value="codice" checked>
                                        <label class="form-check-label">Codice Chiave</label>
                                    </div>
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="info[]" value="ubicazione" checked>
                                        <label class="form-check-label">Ubicazione</label>
                                    </div>
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="info[]" value="stabile" checked>
                                        <label class="form-check-label">Nome Stabile</label>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="text-end">
                            <button type="button" class="btn btn-secondary me-2" onclick="loadSection('varie')">Annulla</button>
                            <button type="submit" class="btn btn-warning">
                                <i class="fas fa-print me-2"></i>Genera Etichette Chiavi
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        `;
    }

    function getBackupDatiContent() {
        return `
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">
                        <i class="fas fa-download me-2"></i>Backup & Esportazione Dati
                    </h5>
                </div>
                <div class="card-body">
                    <div class="alert alert-warning">
                        <i class="fas fa-exclamation-triangle me-2"></i>
                        <strong>Importante:</strong> Effettua regolarmente backup dei dati per evitare perdite accidentali.
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6 mb-3">
                            <div class="card border-success">
                                <div class="card-body text-center">
                                    <i class="fas fa-database fa-3x text-success mb-3"></i>
                                    <h5>Backup Completo</h5>
                                    <p class="text-muted">Esporta tutti i dati del sistema</p>
                                    <button class="btn btn-success" onclick="startFullBackup()">
                                        <i class="fas fa-download me-2"></i>Avvia Backup
                                    </button>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6 mb-3">
                            <div class="card border-info">
                                <div class="card-body text-center">
                                    <i class="fas fa-building fa-3x text-info mb-3"></i>
                                    <h5>Backup per Stabile</h5>
                                    <p class="text-muted">Esporta dati di un singolo stabile</p>
                                    <select class="form-select mb-3" id="stabile-backup">
                                        <option value="">Seleziona stabile...</option>
                                    </select>
                                    <button class="btn btn-info" onclick="startStabileBackup()">
                                        <i class="fas fa-download me-2"></i>Backup Stabile
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <hr>
                    
                    <h6 class="mb-3">Ultimi Backup Effettuati</h6>
                    <div class="table-responsive">
                        <table class="table table-sm">
                            <thead>
                                <tr>
                                    <th>Data</th>
                                    <th>Tipo</th>
                                    <th>Dimensione</th>
                                    <th>Azioni</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td colspan="4" class="text-center text-muted">
                                        <em>Nessun backup precedente</em>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        `;
    }

    function getUtilitaSistemaContent() {
        return `
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">
                        <i class="fas fa-cogs me-2"></i>Utilità Sistema
                    </h5>
                </div>
                <div class="card-body">
                    <div class="alert alert-danger">
                        <i class="fas fa-exclamation-triangle me-2"></i>
                        <strong>Attenzione:</strong> Queste funzioni sono per utenti avanzati. Usare con cautela.
                    </div>
                    
                    <div class="row">
                        <div class="col-md-4 mb-3">
                            <div class="card border-warning">
                                <div class="card-body text-center">
                                    <i class="fas fa-broom fa-2x text-warning mb-2"></i>
                                    <h6>Pulizia Cache</h6>
                                    <button class="btn btn-warning btn-sm" onclick="clearSystemCache()">
                                        Pulisci Cache
                                    </button>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4 mb-3">
                            <div class="card border-info">
                                <div class="card-body text-center">
                                    <i class="fas fa-chart-line fa-2x text-info mb-2"></i>
                                    <h6>Statistiche DB</h6>
                                    <button class="btn btn-info btn-sm" onclick="showDbStats()">
                                        Visualizza Stats
                                    </button>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4 mb-3">
                            <div class="card border-secondary">
                                <div class="card-body text-center">
                                    <i class="fas fa-file-alt fa-2x text-secondary mb-2"></i>
                                    <h6>Log Sistema</h6>
                                    <button class="btn btn-secondary btn-sm" onclick="viewSystemLogs()">
                                        Visualizza Log
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <hr>
                    
                    <h6 class="mb-3">Informazioni Sistema</h6>
                    <div class="row">
                        <div class="col-md-6">
                            <table class="table table-sm">
                                <tr><td><strong>Versione NetGesCon:</strong></td><td>2.0.0</td></tr>
                                <tr><td><strong>Laravel:</strong></td><td>{{ app()->version() }}</td></tr>
                                <tr><td><strong>PHP:</strong></td><td>{{ PHP_VERSION }}</td></tr>
                            </table>
                        </div>
                        <div class="col-md-6">
                            <table class="table table-sm">
                                <tr><td><strong>Database:</strong></td><td>MySQL</td></tr>
                                <tr><td><strong>Spazio Disco:</strong></td><td id="disk-space">Caricamento...</td></tr>
                                <tr><td><strong>Ultimo Backup:</strong></td><td id="last-backup">Mai</td></tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        `;
    }

    // === FUNZIONI GESTIONE DOCUMENTALE ===
    
    function getDocumentiIndexContent() {
        return `
            <div class="row">
                <div class="col-md-4 mb-3">
                    <div class="card h-100">
                        <div class="card-body text-center">
                            <i class="fas fa-stamp fa-3x text-primary mb-3"></i>
                            <h5>Protocollo Generale</h5>
                            <p class="text-muted">Gestione protocollo unico e doppio per documenti stabili e gestionali</p>
                            <button class="btn btn-primary" onclick="loadDashboardSection('documenti', 'protocollo')">
                                Accedi
                            </button>
                        </div>
                    </div>
                </div>
                <div class="col-md-4 mb-3">
                    <div class="card h-100">
                        <div class="card-body text-center">
                            <i class="fas fa-building fa-3x text-success mb-3"></i>
                            <h5>Archivio Stabili</h5>
                            <p class="text-muted">Documenti specifici di ogni stabile (libretti impianti, planimetrie, mappe)</p>
                            <button class="btn btn-success" onclick="loadDashboardSection('documenti', 'archivio-stabili')">
                                Accedi
                            </button>
                        </div>
                    </div>
                </div>
                <div class="col-md-4 mb-3">
                    <div class="card h-100">
                        <div class="card-body text-center">
                            <i class="fas fa-folder-open fa-3x text-warning mb-3"></i>
                            <h5>Archivio Gestionale</h5>
                            <p class="text-muted">Documenti amministrativi, fatture, bollette, contratti fornitori</p>
                            <button class="btn btn-warning" onclick="loadDashboardSection('documenti', 'archivio-gestionale')">
                                Accedi
                            </button>
                        </div>
                    </div>
                </div>
                <div class="col-md-4 mb-3">
                    <div class="card h-100">
                        <div class="card-body text-center">
                            <i class="fas fa-barcode fa-3x text-info mb-3"></i>
                            <h5>Etichette & Barcode</h5>
                            <p class="text-muted">Stampa etichette con codici a barre per localizzazione documenti cartacei</p>
                            <button class="btn btn-info" onclick="loadDashboardSection('documenti', 'etichette-barcode')">
                                Accedi
                            </button>
                        </div>
                    </div>
                </div>
                <div class="col-md-4 mb-3">
                    <div class="card h-100">
                        <div class="card-body text-center">
                            <i class="fas fa-shield-alt fa-3x text-danger mb-3"></i>
                            <h5>Controllo Integrità</h5>
                            <p class="text-muted">Verifica hash e integrità documenti digitali contro modifiche</p>
                            <button class="btn btn-danger" onclick="loadDashboardSection('documenti', 'controllo-integrita')">
                                Accedi
                            </button>
                        </div>
                    </div>
                </div>
                <div class="col-md-4 mb-3">
                    <div class="card h-100">
                        <div class="card-body text-center">
                            <i class="fas fa-search fa-3x text-secondary mb-3"></i>
                            <h5>Ricerca Avanzata</h5>
                            <p class="text-muted">Ricerca cross-archivio con filtri multipli e collegamenti</p>
                            <button class="btn btn-secondary" onclick="loadDashboardSection('documenti', 'ricerca-avanzata')">
                                Accedi
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        `;
    }
    
    function getProtocolloContent() {
        return `
            <div class="alert alert-info">
                <i class="fas fa-stamp me-2"></i>
                <strong>Protocollo Generale:</strong> Sistema di protocollazione unificato per tutti i documenti del sistema.
                Gestisce sia il protocollo per documenti specifici degli stabili che per documenti gestionali generali.
            </div>
            <div class="row">
                <div class="col-md-6">
                    <div class="card">
                        <div class="card-header">
                            <h6 class="mb-0">Protocollo Documenti Stabili</h6>
                        </div>
                        <div class="card-body">
                            <p>Protocollo dedicato per:</p>
                            <ul>
                                <li>Libretti d'impianto</li>
                                <li>Mappe costruttive</li>
                                <li>Planimetrie</li>
                                <li>Contratti con fornitori</li>
                                <li>Documentazione tecnica</li>
                            </ul>
                            <button class="btn btn-primary btn-sm">Nuovo Protocollo Stabile</button>
                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="card">
                        <div class="card-header">
                            <h6 class="mb-0">Protocollo Gestionale</h6>
                        </div>
                        <div class="card-body">
                            <p>Protocollo dedicato per:</p>
                            <ul>
                                <li>Libro verbali assemblee</li>
                                <li>Fatture fornitori</li>
                                <li>Bollette ACEA/energia</li>
                                <li>Corrispondenza amministrativa</li>
                                <li>Documenti legali</li>
                            </ul>
                            <button class="btn btn-success btn-sm">Nuovo Protocollo Gestionale</button>
                        </div>
                    </div>
                </div>
            </div>
        `;
    }
    
    function getArchivioStabiliContent() {
        return `
            <div class="alert alert-primary">
                <i class="fas fa-building me-2"></i>
                <strong>Archivio Documenti Stabili:</strong> Documenti specifici di ogni condominio con spazio dedicato nello studio dell'amministratore.
            </div>
            <div class="card">
                <div class="card-body">
                    <p><strong>Funzionalità in sviluppo:</strong></p>
                    <ul>
                        <li>Archiviazione libretti d'impianto per ogni stabile</li>
                        <li>Gestione mappe costruttive e planimetrie</li>
                        <li>Contratti con fornitori specifici dello stabile</li>
                        <li>Localizzazione fisica dei documenti cartacei</li>
                        <li>Etichette con codice a barre per identificazione</li>
                    </ul>
                </div>
            </div>
        `;
    }
    
    function getArchivioGestionaleContent() {
        return `
            <div class="alert alert-warning">
                <i class="fas fa-folder-open me-2"></i>
                <strong>Archivio Gestionale:</strong> Documenti amministrativi e di gestione generale.
            </div>
            <div class="card">
                <div class="card-body">
                    <p><strong>Funzionalità in sviluppo:</strong></p>
                    <ul>
                        <li>Libro verbali assemblee condominiali</li>
                        <li>Fatture fornitori e prestatori d'opera</li>
                        <li>Bollette ACEA, energia elettrica, gas</li>
                        <li>Corrispondenza con enti e condomini</li>
                        <li>Documenti fiscali e contabili</li>
                        <li>Contratti generali di servizio</li>
                    </ul>
                </div>
            </div>
        `;
    }
    
    function getEtichetteContent() {
        return `
            <div class="alert alert-info">
                <i class="fas fa-barcode me-2"></i>
                <strong>Etichette & Barcode:</strong> Sistema di etichettatura per localizzazione fisica dei documenti cartacei.
            </div>
            <div class="card">
                <div class="card-body">
                    <p><strong>Funzionalità in sviluppo:</strong></p>
                    <ul>
                        <li>Generazione codici a barre univoci per ogni documento</li>
                        <li>Stampa etichette con QR code e informazioni documento</li>
                        <li>Indicazione numero pagine per controllo completezza</li>
                        <li>Localizzazione fisica nel sistema di archiviazione</li>
                        <li>Collegamento tra documento digitale e cartaceo</li>
                    </ul>
                    <button class="btn btn-info">Stampa Etichetta</button>
                    <button class="btn btn-secondary ms-2">Scansiona Barcode</button>
                </div>
            </div>
        `;
    }
    
    function getControlloIntegritaContent() {
        return `
            <div class="alert alert-danger">
                <i class="fas fa-shield-alt me-2"></i>
                <strong>Controllo Integrità:</strong> Protezione contro modifiche non autorizzate dei documenti digitali.
            </div>
            <div class="card">
                <div class="card-body">
                    <p><strong>Funzionalità in sviluppo:</strong></p>
                    <ul>
                        <li>Calcolo hash MD5/SHA256 all'importazione</li>
                        <li>Verifica periodica integrità documenti</li>
                        <li>Rilevamento "topi digitali" (corruzioni file)</li>
                        <li>Firma digitale documenti critici</li>
                        <li>Log modifiche e accessi</li>
                        <li>Backup automatico con verifica integrità</li>
                    </ul>
                    <button class="btn btn-danger">Verifica Integrità</button>
                    <button class="btn btn-warning ms-2">Report Anomalie</button>
                </div>
            </div>
        `;
    }
    
    function getRicercaAvanzataContent() {
        return `
            <div class="alert alert-secondary">
                <i class="fas fa-search me-2"></i>
                <strong>Ricerca Avanzata:</strong> Ricerca cross-archivio con navigazione tra entità collegate.
            </div>
            <div class="card">
                <div class="card-body">
                    <p><strong>Funzionalità in sviluppo:</strong></p>
                    <ul>
                        <li>Ricerca unificata in tutti gli archivi</li>
                        <li>Filtri per tipo documento, data, stabile, fornitore</li>
                        <li>Navigazione tra documenti collegati (assemblea → verbale → ticket → preventivo → pagamento)</li>
                        <li>Ricerca per contenuto con OCR</li>
                        <li>Timeline documenti per pratica</li>
                        <li>Export risultati ricerca</li>
                    </ul>
                    <div class="row">
                        <div class="col-md-8">
                            <input type="text" class="form-control" placeholder="Inserisci termini di ricerca...">
                        </div>
                        <div class="col-md-4">
                            <button class="btn btn-secondary w-100">Ricerca Avanzata</button>
                        </div>
                    </div>
                </div>
            </div>
        `;
    }
    
}); // Chiusura $(document).ready

</script>

@endpush

</x-layout.universal>