{{-- Menu Stabili con route reali e contatori --}}
@php
    $stats = App\Helpers\SidebarStatsHelper::getStats();
    $stabiliStats = $stats['stabili'] ?? ['totale' => 0, 'attivi' => 0, 'unita_libere' => 0];
@endphp

<li class="nav-item mb-1">
    <a class="nav-link d-flex align-items-center justify-content-between text-dark {{ request()->routeIs('admin.stabili.*') ? 'active bg-warning text-dark fw-bold' : '' }}" 
       data-bs-toggle="collapse" href="#stabiliMenu" role="button"
       aria-expanded="{{ request()->routeIs('admin.stabili.*') ? 'true' : 'false' }}"
       aria-controls="stabiliMenu">
        <div class="d-flex align-items-center">
            <i class="fas fa-building me-2"></i>
            <span>Stabili</span>
            {!! App\Helpers\SidebarStatsHelper::getBadge($stabiliStats['totale'], 'info') !!}
        </div>
        <i class="fas fa-chevron-down"></i>
    </a>
    <div class="collapse {{ request()->routeIs('admin.stabili.*') ? 'show' : '' }}" id="stabiliMenu">
        <ul class="nav nav-pills flex-column ms-3">
            <li class="nav-item">
                <a class="nav-link text-dark {{ request()->routeIs('admin.stabili.index') ? 'active bg-light' : '' }}" 
                   href="{{ route('admin.stabili.index') }}">
                    <i class="fas fa-list me-2"></i>Elenco Stabili
                    {!! App\Helpers\SidebarStatsHelper::getBadge($stabiliStats['attivi'], 'success') !!}
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link text-dark {{ request()->routeIs('admin.stabili.create') ? 'active bg-light' : '' }}" 
                   href="{{ route('admin.stabili.create') }}">
                    <i class="fas fa-plus me-2"></i>Nuovo Stabile
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link text-dark {{ request()->routeIs('admin.stabili.unitaImmobiliari.*') ? 'active bg-light' : '' }}" 
                   href="{{ route('admin.stabili.index') }}">
                    <i class="fas fa-home me-2"></i>Unità Immobiliari
                    @if($stabiliStats['unita_libere'] > 0)
                        {!! App\Helpers\SidebarStatsHelper::getBadge($stabiliStats['unita_libere'], 'warning') !!}
                        <small class="text-muted">libere</small>
                    @endif
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link text-dark {{ request()->routeIs('admin.tabelle-millesimali.*') ? 'active bg-light' : '' }}" 
                   href="{{ route('admin.tabelle-millesimali.index') }}">
                    <i class="fas fa-percentage me-2"></i>Tabelle Millesimi
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link text-dark {{ request()->routeIs('admin.anagrafica-condominiale.*') ? 'active bg-light' : '' }}" 
                   href="{{ route('admin.anagrafica-condominiale.index') }}">
                    <i class="fas fa-id-card me-2"></i>Anagrafica Condominiale
                </a>
            </li>
        </ul>
    </div>
</li>
