<?php ($diskUrl = fn (string $path) => \Illuminate\Support\Facades\Storage::url($path)); ?>
<?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('header', null, []); ?> 
        <div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
            <div>
                <h2 class="text-xl font-bold text-slate-900 leading-tight">
                    <?php echo e($patient->name); ?>

                </h2>
                <?php if($patient->clinical_code): ?>
                    <p class="mt-1 font-mono text-sm font-semibold text-teal-700"><?php echo e(__('Expediente paciente')); ?>: <?php echo e($patient->clinical_code); ?></p>
                <?php endif; ?>
            </div>
            <div class="flex flex-wrap items-center gap-2">
                <a href="<?php echo e(route('clients.show', $client)); ?>" class="inline-flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-700 shadow-sm hover:bg-slate-50">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-teal-600" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M10 19l-7-7m0 0l7-7m-7 7h18"/></svg>
                    <?php echo e(__('Volver al titular')); ?>

                </a>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('clients.manage')): ?>
                    <a href="<?php echo e(route('clients.patients.edit', [$client, $patient])); ?>"
                       class="inline-flex items-center gap-1.5 rounded-xl bg-teal-600 px-3 py-2 text-sm font-bold text-white shadow-md hover:bg-teal-700">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>
                        <?php echo e(__('Editar ficha')); ?>

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

    <div class="py-8">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6" x-data="filePreviewModal()" @keydown.escape.window="closePreview()">
            
            <div class="poskn-card overflow-hidden p-6">
                <h3 class="text-xs font-bold uppercase tracking-widest text-violet-700 mb-3"><?php echo e(__('Representante / titular')); ?></h3>
                <div class="flex flex-col gap-4 sm:flex-row sm:items-start">
                    <div class="shrink-0">
                        <?php if($client->photo_path): ?>
                            <img src="<?php echo e(\Illuminate\Support\Facades\Storage::url($client->photo_path)); ?>" alt="" class="h-20 w-20 rounded-xl object-cover border border-slate-200" />
                        <?php else: ?>
                            <div class="h-20 w-20 rounded-xl bg-violet-100 flex items-center justify-center text-2xl font-bold text-violet-500">
                                <?php echo e(mb_strtoupper(mb_substr($client->name, 0, 1))); ?>

                            </div>
                        <?php endif; ?>
                    </div>
                    <div class="flex-1 text-sm text-slate-700 space-y-1">
                        <p><span class="font-semibold text-slate-900"><?php echo e(__('Nombre')); ?>:</span>
                            <a href="<?php echo e(route('clients.show', $client)); ?>" class="text-violet-700 hover:underline"><?php echo e($client->name); ?></a>
                        </p>
                        <?php if($client->registration_code): ?>
                            <p><span class="font-semibold text-slate-900"><?php echo e(__('Código titular')); ?>:</span>
                                <span class="font-mono text-teal-800"><?php echo e($client->registration_code); ?></span></p>
                        <?php endif; ?>
                        <?php if($client->phone): ?>
                            <p><span class="font-semibold text-slate-900"><?php echo e(__('Teléfono')); ?>:</span> <?php echo e($client->phone); ?></p>
                        <?php endif; ?>
                        <?php if($client->email): ?>
                            <p><span class="font-semibold text-slate-900"><?php echo e(__('Correo')); ?>:</span> <?php echo e($client->email); ?></p>
                        <?php endif; ?>
                    </div>
                </div>
            </div>

            
            <div class="poskn-card overflow-hidden">
                <div class="border-b border-teal-100 bg-gradient-to-r from-teal-50 to-cyan-50 px-6 py-3">
                    <h3 class="text-sm font-bold uppercase tracking-wide text-teal-800"><?php echo e(__('Datos del paciente')); ?></h3>
                </div>
                <div class="p-6 md:flex md:gap-8">
                    <div class="shrink-0 mb-4 md:mb-0">
                        <?php if($patient->photo_path): ?>
                            <img src="<?php echo e(\Illuminate\Support\Facades\Storage::url($patient->photo_path)); ?>" alt="" class="h-36 w-36 rounded-2xl object-cover border border-slate-200 shadow-sm" />
                        <?php else: ?>
                            <div class="h-36 w-36 rounded-2xl bg-gradient-to-br from-teal-100 to-cyan-100 flex items-center justify-center text-5xl font-bold text-teal-600">
                                <?php echo e(mb_strtoupper(mb_substr($patient->name, 0, 1))); ?>

                            </div>
                        <?php endif; ?>
                    </div>
                    <div class="flex-1 grid gap-2 text-sm text-slate-700 sm:grid-cols-2">
                        <?php if($patient->species || $patient->breed): ?>
                            <p class="sm:col-span-2"><span class="font-semibold text-slate-900"><?php echo e(__('Especie / raza')); ?>:</span>
                                <?php echo e(collect([$patient->species, $patient->breed])->filter()->join(' · ')); ?></p>
                        <?php endif; ?>
                        <?php if($patient->sex): ?>
                            <p><span class="font-semibold text-slate-900"><?php echo e(__('Sexo')); ?>:</span>
                                <?php echo e(match ($patient->sex) {
                                    'M' => __('Macho'),
                                    'F' => __('Hembra'),
                                    default => __('Desconocido'),
                                }); ?></p>
                        <?php endif; ?>
                        <?php if($patient->birth_date): ?>
                            <p><span class="font-semibold text-slate-900"><?php echo e(__('Nacimiento')); ?>:</span>
                                <?php echo e($patient->birth_date->translatedFormat('d M Y')); ?></p>
                        <?php endif; ?>
                        <?php if($patient->current_weight_kg): ?>
                            <p><span class="font-semibold text-slate-900"><?php echo e(__('Peso actual')); ?>:</span> <?php echo e($patient->current_weight_kg); ?> kg</p>
                        <?php endif; ?>
                        <?php if($patient->color): ?>
                            <p><span class="font-semibold text-slate-900"><?php echo e(__('Color')); ?>:</span> <?php echo e($patient->color); ?></p>
                        <?php endif; ?>
                        <?php if($patient->microchip): ?>
                            <p class="sm:col-span-2"><span class="font-semibold text-slate-900"><?php echo e(__('Microchip')); ?>:</span> <?php echo e($patient->microchip); ?></p>
                        <?php endif; ?>
                        <p><span class="font-semibold text-slate-900"><?php echo e(__('Estado')); ?>:</span>
                            <?php echo e($patient->is_active ? __('Activo') : __('Inactivo')); ?></p>
                        <?php if(! is_null($patient->sterilized)): ?>
                            <p><span class="font-semibold text-slate-900"><?php echo e(__('Esterilización')); ?>:</span>
                                <?php echo e($patient->sterilized ? __('Sí') : __('No')); ?></p>
                        <?php endif; ?>
                        <?php if($patient->allergies): ?>
                            <p class="sm:col-span-2 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-amber-950">
                                <span class="font-semibold"><?php echo e(__('Alergias')); ?>:</span> <?php echo e($patient->allergies); ?>

                            </p>
                        <?php endif; ?>
                        <?php if($patient->notes): ?>
                            <p class="sm:col-span-2 pt-2 border-t border-slate-200">
                                <span class="font-semibold text-slate-900"><?php echo e(__('Notas')); ?>:</span><br>
                                <?php echo e($patient->notes); ?>

                            </p>
                        <?php endif; ?>
                    </div>
                </div>
            </div>

            
            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('clients.view')): ?>
                <div class="poskn-card p-6">
                    <div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-4">
                        <h3 class="text-lg font-semibold text-slate-900"><?php echo e(__('Multimedia del expediente')); ?></h3>
                        <p class="text-xs text-slate-500"><?php echo e(__('Estudios, radiografías, documentos generales del paciente')); ?></p>
                    </div>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('medical_records.edit')): ?>
                        <form method="post" action="<?php echo e(route('clients.patients.media.store', [$client, $patient])); ?>" enctype="multipart/form-data" class="mb-6 rounded-xl border border-dashed border-teal-300 bg-teal-50/40 p-4 space-y-3">
                            <?php echo csrf_field(); ?>
                            <div>
                                <?php if (isset($component)) { $__componentOriginale3da9d84bb64e4bc2eeebaafabfb2581 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginale3da9d84bb64e4bc2eeebaafabfb2581 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-label','data' => ['for' => 'pm_title','value' => __('Título (opcional, aplica a todos los archivos)')]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-label'); ?>
