<?php if (isset($component)) { $__componentOriginale0f1cdd055772eb1d4a99981c240763e = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginale0f1cdd055772eb1d4a99981c240763e = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.admin-layout','data' => ['title' => 'Editar inscripción']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin-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(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['title' => 'Editar inscripción']); ?>
<?php
    $data = $application->data;
    $dependents = old('dependents', $data['dependents'] ?? []);
    $members = old('board_members', $data['board_members'] ?? []);
?>
<div class="page-heading"><div><a href="<?php echo e(route('admin.applications.show', $application)); ?>" class="back-link mb-2"><i data-lucide="arrow-left"></i> Volver al detalle</a><span class="eyebrow"><?php echo e($application->folio); ?></span><h1>Editar formulario</h1><p>Los cambios se reflejarán en el detalle y en los PDF generados.</p></div></div>
<?php if($errors->any()): ?><div class="alert alert-danger">Revisa los campos marcados antes de guardar.</div><?php endif; ?>
<form method="POST" action="<?php echo e(route('admin.applications.update-data', $application)); ?>" enctype="multipart/form-data" x-data="{ dependents: <?php echo \Illuminate\Support\Js::from(array_values($dependents))->toHtml() ?>, members: <?php echo \Illuminate\Support\Js::from(array_values($members))->toHtml() ?> }">
    <?php echo csrf_field(); ?> <?php echo method_field('PATCH'); ?>
    <div class="admin-panel mb-4">
        <h2 class="detail-title">Datos personales</h2>
        <div class="row g-3">
            <?php $__currentLoopData = ['full_name'=>'Nombre completo','rut'=>'RUT','birth_date'=>'Fecha de nacimiento','email'=>'Correo electrónico','phone'=>'Teléfono','address'=>'Dirección','delivery_address'=>'Dirección de entrega']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="<?php echo e(in_array($key, ['full_name','address','delivery_address']) ? 'col-md-8' : 'col-md-4'); ?>"><label class="form-label" for="<?php echo e($key); ?>"><?php echo e($label); ?> <span class="required">*</span></label><input id="<?php echo e($key); ?>" name="<?php echo e($key); ?>" type="<?php echo e($key === 'birth_date' ? 'date' : ($key === 'email' ? 'email' : 'text')); ?>" class="form-control <?php $__errorArgs = [$key];
$__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 value="<?php echo e(old($key, $data[$key] ?? $application->$key)); ?>"><?php $__errorArgs = [$key];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?><div class="field-error"><?php echo e($message); ?></div><?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?></div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </div>
        <h2 class="detail-title mt-4">Datos laborales</h2>
        <?php ($workFields = $application->type === 'particular' ? ['profession'=>'Profesión','company'=>'Empresa','job_title'=>'Cargo','work_phone'=>'Teléfono laboral','work_email'=>'Correo laboral'] : ['profession'=>'Profesión','work_area'=>'Área de trabajo','superintendency'=>'Superintendencia','work_phone'=>'Teléfono laboral','management'=>'Gerencia','work_email'=>'Correo laboral']); ?>
        <div class="row g-3"><?php $__currentLoopData = $workFields; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><div class="col-md-4"><label class="form-label" for="<?php echo e($key); ?>"><?php echo e($label); ?></label><input id="<?php echo e($key); ?>" name="<?php echo e($key); ?>" type="<?php echo e($key === 'work_email' ? 'email' : 'text'); ?>" class="form-control" value="<?php echo e(old($key, $data[$key] ?? '')); ?>"></div><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div>
        <h2 class="detail-title mt-4">Recomendación y firma</h2>
        <div class="row g-3"><div class="col-md-4"><label class="form-label">Socio que recomienda</label><input name="recommender_name" class="form-control" value="<?php echo e(old('recommender_name', $data['recommender_name'] ?? '')); ?>"></div><div class="col-md-4"><label class="form-label">RUT del recomendante</label><input name="recommender_rut" class="form-control" value="<?php echo e(old('recommender_rut', $data['recommender_rut'] ?? '')); ?>"></div><div class="col-md-4"><label class="form-label">Fecha de firma <span class="required">*</span></label><input name="signature_date" type="date" required class="form-control" value="<?php echo e(old('signature_date', $data['signature_date'] ?? '')); ?>"></div></div>
    </div>

    <div class="admin-panel mb-4">
        <div class="panel-heading"><div><h2>Cargas familiares</h2><p>Edita, agrega o elimina cargas declaradas.</p></div><button type="button" class="btn btn-sm btn-outline-copper" @click="dependents.push({full_name:'',rut:'',birth_date:'',relationship:''})"><i data-lucide="plus"></i> Agregar</button></div>
        <template x-for="(dependent,index) in dependents" :key="index"><div class="dynamic-card"><div class="dynamic-head"><strong x-text="`Carga ${index+1}`"></strong><button type="button" class="remove-btn" @click="dependents.splice(index,1)"><i data-lucide="trash-2"></i> Eliminar</button></div><div class="row g-3"><div class="col-md-4"><label class="form-label">Nombre</label><input class="form-control" :name="`dependents[${index}][full_name]`" x-model="dependent.full_name" required></div><div class="col-md-3"><label class="form-label">RUT</label><input class="form-control" :name="`dependents[${index}][rut]`" x-model="dependent.rut" required></div><div class="col-md-3"><label class="form-label">Nacimiento</label><input type="date" class="form-control" :name="`dependents[${index}][birth_date]`" x-model="dependent.birth_date" required></div><div class="col-md-2"><label class="form-label">Parentesco</label><input class="form-control" :name="`dependents[${index}][relationship]`" x-model="dependent.relationship" required></div></div></div></template>
        <p class="text-muted mb-0" x-show="!dependents.length">Sin cargas familiares.</p>
    </div>

    <div class="admin-panel mb-4">
        <div class="panel-heading"><div><h2>Aprobación del Consejo Directivo</h2><p>Esta sección solo es visible y editable en administración.</p></div><button type="button" class="btn btn-sm btn-outline-copper" @click="members.push({name:'',rut:'',signature:''})"><i data-lucide="plus"></i> Agregar integrante</button></div>
        <template x-for="(member,index) in members" :key="index"><div class="dynamic-card"><div class="dynamic-head"><strong x-text="`Integrante ${index+1}`"></strong><button type="button" class="remove-btn" @click="members.splice(index,1)"><i data-lucide="trash-2"></i> Eliminar</button></div><div class="row g-3"><div class="col-md-5"><label class="form-label">Nombre o aprobación</label><input class="form-control" :name="`board_members[${index}][name]`" x-model="member.name"></div><div class="col-md-3"><label class="form-label">RUT</label><input class="form-control" :name="`board_members[${index}][rut]`" x-model="member.rut"></div><div class="col-md-4"><label class="form-label">Firma <span class="text-muted fw-normal" x-show="member.signature">(se conservará la actual)</span></label><input type="file" accept="image/png,image/jpeg" class="form-control" :name="`board_signatures[${index}]`"></div></div></div></template>
        <p class="text-muted mb-0" x-show="!members.length">Aún no hay integrantes registrados.</p>
    </div>
    <div class="d-flex justify-content-end gap-2"><a href="<?php echo e(route('admin.applications.show', $application)); ?>" class="btn btn-light">Cancelar</a><button class="btn btn-copper"><i data-lucide="save"></i> Guardar formulario</button></div>
</form>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginale0f1cdd055772eb1d4a99981c240763e)): ?>
<?php $attributes = $__attributesOriginale0f1cdd055772eb1d4a99981c240763e; ?>
<?php unset($__attributesOriginale0f1cdd055772eb1d4a99981c240763e); ?>
<?php endif; ?>
<?php if (isset($__componentOriginale0f1cdd055772eb1d4a99981c240763e)): ?>
<?php $component = $__componentOriginale0f1cdd055772eb1d4a99981c240763e; ?>
<?php unset($__componentOriginale0f1cdd055772eb1d4a99981c240763e); ?>
<?php endif; ?>
<?php /**PATH C:\Users\bpere\OneDrive\Documentos\WebPrime\CCR\plataforma\resources\views\admin\applications\edit.blade.php ENDPATH**/ ?>