<div class="container-fluid py-4" dir="rtl">
    <div class="row justify-content-center">
        <div class="col-12 col-md-8 col-lg-6">
            <div class="card border-0 shadow-sm">
                <div class="card-header bg-primary bg-opacity-10 py-3">
                    <h5 class="card-title mb-0 text-primary fw-bold text-center">
                        <i class="bi bi-journal-plus me-2"></i>اندراج مضامین
                    </h5>
                    <p class="text-center text-muted small mb-0 mt-1">درجات میں نئے مضامین محفوظ کریں</p>
                </div>
                <div class="card-body p-4">
                    <form id="addSubjectForm">
                        <div class="row g-4">
                            <div class="col-12">
                                <label class="form-label fw-semibold">درجہ منتخب کریں</label>
                                <?php
                                // CRUD and other classes are already loaded in the main context if this is loaded via index.php
                                if (!isset($crud)) {
                                    require_once('../libs/classes/DbPathsArray.php');
                                    require_once('../libs/classes/App_DB.php');
                                    $crud = new App_DB(DBU::$dba_user);
                                }
                                $crud->darjaatCmb('darja', 'class="form-select border-2" id="darja" required');
                                ?>
                            </div>

                            <div class="col-12">
                                <label class="form-label fw-semibold" for="subjectName">مضمون کا نام</label>
                                <input type="text" name="subjectName" id="subjectName" class="form-control border-2"
                                    placeholder="مضمون درج کریں (مثلاً: قرآن، فقہ)" required />
                            </div>

                            <div class="col-12">
                                <label class="form-label fw-semibold" for="totalMarks">کل نمبر (Total Marks)</label>
                                <div class="input-group">
                                    <input type="number" name="totalMarks" id="totalMarks" value="100"
                                        class="form-control border-2" maxlength="3" min="1" max="500" required />
                                    <span class="input-group-text bg-light fw-bold border-2">نمبر</span>
                                </div>
                            </div>

                            <div class="col-12 mt-4">
                                <button type="submit" id="btnSaveSubject"
                                    class="btn btn-primary w-100 py-2 fw-bold shadow-sm">
                                    <i class="bi bi-save me-2"></i>محفوظ کریں
                                </button>
                            </div>
                        </div>
                    </form>

                    <div id="msgR" class="mt-3"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Explicitly link the JS for this page -->
<script src="assets/js/add_subjects.js"></script>