<?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(['for' => 'pm_title','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(__('Título (opcional, aplica a todos los archivos)'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginale3da9d84bb64e4bc2eeebaafabfb2581)): ?>
<?php $attributes = $__attributesOriginale3da9d84bb64e4bc2eeebaafabfb2581; ?>
<?php unset($__attributesOriginale3da9d84bb64e4bc2eeebaafabfb2581); ?>
<?php endif; ?>
<?php if (isset($__componentOriginale3da9d84bb64e4bc2eeebaafabfb2581)): ?>
<?php $component = $__componentOriginale3da9d84bb64e4bc2eeebaafabfb2581; ?>
<?php unset($__componentOriginale3da9d84bb64e4bc2eeebaafabfb2581); ?>
<?php endif; ?>
                                <?php if (isset($component)) { $__componentOriginal18c21970322f9e5c938bc954620c12bb = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal18c21970322f9e5c938bc954620c12bb = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.text-input','data' => ['id' => 'pm_title','class' => 'block mt-1 w-full','type' => 'text','name' => 'title']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('text-input'); ?>
<?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(['id' => 'pm_title','class' => 'block mt-1 w-full','type' => 'text','name' => 'title']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal18c21970322f9e5c938bc954620c12bb)): ?>
<?php $attributes = $__attributesOriginal18c21970322f9e5c938bc954620c12bb; ?>
<?php unset($__attributesOriginal18c21970322f9e5c938bc954620c12bb); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal18c21970322f9e5c938bc954620c12bb)): ?>
<?php $component = $__componentOriginal18c21970322f9e5c938bc954620c12bb; ?>
<?php unset($__componentOriginal18c21970322f9e5c938bc954620c12bb); ?>
<?php endif; ?>
                            </div>
                            <div>
                                <?php if (isset($component)) { $__componentOriginale3da9d84bb64e4bc2eeebaafabfb2581 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginale3da9d84bb64e4bc2eeebaafabfb2581 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-label','data' => ['for' => 'pm_files','value' => __('Archivos (imagen, PDF o video)')]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-label'); ?>
