<?php $__env->startSection('title', 'Control de Pagos'); ?>

<?php $__env->startSection('content'); ?>
<div class="page-header">
    <h1 class="page-title">Control de Pagos de Licencias</h1>
</div>

<?php if(session('success')): ?>
    <div style="background: rgba(35, 134, 54, 0.2); color: #3fb950; padding: 12px; border-radius: 8px; margin-bottom: 20px; border: 1px solid rgba(35, 134, 54, 0.4);">
        <i class="fa-solid fa-check-circle"></i> <?php echo e(session('success')); ?>

    </div>
<?php endif; ?>

<div style="display: grid; grid-template-columns: 300px 1fr; gap: 20px;">
    <!-- Registrar Pago -->
    <div class="card" style="height: fit-content;">
        <h3 style="margin-bottom: 15px; font-size: 1.1rem; color: var(--text-main);">Registrar Pago</h3>
        <form action="<?php echo e(route('pagos.store')); ?>" method="POST">
            <?php echo csrf_field(); ?>
            <div style="margin-bottom: 15px;">
                <label style="display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 0.85rem;">Licencia a Renovar/Pagar</label>
                <select name="licencia_id" required style="width: 100%; padding: 10px; border-radius: 4px; border: 1px solid var(--border-color); background: var(--bg-body); color: var(--text-main);">
                    <?php $__currentLoopData = $licencias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $licencia): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($licencia->id); ?>"><?php echo e($licencia->empresa->razon_social); ?> (<?php echo e($licencia->tipo); ?>)</option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div style="margin-bottom: 15px;">
                <label style="display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 0.85rem;">Monto (S/)</label>
                <input type="number" step="0.01" name="monto" required style="width: 100%; padding: 10px; border-radius: 4px; border: 1px solid var(--border-color); background: var(--bg-body); color: var(--text-main);">
            </div>

            <div style="margin-bottom: 15px;">
                <label style="display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 0.85rem;">Método de Pago</label>
                <select name="metodo_pago" required style="width: 100%; padding: 10px; border-radius: 4px; border: 1px solid var(--border-color); background: var(--bg-body); color: var(--text-main);">
                    <option value="TRANSFERENCIA">Transferencia Bancaria</option>
                    <option value="YAPE">Yape</option>
                    <option value="PLIN">Plin</option>
                    <option value="EFECTIVO">Efectivo</option>
                    <option value="OTROS">Otros</option>
                </select>
            </div>

            <div style="margin-bottom: 15px;">
                <label style="display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 0.85rem;">N° de Operación</label>
                <input type="text" name="num_operacion" style="width: 100%; padding: 10px; border-radius: 4px; border: 1px solid var(--border-color); background: var(--bg-body); color: var(--text-main);">
            </div>

            <div style="margin-bottom: 20px;">
                <label style="display: block; margin-bottom: 5px; color: var(--text-muted); font-size: 0.85rem;">Fecha de Pago</label>
                <input type="date" name="fecha_pago" value="<?php echo e(date('Y-m-d')); ?>" required style="width: 100%; padding: 10px; border-radius: 4px; border: 1px solid var(--border-color); background: var(--bg-body); color: var(--text-main); color-scheme: dark;">
            </div>

            <button type="submit" class="btn btn-primary" style="width: 100%; text-align: center;">Guardar Pago</button>
        </form>
    </div>

    <!-- Lista de Pagos -->
    <div class="card">
        <h3 style="margin-bottom: 15px; font-size: 1.1rem; color: var(--text-main);">Historial de Pagos</h3>
        <table class="table">
            <thead>
                <tr>
                    <th>Fecha</th>
                    <th>Empresa</th>
                    <th>Monto</th>
                    <th>Método</th>
                    <th>Ref/Operación</th>
                </tr>
            </thead>
            <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $pagos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pago): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td><?php echo e(\Carbon\Carbon::parse($pago->fecha_pago)->format('d/m/Y')); ?></td>
                    <td><?php echo e(optional($pago->licencia->empresa)->razon_social ?? 'Desconocida'); ?></td>
                    <td style="font-weight: 600; color: var(--success);">S/ <?php echo e(number_format($pago->monto, 2)); ?></td>
                    <td><span class="badge badge-info"><?php echo e($pago->metodo_pago); ?></span></td>
                    <td><small style="color: var(--text-muted);"><?php echo e($pago->num_operacion ?? '-'); ?></small></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="5" style="text-align: center; color: var(--text-muted); padding: 30px;">No hay pagos registrados.</td>
                </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</div>

<style>
    .table { width: 100%; border-collapse: collapse; }
    .table th, .table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border-color); }
    .table th { font-weight: 600; color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; background: rgba(0,0,0,0.1); }
    .table tr:hover { background: rgba(255,255,255,0.02); }
    .table tr:last-child td { border-bottom: none; }
    .badge { padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
    .badge-info { background: rgba(88, 166, 255, 0.2); color: var(--primary); }
</style>
<?php $__env->stopSection(); ?>

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