import React from 'react'
import {View, Text, StyleSheet, Pressable, Linking} from 'react-native'

interface PrivacyContentProps {
  onLinkPress?: (url: string) => void
}

export default function PrivacyContent({onLinkPress}: PrivacyContentProps) {
  const handleLinkPress = (url: string) => {
    if (onLinkPress) {
      onLinkPress(url)
    } else {
      Linking.openURL(url)
    }
  }

  return (
    <View style={styles.container}>
      <View style={styles.section}>
        <Text style={styles.sectionTitle}>Introduction</Text>
        <Text style={styles.paragraph}>
          This Privacy Policy explains how this AT Protocol client application
          (hereinafter referred to as "the App") handles personal information.
          Please read this policy carefully before using the App.
        </Text>
      </View>

      <View style={styles.section}>
        <Text style={styles.sectionTitle}>Information We Collect</Text>
        <Text style={styles.paragraph}>
          The App may collect and use the following information:
        </Text>

        <Text style={styles.subTitle}>1. Information Collected Automatically</Text>
        <View style={styles.list}>
          <Text style={styles.listItem}>• Device information (model, OS version)</Text>
          <Text style={styles.listItem}>• App usage data (sessions, features used)</Text>
          <Text style={styles.listItem}>• Crash logs and performance data</Text>
        </View>

        <Text style={styles.subTitle}>2. Information Provided by Users</Text>
        <View style={styles.list}>
          <Text style={styles.listItem}>
            • DID (Decentralized Identifier) and handle for authentication
          </Text>
          <Text style={styles.listItem}>• Posts, media, and social interactions</Text>
          <Text style={styles.listItem}>• Profile information (avatar, display name, bio)</Text>
        </View>

        <View style={styles.highlight}>
          <Text style={styles.highlightText}>
            Important: Your data is stored on your chosen PDS (Personal Data Server).
            This app does not store your content on our servers.
          </Text>
        </View>
      </View>

      <View style={styles.section}>
        <Text style={styles.sectionTitle}>How We Use Your Information</Text>
        <View style={styles.list}>
          <Text style={styles.listItem}>
            • To provide AT Protocol social networking features
          </Text>
          <Text style={styles.listItem}>• To improve app performance and user experience</Text>
          <Text style={styles.listItem}>• To diagnose and fix technical issues</Text>
        </View>
      </View>

      <View style={styles.section}>
        <Text style={styles.sectionTitle}>Data Sharing</Text>
        <Text style={styles.paragraph}>
          The App interacts with your chosen PDS and AppView services. Your posts and
          profile information are shared according to the AT Protocol specification and
          your privacy settings.
        </Text>
      </View>

      <View style={styles.section}>
        <Text style={styles.sectionTitle}>Your Rights</Text>
        <Text style={styles.paragraph}>
          You have the right to access, modify, or delete your data through your PDS.
          You can also switch to a different PDS at any time while maintaining your
          identity.
        </Text>
      </View>

      <View style={styles.section}>
        <Text style={styles.sectionTitle}>Contact</Text>
        <Text style={styles.paragraph}>
          For questions about this Privacy Policy, please contact:
        </Text>
        <Pressable onPress={() => handleLinkPress('https://syu.is')}>
          <Text style={styles.link}>https://syu.is</Text>
        </Pressable>
      </View>

      <View style={styles.section}>
        <Text style={styles.lastUpdated}>Last Updated: December 3, 2025</Text>
      </View>
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  section: {
    marginBottom: 24,
  },
  sectionTitle: {
    fontSize: 20,
    fontWeight: '600',
    color: '#1d1d1f',
    marginBottom: 12,
  },
  subTitle: {
    fontSize: 16,
    fontWeight: '500',
    color: '#1d1d1f',
    marginTop: 12,
    marginBottom: 8,
  },
  paragraph: {
    fontSize: 15,
    lineHeight: 22,
    color: '#3a3a3c',
    marginBottom: 8,
  },
  list: {
    marginLeft: 8,
    marginTop: 8,
  },
  listItem: {
    fontSize: 15,
    lineHeight: 24,
    color: '#3a3a3c',
  },
  highlight: {
    backgroundColor: '#fff3cd',
    borderLeftWidth: 4,
    borderLeftColor: '#ffc107',
    padding: 12,
    marginTop: 12,
    borderRadius: 4,
  },
  highlightText: {
    fontSize: 14,
    lineHeight: 20,
    color: '#856404',
  },
  link: {
    fontSize: 15,
    color: '#007aff',
    textDecorationLine: 'underline',
    marginTop: 8,
  },
  lastUpdated: {
    fontSize: 13,
    color: '#8e8e93',
    fontStyle: 'italic',
  },
})
