@extends('admin.layout') @section('title', 'Wellness') @section('content') @php $zoneConfig = [ 'green' => ['label' => 'Groen', 'color' => '#22c55e', 'bg' => '#f0fdf4', 'border' => '#bbf7d0'], 'yellow' => ['label' => 'Geel', 'color' => '#eab308', 'bg' => '#fefce8', 'border' => '#fef08a'], 'orange' => ['label' => 'Oranje', 'color' => '#f97316', 'bg' => '#fff7ed', 'border' => '#fed7aa'], 'red' => ['label' => 'Rood', 'color' => '#ef4444', 'bg' => '#fef2f2', 'border' => '#fecaca'], ]; $maxEmotion = $topEmotions->max('total') ?: 1; $mbtiMax = $mbtiStats->max('total') ?: 1; @endphp
{{-- Emotion overview --}}

{{ __('Emotions') }}

{{-- Totals --}}

{{ __('Total logs') }}

{{ number_format($emotionTotal) }}

{{ __('Unique users') }}

{{ number_format($emotionUsers) }}

{{-- Zone cards --}}
@foreach($zoneConfig as $key => $cfg) @php $zoneTotal = $emotionByZone->get($key)?->total ?? 0; @endphp
{{ $cfg['label'] }}

{{ number_format($zoneTotal) }}

@if($emotionTotal > 0)

{{ round($zoneTotal / $emotionTotal * 100) }}%

@endif
@endforeach
{{-- 30-day trend --}}

{{ __('Last 30 days') }}

@php $trendDays = collect(); $trendMax = 1; for ($i = 29; $i >= 0; $i--) { $day = now()->subDays($i)->format('Y-m-d'); $count = $emotionTrend->get($day, 0); $trendDays->push(['day' => $day, 'count' => $count]); if ($count > $trendMax) $trendMax = $count; } @endphp
@foreach($trendDays as $td) @php $pct = round($td['count'] / $trendMax * 100); @endphp
@endforeach
{{ now()->subDays(29)->format('d M') }} {{ now()->format('d M') }}
{{-- Top emotions + recent logs --}}

{{ __('Top emotions') }}

@foreach($topEmotions as $em)
{{ $em->emotion_key }} {{ number_format($em->total) }}
@endforeach

{{ __('Recent logs') }}

@foreach($recentLogs as $log)
@php $zc = $zoneConfig[$log->zone] ?? ['color'=>'#6b7280','bg'=>'#f9fafb','border'=>'#e5e7eb']; @endphp
{{ $log->emotion_key }} @if($log->user) #{{ $log->user->id }} @endif{{ $log->user?->name ?? '—' }} · {{ $log->logged_at?->diffForHumans() }}
@endforeach
{{-- MBTI --}}

{{ __('MBTI') }}

{{-- Type distribution --}}

{{ __('Type distribution') }} ({{ number_format($mbtiTotal) }} {{ __('total') }})

@foreach($mbtiStats as $ms)
{{ $ms->mbti_type }} {{ $ms->total }}
@endforeach
{{-- Dimension breakdown --}}

{{ __('Dimension breakdown') }}

@foreach($mbtiDimensions as $dim => $counts) @php $keys = array_keys($counts); $total = array_sum($counts); $pctA = $total > 0 ? round($counts[$keys[0]] / $total * 100) : 50; $pctB = 100 - $pctA; @endphp
{{ $keys[0] }} ({{ $counts[$keys[0]] }}) {{ $keys[1] }} ({{ $counts[$keys[1]] }})
{{ $pctA }}% {{ $pctB }}%
@endforeach
@endsection