<?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(['for' => 'pm_files','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(__('Archivos (imagen, PDF o video)'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginale3da9d84bb64e4bc2eeebaafabfb2581)): ?>
<?php $attributes = $__attributesOriginale3da9d84bb64e4bc2eeebaafabfb2581; ?>
<?php unset($__attributesOriginale3da9d84bb64e4bc2eeebaafabfb2581); ?>
<?php endif; ?>
<?php if (isset($__componentOriginale3da9d84bb64e4bc2eeebaafabfb2581)): ?>
<?php $component = $__componentOriginale3da9d84bb64e4bc2eeebaafabfb2581; ?>
<?php unset($__componentOriginale3da9d84bb64e4bc2eeebaafabfb2581); ?>
<?php endif; ?>
                                <input id="pm_files" name="files[]" type="file" multiple required
                                       accept=".jpg,.jpeg,.png,.gif,.webp,.pdf,.mp4,.webm,.mov,image/*,application/pdf,video/*"
                                       class="mt-1 block w-full text-sm text-slate-600 file:mr-4 file:rounded-lg file:border-0 file:bg-teal-600 file:px-4 file:py-2 file:text-sm file:font-semibold file:text-white" />
                                <?php if (isset($component)) { $__componentOriginalf94ed9c5393ef72725d159fe01139746 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf94ed9c5393ef72725d159fe01139746 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-error','data' => ['messages' => $errors->get('files'),'class' => 'mt-2']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-error'); ?>
<?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(['messages' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($errors->get('files')),'class' => 'mt-2']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf94ed9c5393ef72725d159fe01139746)): ?>
<?php $attributes = $__attributesOriginalf94ed9c5393ef72725d159fe01139746; ?>
<?php unset($__attributesOriginalf94ed9c5393ef72725d159fe01139746); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf94ed9c5393ef72725d159fe01139746)): ?>
<?php $component = $__componentOriginalf94ed9c5393ef72725d159fe01139746; ?>
<?php unset($__componentOriginalf94ed9c5393ef72725d159fe01139746); ?>
<?php endif; ?>
                                <?php if (isset($component)) { $__componentOriginalf94ed9c5393ef72725d159fe01139746 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalf94ed9c5393ef72725d159fe01139746 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-error','data' => ['messages' => $errors->get('files.*'),'class' => 'mt-2']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-error'); ?>
