<?php
/**
 * Copyrights Page - (copyRights)
 * Refactored to Bootstrap 5.3 & Secure API
 * This page is included via index.php?cmd=copyRights
 */

// $crud and constants are available via index.php context
$conf_res = $crud->getRecordSet("SELECT * FROM config LIMIT 1");
$conf = !empty($conf_res) ? $conf_res[0] : [];
?>

<style>
    /* Styling similar to madrasa_terms_conditions.php for consistency */
    .report-paper {
        background: white;
        padding: 60px;
        margin: 30px auto;
        width: 210mm;
        /* A4 width */
        min-height: 297mm;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
        border-radius: 4px;
        position: relative;
    }

    .report-header {
        border-bottom: 3px double #212529;
        margin-bottom: 40px;
        padding-bottom: 20px;
    }

    .madrasa-name {
        font-size: 38px;
        font-weight: 800;
        color: #1a2a3a;
        margin-bottom: 10px;
    }

    .report-title {
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        display: inline-block;
        padding: 8px 50px;
        border-radius: 50px;
        font-weight: bold;
        margin: 20px 0;
        font-size: 26px;
    }

    .rights-content {
        font-size: 24px;
        text-align: justify;
        line-height: 2.3;
    }

    .license-box {
        background: #f8f9fa;
        border: 1px solid #ced4da;
        border-radius: 12px;
        padding: 25px;
        margin-bottom: 30px;
    }

    .dua-box {
        background: #fff3cd;
        border: 1px solid #ffe69c;
        border-radius: 12px;
        padding: 20px;
        text-align: center;
        font-weight: 700;
        font-size: 28px;
        margin: 30px 0;
    }

    .signature-area {
        margin-top: 60px;
        text-align: left;
        /* Aligns signature to the left in RTL */
    }

    .signature-line {
        display: inline-block;
        border-top: 2px solid #212529;
        min-width: 220px;
        padding-top: 10px;
        text-align: center;
        font-size: 22px;
        font-weight: bold;
    }

    #tamper_warning {
        display: none;
    }

    @media print {
        body {
            background-color: white !important;
        }

        #content {
            margin: 0 !important;
            padding: 0 !important;
            box-shadow: none !important;
            border: none !important;
        }

        .report-paper {
            margin: 0 auto;
            box-shadow: none;
            padding: 20px;
            width: 100%;
            border: none !important;
        }

        .no-print {
            display: none !important;
        }
    }
</style>

<div class="container no-print mt-4 text-center">
    <div class="d-flex justify-content-center gap-2">
        <button onclick="window.print()" class="btn btn-primary rounded-pill px-4 shadow-sm urdu-regular fs-4">
            <i class="bi bi-printer me-2"></i>پرنٹ کریں (Print)
        </button>
        <a href="index.php" class="btn btn-outline-secondary rounded-pill px-4 shadow-sm urdu-regular fs-4">
            <i class="bi bi-house me-2"></i>ہوم پیج
        </a>
    </div>
</div>

<div id="tamper_warning" class="container mt-4">
    <div class="alert alert-danger d-flex align-items-center urdu-regular fs-4 shadow-sm" role="alert">
        <i class="bi bi-exclamation-triangle-fill me-3 fs-3"></i>
        <div>
            تحتبہ: مواد میں غیر مجاز تبدیلی محسوس ہوئی ہے۔ براہ کرم ایڈمن سے رابطہ کریں۔
        </div>
    </div>
</div>

<div class="report-paper urdu-regular">
    <div class="report-header text-center">
        <h1 class="madrasa-name">
            <?php echo $conf['M_Name'] ?? 'مدرسہ کا نام'; ?>
        </h1>
        <p class="fs-4 text-muted mb-2">
            <?php echo $conf['M_Address'] ?? ''; ?>
        </p>

        <div class="report-title">
            باقاعدہ اجازت نامہ و استعمال سافٹ ویئر
        </div>
    </div>

    <div class="rights-content">
        <p class="mb-4">برائے مہربانی مندرجہ ذیل کو بہت غور و احتیاط کے ساتھ پڑھ لیجئے۔</p>

        <div class="license-box shadow-sm">
            <p id="copy_rights_content">
                <!-- Content loaded via AJAX -->
                <span class="text-muted fst-italic">مواد لوڈ ہو رہا ہے...</span>
            </p>
        </div>

        <div id="copy_rights_dua" class="dua-box shadow-sm">
            <!-- Dua loaded via AJAX -->
        </div>

        <div class="signature-area">
            <div class="signature-line">
                <span id="copy_rights_signature"></span>
            </div>
        </div>
    </div>
</div>

<!-- Scripts -->
<script src="assets/js/copy_rights.js"></script>