<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>Evolución Clínica</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: DejaVu Sans, sans-serif; font-size: 10px; color: #1a1a1a; }
        .page { padding: 15mm 20mm; }
        .header { border-bottom: 2px solid #4f46e5; padding-bottom: 10px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: flex-start; }
        .company-name { font-size: 16px; font-weight: bold; color: #4f46e5; }
        .company-info { font-size: 9px; color: #666; margin-top: 2px; line-height: 1.4; }
        .doc-title h1 { font-size: 13px; font-weight: bold; color: #4f46e5; text-align: right; }
        .doc-title p { font-size: 9px; color: #888; text-align: right; margin-top: 2px; }

        .info-grid { display: flex; gap: 10px; margin-bottom: 14px; }
        .info-box { flex: 1; background: #f8f9ff; border: 1px solid #e0e7ff; border-radius: 4px; padding: 8px; }
        .info-box h3 { font-size: 8px; font-weight: bold; color: #4f46e5; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid #e0e7ff; padding-bottom: 3px; margin-bottom: 5px; }
        .info-row { font-size: 9px; margin-bottom: 2px; }
        .info-label { color: #888; }
        .info-value { font-weight: 500; }

        .section { margin-bottom: 12px; }
        .section h2 { font-size: 10px; font-weight: bold; color: #374151; background: #f3f4f6; padding: 4px 8px; border-left: 3px solid #4f46e5; margin-bottom: 6px; }
        .section p { font-size: 10px; line-height: 1.5; padding: 0 8px; white-space: pre-wrap; }

        .vitals-grid { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px; }
        .vital-item { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 4px; padding: 4px 8px; text-align: center; min-width: 60px; }
        .vital-value { font-size: 11px; font-weight: bold; color: #1d4ed8; }
        .vital-label { font-size: 8px; color: #3b82f6; }

        .diagnoses-list { padding: 0 8px; }
        .diag-item { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
        .diag-badge { padding: 1px 5px; border-radius: 10px; font-size: 8px; font-weight: bold; white-space: nowrap; }
        .badge-primary { background: #fee2e2; color: #b91c1c; }
        .badge-secondary { background: #fef3c7; color: #92400e; }
        .badge-impression { background: #e5e7eb; color: #374151; }
        .diag-name { font-size: 10px; font-weight: 500; }
        .diag-code { font-size: 8px; color: #888; }

        .signed-box { margin-top: 20px; border-top: 1px solid #e5e7eb; padding-top: 14px; display: flex; justify-content: flex-end; }
        .sig-block { text-align: center; }
        .sig-line { width: 150px; border-bottom: 1px solid #333; height: 28px; margin: 0 auto 4px; }
        .sig-name { font-size: 9px; font-weight: bold; }
        .sig-label { font-size: 8px; color: #888; }

        .footer { margin-top: 16px; border-top: 1px solid #e5e7eb; padding-top: 6px; text-align: center; font-size: 8px; color: #aaa; }
    </style>
</head>
<body>
<div class="page">
    <div class="header">
        <div>
            <div class="company-name"><?php echo e($company?->name ?? 'Centro Médico'); ?></div>
            <div class="company-info">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($company?->address): ?><?php echo e($company->address); ?><br><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($company?->phone): ?>Tel: <?php echo e($company->phone); ?><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        </div>
        <div class="doc-title">
            <h1>EVOLUCIÓN CLÍNICA</h1>
            <p><?php echo e($evolution->created_at->format('d \d\e F \d\e Y')); ?></p>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($evolution->isSigned()): ?><p style="color:#16a34a;">✓ FIRMADA</p><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    </div>

    <div class="info-grid">
        <div class="info-box">
            <h3>Paciente</h3>
            <div class="info-row"><span class="info-label">Nombre: </span><span class="info-value"><?php echo e($patient->fullName()); ?></span></div>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($patient->birthdate): ?><div class="info-row"><span class="info-label">Edad: </span><span class="info-value"><?php echo e($patient->age()); ?> años (<?php echo e($patient->birthdate->format('d/m/Y')); ?>)</span></div><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($patient->document_number): ?><div class="info-row"><span class="info-label">Doc: </span><span class="info-value"><?php echo e(strtoupper($patient->document_type ?? '')); ?> <?php echo e($patient->document_number); ?></span></div><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($patient->blood_type): ?><div class="info-row"><span class="info-label">Sangre: </span><span class="info-value"><?php echo e($patient->blood_type); ?></span></div><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
        <div class="info-box">
            <h3>Profesional</h3>
            <div class="info-row"><span class="info-label">Nombre: </span><span class="info-value"><?php echo e($evolution->employee?->user?->name ?? '—'); ?></span></div>
            <div class="info-row"><span class="info-label">Fecha: </span><span class="info-value"><?php echo e($evolution->created_at->format('d/m/Y H:i')); ?></span></div>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($evolution->next_control_date): ?><div class="info-row"><span class="info-label">Próx. control: </span><span class="info-value"><?php echo e($evolution->next_control_date->format('d/m/Y')); ?></span></div><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    </div>

    <div class="section">
        <h2>MOTIVO DE CONSULTA</h2>
        <p><?php echo e($evolution->consultation_reason); ?></p>
    </div>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($evolution->current_illness): ?>
    <div class="section">
        <h2>ENFERMEDAD ACTUAL</h2>
        <p><?php echo e($evolution->current_illness); ?></p>
    </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($evolution->vital_signs): ?>
    <div class="section">
        <h2>SIGNOS VITALES</h2>
        <?php
            $vsLabels = ['weight'=>'Peso (kg)','height'=>'Talla (cm)','bmi'=>'IMC','temperature'=>'Temp °C','systolic_bp'=>'P.A. Sist.','diastolic_bp'=>'P.A. Diast.','heart_rate'=>'F.C. lpm','respiratory_rate'=>'F.R.','oxygen_sat'=>'Sat. O₂'];
        ?>
        <div class="vitals-grid">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $vsLabels; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(!empty($evolution->vital_signs[$key])): ?>
                    <div class="vital-item">
                        <div class="vital-value"><?php echo e($evolution->vital_signs[$key]); ?></div>
                        <div class="vital-label"><?php echo e($label); ?></div>
                    </div>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($evolution->physical_exam): ?>
    <div class="section">
        <h2>EXAMEN FÍSICO</h2>
        <p><?php echo e($evolution->physical_exam); ?></p>
    </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($evolution->diagnoses->count()): ?>
    <div class="section">
        <h2>DIAGNÓSTICOS</h2>
        <div class="diagnoses-list">
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $evolution->diagnoses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $diag): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="diag-item">
                <span class="diag-badge <?php echo e($diag->type === 'primary' ? 'badge-primary' : ($diag->type === 'secondary' ? 'badge-secondary' : 'badge-impression')); ?>">
                    <?php echo e($diag->typeLabel()); ?>

                </span>
                <div>
                    <div class="diag-name"><?php echo e($diag->name); ?></div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($diag->cie10_code): ?><div class="diag-code">CIE-10: <?php echo e($diag->cie10_code); ?></div><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
        </div>
    </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($evolution->treatment_plan): ?>
    <div class="section">
        <h2>PLAN DE TRATAMIENTO</h2>
        <p><?php echo e($evolution->treatment_plan); ?></p>
    </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($evolution->recommendations): ?>
    <div class="section">
        <h2>RECOMENDACIONES</h2>
        <p><?php echo e($evolution->recommendations); ?></p>
    </div>
    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

    <div class="signed-box">
        <div class="sig-block">
            <div class="sig-line"></div>
            <div class="sig-name"><?php echo e($evolution->employee?->user?->name ?? 'Profesional tratante'); ?></div>
            <div class="sig-label">Firma</div>
        </div>
    </div>

    <div class="footer">
        Generado el <?php echo e(now()->format('d/m/Y H:i')); ?> — <?php echo e($company?->name); ?>

        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($evolution->isSigned()): ?> | Firmado el <?php echo e($evolution->signed_at->format('d/m/Y')); ?> por <?php echo e($evolution->signer?->name); ?><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
    </div>
</div>
</body>
</html>
<?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/CitasSoft/resources/views/pdf/evolution.blade.php ENDPATH**/ ?>