'use client';

import { Box, Container, Typography, Paper } from '@mui/material';
import Link from 'next/link';
import { AppShell } from '@/components/layouts/AppShell/AppShell';
import { ProtectedRoute } from '@/components/common/ProtectedRoute';

export default function PrivacyPolicyPage() {
  const lastUpdated = 'October 4, 2025';

  return (
    <ProtectedRoute>
      <AppShell>
        <Container maxWidth="md" sx={{ py: 4 }}>
      <Paper elevation={0} sx={{ p: 4, border: 1, borderColor: 'divider' }}>
        <Typography variant="h3" component="h1" gutterBottom>
          Privacy Policy
        </Typography>

        <Typography variant="body2" color="text.secondary" paragraph>
          Last Updated: {lastUpdated}
        </Typography>

        <Box sx={{ mt: 4 }}>
          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            1. Introduction
          </Typography>
          <Typography paragraph>
            Welcome to ParentFlow ("we," "our," or "us"). We are committed to protecting your privacy and the privacy of your children.
            This Privacy Policy explains how we collect, use, disclose, and safeguard your information when you use our mobile application
            and related services (collectively, the "Service").
          </Typography>
          <Typography paragraph>
            Because our Service is designed for parents and caregivers tracking information about children aged 0-6 years, we take extra
            precautions to comply with the Children's Online Privacy Protection Act (COPPA) and the General Data Protection Regulation (GDPR).
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            2. Information We Collect
          </Typography>

          <Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
            2.1 Personal Information You Provide
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li><strong>Account Information:</strong> Name, email address, date of birth (for COPPA age verification)</li>
              <li><strong>Profile Information:</strong> Profile photo, timezone, language preferences</li>
              <li><strong>Child Information:</strong> Child's name, date of birth, gender, photo (optional)</li>
              <li><strong>Activity Data:</strong> Feeding times, sleep schedules, diaper changes, medication records, milestones</li>
              <li><strong>AI Chat Messages:</strong> Questions and conversations with our AI assistant</li>
              <li><strong>Photos and Media:</strong> Photos of children and milestones (optional)</li>
            </ul>
          </Typography>

          <Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
            2.2 Automatically Collected Information
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li><strong>Device Information:</strong> Device type, operating system, unique device identifiers</li>
              <li><strong>Usage Data:</strong> App features used, session duration, error logs</li>
              <li><strong>Technical Data:</strong> IP address, browser type, time zone settings</li>
            </ul>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            3. How We Use Your Information
          </Typography>
          <Typography component="div" paragraph>
            We use the collected information for:
            <ul>
              <li>Providing and maintaining the Service</li>
              <li>Tracking your child's activities and patterns</li>
              <li>Generating insights and analytics about your child's development</li>
              <li>Providing AI-powered parenting support and answers</li>
              <li>Syncing data across family members' devices</li>
              <li>Sending notifications and reminders</li>
              <li>Improving our Service and developing new features</li>
              <li>Detecting and preventing fraud and security issues</li>
              <li>Complying with legal obligations</li>
            </ul>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            4. Children's Privacy (COPPA Compliance)
          </Typography>
          <Typography paragraph>
            Our Service is designed for parents and caregivers to track information about their children. We do not knowingly collect
            personal information directly from children under 13 years of age.
          </Typography>
          <Typography component="div" paragraph>
            <strong>Parental Rights:</strong>
            <ul>
              <li>Review your child's information</li>
              <li>Request deletion of your child's information</li>
              <li>Refuse further collection or use of your child's information</li>
              <li>Export your child's data in a portable format</li>
            </ul>
          </Typography>
          <Typography paragraph>
            To exercise these rights, please contact us at <strong>hello@parentflow.com</strong>.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            5. Data Sharing and Disclosure
          </Typography>
          <Typography paragraph>
            <strong>We do NOT sell your personal information or your child's information.</strong>
          </Typography>
          <Typography component="div" paragraph>
            We may share information with:
            <ul>
              <li><strong>Family Members:</strong> Data is shared with family members you invite to your family group</li>
              <li><strong>Service Providers:</strong> Cloud hosting (AWS/Azure), analytics (anonymized), customer support</li>
              <li><strong>AI Providers:</strong> OpenAI or Anthropic (for AI chat, with no PII in training data)</li>
              <li><strong>Legal Compliance:</strong> When required by law or to protect rights and safety</li>
            </ul>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            6. Data Security
          </Typography>
          <Typography paragraph>
            We implement industry-standard security measures to protect your information:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>End-to-end encryption for sensitive child data</li>
              <li>Secure HTTPS connections for all communications</li>
              <li>Regular security audits and penetration testing</li>
              <li>Access controls and authentication mechanisms</li>
              <li>Encrypted database storage</li>
            </ul>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            7. Your Rights (GDPR Compliance)
          </Typography>
          <Typography component="div" paragraph>
            Under GDPR, you have the following rights:
            <ul>
              <li><strong>Right to Access:</strong> Request a copy of your personal data</li>
              <li><strong>Right to Rectification:</strong> Correct inaccurate information</li>
              <li><strong>Right to Erasure:</strong> Request deletion of your data ("right to be forgotten")</li>
              <li><strong>Right to Data Portability:</strong> Export your data in a machine-readable format</li>
              <li><strong>Right to Restrict Processing:</strong> Limit how we use your data</li>
              <li><strong>Right to Object:</strong> Opt-out of certain data processing</li>
              <li><strong>Right to Withdraw Consent:</strong> Revoke consent at any time</li>
            </ul>
          </Typography>
          <Typography paragraph>
            To exercise your rights, visit Settings → Privacy → Data Rights or email <strong>hello@parentflow.com</strong>.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            8. Data Retention
          </Typography>
          <Typography paragraph>
            We retain your information for as long as your account is active or as needed to provide the Service.
            When you delete your account, we will delete your personal information within 30 days, except where we are
            required to retain it for legal compliance or dispute resolution.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            9. International Data Transfers
          </Typography>
          <Typography paragraph>
            Your information may be transferred to and processed in countries other than your country of residence.
            We ensure appropriate safeguards are in place to protect your information in accordance with this Privacy Policy
            and applicable laws.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            10. Third-Party Links
          </Typography>
          <Typography paragraph>
            Our Service may contain links to third-party websites. We are not responsible for the privacy practices of these
            external sites. We encourage you to review their privacy policies.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            11. Changes to This Privacy Policy
          </Typography>
          <Typography paragraph>
            We may update this Privacy Policy from time to time. We will notify you of significant changes by email or through
            the app. Your continued use of the Service after changes constitutes acceptance of the updated policy.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            12. Contact Us
          </Typography>
          <Typography paragraph>
            If you have questions about this Privacy Policy or our data practices, please contact us:
          </Typography>
          <Typography component="div" paragraph>
            <strong>Email:</strong> hello@parentflow.com<br />
            <strong>Address:</strong> Serbota 3, Bucharest, Romania
          </Typography>

          <Box sx={{ mt: 4, pt: 3, borderTop: 1, borderColor: 'divider' }}>
            <Typography variant="body2" color="text.secondary">
              Related Legal Documents:
            </Typography>
            <Box sx={{ display: 'flex', gap: 2, mt: 1, flexWrap: 'wrap' }}>
              <Link href="/legal/terms" style={{ textDecoration: 'none' }}>
                <Typography color="primary" sx={{ '&:hover': { textDecoration: 'underline' } }}>
                  Terms of Service
                </Typography>
              </Link>
              <Link href="/legal/eula" style={{ textDecoration: 'none' }}>
                <Typography color="primary" sx={{ '&:hover': { textDecoration: 'underline' } }}>
                  EULA
                </Typography>
              </Link>
              <Link href="/legal/cookies" style={{ textDecoration: 'none' }}>
                <Typography color="primary" sx={{ '&:hover': { textDecoration: 'underline' } }}>
                  Cookie Policy
                </Typography>
              </Link>
            </Box>
          </Box>
        </Box>
      </Paper>
    </Container>
      </AppShell>
    </ProtectedRoute>
  );
}
