<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
        Gestión de Usuarios
     <?php $__env->endSlot(); ?>

    <!-- Content -->
    <div class="bg-white shadow-lg rounded-sm border border-slate-200">
        <header
            class="px-5 py-4 flex flex-col sm:flex-row justify-between items-center border-b border-slate-100 gap-4">
            <h2 class="font-semibold text-slate-800">Cuentas de Usuario <span
                    class="text-slate-400 font-medium">(<?php echo e($users->total()); ?>)</span></h2>

            <div class="flex items-center gap-3">
                <form method="GET" action="<?php echo e(route('admin.users.index')); ?>" class="relative w-full sm:w-auto">
                    <label for="action-search" class="sr-only">Search</label>
                    <input id="action-search" name="search"
                        class="form-input pl-9 pr-4 py-2 w-full focus:border-green-300" type="search"
                        placeholder="Buscar por cédula o nombre…" value="<?php echo e(request('search')); ?>" />
                    <button class="absolute inset-0 right-auto group" type="submit" aria-label="Search">
                        <svg class="w-4 h-4 shrink-0 fill-current text-slate-400 group-hover:text-green-500 ml-3 mr-2"
                            viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
                            <path
                                d="M7 14c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7zM7 2C4.243 2 2 4.243 2 7s2.243 5 5 5 5-2.243 5-5-2.243-5-5-5z" />
                            <path
                                d="M15.707 14.293L13.314 11.9a8.019 8.019 0 01-1.414 1.414l2.393 2.393a.997.997 0 001.414 0 .999.999 0 000-1.414z" />
                        </svg>
                    </button>
                </form>

                <a href="<?php echo e(route('admin.users.create')); ?>"
                    class="btn bg-green-600 hover:bg-green-700 text-white rounded-md px-3 py-2 flex items-center shadow-sm text-sm whitespace-nowrap">
                    <svg class="w-4 h-4 fill-current opacity-50 shrink-0" viewBox="0 0 16 16">
                        <path
                            d="M15 7H9V1c0-.6-.4-1-1-1S7 .4 7 1v6H1c-.6 0-1 .4-1 1s.4 1 1 1h6v6c0 .6.4 1 1 1s1-.4 1-1V9h6c.6 0 1-.4 1-1s-.4-1-1-1z" />
                    </svg>
                    <span class="ml-2">Nuevo Usuario</span>
                </a>
            </div>
        </header>

        <div class="p-3">
            <?php if(session('success')): ?>
                <div x-data="{ show: true }" x-show="show"
                    class="mb-4 p-4 bg-emerald-50 border border-emerald-200 text-emerald-600 rounded flex justify-between">
                    <span><?php echo e(session('success')); ?></span>
                    <button @click="show = false" class="text-emerald-500 hover:text-emerald-700">&times;</button>
                </div>
            <?php endif; ?>
            <?php if(session('error')): ?>
                <div x-data="{ show: true }" x-show="show"
                    class="mb-4 p-4 bg-rose-50 border border-rose-200 text-rose-600 rounded flex justify-between">
                    <span><?php echo e(session('error')); ?></span>
                    <button @click="show = false" class="text-rose-500">&times;</button>
                </div>
            <?php endif; ?>

            <div class="overflow-x-auto">
                <table class="table-auto w-full">
                    <thead
                        class="text-xs font-semibold uppercase text-slate-500 bg-slate-50 border-t border-b border-slate-200">
                        <tr>
                            <th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                <div class="font-semibold text-left">Cédula / Usuario</div>
                            </th>
                            <th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                <div class="font-semibold text-left">Nombre Completo</div>
                            </th>
                            <th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                <div class="font-semibold text-left">Email</div>
                            </th>
                            <th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                <div class="font-semibold text-left">Cargo (Rol)</div>
                            </th>
                            <th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                <div class="font-semibold text-left">Área Operativa / Gerencia</div>
                            </th>
                            <th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                <div class="font-semibold text-center">Acciones</div>
                            </th>
                        </tr>
                    </thead>
                    <tbody class="text-sm divide-y divide-slate-200">
                        <?php $__empty_1 = true; $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                    <div class="font-medium text-sky-500"><?php echo e($u->cedula); ?></div>
                                    <div class="text-xs text-slate-400">@ <?php echo e($u->username); ?></div>
                                </td>
                                <td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                    <div class="font-medium text-slate-800"><?php echo e($u->name); ?> <?php echo e($u->apellido); ?></div>
                                </td>
                                <td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                    <div class="<?php echo e($u->email ? 'text-slate-500' : 'text-rose-400 italic text-xs'); ?>">
                                        <?php echo e($u->email ?? 'Correo no asignado'); ?>

                                    </div>
                                </td>
                                <td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                    <?php if($u->canManageTickets()): ?>
                                        <div
                                            class="inline-flex font-medium rounded-full text-center px-2.5 py-0.5 bg-indigo-100 text-indigo-600">
                                            <?php echo e($u->cargo); ?></div>
                                    <?php else: ?>
                                        <div
                                            class="inline-flex font-medium rounded-full text-center px-2.5 py-0.5 bg-slate-100 text-slate-600">
                                            <?php echo e($u->cargo); ?></div>
                                    <?php endif; ?>
                                </td>
                                <td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                    <?php if($u->departamento_id): ?>
                                        <div class="text-slate-800 font-medium"><?php echo e(optional($u->departamento)->nombre); ?></div>
                                        <div class="text-slate-500 text-xs"><?php echo e(optional(optional($u->departamento)->gerencia)->nombre ?? '—'); ?> (Gerencia)</div>
                                    <?php elseif($u->gerencia_id): ?>
                                        <div class="text-slate-700"><?php echo e(optional($u->gerenciaRel)->nombre ?? '—'); ?></div>
                                    <?php else: ?>
                                        <div class="text-slate-400 text-xs italic">No asignada</div>
                                    <?php endif; ?>
                                </td>
                                <td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
                                    <div class="flex justify-center space-x-2">
                                        <a href="<?php echo e(route('admin.users.edit', $u->id)); ?>"
                                            class="text-slate-400 hover:text-slate-500 rounded-full" title="Editar">
                                            <span class="sr-only">Editar</span>
                                            <svg class="w-8 h-8 fill-current" viewBox="0 0 32 32">
                                                <path
                                                    d="M19.7 8.3c-.4-.4-1-.4-1.4 0l-10 10c-.2.2-.3.4-.3.7v4c0 .6.4 1 1 1h4c.3 0 .5-.1.7-.3l10-10c.4-.4.4-1 0-1.4l-4-4zM12.6 22H10v-2.6l6-6 2.6 2.6-6 6zm7.4-7.4L17.4 12l1.6-1.6 2.6 2.6-1.6 1.6z" />
                                            </svg>
                                        </a>
                                        <form action="<?php echo e(route('admin.users.destroy', $u->id)); ?>" method="POST"
                                            class="inline-block"
                                            onsubmit="return confirm('¿Confirma que desea eliminar este usuario?');">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="text-rose-500 hover:text-rose-600 rounded-full"
                                                title="Eliminar">
                                                <span class="sr-only">Eliminar</span>
                                                <svg class="w-8 h-8 fill-current" viewBox="0 0 32 32">
                                                    <path d="M13 15h2v6h-2zM17 15h2v6h-2z" />
                                                    <path
                                                        d="M20 9c0-.6-.4-1-1-1h-6c-.6 0-1 .4-1 1v2H8v2h1v10c0 .6.4 1 1 1h12c.6 0 1-.4 1-1V13h1v-2h-4V9zm-6 1h4v1h-4v-1zm7 3v9H11v-9h10z" />
                                                </svg>
                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="6"
                                    class="px-2 first:pl-5 last:pr-5 py-5 whitespace-nowrap text-center text-slate-500 italic">
                                    No hay usuarios registrados o que coincidan con la búsqueda.
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>

            <div class="mt-4">
                <?php echo e($users->appends(request()->query())->links()); ?>

            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?><?php /**PATH C:\xampp82\htdocs\siser\siser_v2\resources\views/admin/users/index.blade.php ENDPATH**/ ?>