import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import AppText from 'components/AppText';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { ScrollView, StyleSheet, TouchableOpacity, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import ArrowLeft from 'svg/ArrowLeft';
import { RootStackParamList } from 'types/types';

type TermsScreenNavigationProp = NativeStackNavigationProp<
  RootStackParamList,
  'TermsAndConditions'
>;

const TermsAndConditions = () => {
  const navigation = useNavigation<TermsScreenNavigationProp>();
  const { t } = useTranslation();

  const handleAgree = () => {
    navigation.goBack();
  };

  return (
    <SafeAreaView style={styles.container}>
      <View style={styles.header}>
        <TouchableOpacity onPress={() => navigation.goBack()}>
          <ArrowLeft color="#000" />
        </TouchableOpacity>
        <AppText style={styles.headerTitle}>
          {t('Foydalanish shartlari')}
        </AppText>
        <View style={{ width: 20 }} />
      </View>

      <ScrollView style={styles.content} showsVerticalScrollIndicator={false}>
        <AppText style={styles.title}>
          {t('foydalanish_shartlari_va_qoidalari')}
        </AppText>

        <AppText style={styles.sectionTitle}>{t('umumiy_qoidalar')}</AppText>
        <AppText style={styles.text}>{t('umumiy_qoidalar_text')}</AppText>

        <AppText style={styles.sectionTitle}>
          {t('foydalanuvchi_majburiyatlari')}
        </AppText>
        <AppText style={styles.text}>
          {t('foydalanuvchi_majburiyatlari_text')}
        </AppText>

        <AppText style={styles.sectionTitle}>{t('maxfiylik_siyosati')}</AppText>
        <AppText style={styles.text}>{t('maxfiylik_siyosati_text')}</AppText>

        <AppText style={styles.sectionTitle}>{t('javobgarlik')}</AppText>
        <AppText style={styles.text}>{t('javobgarlik_text')}</AppText>

        <AppText style={styles.sectionTitle}>
          {t('shartlarni_ozgartirish')}
        </AppText>
        <AppText style={styles.text}>
          {t('shartlarni_ozgartirish_text')}
        </AppText>

        <AppText style={styles.sectionTitle}>{t('aloqa')}</AppText>
        <AppText style={styles.text}>{t('aloqa_text')}</AppText>

        <View style={styles.footer}>
          <AppText style={styles.footerText}>
            {t('oxirgi_yangilanish')} {new Date().toLocaleDateString('uz-UZ')}
          </AppText>
        </View>
      </ScrollView>

      <View style={styles.bottomContainer}>
        <TouchableOpacity style={styles.agreeButton} onPress={handleAgree}>
          <AppText style={styles.agreeButtonText}>{t('roziman')}</AppText>
        </TouchableOpacity>
      </View>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
  },
  header: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    paddingHorizontal: 20,
    paddingVertical: 15,
    borderBottomWidth: 1,
    borderBottomColor: '#E5E5E5',
  },
  headerTitle: {
    fontSize: 18,
    fontFamily: 'GolosText-Bold',
    color: '#000',
  },
  content: {
    flex: 1,
    paddingHorizontal: 20,
  },
  title: {
    fontSize: 24,
    fontWeight: 'bold',
    color: '#000',
    marginVertical: 20,
    textAlign: 'center',
  },
  sectionTitle: {
    fontSize: 18,
    fontFamily: 'GolosText-Bold',
    color: '#000',
    marginTop: 20,
    marginBottom: 10,
  },
  text: {
    fontSize: 14,
    lineHeight: 22,
    color: '#333',
    marginBottom: 15,
    textAlign: 'justify',
  },
  footer: {
    marginTop: 30,
    marginBottom: 20,
    alignItems: 'center',
  },
  footerText: {
    fontSize: 12,
    color: '#666',
    fontStyle: 'italic',
  },
  bottomContainer: {
    paddingHorizontal: 20,
    paddingVertical: 15,
    borderTopWidth: 1,
    borderTopColor: '#E5E5E5',
  },
  agreeButton: {
    backgroundColor: '#28A7E8',
    paddingVertical: 15,
    borderRadius: 8,
    alignItems: 'center',
  },
  agreeButtonText: {
    color: '#fff',
    fontSize: 16,
    fontFamily: 'GolosText-Bold',
  },
});

export default TermsAndConditions;
