<?php
require_once 'includes/db.php';
require_once 'includes/functions.php';

$termsTitle = getSetting($pdo, 'terms_page_title', 'Terms of Service');
$termsContent = getSetting($pdo, 'terms_page_content', '');

$pageTitle = $termsTitle;
$pageDescription = 'Read our terms of service to understand the rules for using our job board platform.';

$defaultContent = '
<h2>1. Acceptance of Terms</h2>
<p>By using this website, you agree to be bound by these terms and conditions.</p>

<h2>2. Use of Service</h2>
<p>You agree to use our service only for lawful purposes and in accordance with these Terms.</p>

<h2>3. User Accounts</h2>
<p>You are responsible for maintaining the confidentiality of your account and password.</p>

<h2>4. Job Postings</h2>
<p>Employers are responsible for the accuracy of their job postings.</p>

<h2>5. Contact Us</h2>
<p>If you have any questions about these Terms, please contact us.</p>
';

$displayContent = !empty($termsContent) ? $termsContent : $defaultContent;

require_once 'includes/header.php';
?>

<div style="max-width: 900px; margin: 40px auto; padding: 0 20px;">
    <div style="background: white; border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); padding: 40px;">
        <h1 style="font-size: 2rem; color: #1e293b; margin-bottom: 20px;">
            <i class="fas fa-file-contract" style="color: #6366f1;"></i> <?php echo sanitize($termsTitle); ?>
        </h1>
        <p style="color: #64748b; margin-bottom: 30px;">Last updated: <?php echo date('F d, Y'); ?></p>
        
        <div class="page-content" style="color: #475569; line-height: 1.8;">
            <?php echo $displayContent; ?>
        </div>
    </div>
</div>

<style>
.page-content h2 { color: #1e293b; font-size: 1.3rem; margin: 25px 0 15px; }
.page-content ul { margin: 15px 0; padding-left: 25px; }
.page-content li { margin-bottom: 8px; }
.page-content p { margin-bottom: 15px; }
</style>

<?php require_once 'includes/footer.php'; ?>
