@php $data = $report->report_data ?? []; $score = is_array($data['score_cognitivo'] ?? null) ? $data['score_cognitivo'] : []; $semaforo = is_array($data['semaforo'] ?? null) ? $data['semaforo'] : []; $variables = is_array($data['variables_clave'] ?? null) ? $data['variables_clave'] : []; $diasPeores = is_array($data['ranking_dias_peores'] ?? null) ? $data['ranking_dias_peores'] : []; $predictivo = is_array($data['modelo_predictivo'] ?? null) ? $data['modelo_predictivo'] : []; $perfil = is_array($data['perfil_cognitivo'] ?? null) ? $data['perfil_cognitivo'] : []; $patron = is_array($data['patron_temporal'] ?? null) ? $data['patron_temporal'] : []; $resumen = $data['resumen_ejecutivo'] ?? ''; $evolucion = $data['evolucion'] ?? []; $scoreValor = (int)($score['valor'] ?? 0); $semaforoColor = $semaforo['color'] ?? 'verde'; $semBg = match($semaforoColor){ 'amarillo'=>'#F59E0B','rojo'=>'#EF4444',default=>'#10B981' }; $semText = match($semaforoColor){ 'amarillo'=>'Fatiga incipiente','rojo'=>'Mal día cognitivo',default=>'Buen rendimiento' }; $desglose = is_array($score['desglose'] ?? null) ? $score['desglose'] : []; $diasSemana = ['','Lun','Mar','Mié','Jue','Vie','Sáb','Dom']; $diasSemanaFull = ['','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado','Domingo']; $estadoActual = is_array($data['estado_actual'] ?? null) ? $data['estado_actual'] : []; $tendenciaReciente= is_array($data['tendencia_reciente'] ?? null) ? $data['tendencia_reciente'] : []; $calendarioOptimo = is_array($data['calendario_optimo'] ?? null) ? $data['calendario_optimo'] : []; $recomendacionIA = is_array($data['recomendacion_ia'] ?? null) ? $data['recomendacion_ia'] : []; $eaSem = $estadoActual['semaforo'] ?? ''; $eaBg = match($eaSem){ 'amarillo'=>'#F59E0B','rojo'=>'#EF4444',default=>'#10B981' }; $tendDir = $tendenciaReciente['direccion'] ?? ''; $tendColor= match($tendDir){ 'empeorando'=>'#EF4444','estable'=>'#6B7280',default=>'#10B981' }; // Iconos compatibles con Font Awesome 5 $tendIcon = match($tendDir){ 'empeorando'=>'fa-long-arrow-alt-down','estable'=>'fa-minus',default=>'fa-long-arrow-alt-up' }; $recUrgencia= $recomendacionIA['urgencia'] ?? 'baja'; $recColor = match($recUrgencia){ 'alta'=>'#EF4444','media'=>'#F59E0B',default=>'#10B981' }; $recBgLight = match($recUrgencia){ 'alta'=>'#fef2f2','media'=>'#fffbeb',default=>'#f0fdf4' }; $recAccion= $recomendacionIA['accion'] ?? ''; $recIcon = match($recAccion){ 'descanso'=>'fa-bed','competicion'=>'fa-trophy','precaucion'=>'fa-exclamation-triangle',default=>'fa-check-circle' }; $circumference = round(2 * M_PI * 46, 2); $ringOffset = round($circumference * (1 - $scoreValor / 100), 2); @endphp {{-- HERO ─────────────────────────────────────────── --}}
{{-- Datos del jugador --}}
Informe Cognitivo KOR
@if($user)
{{ $user->first_name }} {{ $user->last_name }}
Informe generado el {{ $report->created_at->format('d/m/Y \a \l\a\s H:i') }}
@if($user->association) {{ $user->association }} @endif @if($user->position) {{ $user->position }} @endif @if($user->age) {{ $user->age }} años @endif @if($user->group) {{ $user->group }} @endif
@else
Análisis Cognitivo
{{ $report->created_at->format('d/m/Y H:i') }}
@endif @if($resumen)

{{ $resumen }}

