
<?php
    use App\Helpers\MenuHelper;
    $user = auth()->user();
    $menus = MenuHelper::getMenusUsuario($user);

    // Obtener iniciales del nombre
    $initials = '';
    $nameParts = explode(' ', $user->name);
    if (count($nameParts) >= 2) {
        $initials = strtoupper(substr($nameParts[0], 0, 1) . substr($nameParts[1], 0, 1));
    } else {
        $initials = strtoupper(substr($user->name, 0, 2));
    }

    // Obtener perfil (desde usuario vinculado o directo)
    $perfilNombre = 'Sin perfil';
    if ($user->esInterno() && $user->usuario && $user->usuario->perfil) {
        $perfilNombre = $user->usuario->perfil->per_nombre;
    } elseif ($user->perfil) {
        $perfilNombre = $user->perfil->per_nombre;
    }
?>

<aside class="main-sidebar" id="mainSidebar">
    
    <div class="sidebar-brand">
        <img src="<?php echo e(asset('assets/img/logo-siryc-white.png')); ?>" alt="SIRYC" class="logo-full" onerror="this.style.display='none'">
        <img src="<?php echo e(asset('assets/img/logo_miniatura.png')); ?>" alt="SIRYC" class="logo-mini" onerror="this.src='<?php echo e(asset('assets/img/logo-siryc-white.png')); ?>'">
        <span class="brand-text">SIRYC</span>
    </div>

    
    <nav class="sidebar-nav-container">
        <ul class="sidebar-nav">
            
            <li class="nav-item">
                <a href="<?php echo e(route('dashboard')); ?>" class="nav-link <?php echo e(request()->routeIs('dashboard') ? 'active' : ''); ?>">
                    <i class="fas fa-tachometer-alt"></i>
                    <span>Dashboard</span>
                </a>
                <div class="nav-tooltip">Dashboard</div>
            </li>

            
            <?php $__currentLoopData = $menus; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $seccion => $config): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <li class="nav-section"><?php echo e($config['titulo']); ?></li>

                <?php $__currentLoopData = $config['items']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <li class="nav-item">
                        <a href="<?php echo e(route($item['ruta'])); ?>"
                           class="nav-link <?php echo e(request()->routeIs(str_replace('.index', '.*', $item['ruta'])) ? 'active' : ''); ?>">
                            <i class="fas <?php echo e($item['icono']); ?>"></i>
                            <span><?php echo e($item['nombre']); ?></span>
                            <?php if(isset($item['badge_count']) && $item['badge_count'] > 0): ?>
                                <span class="badge <?php echo e($item['badge']['clase']); ?>"><?php echo e($item['badge_count']); ?></span>
                            <?php endif; ?>
                        </a>
                        <div class="nav-tooltip"><?php echo e($item['nombre']); ?></div>
                    </li>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </ul>
    </nav>

    
    <div class="user-panel">
        <div class="user-avatar">
            <?php echo e($initials); ?>

        </div>
        <div class="user-info">
            <div class="user-name"><?php echo e($user->name); ?></div>
            <div class="user-role"><?php echo e($perfilNombre); ?></div>
        </div>
    </div>
</aside>
<?php /**PATH /var/www/tecnicos/sistema_mantenimiento/resources/views/layouts/partials/sidebar.blade.php ENDPATH**/ ?>