import React from 'react';
import { View, StyleSheet, TouchableOpacity, ScrollView, Image } from 'react-native';
import { Ionicons } from '@expo/vector-icons';
import { colors, spacing, radii, shadows } from '../../theme/tokens';
import { SafeScreen } from '../../components/layout/SafeScreen';
import { H2, Body, BodyMedium, Caption, Badge } from '../../components/ui';
import { t } from '../../i18n';

interface MenuItem {
  icon: keyof typeof Ionicons.glyphMap;
  titleKey: string;
  descKey: string;
  route: string;
  badge?: string;
  color: string;
}

const MENU_ITEMS: MenuItem[] = [
  { icon: 'scale-outline', titleKey: 'plus.equity', descKey: 'plus.equityDesc', route: 'Equity', color: colors.primary[500] },
  { icon: 'heart-outline', titleKey: 'plus.bigSister', descKey: 'plus.bigSisterDesc', route: 'BigSister', badge: 'comingSoon', color: colors.accent[500] },
  { icon: 'gift-outline', titleKey: 'plus.aids', descKey: 'plus.aidsDesc', route: 'Aids', badge: 'comingSoon', color: colors.secondary[500] },
  { icon: 'settings-outline', titleKey: 'plus.settings', descKey: 'plus.settingsDesc', route: 'Settings', color: colors.neutral[600] },
  { icon: 'shield-checkmark-outline', titleKey: 'plus.privacy', descKey: 'plus.privacyDesc', route: 'Privacy', color: colors.brand.green },
  { icon: 'help-circle-outline', titleKey: 'plus.help', descKey: 'plus.helpDesc', route: 'Help', color: colors.neutral[500] },
];

export function PlusScreen({ navigation }: any) {
  return (
    <SafeScreen scroll padded={false}>
      <ScrollView showsVerticalScrollIndicator={false} contentContainerStyle={styles.scrollContent}>
        <View style={styles.header}>
          <Image
            source={require('../../../assets/branding/logo-wifaq.png')}
            style={styles.logo}
            resizeMode="contain"
          />
          <H2>{t('plus.title')}</H2>
        </View>

        <View style={styles.list}>
          {MENU_ITEMS.map((item) => (
            <TouchableOpacity
              key={item.route}
              style={styles.menuItem}
              onPress={() => navigation.navigate(item.route)}
              accessibilityRole="button"
              accessibilityLabel={t(item.titleKey)}
            >
              <View style={[styles.iconWrap, { backgroundColor: item.color + '15' }]}>
                <Ionicons name={item.icon} size={22} color={item.color} />
              </View>
              <View style={styles.menuInfo}>
                <BodyMedium>{t(item.titleKey)}</BodyMedium>
                <Caption>{t(item.descKey)}</Caption>
              </View>
              {item.badge && (
                <Badge label={t(`common.${item.badge}`)} variant="info" />
              )}
              <Ionicons name="chevron-forward" size={18} color={colors.neutral[300]} />
            </TouchableOpacity>
          ))}
        </View>
      </ScrollView>
    </SafeScreen>
  );
}

const styles = StyleSheet.create({
  scrollContent: {
    paddingHorizontal: spacing.xl,
    paddingBottom: spacing['5xl'],
  },
  header: {
    flexDirection: 'row',
    alignItems: 'center',
    gap: spacing.md,
    paddingTop: spacing.lg,
    marginBottom: spacing['2xl'],
  },
  logo: {
    width: 36,
    height: 36,
  },
  list: {
    gap: spacing.sm,
  },
  menuItem: {
    flexDirection: 'row',
    alignItems: 'center',
    padding: spacing.lg,
    backgroundColor: colors.surface,
    borderRadius: radii.xl,
    gap: spacing.md,
    ...shadows.sm,
  },
  iconWrap: {
    width: 44,
    height: 44,
    borderRadius: 22,
    alignItems: 'center',
    justifyContent: 'center',
  },
  menuInfo: {
    flex: 1,
  },
});
