<?php
/**
 * Practice Test Submitted Page — Gmind Institute
 *
 * Shown when result_published is DISABLED. Displays a clean
 * submission confirmation message with checkmark icon and
 * back to practice tests button.
 *
 * Expected PHP variables:
 *   $attempt    — attempt record
 *   $csrfToken  — CSRF token string
 *   $currentPage — string 'practice'
 *   $title      — page title
 */

$attempt    = $attempt    ?? [];
$csrfToken  = $csrfToken  ?? '';
$basePath   = defined('BASE_PATH') ? BASE_PATH : '/gmind';
$currentPage = $currentNav ?? 'practice';
include __DIR__ . '/../layouts/header.php';

?>
<!-- Practice Submitted Styles -->
<style>
/* Submitted Section */
.practice-submitted-section { background-color: #f4f7fc; padding: 80px 0; min-height: 60vh; display: flex; align-items: center; }
.submitted-wrapper { max-width: 520px; margin: 0 auto; text-align: center; }

/* Checkmark Animation */
.submitted-icon { margin-bottom: 24px; }
.submitted-checkmark { width: 90px; height: 90px; border-radius: 50%; background-color: #27ae60; display: inline-flex; align-items: center; justify-content: center; animation: checkmarkPop 0.5s ease 0.2s both; }
@keyframes checkmarkPop { 0% { transform: scale(0); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.submitted-checkmark svg { color: #ffffff; }

/* Card */
.submitted-card { background-color: #ffffff; border-radius: 16px; padding: 36px 28px; box-shadow: 0 4px 20px rgba(26,79,160,0.10); }
.submitted-card h1 { font-size: 1.8rem; color: #0d2b6e; margin-bottom: 12px; }
.submitted-card p { font-size: 0.95rem; color: #666666; line-height: 1.7; margin-bottom: 8px; }
.submitted-card .submitted-note { font-size: 0.85rem; color: #999999; margin-bottom: 24px; }

/* Back Button */
.btn-back-practice { display: inline-flex; align-items: center; gap: 6px; padding: 14px 28px; background-color: #1a4fa0; color: #ffffff; border-radius: 8px; font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 0.95rem; text-decoration: none; transition: background-color 0.25s, transform 0.25s; }
.btn-back-practice:hover { background-color: #0d2b6e; transform: translateY(-1px); color: #ffffff; }

/* Attempt Info */
.submitted-attempt-info { display: flex; justify-content: center; gap: 20px; margin-top: 20px; padding-top: 20px; border-top: 1px solid #f0f0f0; flex-wrap: wrap; }
.submitted-attempt-info .info-item { font-size: 0.82rem; color: #999999; }
.submitted-attempt-info .info-item strong { color: #555555; }
</style>

<!-- ============================================================
     Practice Test Submitted Section
     ============================================================ -->
<section class="practice-submitted-section" aria-label="<?= __('practice.submitted_title') ?>">
    <div class="container">
        <div class="submitted-wrapper">
            <!-- Checkmark Icon -->
            <div class="submitted-icon">
                <div class="submitted-checkmark">
                    <svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>
                </div>
            </div>

            <!-- Submission Card -->
            <div class="submitted-card">
                <h1><?= __('practice.submitted_title') ?></h1>
                <p><?= __('practice.submitted_msg') ?></p>
                <p class="submitted-note"><?= __('practice.results_later_note') ?></p>

                <?php if (!empty($attempt)): ?>
                <div class="submitted-attempt-info">
                    <?php if (!empty($attempt['id'])): ?>
                    <span class="info-item"><?= __('practice.attempt_id') ?> <strong>#<?= (int) ($attempt['id'] ?? 0) ?></strong></span>
                    <?php endif; ?>
                    <?php if (!empty($attempt['completed_at'])): ?>
                    <span class="info-item"><?= __('practice.submitted_label') ?> <strong><?= htmlspecialchars($attempt['completed_at'], ENT_QUOTES, 'UTF-8') ?></strong></span>
                    <?php endif; ?>
                </div>
                <?php endif; ?>

                <div style="margin-top: 24px;">
                    <a href="<?= $basePath ?>/practice" class="btn-back-practice">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"/></svg>
                        <?= __('practice.back_to_list') ?>
                    </a>
                </div>
            </div>
        </div>
    </div>
</section>

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