<?php $__env->startSection('title', 'Alumnos'); ?>
<?php $__env->startSection('page-title', 'Gestión de Alumnos'); ?>

<?php $__env->startSection('content'); ?>

<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;">
    <div>
        <p style="color:var(--muted);font-size:13px;">Total: <strong><?php echo e($alumnos->total()); ?></strong> alumnos encontrados</p>
    </div>
    <a href="<?php echo e(route('alumnos.create')); ?>" class="btn btn-primary">
        <i class="fas fa-plus"></i> Nuevo Alumno
    </a>
</div>


<div class="card" style="margin-bottom:20px;">
    <div class="card-body" style="padding:16px 22px;">
        <form method="GET" style="display:flex;gap:12px;align-items:flex-end;flex-wrap:wrap;">
            <div style="flex:1;min-width:200px;">
                <label class="form-label" style="margin-bottom:4px;">Buscar</label>
                <div style="position:relative;">
                    <i class="fas fa-search" style="position:absolute;left:11px;top:50%;transform:translateY(-50%);color:var(--muted);"></i>
                    <input type="text" name="buscar" class="form-control" style="padding-left:34px;"
                        placeholder="Nombre, apellido o DNI..." value="<?php echo e(request('buscar')); ?>">
                </div>
            </div>
            <div style="min-width:160px;">
                <label class="form-label" style="margin-bottom:4px;">Estado</label>
                <select name="estado" class="form-control">
                    <option value="">Todos</option>
                    <option value="activo"     <?php echo e(request('estado')=='activo'     ? 'selected':''); ?>>Activo</option>
                    <option value="inactivo"   <?php echo e(request('estado')=='inactivo'   ? 'selected':''); ?>>Inactivo</option>
                    <option value="trasladado" <?php echo e(request('estado')=='trasladado' ? 'selected':''); ?>>Trasladado</option>
                    <option value="egresado"   <?php echo e(request('estado')=='egresado'   ? 'selected':''); ?>>Egresado</option>
                </select>
            </div>
            <div style="display:flex;gap:8px;">
                <button type="submit" class="btn btn-primary">
                    <i class="fas fa-filter"></i> Filtrar
                </button>
                <a href="<?php echo e(route('alumnos.index')); ?>" class="btn btn-secondary">
                    <i class="fas fa-times"></i>
                </a>
            </div>
        </form>
    </div>
</div>


<div class="card">
    <div class="table-wrapper">
        <table>
            <thead>
                <tr>
                    <th>Código</th>
                    <th>Alumno</th>
                    <th>DNI</th>
                    <th>Grado / Sección</th>
                    <th>Apoderado</th>
                    <th>Estado</th>
                    <th style="text-align:center;">Acciones</th>
                </tr>
            </thead>
            <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $alumnos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $alumno): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <?php $matricula = $alumno->matriculaActiva(); ?>
                <tr>
                    <td>
                        <span style="font-family:monospace;font-size:12px;background:#f1f5f9;padding:3px 8px;border-radius:6px;">
                            <?php echo e($alumno->codigo); ?>

                        </span>
                    </td>
                    <td>
                        <div style="display:flex;align-items:center;gap:10px;">
                            <div style="width:34px;height:34px;border-radius:10px;background:linear-gradient(135deg,#1e3a8a,#3b82f6);display:flex;align-items:center;justify-content:center;color:white;font-weight:700;font-size:13px;flex-shrink:0;">
                                <?php echo e(strtoupper(substr($alumno->nombres,0,1))); ?><?php echo e(strtoupper(substr($alumno->apellidos,0,1))); ?>

                            </div>
                            <div>
                                <div style="font-weight:600;"><?php echo e($alumno->nombre_completo); ?></div>
                                <div style="font-size:11px;color:var(--muted);"><?php echo e($alumno->genero === 'M' ? 'Masculino' : 'Femenino'); ?></div>
                            </div>
                        </div>
                    </td>
                    <td style="font-family:monospace;"><?php echo e($alumno->dni); ?></td>
                    <td>
                        <?php if($matricula): ?>
                            <span style="font-size:13px;"><?php echo e($matricula->grado->nombre ?? '—'); ?></span>
                            <span style="font-size:11px;color:var(--muted);"> / Sec. <?php echo e($matricula->seccion->nombre ?? '—'); ?></span>
                        <?php else: ?>
                            <span style="color:var(--muted);font-size:12px;">Sin matrícula</span>
                        <?php endif; ?>
                    </td>
                    <td>
                        <div style="font-size:13px;"><?php echo e($alumno->apoderado_nombre ?? '—'); ?></div>
                        <div style="font-size:11px;color:var(--muted);"><?php echo e($alumno->apoderado_telefono ?? ''); ?></div>
                    </td>
                    <td>
                        <?php
                            $estadoClass = match($alumno->estado) {
                                'activo'     => 'badge-success',
                                'inactivo'   => 'badge-secondary',
                                'trasladado' => 'badge-warning',
                                'egresado'   => 'badge-info',
                                default      => 'badge-secondary'
                            };
                        ?>
                        <span class="badge <?php echo e($estadoClass); ?>"><?php echo e(ucfirst($alumno->estado)); ?></span>
                    </td>
                    <td>
                        <div style="display:flex;gap:6px;justify-content:center;">
                            <a href="<?php echo e(route('alumnos.show', $alumno)); ?>" class="btn btn-sm btn-secondary btn-icon" title="Ver">
                                <i class="fas fa-eye"></i>
                            </a>
                            <a href="<?php echo e(route('alumnos.edit', $alumno)); ?>" class="btn btn-sm btn-secondary btn-icon" title="Editar">
                                <i class="fas fa-edit"></i>
                            </a>
                            <form method="POST" action="<?php echo e(route('alumnos.destroy', $alumno)); ?>"
                                  onsubmit="return confirm('¿Desactivar este alumno?')">
                                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                <button type="submit" class="btn btn-sm btn-danger btn-icon" title="Desactivar">
                                    <i class="fas fa-user-slash"></i>
                                </button>
                            </form>
                        </div>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="7" style="text-align:center;padding:48px;color:var(--muted);">
                        <i class="fas fa-user-graduate" style="font-size:36px;margin-bottom:12px;display:block;opacity:.3;"></i>
                        No se encontraron alumnos.
                        <br><a href="<?php echo e(route('alumnos.create')); ?>" style="color:var(--primary-l);">Registrar el primero</a>
                    </td>
                </tr>
            <?php endif; ?>
            </tbody>
        </table>
    </div>

    <?php if($alumnos->hasPages()): ?>
    <div style="padding:16px 22px;border-top:1px solid var(--border);display:flex;justify-content:space-between;align-items:center;">
        <div style="font-size:13px;color:var(--muted);">
            Mostrando <?php echo e($alumnos->firstItem()); ?>–<?php echo e($alumnos->lastItem()); ?> de <?php echo e($alumnos->total()); ?>

        </div>
        <?php echo e($alumnos->links()); ?>

    </div>
    <?php endif; ?>
</div>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\CRMyERP\crm-colegio\resources\views/students/index.blade.php ENDPATH**/ ?>