<?php
/**
 * Terms of Service Page
 * Digital Product Store - Premium Edition
 */

require_once __DIR__ . '/config/database.php';

$page_title = 'Terms of Service';

// Try to get from CMS pages
$page = get_page_by_slug('terms-of-service');

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

<!-- Page Header -->
<section class="page-header py-5 bg-light">
    <div class="container text-center">
        <h1 class="display-5 fw-bold">Terms of Service</h1>
        <p class="lead text-muted">Please read these terms carefully before using our services</p>
    </div>
</section>

<!-- Terms Content -->
<section class="terms-section py-5">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-8">
                <div class="terms-content">
                    <?php if ($page && !empty($page['content'])): ?>
                        <?php echo $page['content']; ?>
                    <?php else: ?>
                        <div class="terms-block">
                            <h4>1. Acceptance of Terms</h4>
                            <p>Welcome to <?php echo get_setting('site_name', 'Digital Store'); ?>. By accessing and using this website, you accept and agree to be bound by these terms and conditions. If you do not agree to these terms, please do not use our services.</p>
                        </div>
                        
                        <div class="terms-block">
                            <h4>2. Use of Service</h4>
                            <p>You agree to use our services only for lawful purposes. You are prohibited from:</p>
                            <ul>
                                <li>Violating any applicable laws or regulations</li>
                                <li>Infringing on the intellectual property rights of others</li>
                                <li>Uploading or transmitting viruses or malicious code</li>
                                <li>Attempting to gain unauthorized access to our systems</li>
                                <li>Interfering with the proper working of the website</li>
                            </ul>
                        </div>
                        
                        <div class="terms-block">
                            <h4>3. Account Registration</h4>
                            <p>To access certain features of our website, you may need to create an account. You are responsible for:</p>
                            <ul>
                                <li>Maintaining the confidentiality of your account credentials</li>
                                <li>All activities that occur under your account</li>
                                <li>Notifying us immediately of any unauthorized use</li>
                            </ul>
                        </div>
                        
                        <div class="terms-block">
                            <h4>4. Purchases and Payments</h4>
                            <p>All purchases are subject to availability and confirmation of order price. When you place an order:</p>
                            <ul>
                                <li>You agree to provide current, complete, and accurate purchase information</li>
                                <li>You authorize us to charge your payment method for the total amount</li>
                                <li>All prices are in <?php echo get_setting('currency_code', 'USD'); ?> unless otherwise stated</li>
                            </ul>
                        </div>
                        
                        <div class="terms-block">
                            <h4>5. Digital Products</h4>
                            <p>Our products are digital downloads. Once purchased:</p>
                            <ul>
                                <li>You will receive download instructions via email</li>
                                <li>Downloads may have usage limits as specified in the product description</li>
                                <li>All sales are final unless otherwise stated in our refund policy</li>
                                <li>You may not redistribute or resell the products</li>
                            </ul>
                        </div>
                        
                        <div class="terms-block">
                            <h4>6. Intellectual Property</h4>
                            <p>All content on this website, including text, graphics, logos, and software, is the property of <?php echo get_setting('site_name', 'Digital Store'); ?> or its licensors and is protected by copyright and other intellectual property laws.</p>
                        </div>
                        
                        <div class="terms-block">
                            <h4>7. Limitation of Liability</h4>
                            <p><?php echo get_setting('site_name', 'Digital Store'); ?> shall not be liable for any indirect, incidental, special, consequential, or punitive damages resulting from your use of our services.</p>
                        </div>
                        
                        <div class="terms-block">
                            <h4>8. Changes to Terms</h4>
                            <p>We reserve the right to modify these terms at any time. Changes will be effective immediately upon posting to the website. Your continued use of the service constitutes acceptance of the modified terms.</p>
                        </div>
                        
                        <div class="terms-block">
                            <h4>9. Contact Information</h4>
                            <p>If you have any questions about these Terms of Service, please contact us at:</p>
                            <p><strong>Email:</strong> <?php echo get_setting('site_email', 'support@digitalstore.com'); ?></p>
                            <?php if ($phone = get_setting('site_phone')): ?>
                            <p><strong>Phone:</strong> <?php echo htmlspecialchars($phone); ?></p>
                            <?php endif; ?>
                        </div>
                        
                        <div class="terms-block">
                            <h4>10. Governing Law</h4>
                            <p>These terms shall be governed by and construed in accordance with the laws of the jurisdiction in which <?php echo get_setting('site_name', 'Digital Store'); ?> operates, without regard to its conflict of law provisions.</p>
                        </div>
                    <?php endif; ?>
                </div>
                
                <div class="text-center mt-5">
                    <p class="text-muted">Last updated: <?php echo date('F Y'); ?></p>
                </div>
            </div>
        </div>
    </div>
</section>

<style>
.page-header {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.terms-content {
    background: white;
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.terms-block {
    margin-bottom: 2rem;
}

.terms-block:last-child {
    margin-bottom: 0;
}

.terms-block h4 {
    color: #1f2937;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.terms-block p {
    color: #4b5563;
    line-height: 1.7;
}

.terms-block ul {
    color: #4b5563;
    line-height: 1.8;
}

.terms-block li {
    margin-bottom: 0.5rem;
}

@media (max-width: 767px) {
    .terms-content {
        padding: 1.5rem;
    }
}
</style>

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