<?php
/**
 * Branch Exam — Thank You / Results Pending Page
 *
 * Shown after the student submits their exam, when the branch admin has set
 * show_result = OFF. The student sees only a "thanks, results will be
 * published later" page — no score is revealed.
 */
$bp = defined('BASE_PATH') ? BASE_PATH : '/gmind';
$exam = $exam ?? [];
$userName = $userName ?? '';
$lang = function_exists('getCurrentLocale') ? getCurrentLocale() : 'en';
$isHindi = $lang === 'hi';
$needsHindi = in_array($exam['language'] ?? 'en', ['hi','both'], true);

include __DIR__ . '/../layouts/header.php';
?>
<style>
.thank-you-wrap {
    max-width: 680px; margin: 60px auto; padding: 0 20px; text-align: center;
}
.thank-you-card {
    background: #fff; border-radius: 18px; padding: 48px 36px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.08);
    border-top: 6px solid #16a085;
}
.thank-you-icon {
    width: 100px; height: 100px;
    background: linear-gradient(135deg, #27ae60, #1e7e44);
    border-radius: 50%; display: inline-flex;
    align-items: center; justify-content: center;
    color: #fff; font-size: 3rem; margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(39,174,96,0.35);
}
.thank-you-title {
    margin: 0 0 12px; font-size: 1.7rem;
    color: #0d3b3b; font-weight: 700;
}
.thank-you-meta {
    margin: 0 0 24px; font-size: 0.95rem; color: #666;
}
.thank-you-info {
    background: #eaf0fb; border-radius: 10px; padding: 18px;
    margin: 20px 0; font-size: 0.9rem; color: #1a4fa0;
    line-height: 1.6; text-align: left;
}
.thank-you-actions {
    margin-top: 28px; display: flex; gap: 10px;
    justify-content: center; flex-wrap: wrap;
}
</style>

<div class="container thank-you-wrap">
    <div class="thank-you-card">
        <div class="thank-you-icon">✓</div>

        <h1 class="thank-you-title">
            <?= $isHindi ? 'आपकी परीक्षा सफलतापूर्वक जमा हो गई!' : 'Your exam has been submitted successfully!' ?>
        </h1>

        <p class="thank-you-meta">
            <?= $isHindi ? 'धन्यवाद' : 'Thank you' ?>, <strong><?= htmlspecialchars($userName, ENT_QUOTES, 'UTF-8') ?></strong>.
        </p>

        <p style="margin:0 0 22px;font-size:0.95rem;color:#666;">
            <?= $isHindi ? 'परीक्षा' : 'Exam' ?>: <strong>
                <?= htmlspecialchars($exam['title'] ?? '', ENT_QUOTES, 'UTF-8') ?>
                <?php if ($needsHindi && !empty($exam['title_hindi'])): ?>
                    <span style="font-weight:400;font-family:'Noto Sans Devanagari',sans-serif;"> · <?= htmlspecialchars($exam['title_hindi'], ENT_QUOTES, 'UTF-8') ?></span>
                <?php endif; ?>
            </strong>
        </p>

        <div class="thank-you-info">
            <strong>📋 <?= $isHindi ? 'परिणाम की जानकारी' : 'About your result' ?>:</strong><br>
            <?= $isHindi
                ? 'इस परीक्षा के परिणाम अभी प्रकाशित नहीं किए गए हैं। आपकी शाखा द्वारा परिणाम स्वीकृत होने के बाद, आपको सूचित किया जाएगा।'
                : 'The results for this exam are not yet published. Once your branch reviews and approves the results, you will be notified.' ?>
        </div>

        <p style="margin:14px 0 0;font-size:0.82rem;color:#999;">
            📅 <?= $isHindi ? 'जमा करने का समय' : 'Submitted at' ?>: <?= date('d M Y, g:i A') ?>
        </p>

        <div class="thank-you-actions">
            <a href="<?= $bp ?>/branch-exam/dashboard"
               style="padding:13px 28px;background:linear-gradient(135deg,#16a085,#117a65);color:#fff;border:none;border-radius:8px;font-weight:600;font-size:0.92rem;text-decoration:none;">
                <?= $isHindi ? '← वापस परीक्षाओं पर' : '← Back to My Exams' ?>
            </a>
            <form method="POST" action="<?= $bp ?>/branch-exam/logout" style="display:inline;">
                <input type="hidden" name="csrf_token" value="<?= htmlspecialchars($csrfToken ?? '', ENT_QUOTES, 'UTF-8') ?>">
                <button type="submit" style="padding:13px 28px;background:#fff;color:#666;border:1px solid #ddd;border-radius:8px;font-weight:600;font-size:0.92rem;cursor:pointer;">
                    <?= $isHindi ? 'लॉगआउट' : 'Logout' ?>
                </button>
            </form>
        </div>
    </div>
</div>

<?php
include __DIR__ . '/../layouts/footer.php';
