<?= $this->extend('layout/email_layout') ?>

<?= $this->section('content') ?>
<div style="font-size:16px; font-family:Arial, Helvetica, sans-serif; color:#333;">
  <p style="margin:0 0 12px 0;line-height:1.5;">
    Dear <?= esc($parent_name ?? 'Parent/Guardian') ?>,
  </p>

  <p style="margin:0 0 12px 0;line-height:1.5;">
    We are reaching out about <strong><?= esc($student_name ?? 'your student') ?></strong>
    <?php if (!empty($class_section_name)): ?>(<?= esc($class_section_name) ?>)<?php endif; ?>
    <?php if (!empty($semester) || !empty($school_year)): ?>
      for <?= esc(trim(($semester ?? '') . ' ' . ($school_year ?? ''))) ?>.
    <?php endif; ?>
    The current semester performance is below 60.
  </p>

  <?php $scores = is_array($scores ?? null) ? $scores : []; ?>
  <table style="width:100%; border-collapse:collapse; margin:12px 0; font-size:14px;">
    <thead>
      <tr>
        <th style="border:1px solid #ddd; padding:6px; text-align:left;">Item</th>
        <th style="border:1px solid #ddd; padding:6px; text-align:left;">Score</th>
      </tr>
    </thead>
    <tbody>
      <?php
        $rows = [
          'Homework Avg' => $scores['homework_avg'] ?? null,
          'Project Avg' => $scores['project_avg'] ?? null,
          'Participation' => $scores['participation_score'] ?? null,
          'Test Avg' => $scores['test_avg'] ?? null,
          'PTAP Score' => $scores['ptap_score'] ?? null,
          'Attendance' => $scores['attendance_score'] ?? null,
          'Midterm Score' => $scores['midterm_exam_score'] ?? null,
          'Semester Score' => $scores['semester_score'] ?? null,
        ];
      ?>
      <?php foreach ($rows as $label => $val): ?>
        <tr>
          <td style="border:1px solid #ddd; padding:6px;"><?= esc($label) ?></td>
          <td style="border:1px solid #ddd; padding:6px;"><?= esc($val === null || $val === '' ? '—' : number_format((float)$val, 2, '.', '')) ?></td>
        </tr>
      <?php endforeach; ?>
    </tbody>
  </table>

  <?php if (!empty($comment)): ?>
    <p style="margin:0 0 12px 0;line-height:1.5;">
      <strong>Teacher Comment:</strong> <?= esc($comment) ?>
    </p>
  <?php endif; ?>

  <p style="margin:0 0 12px 0;line-height:1.5;">
    Please contact the school to discuss support plans for your child.
  </p>

  <p style="margin:0;line-height:1.5;">
    Thank you,<br>
    Al Rahma Sunday School
  </p>
</div>
<?= $this->endSection() ?>