<?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(['messages' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($errors->get('files.*')),'class' => 'mt-2']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalf94ed9c5393ef72725d159fe01139746)): ?>
<?php $attributes = $__attributesOriginalf94ed9c5393ef72725d159fe01139746; ?>
<?php unset($__attributesOriginalf94ed9c5393ef72725d159fe01139746); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalf94ed9c5393ef72725d159fe01139746)): ?>
<?php $component = $__componentOriginalf94ed9c5393ef72725d159fe01139746; ?>
<?php unset($__componentOriginalf94ed9c5393ef72725d159fe01139746); ?>
<?php endif; ?>
                            </div>
                            <?php if (isset($component)) { $__componentOriginald411d1792bd6cc877d687758b753742c = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginald411d1792bd6cc877d687758b753742c = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.primary-button','data' => ['type' => 'submit']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('primary-button'); ?>
<?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(['type' => 'submit']); ?><?php echo e(__('Subir archivos')); ?> <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginald411d1792bd6cc877d687758b753742c)): ?>
<?php $attributes = $__attributesOriginald411d1792bd6cc877d687758b753742c; ?>
<?php unset($__attributesOriginald411d1792bd6cc877d687758b753742c); ?>
<?php endif; ?>
<?php if (isset($__componentOriginald411d1792bd6cc877d687758b753742c)): ?>
<?php $component = $__componentOriginald411d1792bd6cc877d687758b753742c; ?>
<?php unset($__componentOriginald411d1792bd6cc877d687758b753742c); ?>
<?php endif; ?>
                        </form>
                    <?php endif; ?>
                    <?php if($patient->mediaFiles->isEmpty()): ?>
                        <p class="text-sm text-slate-500"><?php echo e(__('No hay archivos en el expediente todavía.')); ?></p>
                    <?php else: ?>
                        <ul class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
                            <?php $__currentLoopData = $patient->mediaFiles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $file): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php ($u = $diskUrl($file->path)); ?>
                                <li class="overflow-hidden rounded-xl border border-slate-200 bg-slate-50/80 shadow-sm dark:border-slate-600 dark:bg-slate-900/40">
                                    <div class="relative h-32 w-full overflow-hidden bg-slate-200 dark:bg-slate-700">
                                        <?php if($file->isImage()): ?>
                                            <img src="<?php echo e($u); ?>" alt="" class="h-full w-full object-cover" loading="lazy" />
                                        <?php elseif($file->isPdf()): ?>
                                            <div class="flex h-full flex-col items-center justify-center gap-1 text-red-600">
                                                <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12" fill="currentColor" viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6zm-1 2l5 5h-5V4z"/></svg>
                                                <span class="text-xs font-bold">PDF</span>
                                            </div>
                                        <?php elseif($file->isVideo()): ?>
                                            <div class="flex h-full items-center justify-center text-violet-600">
                                                <svg xmlns="http://www.w3.org/2000/svg" class="h-14 w-14" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"/><path stroke-linecap="round" stroke-linejoin="round" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
                                            </div>
                                        <?php else: ?>
                                            <div class="flex h-full items-center justify-center text-slate-500">
                                                <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"/></svg>
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                    <div class="p-3">
                                        <p class="truncate text-xs font-medium text-slate-800 dark:text-slate-200" title="<?php echo e($file->original_name); ?>"><?php echo e($file->title ?: $file->original_name); ?></p>
                                        <p class="text-xs text-slate-500"><?php echo e($file->created_at->translatedFormat('d M Y H:i')); ?></p>
                                        <div class="mt-3 flex flex-wrap gap-2">
                                            <button type="button"
                                                    class="inline-flex flex-1 items-center justify-center gap-1.5 rounded-lg bg-teal-600 px-3 py-2 text-xs font-semibold text-white hover:bg-teal-700 sm:flex-initial"
                                                    @click="openPreview(<?php echo e(\Illuminate\Support\Js::from(['url' => str_replace('\\', '/', $u), 'title' => $file->original_name, 'mime' => $file->mime])); ?>)">
                                                <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>
                                                <?php echo e(__('Ver')); ?>

                                            </button>
                                            <a href="<?php echo e($u); ?>" download="<?php echo e($file->original_name); ?>"
                                               class="inline-flex flex-1 items-center justify-center gap-1.5 rounded-lg border border-slate-300 bg-white px-3 py-2 text-xs font-semibold text-slate-700 hover:bg-slate-50 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200 sm:flex-initial">
                                                <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/></svg>
                                                <?php echo e(__('Descargar')); ?>

                                            </a>
                                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('medical_records.edit')): ?>
                                                <form method="post" action="<?php echo e(route('clients.patients.media.destroy', [$client, $patient, $file])); ?>" class="inline"
                                                      onsubmit="return confirm(<?php echo \Illuminate\Support\Js::from(__('¿Eliminar este archivo?'))->toHtml() ?>);">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('delete'); ?>
                                                    <button type="submit" class="inline-flex items-center gap-1 rounded-lg px-2 py-2 text-xs font-semibold text-red-600 hover:bg-red-50 dark:hover:bg-red-950/30" title="<?php echo e(__('Eliminar')); ?>">
                                                        <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
                                                    </button>
                                                </form>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </ul>
                    <?php endif; ?>
                </div>
            <?php endif; ?>

            
            <div class="poskn-card p-6">
                <div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-4">
                    <h3 class="text-lg font-semibold text-slate-900"><?php echo e(__('Historia clínica')); ?></h3>
                    <div class="flex flex-wrap items-center gap-2">
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('medical_records.view')): ?>
                            <a href="<?php echo e(route('clients.patients.medical-records.index', [$client, $patient])); ?>"
                               class="inline-flex items-center gap-1.5 rounded-lg border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-800 hover:bg-teal-100">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 10h16M4 14h16M4 18h16"/></svg>
                                <?php echo e(__('Ver historial completo')); ?>

                            </a>
                        <?php endif; ?>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('medical_records.edit')): ?>
                            <a href="<?php echo e(route('clients.patients.medical-records.create', [$client, $patient])); ?>"
                               class="inline-flex items-center gap-2 rounded-xl bg-violet-600 px-4 py-2.5 text-sm font-bold !text-white shadow-lg shadow-violet-600/30 ring-2 ring-violet-800/20 hover:bg-violet-700 hover:!text-white focus:outline-none focus:ring-2 focus:ring-violet-500 focus:ring-offset-2">
                                <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 shrink-0 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4"/></svg>
                                <span class="text-white"><?php echo e(__('Nueva consulta')); ?></span>
                            </a>
                        <?php endif; ?>
                    </div>
                </div>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('medical_records.view')): ?>
                    <?php if($patient->medicalRecords->isEmpty()): ?>
                        <p class="text-sm text-slate-500"><?php echo e(__('Sin consultas registradas.')); ?></p>
                    <?php else: ?>
                        <ul class="divide-y divide-slate-200 text-sm">
                            <?php $__currentLoopData = $patient->medicalRecords; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $record): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <li class="py-3 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between">
                                    <div class="min-w-0 flex-1">
                                        <p class="font-semibold text-slate-900"><?php echo e($record->title ?: __('Consulta')); ?></p>
                                        <p class="text-slate-500">
                                            <?php echo e($record->recorded_at->translatedFormat('d M Y H:i')); ?>

                                            <?php if($record->author): ?>
                                                · <?php echo e($record->author->name); ?>

                                            <?php endif; ?>
                                            <?php if(($record->attachments_count ?? 0) > 0): ?>
                                                · <?php echo e($record->attachments_count); ?> <?php echo e($record->attachments_count === 1 ? __('adjunto') : __('adjuntos')); ?>

                                            <?php endif; ?>
                                        </p>
                                    </div>
                                    <div class="flex shrink-0 flex-wrap items-center gap-2">
                                        <a href="<?php echo e(route('clients.patients.medical-records.show', [$client, $patient, $record])); ?>"
                                           class="inline-flex items-center gap-1 rounded-lg bg-teal-600 px-3 py-1.5 text-xs font-semibold text-white shadow-sm hover:bg-teal-700">
                                            <svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path stroke-linecap="round" stroke-linejoin="round" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/></svg>
                                            <?php echo e(__('Ver')); ?>

                                        </a>
                                        <a href="<?php echo e(route('clients.patients.medical-records.print', [$client, $patient, $record])); ?>"
                                           target="_blank" rel="noopener"
                                           class="inline-flex items-center gap-1 rounded-lg border border-slate-300 bg-white px-3 py-1.5 text-xs font-semibold text-slate-700 shadow-sm hover:bg-slate-50 dark:border-slate-600 dark:bg-slate-800 dark:text-slate-200">
                                            <svg xmlns="http://www.w3.org/2000/svg" class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z"/></svg>
                                            <?php echo e(__('Imprimir')); ?>

                                        </a>
                                    </div>
                                </li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </ul>
                        <?php if($patient->medical_records_count > $patient->medicalRecords->count()): ?>
                            <p class="mt-3 text-sm text-slate-500">
                                <a href="<?php echo e(route('clients.patients.medical-records.index', [$client, $patient])); ?>" class="text-teal-700 hover:underline">
                                    <?php echo e(__('Ver las :total entradas', ['total' => $patient->medical_records_count])); ?>

                                </a>
                            </p>
                        <?php endif; ?>
                    <?php endif; ?>
                <?php else: ?>
                    <p class="text-sm text-slate-500"><?php echo e(__('No tiene permiso para ver el historial clínico.')); ?></p>
                <?php endif; ?>
            </div>

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('reservations.view')): ?>
                <div class="poskn-card p-6">
                    <div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between mb-4">
                        <h3 class="text-lg font-semibold text-slate-900"><?php echo e(__('Reservas de farmacia (caja)')); ?></h3>
                        <div class="flex flex-wrap gap-2">
                            <a href="<?php echo e(route('clients.patients.product-reservations.index', [$client, $patient])); ?>"
                               class="text-sm text-teal-700 hover:underline"><?php echo e(__('Ver reservas')); ?></a>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('reservations.manage')): ?>
                                <a href="<?php echo e(route('clients.patients.product-reservations.create', [$client, $patient])); ?>"
                                   class="inline-flex items-center rounded-xl bg-violet-600 px-3 py-2 text-sm font-medium text-white hover:bg-violet-500">
                                    <?php echo e(__('Nueva reserva para caja')); ?>

                                </a>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('appointments.manage')): ?>
                                <a href="<?php echo e(route('clinica.appointments.create', ['patient_id' => $patient->id])); ?>"
                                   class="inline-flex items-center rounded-xl bg-slate-700 px-3 py-2 text-sm font-medium text-white hover:bg-slate-600">
                                    <?php echo e(__('Nueva cita')); ?>

                                </a>
                            <?php endif; ?>
                        </div>
                    </div>
                    <p class="text-sm text-slate-500">
                        <?php echo e(__('El médico indica productos de farmacia clínica; en el POS se cargan y cobran cuando el cliente paga.')); ?>

                    </p>
                </div>
            <?php endif; ?>

            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('clients.manage')): ?>
                <form method="post" action="<?php echo e(route('clients.patients.destroy', [$client, $patient])); ?>" class="text-right"
                      onsubmit="return confirm(<?php echo \Illuminate\Support\Js::from(__('¿Eliminar este paciente?'))->toHtml() ?>);">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('delete'); ?>
                    <button type="submit" class="text-sm text-red-600 hover:underline">
                        <?php echo e(__('Eliminar paciente')); ?>

                    </button>
                </form>
            <?php endif; ?>

            <?php echo $__env->make('partials.file-preview-modal', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
        </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:\wamp64\www\vet\resources\views/patients/show.blade.php ENDPATH**/ ?>