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

<?= $this->section('content') ?>
<div class="modal fade" id="classWarningModal" tabindex="-1" aria-labelledby="classWarningLabel" aria-hidden="true" role="alertdialog">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content border-warning">
            <div class="modal-header bg-warning text-dark">
                <h5 class="modal-title" id="classWarningLabel">
                    <i class="bi bi-exclamation-triangle-fill me-2"></i> Warning
                </h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>

            <div class="modal-body text-dark fs-6">
                <?= esc($warningMessage ?? 'An unexpected issue occurred.') ?>
            </div>

            <div class="modal-footer justify-content-between">
                <a href="<?= base_url('/administrator/student_class_assignment') ?>" class="btn btn-secondary">
                    <i class="bi bi-arrow-left-circle me-1"></i> Back to Class Assignment
                </a>
                <!-- Optional dynamic action (add if needed) -->
                <!-- <a href="<?= base_url('/some-action') ?>" class="btn btn-warning">Proceed</a> -->
            </div>
        </div>
    </div>
</div>
<?= $this->endSection() ?>

<?= $this->section('scripts') ?>
<script>
    document.addEventListener('DOMContentLoaded', function () {
        const classWarningModalEl = document.getElementById('classWarningModal');
        if (classWarningModalEl) {
            const modal = new bootstrap.Modal(classWarningModalEl);
            modal.show();
        }
    });
</script>
<?= $this->endSection() ?>
