{{-- Sidebar moderna professionale --}}
<nav class="h-full flex flex-col bg-gray-800 dark:bg-gray-900 py-6 px-3 w-full shadow-xl z-50">
    @php
        $userRoles = auth()->check() ? auth()->user()->getRoleNames()->toArray() : [];
        $panelPrefix = '';
        if (in_array('super-admin', $userRoles)) {
            $panelPrefix = 'superadmin.';
        } elseif (in_array('admin', $userRoles) || in_array('amministratore', $userRoles)) {
            $panelPrefix = 'admin.';
        }
    @endphp
    
    <!-- Header della sidebar -->
    <div class="mb-8">
        <h2 class="text-white text-lg font-semibold">NetGescon</h2>
        <p class="text-gray-400 text-sm">Gestionale Condomini</p>
    </div>
    
    <!-- Menu principale -->
    <div class="flex-1 space-y-2">
        <!-- Dashboard -->
        <a href="{{ route('admin.dashboard') }}" 
           class="flex items-center px-4 py-3 text-gray-300 hover:bg-gray-700 hover:text-white rounded-lg transition-colors duration-200 {{ request()->routeIs('admin.dashboard') ? 'bg-blue-600 text-white' : '' }}">
            <i class="fas fa-tachometer-alt w-5 h-5 mr-3"></i>
            <span>Dashboard</span>
        </a>
        
        <!-- Stabili -->
        <a href="{{ route('admin.stabili.index') }}" 
           class="flex items-center px-4 py-3 text-gray-300 hover:bg-gray-700 hover:text-white rounded-lg transition-colors duration-200 {{ request()->routeIs('admin.stabili.*') ? 'bg-blue-600 text-white' : '' }}">
            <i class="fas fa-building w-5 h-5 mr-3"></i>
            <span>Stabili</span>
        </a>
        
        <!-- Unità Immobiliari -->
        <a href="#" 
           class="flex items-center px-4 py-3 text-gray-300 hover:bg-gray-700 hover:text-white rounded-lg transition-colors duration-200">
            <i class="fas fa-home w-5 h-5 mr-3"></i>
            <span>Unità Immobiliari</span>
        </a>
        
        <!-- Anagrafica -->
        <div class="space-y-1">
            <button class="w-full flex items-center px-4 py-3 text-gray-300 hover:bg-gray-700 hover:text-white rounded-lg transition-colors duration-200" 
                    onclick="toggleSubmenu('anagrafica')">
                <i class="fas fa-users w-5 h-5 mr-3"></i>
                <span>Anagrafica</span>
                <i class="fas fa-chevron-down w-4 h-4 ml-auto transition-transform duration-200" id="anagrafica-chevron"></i>
            </button>
            <div id="anagrafica-submenu" class="hidden pl-6 space-y-1">
                <a href="#" class="block px-4 py-2 text-gray-400 hover:text-white text-sm">Soggetti</a>
                <a href="#" class="block px-4 py-2 text-gray-400 hover:text-white text-sm">Fornitori</a>
                <a href="#" class="block px-4 py-2 text-gray-400 hover:text-white text-sm">Contatti</a>
            </div>
        </div>
        
        <!-- Contabilità -->
        <div class="space-y-1">
            <button class="w-full flex items-center px-4 py-3 text-gray-300 hover:bg-gray-700 hover:text-white rounded-lg transition-colors duration-200" 
                    onclick="toggleSubmenu('contabilita')">
                <i class="fas fa-calculator w-5 h-5 mr-3"></i>
                <span>Contabilità</span>
                <i class="fas fa-chevron-down w-4 h-4 ml-auto transition-transform duration-200" id="contabilita-chevron"></i>
            </button>
            <div id="contabilita-submenu" class="hidden pl-6 space-y-1">
                <a href="#" class="block px-4 py-2 text-gray-400 hover:text-white text-sm">Movimenti</a>
                <a href="#" class="block px-4 py-2 text-gray-400 hover:text-white text-sm">Preventivi</a>
                <a href="#" class="block px-4 py-2 text-gray-400 hover:text-white text-sm">Bilanci</a>
            </div>
        </div>
        
        <!-- Documenti -->
        <a href="#" 
           class="flex items-center px-4 py-3 text-gray-300 hover:bg-gray-700 hover:text-white rounded-lg transition-colors duration-200">
            <i class="fas fa-file-alt w-5 h-5 mr-3"></i>
            <span>Documenti</span>
        </a>
        
        <!-- Tickets -->
        <a href="#" 
           class="flex items-center px-4 py-3 text-gray-300 hover:bg-gray-700 hover:text-white rounded-lg transition-colors duration-200">
            <i class="fas fa-ticket-alt w-5 h-5 mr-3"></i>
            <span>Tickets</span>
        </a>
    </div>
    
    <!-- Footer sidebar -->
    <div class="pt-6 border-t border-gray-700">
        <div class="flex items-center px-4 py-2">
            <div class="flex-shrink-0">
                <div class="w-8 h-8 bg-blue-500 rounded-full flex items-center justify-center">
                    <span class="text-white text-sm font-medium">
                        {{ auth()->user() ? substr(auth()->user()->name, 0, 2) : 'U' }}
                    </span>
                </div>
            </div>
            <div class="ml-3">
                <p class="text-sm font-medium text-white">{{ auth()->user()->name ?? 'Utente' }}</p>
                <p class="text-xs text-gray-400">{{ auth()->user()->email ?? '' }}</p>
            </div>
        </div>
        
        <div class="mt-3 space-y-1">
            <a href="#" class="flex items-center px-4 py-2 text-gray-400 hover:text-white text-sm">
                <i class="fas fa-cog w-4 h-4 mr-3"></i>
                Impostazioni
            </a>
            <form method="POST" action="{{ route('logout') }}">
                @csrf
                <button type="submit" class="w-full flex items-center px-4 py-2 text-gray-400 hover:text-white text-sm">
                    <i class="fas fa-sign-out-alt w-4 h-4 mr-3"></i>
                    Logout
                </button>
            </form>
        </div>
    </div>
</nav>

<script>
function toggleSubmenu(menuId) {
    const submenu = document.getElementById(menuId + '-submenu');
    const chevron = document.getElementById(menuId + '-chevron');
    
    if (submenu.classList.contains('hidden')) {
        submenu.classList.remove('hidden');
        chevron.style.transform = 'rotate(180deg)';
    } else {
        submenu.classList.add('hidden');
        chevron.style.transform = 'rotate(0deg)';
    }
}
</script>
