import React from 'react';
import {
  View,
  Text,
  StyleSheet,
  ScrollView,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { AppColors, BorderRadius, FontSizes, Spacing } from '@/constants/theme';
import { PageHeader } from '@/components/PageHeader';

export default function TermsScreen() {
  return (
    <SafeAreaView style={styles.container} edges={['top', 'bottom']}>
      <PageHeader title="Terms of Service" />
      <ScrollView showsVerticalScrollIndicator={false}>
        <View style={styles.content}>
          <Text style={styles.lastUpdated}>Last Updated: December 2024</Text>

          <Text style={styles.sectionTitle}>1. Acceptance of Terms</Text>
          <Text style={styles.paragraph}>
            By accessing and using WellNuo ("the Service"), you agree to be bound by these
            Terms of Service and all applicable laws and regulations. If you do not agree
            with any of these terms, you are prohibited from using or accessing this Service.
          </Text>

          <Text style={styles.sectionTitle}>2. Description of Service</Text>
          <Text style={styles.paragraph}>
            WellNuo provides an elderly care monitoring platform that allows caregivers and
            family members to monitor the wellness and activity of their loved ones through
            connected sensors and devices. The Service includes:
          </Text>
          <Text style={styles.bulletPoint}>• Real-time activity monitoring</Text>
          <Text style={styles.bulletPoint}>• Wellness score tracking</Text>
          <Text style={styles.bulletPoint}>• Emergency alert notifications</Text>
          <Text style={styles.bulletPoint}>• AI-powered health insights (Pro plan)</Text>
          <Text style={styles.bulletPoint}>• Data analytics and reporting</Text>

          <Text style={styles.sectionTitle}>3. User Accounts</Text>
          <Text style={styles.paragraph}>
            To use the Service, you must create an account and provide accurate, complete
            information. You are responsible for:
          </Text>
          <Text style={styles.bulletPoint}>• Maintaining the confidentiality of your account</Text>
          <Text style={styles.bulletPoint}>• All activities that occur under your account</Text>
          <Text style={styles.bulletPoint}>• Notifying us immediately of any unauthorized use</Text>

          <Text style={styles.sectionTitle}>4. Privacy and Data Protection</Text>
          <Text style={styles.paragraph}>
            Your privacy is critically important to us. Our Privacy Policy explains how we
            collect, use, and protect your personal information and the data of beneficiaries.
            By using the Service, you consent to our data practices.
          </Text>
          <Text style={styles.paragraph}>
            Key privacy commitments:
          </Text>
          <Text style={styles.bulletPoint}>• End-to-end encryption for all data</Text>
          <Text style={styles.bulletPoint}>• HIPAA-compliant data storage</Text>
          <Text style={styles.bulletPoint}>• No sale of personal data to third parties</Text>
          <Text style={styles.bulletPoint}>• Right to data export and deletion</Text>

          <Text style={styles.sectionTitle}>5. Acceptable Use</Text>
          <Text style={styles.paragraph}>
            You agree to use the Service only for lawful purposes and in accordance with
            these Terms. You agree NOT to:
          </Text>
          <Text style={styles.bulletPoint}>• Use the Service for any illegal purpose</Text>
          <Text style={styles.bulletPoint}>• Violate any beneficiary's privacy rights</Text>
          <Text style={styles.bulletPoint}>• Share your account credentials with others</Text>
          <Text style={styles.bulletPoint}>• Attempt to reverse engineer the Service</Text>
          <Text style={styles.bulletPoint}>• Transmit any malware or harmful code</Text>

          <Text style={styles.sectionTitle}>6. Subscription and Billing</Text>
          <Text style={styles.paragraph}>
            WellNuo offers both free and paid subscription plans:
          </Text>
          <Text style={styles.bulletPoint}>• Free Plan: Basic features with limited beneficiaries</Text>
          <Text style={styles.bulletPoint}>• Pro Plan: Full features billed monthly or annually</Text>
          <Text style={styles.paragraph}>
            Subscription fees are billed in advance. You may cancel at any time, but refunds
            are not provided for partial billing periods.
          </Text>

          <Text style={styles.sectionTitle}>7. Disclaimers</Text>
          <Text style={styles.paragraph}>
            The Service is provided "as is" without warranties of any kind. WellNuo:
          </Text>
          <Text style={styles.bulletPoint}>• Does not guarantee continuous, uninterrupted service</Text>
          <Text style={styles.bulletPoint}>• Is not a medical device or substitute for professional care</Text>
          <Text style={styles.bulletPoint}>• Cannot guarantee detection of all emergencies</Text>
          <Text style={styles.paragraph}>
            Always seek professional medical advice for health concerns.
          </Text>

          <Text style={styles.sectionTitle}>8. Limitation of Liability</Text>
          <Text style={styles.paragraph}>
            To the maximum extent permitted by law, WellNuo shall not be liable for any
            indirect, incidental, special, consequential, or punitive damages arising out
            of your use of the Service.
          </Text>

          <Text style={styles.sectionTitle}>9. Indemnification</Text>
          <Text style={styles.paragraph}>
            You agree to indemnify and hold harmless WellNuo and its affiliates from any
            claims, damages, or expenses arising from your use of the Service or violation
            of these Terms.
          </Text>

          <Text style={styles.sectionTitle}>10. Modifications</Text>
          <Text style={styles.paragraph}>
            We reserve the right to modify these Terms at any time. We will notify you of
            material changes through the app or email. Continued use after changes constitutes
            acceptance of the new Terms.
          </Text>

          <Text style={styles.sectionTitle}>11. Termination</Text>
          <Text style={styles.paragraph}>
            We may terminate or suspend your account at any time for violation of these Terms.
            Upon termination, your right to use the Service ceases immediately.
          </Text>

          <Text style={styles.sectionTitle}>12. Governing Law</Text>
          <Text style={styles.paragraph}>
            These Terms shall be governed by the laws of the State of California, United States,
            without regard to conflict of law provisions.
          </Text>

          <Text style={styles.sectionTitle}>13. Contact Information</Text>
          <Text style={styles.paragraph}>
            For questions about these Terms, please contact us:
          </Text>
          <Text style={styles.contactInfo}>WellNuo Inc.</Text>
          <Text style={styles.contactInfo}>Email: legal@wellnuo.com</Text>
          <Text style={styles.contactInfo}>Address: 123 Care Street, San Francisco, CA 94102</Text>

          <View style={styles.footer}>
            <Text style={styles.footerText}>
              By using WellNuo, you acknowledge that you have read, understood, and agree
              to be bound by these Terms of Service.
            </Text>
          </View>
        </View>
      </ScrollView>
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: AppColors.background,
  },
  content: {
    padding: Spacing.lg,
  },
  lastUpdated: {
    fontSize: FontSizes.sm,
    color: AppColors.textMuted,
    marginBottom: Spacing.lg,
    textAlign: 'center',
  },
  sectionTitle: {
    fontSize: FontSizes.lg,
    fontWeight: '600',
    color: AppColors.textPrimary,
    marginTop: Spacing.lg,
    marginBottom: Spacing.sm,
  },
  paragraph: {
    fontSize: FontSizes.sm,
    color: AppColors.textSecondary,
    lineHeight: 22,
    marginBottom: Spacing.sm,
  },
  bulletPoint: {
    fontSize: FontSizes.sm,
    color: AppColors.textSecondary,
    lineHeight: 22,
    marginLeft: Spacing.md,
    marginBottom: 4,
  },
  contactInfo: {
    fontSize: FontSizes.sm,
    color: AppColors.textPrimary,
    marginBottom: 4,
  },
  footer: {
    marginTop: Spacing.xl,
    paddingTop: Spacing.lg,
    borderTopWidth: 1,
    borderTopColor: AppColors.border,
  },
  footerText: {
    fontSize: FontSizes.xs,
    color: AppColors.textMuted,
    textAlign: 'center',
    fontStyle: 'italic',
  },
});
