<?php $__env->startSection('content'); ?>
<div class="bg-body-light">
    <div class="content content-full">
        <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center py-2">
            <div class="flex-grow-1">
                <h1 class="h3 fw-bold mb-2">
                    Detalle de Recibo <span class="text-primary">#<?php echo e($recibo->id); ?></span>
                </h1>
                <h2 class="fs-base lh-base fw-medium text-muted mb-0">
                    Comprobante de Ingreso — <?php echo e(strtoupper($tipore)); ?>

                </h2>
            </div>
            <div class="flex-shrink-0 mt-3 mt-sm-0 ms-sm-3">
                <a href="<?php echo e(route('recibos.index')); ?>" class="btn btn-alt-secondary">
                    <i class="fa fa-arrow-left me-1"></i> Volver al Listado
                </a>
                <a href="<?php echo e(route('recibos.pdf', $recibo->id)); ?>" target="_blank" class="btn btn-alt-primary">
                    <i class="fa fa-print me-1"></i> Imprimir
                </a>
            </div>
        </div>
    </div>
</div>

<div class="content">
    
    <?php if(session('success')): ?>
        <div class="alert alert-success d-flex align-items-center" role="alert">
            <i class="fa fa-check-circle me-2"></i>
            <p class="mb-0"><?php echo e(session('success')); ?></p>
            <button type="button" class="btn-close ms-auto" data-bs-dismiss="alert"></button>
        </div>
    <?php endif; ?>

    <div class="row">
        
        <div class="col-xl-7">
            <div class="block block-rounded">
                <div class="block-header block-header-default border-bottom">
                    <h3 class="block-title"><i class="fa fa-info-circle me-1 text-muted"></i> Datos Generales</h3>
                    <div class="block-options">
                        <span class="badge bg-primary px-3 py-2">
                            T/C: <?php echo e(number_format($recibo->tc, 2)); ?>

                        </span>
                    </div>
                </div>
                <div class="block-content p-0">
                    <table class="table table-vcenter table-sm fs-sm mb-0">
                        <tbody>
                            <tr>
                                <td class="fw-semibold bg-body-light" style="width: 35%;">Fecha de Pago</td>
                                <td class="fw-bold"><?php echo e(\App\Helpers\FechaHelper::bdToLocal($recibo->fecha)); ?></td>
                            </tr>
                            <tr>
                                <td class="fw-semibold bg-body-light">Cliente / Titular</td>
                                <td>
                                    <div class="fw-bold text-dark"><?php echo e($cliente->nombre ?? '—'); ?></div>
                                    <div class="text-muted fs-xs">ID Cliente: <?php echo e($recibo->idcliente); ?></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="fw-semibold bg-body-light">Referencia de Saldo</td>
                                <td><?php echo e(\App\Helpers\FechaHelper::bdToLocal($recibo->fechasal)); ?></td>
                            </tr>
                            <tr>
                                <td class="fw-semibold bg-body-light">Observaciones</td>
                                <td class="italic text-muted"><?php echo e($recibo->observaciones ?: 'Sin observaciones adicionales.'); ?></td>
                            </tr>
                            <tr>
                                <td class="fw-semibold bg-body-light">Cajero / Cobrador</td>
                                <td><i class="fa fa-user-check me-1 opacity-50"></i> <?php echo e($cobrador->nombre ?? 'Desconocido'); ?></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        
        <div class="col-xl-5">
            <?php if($contrato): ?>
            <div class="block block-rounded">
                <div class="block-header block-header-default border-bottom">
                    <h3 class="block-title"><i class="fa fa-map-marker-alt me-1 text-muted"></i> Ubicación y Contrato</h3>
                </div>
                <div class="block-content p-0">
                    <table class="table table-vcenter table-sm fs-sm mb-0">
                        <tbody>
                            <tr>
                                <td class="fw-semibold bg-body-light" style="width: 40%;">Urbanización</td>
                                <td><?php echo e($urb->nombre ?? '—'); ?></td>
                            </tr>
                            <tr>
                                <td class="fw-semibold bg-body-light">Zona / Distrito</td>
                                <td><?php echo e($dis->nombre ?? '—'); ?></td>
                            </tr>
                            <tr>
                                <td class="fw-semibold bg-body-light">Manzano / Lote</td>
                                <td>
                                    <span class="badge bg-dark">Mzo: <?php echo e($contrato->manzano); ?></span>
                                    <span class="badge bg-primary">Lote: <?php echo e($contrato->lote); ?></span>
                                </td>
                            </tr>
                            <tr>
                                <td class="fw-semibold bg-body-light text-primary">Contrato Maestro</td>
                                <td class="fw-bold">
                                    <a href="<?php echo e(route('contratos.show', $contrato->id)); ?>" class="link-fx">#<?php echo e($contrato->id); ?></a>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <?php endif; ?>

            
            <div class="row g-2">
                <div class="col-6">
                    <div class="block block-rounded text-center mb-0 bg-body-light border">
                        <div class="block-content block-content-full">
                            <div class="fs-xs fw-semibold text-muted text-uppercase">Total en $us</div>
                            <div class="fs-4 fw-bold text-primary"><?php echo e(number_format($recibo->montocod, 2)); ?></div>
                        </div>
                    </div>
                </div>
                <div class="col-6">
                    <div class="block block-rounded text-center mb-0 bg-body-light border">
                        <div class="block-content block-content-full">
                            <div class="fs-xs fw-semibold text-muted text-uppercase">Total en Bs</div>
                            <div class="fs-4 fw-bold text-dark"><?php echo e(number_format($recibo->montocob, 2)); ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    
    <div class="block block-rounded mt-4">
        <div class="block-header block-header-default border-bottom">
            <h3 class="block-title"><i class="fa fa-list-ol me-1 text-muted"></i> Desglose de Pagos Aplicados</h3>
        </div>
        <div class="block-content p-0">
            <div class="table-responsive">
                <table class="table table-vcenter table-hover mb-0 fs-sm">
                    <thead class="bg-body-dark text-uppercase fs-xs">
                        <tr>
                            <th class="text-end">Saldo Total del Contrato ($us)</th>
                            <th class="text-end">Saldo a la Fecha ($us)</th>
                            <th class="text-end bg-primary-lighter text-primary" style="width: 200px;">Monto Pagado ($us)</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $sumTotal = $sumSaldo = $sumPagado = 0; ?>
                        <?php $__currentLoopData = $recibosmov; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mv): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td class="text-end text-muted"><?php echo e(number_format($mv->montotal, 2)); ?></td>
                            <td class="text-end fw-semibold"><?php echo e(number_format($mv->monto, 2)); ?></td>
                            <td class="text-end fw-bold text-primary bg-primary-lighter"><?php echo e(number_format($mv->monpagado, 2)); ?></td>
                        </tr>
                        <?php 
                            $sumTotal += $mv->montotal; 
                            $sumSaldo += $mv->monto; 
                            $sumPagado += $mv->monpagado; 
                        ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                    <tfoot class="bg-body-light fw-bold">
                        <tr>
                            <td class="text-end fs-base"><?php echo e(number_format($sumTotal, 2)); ?></td>
                            <td class="text-end fs-base"><?php echo e(number_format($sumSaldo, 2)); ?></td>
                            <td class="text-end fs-base bg-primary text-white">
                                <span class="fs-xs opacity-75 fw-normal me-1">TOTAL</span>
                                <?php echo e(number_format($sumPagado, 2)); ?> $us
                            </td>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>

    
    <?php if(auth()->user()->tipo == 1): ?>
    <div class="block block-rounded border-top border-4 border-danger border-opacity-25">
        <div class="block-content block-content-full d-flex justify-content-between align-items-center">
            <div class="text-muted fs-sm italic">
                <i class="fa fa-shield-alt me-1"></i> Zona Administrativa: La anulación de este recibo revertirá los saldos.
            </div>
            <form method="POST" action="<?php echo e(route('recibos.anular', $recibo->id)); ?>"
                  onsubmit="return confirm('¿Está seguro de anular el recibo #<?php echo e($recibo->id); ?>?')">
                <?php echo csrf_field(); ?>
                <button class="btn btn-sm btn-alt-danger">
                    <i class="fa fa-ban me-1"></i> Anular Comprobante
                </button>
            </form>
        </div>
    </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 /var/www/proyect-laravel/cosmos-app/resources/views/recibos/show.blade.php ENDPATH**/ ?>