<?php
/**
 * Exam Marks Empty Report Page - Refactored for Bootstrap 5.3
 * Generates an empty marksheet for examinations.
 */

// Hijri Date Logic for Defaults
$defaultYear = date('Y-m-d');
if (isset($_SESSION['hijri']) && !empty($_SESSION['hijri'])) {
    $dt = new DateTime($_SESSION['hijri']);
    $defaultYear = $dt->format('Y-m-d');
}
?>

<!-- Custom Styles for Print and Professional Look -->
<style>
    .report-table th {
        background-color: #f8f9fa !important;
        font-weight: 700;
        vertical-align: middle;
    }

    .report-table td {
        vertical-align: middle;
        height: 45px;
    }

    .empty-cell {
        background-color: #fff !important;
    }

    .report-page {
        background: #fff;
        padding: 40px;
        margin-bottom: 20px;
    }

    .urdu-bold {
        font-family: 'Jameel Noori Nastaleeq', serif;
        font-weight: bold;
    }

    .urdu-regular {
        font-family: 'Jameel Noori Nastaleeq', serif;
    }

    @media print {
        body {
            background: #fff !important;
            padding: 0 !important;
        }

        .no-print {
            display: none !important;
        }

        .report-page {
            margin-bottom: 0;
            padding: 0;
            page-break-after: always;
        }

        .report-page:last-child {
            page-break-after: auto;
        }

        #content-wrapper {
            padding: 0 !important;
            margin: 0 !important;
        }

        #content {
            padding: 0 !important;
        }

        .shadow-sm {
            box-shadow: none !important;
        }

        .card {
            border: none !important;
        }

        .table {
            border-color: #000 !important;
        }

        .report-table th,
        .report-table td {
            border-color: #000 !important;
        }

        .no-print-visible {
            display: flex !important;
        }
    }

    /* Input group alignment fix */
    .input-group-reverse {
        flex-direction: row-reverse;
    }

    .input-group-reverse .form-select,
    .input-group-reverse .form-control {
        text-align: right;
    }
</style>

<div id="examMarksEmptyWrapper" dir="rtl">
    <!-- Page Header & Actions -->
    <div class="d-flex justify-content-between align-items-center mb-4 no-print">
        <div>
            <h2 class="fw-bold mb-0 text-primary urdu-bold">
                <i class="bi bi-file-earmark-text me-2"></i> خالی امتحانی لسِٹ (Exam Marks Empty Report)
            </h2>
            <p class="text-muted small urdu-regular fs-5">
                امتحان کے لیے طلباء کی خالی فہرست تیار کریں
            </p>
        </div>
        <a href="dashboard" class="btn btn-outline-dark urdu-regular fs-5">
            <i class="bi bi-house me-1"></i> ڈیش بورڈ
        </a>
    </div>

    <!-- Filter Card -->
    <div class="card border-0 shadow-sm rounded-4 mb-4 no-print">
        <div class="card-body p-4">
            <form id="examMarksEmptyForm" class="row g-4 align-items-end">
                <!-- Darja -->
                <div class="col-md-4">
                    <label class="form-label fw-bold urdu-regular fs-5">درجہ منتخب کریں</label>
                    <div class="input-group input-group-lg shadow-sm rounded-3 overflow-hidden input-group-reverse"
                        dir="ltr">
                        <span class="input-group-text bg-light border-0 text-primary"><i
                                class="bi bi-journal-bookmark"></i></span>
                        <?php $crud->darjaatCmb('rpt_darja', '', 'form-select border-0 urdu-regular'); ?>
                    </div>
                </div>

                <!-- Year -->
                <div class="col-md-3">
                    <label class="form-label fw-bold urdu-regular fs-5">داخلہ سال</label>
                    <div class="input-group input-group-lg shadow-sm rounded-3 overflow-hidden input-group-reverse"
                        dir="ltr">
                        <span class="input-group-text bg-light border-0 text-primary"><i
                                class="bi bi-calendar-event"></i></span>
                        <input type="text" id="rpt_year" class="form-control border-0 hijri-picker"
                            value="<?php echo $defaultYear; ?>" readonly required>
                    </div>
                </div>

                <!-- Exam Type -->
                <div class="col-md-3">
                    <label class="form-label fw-bold urdu-regular fs-5">امتحان</label>
                    <div class="input-group input-group-lg shadow-sm rounded-3 overflow-hidden input-group-reverse"
                        dir="ltr">
                        <span class="input-group-text bg-light border-0 text-primary"><i
                                class="bi bi-info-circle"></i></span>
                        <select id="rpt_exam_type" class="form-select border-0 urdu-regular">
                            <option value="1">سہ ماہی</option>
                            <option value="2">ششماہی</option>
                            <option value="3">سالانہ</option>
                        </select>
                    </div>
                </div>

                <!-- Submit Button -->
                <div class="col-md-2 text-end">
                    <button type="submit" id="btnShowReport"
                        class="btn btn-primary btn-lg w-100 shadow-sm urdu-regular py-2">
                        <i class="bi bi-search ms-2"></i> رپورٹ دکھائیں
                    </button>
                </div>
            </form>
        </div>
    </div>

    <!-- Results Container -->
    <div id="report-results">
        <div class="alert alert-light border-0 shadow-sm py-5 text-center text-muted urdu-regular fs-5 no-print">
            <i class="bi bi-arrow-up-circle fs-1 d-block mb-3 opacity-25"></i>
            رپورٹ دیکھنے کے لیے اوپر دی گئی معلومات درج کر کے "رپورٹ دکھائیں" پر کلک کریں۔
        </div>
    </div>
</div>

<!-- Page Specific JS -->
<script src="assets/js/exam_marks_empty_report.js"></script>