<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('title', null, []); ?> 
        <div class="d-flex align-items-center gap-2">
            <a href="<?php echo e(route('recetas.index')); ?>" class="btn btn-sm btn-light rounded-circle shadow-sm border-0 me-2" title="Volver al Directorio">
                <i class="bi bi-arrow-left text-secondary"></i>
            </a>
            <span class="text-secondary fw-normal">Recetas / Cotizador / </span> <?php echo e($receta->nombre); ?>

        </div>
     <?php $__env->endSlot(); ?>

    <?php
        $costoEsperado = $receta->costo_esperado;
        $costoRealPorcion = $receta->costo_real_porcion;
        $variacion = $receta->variacion_porcentual;
        $esRentable = $costoRealPorcion <= $costoEsperado;
    ?>

    <div class="row g-4 mb-4">
        <!-- Tarjeta Principal: Título y Datos de Receta -->
        <div class="col-lg-6">
            <div class="card border-0 shadow-sm rounded-4 h-100" style="background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);">
                <div class="card-body p-4 d-flex flex-column justify-content-center">
                    <div class="d-flex align-items-start justify-content-between mb-3">
                        <div class="d-flex align-items-center gap-3">
                            <div class="bg-primary bg-opacity-10 text-primary rounded-4 d-flex align-items-center justify-content-center" style="width: 70px; height: 70px;">
                                <i class="bi bi-egg-fried fs-1"></i>
                            </div>
                            <div>
                                <h3 class="fw-bold text-dark mb-1"><?php echo e(strtoupper($receta->nombre)); ?></h3>
                                <div class="text-muted small">
                                    <i class="bi bi-calendar-check me-1"></i> Creado por <strong><?php echo e($receta->creadaPor->name ?? 'Sistema'); ?></strong> el <?php echo e($receta->created_at->format('d/m/Y')); ?>

                                </div>
                            </div>
                        </div>
                        <div>
                            <?php if($receta->activa): ?>
                                <span class="badge bg-success bg-opacity-10 text-success rounded-pill px-3 py-2 border border-success border-opacity-25">Receta Activa</span>
                            <?php else: ?>
                                <span class="badge bg-secondary bg-opacity-10 text-secondary rounded-pill px-3 py-2 border border-secondary border-opacity-25">Inactiva (Archivada)</span>
                            <?php endif; ?>
                        </div>
                    </div>
                    
                    <div class="row g-3 mt-1">
                        <div class="col-sm-6">
                            <div class="bg-white border rounded-3 p-3">
                                <div class="text-muted small fw-bold text-uppercase mb-1" style="font-size: 0.70rem; letter-spacing: 0.05em;"><i class="bi bi-people-fill text-primary me-2"></i> Rendimiento</div>
                                <h4 class="fw-bold text-dark mb-0"><?php echo e($receta->porciones); ?> <span class="fs-6 fw-normal text-muted">PorcioneS/Unidades</span></h4>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="bg-white border rounded-3 p-3">
                                <div class="text-muted small fw-bold text-uppercase mb-1" style="font-size: 0.70rem; letter-spacing: 0.05em;"><i class="bi bi-basket-fill text-warning me-2"></i> Ingredientes</div>
                                <h4 class="fw-bold text-dark mb-0"><?php echo e($receta->ingredientes->count()); ?> <span class="fs-6 fw-normal text-muted">Insumos asociados</span></h4>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Tarjeta de Análisis de Rentabilidad (Cotizador) -->
        <div class="col-lg-6">
            <div class="card border-0 shadow-sm rounded-4 h-100 bg-dark text-white" style="position: relative; overflow: hidden;">
                <!-- Decoración -->
                <div style="position: absolute; top: -30px; right: -30px; opacity: 0.05;">
                    <i class="bi bi-calculator" style="font-size: 15rem;"></i>
                </div>
                
                <div class="card-body p-4 position-relative z-1 d-flex flex-column h-100">
                    <h6 class="fw-bold text-white-50 text-uppercase mb-4" style="font-size: 0.75rem; letter-spacing: 0.1em;">
                        <i class="bi bi-bar-chart-line me-2"></i> Análisis de Rentabilidad (Por Porción)
                    </h6>
                    
                    <div class="row g-0 flex-grow-1 align-items-center">
                        <!-- Costo Esperado (Meta) -->
                        <div class="col-5 border-end border-secondary border-opacity-25 pe-4">
                            <div class="text-white-50 small mb-2 fw-bold text-uppercase" style="font-size:0.75rem;">Costo Ideal (Meta) <i class="bi bi-bullseye ms-1 text-info"></i></div>
                            <h2 class="fw-bold mb-0 text-white"><?php echo e($moneda); ?> <?php echo e(number_format($costoEsperado, 2)); ?></h2>
                            <div class="small mt-2 <?php echo $esRentable ? 'text-success' : 'text-danger'; ?> d-flex align-items-center">
                                <?php if($costoEsperado == 0): ?>
                                    <span class="text-white-50"><i class="bi bi-info-circle me-1"></i> No se fijó costo ideal</span>
                                <?php else: ?>
                                    <i class="bi <?php echo $esRentable ? 'bi-check-circle-fill' : 'bi-exclamation-triangle-fill'; ?> me-1"></i>
                                    <?php echo $esRentable ? 'Dentro del margen' : 'Costo excedido'; ?>

                                <?php endif; ?>
                            </div>
                        </div>
                        
                        <!-- Costo Real Calculado -->
                        <div class="col-7 ps-4">
                            <div class="text-white-50 small mb-2 fw-bold text-uppercase d-flex justify-content-between" style="font-size: 0.75rem;">
                                <span>Costo Real (Calculado)</span>
                                <?php if($costoEsperado > 0): ?>
                                    <?php $margenSoles = $costoEsperado - $costoRealPorcion; ?>
                                    <span class="badge <?php echo $esRentable ? 'bg-success' : 'bg-danger'; ?> rounded-pill" title="Margen de Ganancia/Pérdida">
                                        <?php echo e($margenSoles >= 0 ? '+' : '-'); ?> <?php echo e($moneda); ?> <?php echo e(number_format(abs($margenSoles), 2)); ?> (<?php echo e($variacion > 0 ? '+' : ''); ?><?php echo e($variacion); ?>%)
                                    </span>
                                <?php endif; ?>
                            </div>
                            <!-- Lo pintamos rojo si está perdiendo dinero, verde si ahorra -->
                            <h1 class="fw-bold mb-0 display-6 <?php echo $esRentable ? 'text-success' : 'text-danger'; ?>">
                                <?php echo e($moneda); ?> <?php echo e(number_format($costoRealPorcion, 2)); ?>

                            </h1>
                            <div class="small mt-2 text-white-50">
                                Calculado en base al almacén actual.
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Lista Estilo Excel y Preparación -->
    <div class="row g-4">
        <!-- Tabla de Ingredientes (Excel) -->
        <div class="col-lg-8">
            <div class="card border-0 shadow-sm rounded-4 h-100">
                <div class="card-header bg-white border-bottom-0 pt-4 pb-3 px-4 d-flex justify-content-between align-items-center">
                    <h5 class="fw-bold text-dark mb-0"><i class="bi bi-table text-primary me-2"></i> Estructura de Costos (Ingredientes)</h5>
                    <a href="<?php echo e(route('recetas.edit', $receta)); ?>" class="btn btn-sm btn-outline-primary rounded-pill fw-bold">
                        <i class="bi bi-pencil-fill me-1"></i> Modificar Receta
                    </a>
                </div>
                <div class="card-body p-0">
                    <div class="table-responsive">
                        <!-- Estilo que simula una hoja de cálculo -->
                        <table class="table table-bordered table-hover align-middle mb-0" style="border-color: #e5e7eb;">
                            <thead style="background-color: #f39c12; color: #fff;">
                                <tr>
                                    <th class="py-3 px-4 text-uppercase border-bottom-0" style="font-size: 0.75rem; font-weight: 700;">Ingredientes</th>
                                    <th class="py-3 text-center text-uppercase border-bottom-0" style="font-size: 0.75rem; font-weight: 700;">Cantidad</th>
                                    <th class="py-3 text-center text-uppercase border-bottom-0" style="font-size: 0.75rem; font-weight: 700;">Unidad</th>
                                    <th class="py-3 text-end text-uppercase border-bottom-0" style="font-size: 0.75rem; font-weight: 700;">Costo/Uso (<?php echo e($moneda); ?> )</th>
                                    <th class="py-3 px-4 text-end text-uppercase border-bottom-0" style="font-size: 0.75rem; font-weight: 700;">Costo Total (<?php echo e($moneda); ?> )</th>
                                </tr>
                            </thead>
                            <tbody class="border-top-0" style="background-color: #fcd34d; color: #451a03;">
                                <?php $__empty_1 = true; $__currentLoopData = $receta->ingredientes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ingrediente): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <?php
                                        $costoUnitario = $ingrediente->insumo?->getCostoPorUso() ?? 0;
                                        $subtotal = $ingrediente->cantidad * $costoUnitario;
                                    ?>
                                    <tr style="border-color: #f59e0b;">
                                        <td class="px-4 py-2 border-end-0 fw-semibold">
                                            <?php echo e($ingrediente->insumo->nombre ?? 'Insumo Eliminado'); ?>

                                        </td>
                                        <td class="py-2 text-center border-end-0 border-start-0">
                                            <?php echo e(floatval($ingrediente->cantidad)); ?>

                                        </td>
                                        <td class="py-2 text-center border-end-0 border-start-0 text-opacity-75">
                                            <?php echo e($ingrediente->insumo->unidad_uso ?? 'N/A'); ?>

                                        </td>
                                        <td class="py-2 text-end border-end-0 border-start-0 text-opacity-75">
                                            <?php echo e(number_format($costoUnitario, 2)); ?>

                                        </td>
                                        <td class="px-4 py-2 text-end border-start-0 fw-bold">
                                            <?php echo e(number_format($subtotal, 2)); ?>

                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr style="background-color: #fff;">
                                        <td colspan="5" class="text-center py-5 text-muted">
                                            <i class="bi bi-cart-x fs-2 d-block mb-3 text-light"></i>
                                            Esta receta aún no tiene ingredientes o insumos asociados.
                                        </td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                            <tfoot style="background-color: #d97706; color: white;">
                                <tr>
                                    <td colspan="4" class="text-end py-3 fw-bold text-uppercase" style="font-size: 0.85rem; letter-spacing: 0.05em;">Total Costo (<?php echo e($receta->porciones); ?> Porciones):</td>
                                    <td class="px-4 py-3 fw-bold fs-5 text-end text-dark">
                                        <?php echo e($moneda); ?> <?php echo e(number_format($receta->costo_real, 2)); ?>

                                    </td>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <!-- Columna Preparación -->
        <div class="col-lg-4">
            <div class="card border-0 shadow-sm rounded-4 h-100" style="background-color: #fce8b2; border: 1px solid #f1c40f !important;">
                <div class="card-body p-4">
                    <h5 class="fw-bold text-uppercase text-dark mb-4 text-center border-bottom border-dark pb-3" style="font-size: 1rem; letter-spacing: 0.1em; color: #b7791f !important;">
                        Preparación
                    </h5>
                    
                    <?php if($receta->preparacion): ?>
                        <div class="text-dark" style="font-size: 0.95rem; line-height: 1.6; white-space: pre-wrap;"><?php echo e($receta->preparacion); ?></div>
                    <?php else: ?>
                        <div class="text-center text-muted py-5 opacity-75">
                            <i class="bi bi-journal-x fs-1 d-block mb-3"></i>
                            El Chef no ha detallado los pasos de preparación.
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\laragon\www\gastrog\resources\views/recetas/show.blade.php ENDPATH**/ ?>