<?php include app()->basePath('app/Views/partials/header.php'); ?>

<section class="panel">
    <p class="eyebrow">Comunicacao</p>
    <h1>Minhas perguntas</h1>
    <p>Acompanhe as respostas dos instrutores e administradores.</p>

    <div class="question-list">
        <?php if (!$questions): ?>
            <div class="sub-panel"><p>Ainda nao fez perguntas.</p></div>
        <?php endif; ?>

        <?php foreach ($questions as $question): ?>
            <article class="question-card">
                <div class="question-head">
                    <div>
                        <strong><?= e($question['course_title']) ?></strong>
                        <span class="muted"><?= $question['lesson_title'] ? e($question['lesson_title']) : 'Curso' ?></span>
                    </div>
                    <span class="badge <?= e($question['status']) ?>"><?= $question['status'] === 'answered' ? 'Respondida' : 'Aberta' ?></span>
                </div>
                <p><?= nl2br(e($question['body'])) ?></p>
                <span class="muted"><?= e(format_date($question['created_at'])) ?></span>

                <?php if (!empty($question['answer'])): ?>
                    <div class="answer-box">
                        <strong><?= e($question['answered_by_name']) ?></strong>
                        <p><?= nl2br(e($question['answer'])) ?></p>
                        <span class="muted"><?= e(format_date($question['answered_at'])) ?></span>
                    </div>
                <?php endif; ?>
            </article>
        <?php endforeach; ?>
    </div>
</section>

<?php include app()->basePath('app/Views/partials/footer.php'); ?>
