<?php $__env->startSection('title', 'Talleres'); ?>

<?php $__env->startSection('content'); ?>
<?php $estados = \App\Models\Taller::estados(); ?>

<div class="page-head">
    <div>
        <h1>Talleres suscritos</h1>
        <div class="crumb"><a href="<?php echo e(route('admin.dashboard')); ?>">Panel</a> · Talleres</div>
    </div>
    <a href="<?php echo e(route('admin.talleres.create')); ?>" class="btn btn-primary"><i class="fa-solid fa-plus"></i> Nuevo taller</a>
</div>

<div class="panel">
    <div class="panel-head" style="gap:12px; flex-wrap:wrap;">
        <div><h3>Listado</h3><div class="sub"><?php echo e($talleres->total()); ?> talleres</div></div>
        <form method="GET" action="<?php echo e(route('admin.talleres.index')); ?>" style="display:flex; gap:10px; flex-wrap:wrap; margin-left:auto;">
            <div class="search" style="max-width:240px;"><i class="fa-solid fa-magnifying-glass"></i><input type="text" name="q" value="<?php echo e($q); ?>" placeholder="Nombre, RUC o correo..."></div>
            <select name="estado" class="filter-select" onchange="this.form.submit()">
                <option value="">Todos los estados</option>
                <?php $__currentLoopData = $estados; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($k); ?>" <?php if($estado === $k): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <button type="submit" class="btn btn-primary" style="height:40px;">Filtrar</button>
            <?php if($q || $estado): ?><a href="<?php echo e(route('admin.talleres.index')); ?>" class="btn btn-light" style="height:40px;">Limpiar</a><?php endif; ?>
        </form>
    </div>
    <div class="table-wrap">
        <table class="tbl">
            <thead><tr><th>Taller</th><th>Plan</th><th>Periodo</th><th>Estado</th><th>Vencimiento</th><th style="text-align:right;">Acciones</th></tr></thead>
            <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $talleres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td>
                        <div class="cell-strong"><?php echo e($t->nombre); ?></div>
                        <div class="cell-muted"><?php echo e($t->ciudad); ?> · <?php echo e($t->email); ?></div>
                    </td>
                    <td><?php echo e($t->plan->nombre ?? '—'); ?></td>
                    <td class="cell-muted" style="text-transform:capitalize;"><?php echo e($t->periodo); ?></td>
                    <td><span class="badge-pill b-<?php echo e($t->estadoColor()); ?>"><?php echo e($estados[$t->estado] ?? $t->estado); ?></span></td>
                    <td>
                        <?php echo e(optional($t->fecha_vencimiento)->format('d/m/Y') ?? '—'); ?>

                        <?php if($t->vencido): ?><div><span class="badge-pill b-danger">Vencido</span></div>
                        <?php elseif($t->por_vencer): ?><div><span class="badge-pill b-warning"><?php echo e($t->dias_restantes); ?> días</span></div><?php endif; ?>
                    </td>
                    <td>
                        <div class="row-actions">
                            <a href="<?php echo e(route('admin.talleres.show', $t)); ?>" class="ico-btn" title="Ver"><i class="fa-solid fa-eye"></i></a>
                            <a href="<?php echo e(route('admin.talleres.edit', $t)); ?>" class="ico-btn" title="Editar"><i class="fa-solid fa-pen"></i></a>
                            <form method="POST" action="<?php echo e(route('admin.talleres.destroy', $t)); ?>" onsubmit="return confirm('¿Eliminar el taller <?php echo e($t->nombre); ?>?');">
                                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                <button type="submit" class="ico-btn ico-danger" title="Eliminar"><i class="fa-solid fa-trash"></i></button>
                            </form>
                        </div>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="6" class="cell-muted" style="text-align:center; padding:34px;">No se encontraron talleres.</td></tr>
            <?php endif; ?>
            </tbody>
        </table>
    </div>
    <?php echo $__env->make('partials.pager', ['paginator' => $talleres], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\SAAS\saas_taller-automotriz\resources\views/admin/talleres/index.blade.php ENDPATH**/ ?>