<?php $__template->layout('Layout.main'); ?>
<?php $__template->section('title'); ?>تقرير التقييمات — <?= e($session['group_name'] ?? '') ?><?php $__template->endSection(); ?>
<?php $__template->section('page_actions'); ?>
<a href="/sessions/<?= $sessionId ?>" class="btn btn-outline">العودة للجلسة</a>
<?php $__template->endSection(); ?>
<?php $__template->section('content'); ?>

<!-- Session Info -->
<div class="card" style="padding:15px;margin-bottom:20px;display:flex;justify-content:space-between;align-items:center;">
    <div>
        <strong><?= e($session['group_name'] ?? '') ?></strong>
        <span style="font-size:13px;color:#6B7280;margin-right:10px;"><?= e($session['session_date'] ?? '') ?> | <?= e(substr($session['start_time'] ?? '', 0, 5)) ?>-<?= e(substr($session['end_time'] ?? '', 0, 5)) ?></span>
    </div>
    <div style="font-size:13px;color:#6B7280;">المدرب: <?= e($session['coach_name'] ?? '') ?></div>
</div>

<!-- Averages -->
<?php if (!empty($averages) && (int) ($averages['total_responses'] ?? 0) > 0): ?>
<div style="display:grid;grid-template-columns:repeat(4,1fr);gap:15px;margin-bottom:20px;">
    <div class="card" style="padding:20px;text-align:center;">
        <div style="font-size:28px;font-weight:700;color:#F59E0B;"><?= $averages['avg_rating'] ?? '0' ?></div>
        <div style="font-size:12px;color:#6B7280;">التقييم العام</div>
        <div style="font-size:11px;color:#9CA3AF;">(<?= $averages['total_responses'] ?> تقييم)</div>
    </div>
    <div class="card" style="padding:20px;text-align:center;">
        <div style="font-size:28px;font-weight:700;color:#059669;"><?= $averages['avg_enjoyment'] ?? '0' ?></div>
        <div style="font-size:12px;color:#6B7280;">الاستمتاع</div>
    </div>
    <div class="card" style="padding:20px;text-align:center;">
        <div style="font-size:28px;font-weight:700;color:#7C3AED;"><?= $averages['avg_difficulty'] ?? '0' ?></div>
        <div style="font-size:12px;color:#6B7280;">الصعوبة</div>
    </div>
    <div class="card" style="padding:20px;text-align:center;">
        <div style="font-size:14px;">
            <span style="color:#059669;">⚡ <?= (int) ($averages['energy_high'] ?? 0) ?></span>
            <span style="color:#F59E0B;margin:0 5px;">🔋 <?= (int) ($averages['energy_medium'] ?? 0) ?></span>
            <span style="color:#DC2626;">😴 <?= (int) ($averages['energy_low'] ?? 0) ?></span>
        </div>
        <div style="font-size:12px;color:#6B7280;margin-top:8px;">مستوى الطاقة</div>
    </div>
</div>
<?php else: ?>
<div class="card" style="padding:30px;text-align:center;color:#6B7280;margin-bottom:20px;">لا توجد تقييمات لهذه الجلسة</div>
<?php endif; ?>

<!-- Individual Feedback -->
<?php if (!empty($feedback)): ?>
<div class="card" style="padding:20px;">
    <h4 style="margin-bottom:15px;">التقييمات الفردية</h4>
    <?php foreach ($feedback as $fb): ?>
    <div style="padding:12px;border-bottom:1px solid #F3F4F6;">
        <div style="display:flex;justify-content:space-between;align-items:center;">
            <div>
                <span style="font-weight:600;"><?= e($fb['player_name'] ?? '') ?></span>
                <span style="margin-right:10px;color:#F59E0B;"><?= str_repeat('★', (int) $fb['rating']) ?><?= str_repeat('☆', 5 - (int) $fb['rating']) ?></span>
            </div>
            <div style="font-size:12px;color:#6B7280;">
                استمتاع: <?= $fb['enjoyment_level'] ?>/5 | صعوبة: <?= $fb['difficulty_level'] ?>/5 | طاقة: <?= $fb['energy_level'] === 'high' ? '⚡' : ($fb['energy_level'] === 'medium' ? '🔋' : '😴') ?>
            </div>
        </div>
        <?php if (!empty($fb['comments_ar'])): ?>
        <div style="font-size:13px;color:#4B5563;margin-top:6px;padding:8px;background:#F9FAFB;border-radius:4px;"><?= e($fb['comments_ar']) ?></div>
        <?php endif; ?>
    </div>
    <?php endforeach; ?>
</div>
<?php endif; ?>
<?php $__template->endSection(); ?>
