@php
    use App\Domain\Training\Support\GroupColor;
@endphp

<x-print.sheet
    :title="__('بطاقات المدربين')"
    :subtitle="$dayLabel"
    size="A4 portrait"
    :meta="[
        __('الفرع') => $branchName ?? '—',
        __('التاريخ') => $date->format('Y-m-d'),
        __('المدربون') => count($trainers),
    ]">

    @push('styles')
    <style>
        /* Two per row, cut along the dashed line — a trainer wants something
           pocket-sized, not an A3 off the wall. */
        .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 10px; }
        .card {
            break-inside: avoid;
            border: 1px dashed #9CA3AF;
            padding: 10px 12px;
            min-height: 62mm;
        }
        .card h2 { margin: 0 0 2px; font-size: 15px; font-weight: 900; }
        .card .role { font-size: 10.5px; color: #6B7280; margin-bottom: 8px; }
        .slot {
            display: flex;
            gap: 8px;
            padding: 5px 0;
            border-top: 1px solid #F3F4F6;
        }
        .slot .when {
            font-weight: 700;
            font-size: 12px;
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
            min-width: 84px;
        }
        .slot .what b { display: block; font-size: 11.5px; }
        .slot .what span { font-size: 10px; color: #4B5563; }
        .rail { width: 4px; border-radius: 2px; flex: none; }
        .none { font-size: 11px; color: #9CA3AF; padding: 10px 0; }
    </style>
    @endpush

    <div class="cards">
        @foreach($trainers as $trainer)
            <div class="card">
                <h2>{{ $trainer['name'] }}</h2>
                <div class="role num">{{ $dayLabel }} · {{ $date->format('Y-m-d') }}</div>

                @forelse($trainer['slots'] as $slot)
                    <div class="slot">
                        <span class="rail" style="background: {{ GroupColor::for($slot['group_id']) }}"></span>
                        <span class="when">{{ $slot['start'] }}–{{ $slot['end'] }}</span>
                        <span class="what">
                            <b>{{ $slot['group'] }}</b>
                            <span>
                                {{ $slot['facility'] }}@if($slot['segments']) · {{ $slot['segments'] }}@endif
                                @if($slot['count'] !== null) · {{ $slot['count'] }} {{ __('لاعب') }} @endif
                            </span>
                        </span>
                    </div>
                @empty
                    <p class="none">{{ __('لا توجد حصص اليوم') }}</p>
                @endforelse
            </div>
        @endforeach
    </div>
</x-print.sheet>
