<?php
include 'auth/function.php';
$brand = htmlspecialchars($site_settings['brand_name'] ?? 'Our Platform');
$siteLink = htmlspecialchars($site_settings['site_link'] ?? '#');
$whatsapp = htmlspecialchars($site_settings['whatsapp_number'] ?? '');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Privacy Policy — <?php echo $brand; ?></title>
<style>
    :root{ --primary:#6B4EFF; --text:#1A1A24; --muted:#6B7280; --bg:#F8F6FF; }
    *{box-sizing:border-box;}
    body{margin:0;font-family:-apple-system,'Segoe UI',Roboto,sans-serif;background:var(--bg);color:var(--text);line-height:1.7;}
    header{background:#fff;padding:18px 20px;border-bottom:1px solid rgba(0,0,0,.06);position:sticky;top:0;}
    header a{color:var(--primary);text-decoration:none;font-weight:700;font-size:1.05rem;}
    main{max-width:760px;margin:0 auto;padding:32px 20px 80px;}
    h1{font-size:1.6rem;margin-bottom:4px;}
    .updated{color:var(--muted);font-size:.85rem;margin-bottom:28px;}
    h2{font-size:1.15rem;margin-top:34px;margin-bottom:10px;color:var(--primary);}
    p, li{font-size:.95rem;color:#2c2c38;}
    ul{padding-left:20px;}
    .box{background:#fff;border:1px solid rgba(107,78,255,.12);border-radius:14px;padding:16px 18px;margin:16px 0;font-size:.9rem;}
    footer{text-align:center;padding:24px;color:var(--muted);font-size:.8rem;}
</style>
</head>
<body>
<header><a href="index">&larr; <?php echo $brand; ?></a></header>
<main>
    <h1>Privacy Policy</h1>
    <p class="updated">Last updated: <?php echo date('d F Y'); ?></p>

    <p><?php echo $brand; ?> ("we", "us", "our") operates a UPI payment gateway and merchant payment-collection platform. This Privacy Policy explains what information we collect, how we use it, and the choices you have — for both platform account holders (merchants) and their customers making payments.</p>

    <h2>1. Information We Collect</h2>
    <ul>
        <li><strong>Account information</strong> — name, mobile number, email address, and login credentials when you register.</li>
        <li><strong>Payment gateway details</strong> — UPI ID / VPA, connected merchant mobile numbers, and gateway configuration you add to your account.</li>
        <li><strong>Transaction data</strong> — order IDs, amounts, UPI transaction references (UTR), timestamps, and payment status for orders processed through the platform.</li>
        <li><strong>Technical data</strong> — IP address, browser/device type, and basic usage logs for security and troubleshooting.</li>
    </ul>

    <h2>2. Google Account Access (Gmail)</h2>
    <div class="box">
        <p>If you choose to connect a FamPay merchant account using "Sign in with Google," we request <strong>read-only access to your Gmail inbox</strong> (<code>gmail.readonly</code> scope) solely to automatically detect payment-confirmation emails and match them to your orders on <?php echo $brand; ?>, so we can confirm a payment without asking you to manually enter a UPI reference number.</p>
        <p>We do not read, store, or use any email unrelated to payment confirmation. We do not send email on your behalf, and we never share your Gmail data with advertisers or third parties.</p>
        <p><?php echo $brand; ?>'s use and transfer of information received from Google APIs to any other app will adhere to the <a href="https://developers.google.com/terms/api-services-user-data-policy" target="_blank" rel="noopener">Google API Services User Data Policy</a>, including the Limited Use requirements.</p>
        <p>You can revoke this access at any time from your <a href="https://myaccount.google.com/permissions" target="_blank" rel="noopener">Google Account permissions page</a>, or by disconnecting the merchant from your <?php echo $brand; ?> dashboard.</p>
    </div>

    <h2>3. How We Use Information</h2>
    <ul>
        <li>To process, verify, and display the status of UPI payments made through your payment links and QR codes.</li>
        <li>To operate your merchant dashboard, wallet, and commission tracking.</li>
        <li>To detect fraud, prevent abuse, and secure accounts.</li>
        <li>To send you service-related notifications (e.g. payment confirmations, security alerts).</li>
    </ul>

    <h2>4. Data Sharing</h2>
    <p>We do not sell your personal data. We only share information with:</p>
    <ul>
        <li>Payment/UPI infrastructure providers strictly to process the transaction you initiate.</li>
        <li>Law enforcement or regulators when legally required.</li>
    </ul>

    <h2>5. Data Retention</h2>
    <p>We retain account and transaction data for as long as your account is active and as needed to comply with legal, accounting, or reporting obligations. You may request deletion of your account and associated data by contacting us below.</p>

    <h2>6. Data Security</h2>
    <p>We use industry-standard measures (encrypted connections, access controls) to protect your data. No online system is 100% secure, and we encourage you to use a strong password and enable two-factor authentication where available.</p>

    <h2>7. Children's Privacy</h2>
    <p>Our services are not directed to children under 18, and we do not knowingly collect data from them.</p>

    <h2>8. Changes to This Policy</h2>
    <p>We may update this Privacy Policy from time to time. Material changes will be reflected by updating the "Last updated" date above.</p>

    <h2>9. Contact Us</h2>
    <p>Questions about this policy or your data? Reach us at:</p>
    <ul>
        <li>Website: <a href="<?php echo $siteLink; ?>"><?php echo $siteLink; ?></a></li>
        <?php if ($whatsapp): ?><li>WhatsApp: <?php echo $whatsapp; ?></li><?php endif; ?>
    </ul>
</main>
<footer>&copy; <?php echo date('Y'); ?> <?php echo $brand; ?>. All rights reserved.</footer>
</body>
</html>
