<?php
$settingsFile = __DIR__ . '/data/settings.json';
$settings = file_exists($settingsFile) ? json_decode(file_get_contents($settingsFile), true) : [];
$pageSettings = $settings['pages'] ?? [];
$brandingSettings = $settings['branding'] ?? [];

$siteName = $brandingSettings['siteName'] ?? 'Weather Portal';
$privacyContent = $pageSettings['privacyContent'] ?? '';
$privacyLastUpdated = $pageSettings['privacyLastUpdated'] ?? date('F Y');
$privacyEmail = $pageSettings['privacyEmail'] ?? 'privacy@weatherportal.com';

include 'header.php';
?>

<div class="page-header">
    <h1 class="page-title" data-translate="privacy_policy">Privacy Policy</h1>
    <p class="page-subtitle" data-translate="privacy_subtitle">Your privacy is important to us</p>
</div>

<div class="content-card">
    <p><strong data-translate="last_updated">Last Updated:</strong> <?php echo htmlspecialchars($privacyLastUpdated); ?></p>
    
    <?php if (!empty($privacyContent)): ?>
        <?php echo $privacyContent; ?>
    <?php else: ?>
    <h2 style="margin-top: 30px;" data-translate="introduction">Introduction</h2>
    <p>Welcome to <?php echo htmlspecialchars($siteName); ?>. We respect your privacy and are committed to protecting your personal data. This privacy policy will inform you about how we look after your personal data when you visit our website and tell you about your privacy rights.</p>
    
    <h2 style="margin-top: 30px;" data-translate="info_we_collect">Information We Collect</h2>
    <p>We may collect and process the following types of information:</p>
    <ul>
        <li><strong data-translate="usage_data">Usage Data:</strong> <span data-translate="usage_data_desc">Information about how you use our website, including pages visited, time spent on pages, and navigation patterns</span></li>
        <li><strong data-translate="device_info">Device Information:</strong> <span data-translate="device_info_desc">Technical information about the device you use to access our website, including browser type, operating system, and screen resolution</span></li>
        <li><strong data-translate="location_data">Location Data:</strong> <span data-translate="location_data_desc">If you choose to share your location, we use it to provide you with localized weather information</span></li>
        <li><strong data-translate="contact_info">Contact Information:</strong> <span data-translate="contact_info_desc">If you contact us through our contact form, we collect your name, email address, and message content</span></li>
    </ul>
    
    <h2 style="margin-top: 30px;" data-translate="how_we_use_info">How We Use Your Information</h2>
    <p>We use the information we collect for the following purposes:</p>
    <ul>
        <li data-translate="use_purpose_1">To provide and maintain our service</li>
        <li data-translate="use_purpose_2">To personalize your experience based on your location</li>
        <li data-translate="use_purpose_3">To improve our website and services</li>
        <li data-translate="use_purpose_4">To respond to your inquiries and support requests</li>
        <li data-translate="use_purpose_5">To analyze usage patterns and optimize performance</li>
    </ul>
    
    <h2 style="margin-top: 30px;" data-translate="cookies">Cookies</h2>
    <p data-translate="cookies_intro">We use cookies and similar tracking technologies to track activity on our website and hold certain information. Cookies are files with small amounts of data that may include an anonymous unique identifier.</p>
    <p>We use cookies for:</p>
    <ul>
        <li><strong data-translate="essential_cookies">Essential Cookies:</strong> <span data-translate="essential_cookies_desc">Required for the website to function properly (e.g., remembering your theme preference)</span></li>
        <li><strong data-translate="analytics_cookies">Analytics Cookies:</strong> <span data-translate="analytics_cookies_desc">Help us understand how visitors interact with our website</span></li>
        <li><strong data-translate="advertising_cookies">Advertising Cookies:</strong> <span data-translate="advertising_cookies_desc">Used to deliver relevant advertisements</span></li>
    </ul>
    <p data-translate="cookies_control">You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent.</p>
    
    <h2 style="margin-top: 30px;" data-translate="third_party_services">Third-Party Services</h2>
    <p data-translate="third_party_intro">We may use third-party services that collect, monitor, and analyze user data:</p>
    <ul>
        <li><strong>Google Analytics:</strong> <span data-translate="google_analytics_desc">For website analytics and performance monitoring</span></li>
        <li><strong>Google AdSense:</strong> <span data-translate="google_adsense_desc">For displaying advertisements</span></li>
    </ul>
    <p data-translate="third_party_policies">These third parties have their own privacy policies addressing how they use such information.</p>
    
    <h2 style="margin-top: 30px;" data-translate="data_security">Data Security</h2>
    <p data-translate="data_security_desc">The security of your data is important to us, but remember that no method of transmission over the Internet or method of electronic storage is 100% secure. We strive to use commercially acceptable means to protect your personal data.</p>
    
    <h2 style="margin-top: 30px;" data-translate="your_rights">Your Rights</h2>
    <p>You have the following rights regarding your personal data:</p>
    <ul>
        <li data-translate="right_access">The right to access your personal data</li>
        <li data-translate="right_correction">The right to request correction of your personal data</li>
        <li data-translate="right_deletion">The right to request deletion of your personal data</li>
        <li data-translate="right_object">The right to object to processing of your personal data</li>
        <li data-translate="right_portability">The right to data portability</li>
    </ul>
    
    <h2 style="margin-top: 30px;" data-translate="childrens_privacy">Children's Privacy</h2>
    <p data-translate="childrens_privacy_desc">Our service does not address anyone under the age of 13. We do not knowingly collect personally identifiable information from anyone under the age of 13.</p>
    
    <h2 style="margin-top: 30px;" data-translate="changes_policy">Changes to This Privacy Policy</h2>
    <p data-translate="changes_policy_desc">We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page and updating the "Last Updated" date.</p>
    
    <h2 style="margin-top: 30px;" data-translate="contact_us">Contact Us</h2>
    <p data-translate="privacy_contact_intro">If you have any questions about this Privacy Policy, please contact us:</p>
    <ul>
        <li>By visiting our <a href="/contact.php" data-translate="contact_page">Contact Page</a></li>
        <?php if (!empty($privacyEmail)): ?>
        <li>By email: <a href="mailto:<?php echo htmlspecialchars($privacyEmail); ?>"><?php echo htmlspecialchars($privacyEmail); ?></a></li>
        <?php endif; ?>
    </ul>
    <?php endif; ?>
</div>

<div class="ad-space">Advertisement Space</div>

<?php include 'footer.php'; ?>
