<?php $__env->startSection('title', 'Detalle de Proveedor'); ?>

<?php $__env->startSection('header', 'Gestión de Proveedores'); ?>

<?php $__env->startSection('content'); ?>
<div class="page-container">
    <div class="page-header">
        <h2 class="page-title"><?php echo e($proveedor->nombre); ?></h2>
        <div class="page-actions">
            <a href="<?php echo e(route('proveedores.edit', $proveedor)); ?>" class="btn btn-warning">
                <i class="fa-solid fa-pen-to-square"></i>
                Editar
            </a>
            <a href="<?php echo e(route('proveedores.index')); ?>" class="btn btn-secondary">
                <i class="fa-solid fa-arrow-left"></i>
                Volver
            </a>
        </div>
    </div>

    <div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem;">
        <!-- Información del Proveedor -->
        <div class="card">
            <div class="card-header">
                <h3><i class="fa-solid fa-truck"></i> Información del Proveedor</h3>
            </div>
            <div class="card-body">
                <div class="info-row-2col">
                    <div class="info-item">
                        <span class="info-label">Nombre / Empresa</span>
                        <span class="info-value"><?php echo e($proveedor->nombre); ?></span>
                    </div>
                    <div class="info-item">
                        <span class="info-label">Documento</span>
                        <span class="info-value fw-bold"><?php echo e($proveedor->documento); ?></span>
                    </div>
                </div>

                <div class="info-row-2col">
                    <div class="info-item">
                        <span class="info-label">Persona de Contacto</span>
                        <span class="info-value"><?php echo e($proveedor->contacto ?? '-'); ?></span>
                    </div>
                    <div class="info-item">
                        <span class="info-label">Teléfono</span>
                        <span class="info-value"><?php echo e($proveedor->telefono ?? '-'); ?></span>
                    </div>
                </div>

                <div class="info-row-2col">
                    <div class="info-item">
                        <span class="info-label">Email</span>
                        <span class="info-value"><?php echo e($proveedor->email ?? '-'); ?></span>
                    </div>
                    <div class="info-item">
                        <span class="info-label">Estado</span>
                        <span class="badge <?php echo e($proveedor->estado ? 'badge-success' : 'badge-danger'); ?>">
                            <?php echo e($proveedor->estado ? 'Activo' : 'Inactivo'); ?>

                        </span>
                    </div>
                </div>

                <?php if($proveedor->direccion): ?>
                <div class="info-row">
                    <div class="info-item full">
                        <span class="info-label">Dirección</span>
                        <p class="info-text"><?php echo e($proveedor->direccion); ?></p>
                    </div>
                </div>
                <?php endif; ?>

                <div class="info-row">
                    <div class="info-item">
                        <span class="info-label">Fecha de Registro</span>
                        <span class="info-value"><?php echo e($proveedor->created_at->format('d/m/Y H:i')); ?></span>
                    </div>
                </div>
            </div>
        </div>

        <!-- Historial de Compras -->
        <div class="card">
            <div class="card-header">
                <h3><i class="fa-solid fa-cart-shopping"></i> Historial de Compras</h3>
            </div>
            <div class="card-body">
                <?php if($proveedor->compras->count() > 0): ?>
                    <div class="table-container-scroll" style="max-height: 300px;">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>N° Compra</th>
                                    <th>Fecha</th>
                                    <th>Total</th>
                                    <th>Estado</th>
                                    <th class="text-center">Acciones</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $proveedor->compras; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $compra): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td class="fw-bold"><?php echo e($compra->numero_compra); ?></td>
                                        <td><?php echo e($compra->fecha_compra->format('d/m/Y')); ?></td>
                                        <td class="fw-bold">$<?php echo e(number_format($compra->total, 0, ',', '.')); ?></td>
                                        <td>
                                            <?php if($compra->estado === 'completada'): ?>
                                                <span class="badge badge-success">Completada</span>
                                            <?php elseif($compra->estado === 'pendiente'): ?>
                                                <span class="badge badge-warning">Pendiente</span>
                                            <?php else: ?>
                                                <span class="badge badge-danger">Cancelada</span>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <div class="action-buttons">
                                                <a href="<?php echo e(route('compras.show', $compra)); ?>"
                                                    class="btn-action btn-view" title="Ver">
                                                    <i class="fa-solid fa-eye"></i>
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                        </table>
                    </div>

                    <div class="info-row mt-3">
                        <div class="info-item">
                            <span class="info-label">Total de Compras</span>
                            <span class="info-value fw-bold"><?php echo e($proveedor->compras->count()); ?></span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">Total Invertido</span>
                            <span class="info-value fw-bold">$<?php echo e(number_format($proveedor->compras->sum('total'), 0, ',', '.')); ?></span>
                        </div>
                    </div>
                <?php else: ?>
                    <div class="empty-state">
                        <p class="empty-message">No hay compras registradas para este proveedor</p>
                    </div>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\perfumeChimi\resources\views/proveedores/show.blade.php ENDPATH**/ ?>