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

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

<?php $__env->startPush('styles'); ?>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<link href="<?php echo e(url('/css/select2-custom.css')); ?>" rel="stylesheet">
<style>
.form-compact .form-group { margin-bottom: 1rem; }
.form-compact .card { margin-bottom: 1rem; }
.readonly-compact {
    background-color: #f8fafc;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: right;
    padding-right: 1rem !important;
}
.price-highlight {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    font-weight: 700;
    font-size: 1rem;
}
.form-text-sm {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="page-container">
    <div class="page-header">
        <h2 class="page-title">Editar Producto</h2>
        <a href="<?php echo e(route('productos.index')); ?>" class="btn btn-secondary">
            <i class="fa-solid fa-arrow-left"></i>
            Volver
        </a>
    </div>

    <form action="<?php echo e(route('productos.update', $producto)); ?>" method="POST" class="form-compact">
        <?php echo csrf_field(); ?>
        <?php echo method_field('PUT'); ?>

        <!-- Información Principal -->
        <div class="card">
            <div class="card-header">
                <h3><i class="fa-solid fa-info-circle"></i> Información del Producto</h3>
            </div>
            <div class="card-body">
                <div class="form-row">
                    <div class="form-group">
                        <label for="codigo" class="form-label required">Código</label>
                        <input type="text" id="codigo" name="codigo" class="form-control <?php $__errorArgs = ['codigo'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('codigo', $producto->codigo)); ?>" required autofocus maxlength="50">
                        <?php $__errorArgs = ['codigo'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="form-group">
                        <label for="categoria_id" class="form-label required">Categoría</label>
                        <select id="categoria_id" name="categoria_id" class="form-control <?php $__errorArgs = ['categoria_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" required>
                            <option value="">Seleccione una categoría</option>
                            <?php $__currentLoopData = $categorias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $categoria): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($categoria->id); ?>" <?php echo e(old('categoria_id', $producto->categoria_id) == $categoria->id ? 'selected' : ''); ?>><?php echo e($categoria->nombre); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                        <?php $__errorArgs = ['categoria_id'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="form-group">
                        <label for="nombre" class="form-label required">Producto</label>
                        <input type="text" id="nombre" name="nombre" class="form-control <?php $__errorArgs = ['nombre'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('nombre', $producto->nombre)); ?>" required maxlength="200" placeholder="Nombre del proveedor">
                        <?php $__errorArgs = ['nombre'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                </div>

                <div class="form-row">
                    <div class="form-group">
                        <label for="fragancia" class="form-label required">Fragancia</label>
                        <input type="text" id="fragancia" name="fragancia" class="form-control <?php $__errorArgs = ['fragancia'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('fragancia', $producto->fragancia)); ?>" required maxlength="200" placeholder="Nombre comercial">
                        <?php $__errorArgs = ['fragancia'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="form-group">
                        <label for="presentacion" class="form-label">Presentación</label>
                        <input type="text" id="presentacion" name="presentacion" class="form-control <?php $__errorArgs = ['presentacion'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('presentacion', $producto->presentacion)); ?>" placeholder="100ml, 50ml, etc." maxlength="100">
                        <?php $__errorArgs = ['presentacion'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="form-group">
                        <div class="form-check" style="padding-top: 2rem;">
                            <input type="checkbox" id="estado" name="estado" class="form-check-input" value="1" <?php echo e(old('estado', $producto->estado) ? 'checked' : ''); ?>>
                            <label for="estado" class="form-check-label"><strong>Producto activo</strong></label>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Costos y Precios -->
        <div class="card">
            <div class="card-header">
                <h3><i class="fa-solid fa-calculator"></i> Costos y Precios</h3>
            </div>
            <div class="card-body">
                <!-- Valores de entrada -->
                <div class="form-row" style="margin-bottom: 1.5rem;">
                    <div class="form-group">
                        <label for="costo_1k" class="form-label required">Costo 1k</label>
                        <div class="input-group">
                            <span class="input-group-text">$</span>
                            <input type="text" id="costo_1k" name="costo_1k_display" class="form-control number-format <?php $__errorArgs = ['costo_1k'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('costo_1k', $producto->costo_1k)); ?>" required>
                            <input type="hidden" name="costo_1k" id="costo_1k_hidden" value="<?php echo e(old('costo_1k', $producto->costo_1k)); ?>">
                        </div>
                        <small class="form-text-sm text-muted">Costo por kilogramo</small>
                        <?php $__errorArgs = ['costo_1k'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="form-group">
                        <label for="costo_frag_cf_cv" class="form-label required">Costo frag + cf + cv</label>
                        <div class="input-group">
                            <span class="input-group-text">$</span>
                            <input type="text" id="costo_frag_cf_cv" name="costo_frag_cf_cv_display" class="form-control number-format <?php $__errorArgs = ['costo_frag_cf_cv'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('costo_frag_cf_cv', $producto->costo_frag_cf_cv)); ?>" required>
                            <input type="hidden" name="costo_frag_cf_cv" id="costo_frag_cf_cv_hidden" value="<?php echo e(old('costo_frag_cf_cv', $producto->costo_frag_cf_cv)); ?>">
                        </div>
                        <small class="form-text-sm text-muted">Costo total del producto terminado</small>
                        <?php $__errorArgs = ['costo_frag_cf_cv'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="invalid-feedback"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                </div>

                <!-- Valores calculados (compactos) -->
                <div class="form-row">
                    <div class="form-group">
                        <label class="form-label" style="font-size: 0.85rem;">IVA 19%</label>
                        <input type="text" id="iva_19" class="form-control form-control-sm readonly-compact" value="<?php echo e(number_format($producto->iva_19, 0, '', '.')); ?>" readonly>
                    </div>

                    <div class="form-group">
                        <label class="form-label" style="font-size: 0.85rem;">COSTO 1K + IVA</label>
                        <input type="text" id="costo_1k_con_iva" class="form-control form-control-sm readonly-compact" value="<?php echo e(number_format($producto->costo_1k_con_iva, 0, '', '.')); ?>" readonly>
                    </div>

                    <div class="form-group">
                        <label class="form-label" style="font-size: 0.85rem;">COSTO GR</label>
                        <input type="text" id="costo_gr" class="form-control form-control-sm readonly-compact" value="<?php echo e(number_format($producto->costo_gr, 0, '', '.')); ?>" readonly>
                    </div>
                </div>

                <hr style="margin: 1.5rem 0;">

                <!-- Precios de venta -->
                <label class="form-label" style="font-weight: 700; margin-bottom: 1rem;"><i class="fa-solid fa-tags"></i> Precios de Venta</label>
                <div class="form-row">
                    <div class="form-group">
                        <label class="form-label" style="font-size: 0.85rem;">Precio 30%</label>
                        <div class="input-group input-group-sm">
                            <span class="input-group-text">$</span>
                            <input type="text" id="precio_30" class="form-control readonly-compact price-highlight" value="<?php echo e(number_format($producto->precio_30, 0, '', '.')); ?>" readonly>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="form-label" style="font-size: 0.85rem;">Precio 50%</label>
                        <div class="input-group input-group-sm">
                            <span class="input-group-text">$</span>
                            <input type="text" id="precio_50" class="form-control readonly-compact price-highlight" value="<?php echo e(number_format($producto->precio_50, 0, '', '.')); ?>" readonly>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="form-label" style="font-size: 0.85rem;">Precio 75%</label>
                        <div class="input-group input-group-sm">
                            <span class="input-group-text">$</span>
                            <input type="text" id="precio_75" class="form-control readonly-compact price-highlight" value="<?php echo e(number_format($producto->precio_75, 0, '', '.')); ?>" readonly>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="form-label" style="font-size: 0.85rem;">Precio 100%</label>
                        <div class="input-group input-group-sm">
                            <span class="input-group-text">$</span>
                            <input type="text" id="precio_100" class="form-control readonly-compact price-highlight" value="<?php echo e(number_format($producto->precio_100, 0, '', '.')); ?>" readonly>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        
        

        <!-- Botones de Acción -->
        <div class="form-actions-bottom">
            <button type="submit" class="btn btn-primary btn-lg">
                <i class="fa-solid fa-save"></i>
                Actualizar Producto
            </button>
            <a href="<?php echo e(route('productos.index')); ?>" class="btn btn-secondary btn-lg">
                <i class="fa-solid fa-xmark"></i>
                Cancelar
            </a>
        </div>
    </form>
</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script src="<?php echo e(url('/js/number-format.js')); ?>"></script>
<script src="<?php echo e(url('/js/productos-form.js')); ?>"></script>

<?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/productos/edit.blade.php ENDPATH**/ ?>