@endif
{{-- Score + semáforo --}}
{{ $scoreValor }} Score
@if($semaforoColor === 'verde') 🟢 @elseif($semaforoColor === 'amarillo') 🟡 @else 🔴 @endif {{ strtoupper($semText) }}
{{-- CONTENIDO ──────────────────────────────────────── --}}
{{-- ESTADO ACTUAL + TENDENCIA + RECOMENDACION --}} {{-- flex-wrap para que si solo hay 1 o 2 tarjetas no queden huecos --}} @if(!empty($estadoActual) || !empty($tendenciaReciente) || !empty($recomendacionIA))
@if(!empty($estadoActual))
Estado actual @if(!empty($estadoActual['basado_en'])) — últimos {{ $estadoActual['basado_en'] }} tests @endif
{{ $estadoActual['titulo'] ?? strtoupper($eaSem) }}
@if(!empty($estadoActual['comparativa']))
{{ $estadoActual['comparativa'] }}
@endif @if(!empty($estadoActual['descripcion']))

{{ $estadoActual['descripcion'] }}

@endif
@endif @if(!empty($tendenciaReciente) && !empty($tendenciaReciente['direccion']))
Tendencia 2 semanas
{{ ucfirst($tendDir) }}
@if(!empty($tendenciaReciente['cambio_rendimiento_pct']))
Rendimiento: {{ $tendenciaReciente['cambio_rendimiento_pct'] > 0 ? '+' : '' }}{{ $tendenciaReciente['cambio_rendimiento_pct'] }}% @if(!empty($tendenciaReciente['cambio_tiempo_pct']))  · Tiempo: {{ $tendenciaReciente['cambio_tiempo_pct'] > 0 ? '+' : '' }}{{ $tendenciaReciente['cambio_tiempo_pct'] }}% @endif
@endif @if(!empty($tendenciaReciente['descripcion']))

{{ $tendenciaReciente['descripcion'] }}

@endif
@endif @if(!empty($recomendacionIA))
Recomendación IA {{ strtoupper($recUrgencia) }}
{{ $recomendacionIA['titulo'] ?? ucfirst($recAccion) }}
@if(!empty($recomendacionIA['descripcion']))

{{ $recomendacionIA['descripcion'] }}

@endif
@endif
@endif {{-- Calendario semanal --}} @if(!empty($calendarioOptimo) && !empty($calendarioOptimo['rendimiento_por_dia']))
Cuándo rinde mejor — Calendario semanal
@if(!empty($calendarioOptimo['recomendacion_horaria'])) {{ $calendarioOptimo['recomendacion_horaria'] }} @endif
@foreach(range(1,7) as $d) @php $dVal = (int)(($calendarioOptimo['rendimiento_por_dia'][$d] ?? $calendarioOptimo['rendimiento_por_dia'][(string)$d] ?? 0)); $dColor = $dVal >= 80 ? '#10B981' : ($dVal >= 65 ? '#F59E0B' : '#EF4444'); $isBest = ($calendarioOptimo['mejor_dia'] ?? null) == $d; $isWorst= ($calendarioOptimo['peor_dia'] ?? null) == $d; @endphp
{{ $diasSemana[$d] }} @if($isBest) @endif @if($isWorst) @endif
{{ $dVal > 0 ? $dVal : '—' }}
@endforeach
@if(!empty($calendarioOptimo['mejor_dia'])) ★ Mejor: {{ $diasSemanaFull[$calendarioOptimo['mejor_dia']] ?? '' }} @endif @if(!empty($calendarioOptimo['peor_dia'])) ↓ Peor: {{ $diasSemanaFull[$calendarioOptimo['peor_dia']] ?? '' }} @endif @if(!empty($calendarioOptimo['mejor_franja'])) {{ ucfirst($calendarioOptimo['mejor_franja']) }} @endif
@endif {{-- Desglose score --}} @if(!empty($desglose))
Desglose del Score Cognitivo
@foreach($desglose as $key => $item) @php $val = (int)($item['valor'] ?? 0); $peso = round(($item['peso'] ?? 0)*100); $bc = match($key){'rendimiento'=>'#3699FF','tiempos'=>'#10B981','movimiento'=>'#8B5CF6',default=>'#6B7280'}; $ico = match($key){'rendimiento'=>'fa-trophy','tiempos'=>'fa-clock','movimiento'=>'fa-running',default=>'fa-chart-bar'}; @endphp
{{ ucfirst($key) }} peso {{ $peso }}% {{ $val }}/100
@if(!empty($item['descripcion']))
{{ $item['descripcion'] }}
@endif
@endforeach @if(!empty($semaforo['descripcion']))
{{ $semaforo['descripcion'] }}
@endif
@endif {{-- Evolución temporal --}} @if(!empty($chartEvolution['labels']))
Evolución temporal del rendimiento
@if(!empty($evolucion['tendencia'])) @php $tend = $evolucion['tendencia']; $tc = match($tend){'mejorando'=>'#10B981','empeorando'=>'#EF4444',default=>'#6B7280'}; @endphp
{{ ucfirst($tend) }}
@endif
@endif {{-- Variables clave --}} @if(!empty($variables))
Variables clave para este jugador
@foreach($variables as $var) @php $imp = $var['impacto'] ?? ''; $ic = match($imp){ 'alto'=>'#EF4444','medio'=>'#F59E0B',default=>'#3699FF' }; $ibg= match($imp){ 'alto'=>'#fef2f2','medio'=>'#fffbeb',default=>'#eff6ff' }; @endphp
{{ strtoupper($imp) }}
{{ $var['variable'] ?? '' }}
{{ $var['descripcion'] ?? '' }}
@endforeach
@endif {{-- Modelo predictivo --}} @if(!empty($predictivo['descripcion']))
Modelo Predictivo — Detectar fatiga antes del fallo
PREDICCIÓN TEMPRANA
@if(!empty($predictivo['predictor_principal']))
Predictor principal
{{ ucfirst($predictivo['predictor_principal']) }}
@endif

