<?php
define('SECURE_ACCESS', true);

$pageTitle = "Privacy Policy";
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/db.php';
require_once __DIR__ . '/../includes/auth.php';

$page = null;
if ($pdo) {
    try {
        $stmt = $pdo->prepare("SELECT * FROM cms_pages WHERE slug = 'privacy'");
        $stmt->execute();
        $page = $stmt->fetch();
    } catch (PDOException $e) {
        // Fallback to static
    }
}

require_once __DIR__ . '/../includes/header.php';
?>

<div class="container-fluid px-md-5 py-5">
    <div class="row justify-content-center">
        <div class="col-12 col-lg-10">
            <div class="card border-0 shadow-sm p-4 p-md-5 rounded-3 bg-white">
                <?php if ($page): ?>
                    <div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center gap-2 mb-3">
                        <h1 class="fw-bold text-dark mb-0"><i class="bi bi-shield-fill-check text-success me-2"></i><?php echo htmlspecialchars($page['title']); ?></h1>
                        <span class="text-secondary small font-monospace">Last updated: <?php echo date('F d, Y', strtotime($page['updated_at'])); ?></span>
                    </div>
                    <hr class="my-4">
                    <div class="cms-rendered-content text-secondary leading-relaxed" style="font-size: 0.95rem; line-height: 1.75;">
                        <?php echo $page['content']; ?>
                    </div>
                <?php else: ?>
                    <h1 class="fw-bold mb-4 text-dark"><i class="bi bi-shield-fill-check text-success me-2"></i>Privacy Policy</h1>
                    <p class="text-muted small">Last updated: July 05, 2026</p>
                    <hr class="my-4">
                    
                    <section class="mb-4">
                        <h5 class="fw-bold text-dark mb-3">1. Information We Collect</h5>
                        <p class="text-secondary leading-relaxed">
                            We collect your email address, dynamic username, employee code, and transaction logs. When verifying your account, you upload your PAN Card, Aadhaar Card, and bank account information.
                        </p>
                    </section>

                    <section class="mb-4">
                        <h5 class="fw-bold text-dark mb-3">2. KYC & Identity Data Security</h5>
                        <p class="text-secondary leading-relaxed">
                            Uploaded identification documents are processed using secure hash naming methods. They are strictly used for verifying withdrawals, payouts, and compliance guidelines, and are never shared with third parties.
                        </p>
                    </section>

                    <section class="mb-4">
                        <h5 class="fw-bold text-dark mb-3">3. Cookies & Session Storage</h5>
                        <p class="text-secondary leading-relaxed">
                            We utilize cookies and session variables to maintain authentication states, track registration referrals, and store system settings parameters to enhance site performance.
                        </p>
                    </section>

                    <section class="mb-0">
                        <h5 class="fw-bold text-dark mb-3">4. Your Rights & Contacts</h5>
                        <p class="text-secondary leading-relaxed mb-0">
                            You hold the right to review, update, or request deletion of your account profile. For queries regarding your data protection, please contact the administrator.
                        </p>
                    </section>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>

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