{{ $predictivo['descripcion'] }}

@if(!empty($predictivo['descripcion_prediccion']))

{{ $predictivo['descripcion_prediccion'] }}

@endif @if(!empty($predictivo['señales_alerta_temprana']))
Señales de alerta
@foreach($predictivo['señales_alerta_temprana'] as $s)
{{ $s }}
@endforeach @endif
@if(!empty($predictivo['umbral_tiempo_alerta']) || !empty($predictivo['umbral_rotacion_alerta']))
@if(!empty($predictivo['umbral_tiempo_alerta']))
Umbral tiempo
{{ $predictivo['umbral_tiempo_alerta'] }}s
respuesta media
@endif @if(!empty($predictivo['umbral_rotacion_alerta']))
Umbral rotación
{{ $predictivo['umbral_rotacion_alerta'] }}%
tiempo cabeza
@endif
@endif
@endif {{-- Patrón temporal + peores días --}}
@if(!empty($patron))
Patrón temporal
Mejor día
{{ $diasSemanaFull[$patron['mejor_dia_semana'] ?? 0] ?? 'N/A' }}
Peor día
{{ $diasSemanaFull[$patron['peor_dia_semana'] ?? 0] ?? 'N/A' }}
Mejor hora
{{ ucfirst($patron['mejor_hora'] ?? 'N/A') }}
@if(!empty($patron['descripcion']))

{{ $patron['descripcion'] }}

@endif
@endif @if(!empty($diasPeores))
Ranking de peores días
@foreach($diasPeores as $i => $dia) @php try { $fd = isset($dia['fecha']) ? \Carbon\Carbon::parse($dia['fecha'])->format('d/m/Y') : 'N/A'; } catch(\Exception $e) { $fd = 'N/A'; } @endphp
{{ $i+1 }}
{{ $fd }}
{{ $dia['motivo'] ?? '' }}
{{ $dia['score'] ?? '?' }}/100
@endforeach
@endif
{{-- Perfil cognitivo --}} @if(!empty($perfil))
Fortalezas
@foreach(is_array($perfil['fortalezas'] ?? null) ? $perfil['fortalezas'] : [] as $f)
{{ $f }}
@endforeach
Áreas de mejora
@foreach(is_array($perfil['areas_mejora'] ?? null) ? $perfil['areas_mejora'] : [] as $a)
{{ $a }}
@endforeach @if(!empty($perfil['descripcion_general']))

{{ $perfil['descripcion_general'] }}

@endif
@endif