import React, { useState, useCallback, useRef, useEffect } from 'react'; import { View, Text, StyleSheet, FlatList, TextInput, TouchableOpacity, KeyboardAvoidingView, Platform, Alert, ActivityIndicator, Modal, ScrollView, Animated, } from 'react-native'; import { Ionicons } from '@expo/vector-icons'; import { SafeAreaView } from 'react-native-safe-area-context'; import * as SecureStore from 'expo-secure-store'; import * as Speech from 'expo-speech'; import { useBeneficiary } from '@/contexts/BeneficiaryContext'; import { api } from '@/services/api'; import SherpaTTS from '@/services/sherpaTTS'; import { AppColors, BorderRadius, FontSizes, Spacing, FontWeights, Shadows, } from '@/constants/theme'; import type { Message, Beneficiary } from '@/types'; // Try to import speech recognition if available (not available in Expo Go) let ExpoSpeechRecognitionModule: any = null; let SPEECH_RECOGNITION_AVAILABLE = false; try { const speechRecognition = require('expo-speech-recognition'); ExpoSpeechRecognitionModule = speechRecognition.ExpoSpeechRecognitionModule; SPEECH_RECOGNITION_AVAILABLE = true; } catch (e) { console.log('[Voice] expo-speech-recognition not available in Expo Go'); } const OLD_API_URL = 'https://eluxnetworks.net/function/well-api/api'; // DEV ONLY: Voice options for testing different TTS voices const DEV_MODE = __DEV__; interface VoiceOption { id: string; name: string; language: string; voice?: string; // iOS voice identifier } // Available iOS voices for testing const AVAILABLE_VOICES: VoiceOption[] = [ // English voices { id: 'en-US-default', name: 'English (US) - Default', language: 'en-US' }, { id: 'en-US-samantha', name: 'Samantha (US)', language: 'en-US', voice: 'com.apple.ttsbundle.Samantha-compact' }, { id: 'en-GB-daniel', name: 'Daniel (UK)', language: 'en-GB', voice: 'com.apple.ttsbundle.Daniel-compact' }, { id: 'en-AU-karen', name: 'Karen (Australia)', language: 'en-AU', voice: 'com.apple.ttsbundle.Karen-compact' }, { id: 'en-IE-moira', name: 'Moira (Ireland)', language: 'en-IE', voice: 'com.apple.ttsbundle.Moira-compact' }, { id: 'en-ZA-tessa', name: 'Tessa (South Africa)', language: 'en-ZA', voice: 'com.apple.ttsbundle.Tessa-compact' }, { id: 'en-IN-rishi', name: 'Rishi (India)', language: 'en-IN', voice: 'com.apple.ttsbundle.Rishi-compact' }, // European languages { id: 'fr-FR', name: 'French (France)', language: 'fr-FR' }, { id: 'de-DE', name: 'German', language: 'de-DE' }, { id: 'es-ES', name: 'Spanish (Spain)', language: 'es-ES' }, { id: 'es-MX', name: 'Spanish (Mexico)', language: 'es-MX' }, { id: 'it-IT', name: 'Italian', language: 'it-IT' }, { id: 'pt-BR', name: 'Portuguese (Brazil)', language: 'pt-BR' }, { id: 'ru-RU', name: 'Russian', language: 'ru-RU' }, // Asian languages { id: 'zh-CN', name: 'Chinese (Mandarin)', language: 'zh-CN' }, { id: 'ja-JP', name: 'Japanese', language: 'ja-JP' }, { id: 'ko-KR', name: 'Korean', language: 'ko-KR' }, ]; interface ActivityData { name: string; rooms: Array<{ name: string; data: Array<{ title: string; events: number; hours: number; }>; }>; } interface ActivitiesResponse { alert_text: string; chart_data: ActivityData[]; } interface VoiceAskResponse { ok: boolean; response: { Command: string; body: string; name?: string; reflected?: string; language?: string; time?: number; }; status: string; } export default function VoiceAIScreen() { const { currentBeneficiary, setCurrentBeneficiary } = useBeneficiary(); const [messages, setMessages] = useState([ { id: '1', role: 'assistant', content: 'Hello! I\'m Julia, your voice assistant for monitoring your loved ones. Select a beneficiary and tap the microphone to ask a question.', timestamp: new Date(), }, ]); const [input, setInput] = useState(''); const [isSending, setIsSending] = useState(false); const [isSpeaking, setIsSpeaking] = useState(false); const [isListening, setIsListening] = useState(false); const [recognizedText, setRecognizedText] = useState(''); const [showBeneficiaryPicker, setShowBeneficiaryPicker] = useState(false); const [isContinuousMode, setIsContinuousMode] = useState(false); const [beneficiaries, setBeneficiaries] = useState([]); const [selectedVoice, setSelectedVoice] = useState(AVAILABLE_VOICES[0]); const [showVoicePicker, setShowVoicePicker] = useState(false); const [sherpaTTSReady, setSherpaTTSReady] = useState(false); const [useNeuralTTS, setUseNeuralTTS] = useState(true); const flatListRef = useRef(null); const lastSendTimeRef = useRef(0); const pulseAnim = useRef(new Animated.Value(1)).current; const fadeAnim = useRef(new Animated.Value(0)).current; const SEND_COOLDOWN_MS = 1000; // Speech recognition event handlers useEffect(() => { if (!SPEECH_RECOGNITION_AVAILABLE || !ExpoSpeechRecognitionModule) { return; } const subscriptions: any[] = []; try { if (ExpoSpeechRecognitionModule.addListener) { subscriptions.push( ExpoSpeechRecognitionModule.addListener('start', () => { setIsListening(true); setRecognizedText(''); }) ); subscriptions.push( ExpoSpeechRecognitionModule.addListener('end', () => { setIsListening(false); }) ); subscriptions.push( ExpoSpeechRecognitionModule.addListener('result', (event: any) => { const transcript = event.results?.[0]?.transcript || ''; setRecognizedText(transcript); if (event.isFinal && transcript.trim()) { setInput(transcript); setTimeout(() => { handleSendWithText(transcript); }, 300); } }) ); subscriptions.push( ExpoSpeechRecognitionModule.addListener('error', (event: any) => { setIsListening(false); if (event.error !== 'no-speech') { Alert.alert('Voice Error', event.message || 'Could not recognize speech.'); } }) ); } } catch (e) { console.log('[Voice] Could not set up speech recognition listeners:', e); } return () => { subscriptions.forEach((sub) => sub?.remove?.()); }; }, []); // Load beneficiaries and initialize TTS useEffect(() => { loadBeneficiaries(); const initTTS = async () => { try { const success = await SherpaTTS.initialize(); setSherpaTTSReady(success); if (!success) { setUseNeuralTTS(false); } } catch (error) { setUseNeuralTTS(false); } }; initTTS(); return () => { Speech.stop(); SherpaTTS.stop(); SherpaTTS.deinitialize(); }; }, []); // Modal animation useEffect(() => { Animated.timing(fadeAnim, { toValue: showBeneficiaryPicker || showVoicePicker ? 1 : 0, duration: 250, useNativeDriver: true, }).start(); }, [showBeneficiaryPicker, showVoicePicker]); const loadBeneficiaries = async () => { const response = await api.getAllBeneficiaries(); if (response.ok && response.data) { setBeneficiaries(response.data); } }; // Pulse animation for speaking useEffect(() => { if (isSpeaking) { const pulse = Animated.loop( Animated.sequence([ Animated.timing(pulseAnim, { toValue: 1.3, duration: 500, useNativeDriver: true, }), Animated.timing(pulseAnim, { toValue: 1, duration: 500, useNativeDriver: true, }), ]) ); pulse.start(); return () => pulse.stop(); } }, [isSpeaking]); // Fetch activity data const getActivityContext = async (token: string, deploymentId: string): Promise => { try { const response = await fetch(OLD_API_URL, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ function: 'activities_report_details', token: token, deployment_id: deploymentId, filter: '0', }).toString(), }); const data: ActivitiesResponse = await response.json(); if (!data.chart_data || data.chart_data.length === 0) { return ''; } const weeklyData = data.chart_data.find(d => d.name === 'Weekly'); if (!weeklyData) return ''; const lines: string[] = []; lines.push(`Alert status: ${data.alert_text || 'No alert'}`); const todayStats: string[] = []; for (const room of weeklyData.rooms) { const todayData = room.data[room.data.length - 1]; if (todayData && todayData.hours > 0) { todayStats.push(`${room.name}: ${todayData.hours.toFixed(1)} hours (${todayData.events} events)`); } } if (todayStats.length > 0) { lines.push(`Today's activity: ${todayStats.join(', ')}`); } return lines.join('. '); } catch (error) { return ''; } }; const getDashboardContext = async (token: string, deploymentId: string): Promise => { try { const today = new Date().toISOString().split('T')[0]; const response = await fetch(OLD_API_URL, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ function: 'dashboard_single', token: token, deployment_id: deploymentId, date: today, }).toString(), }); const data = await response.json(); if (!data.result_list || data.result_list.length === 0) return ''; const info = data.result_list[0]; const lines: string[] = []; if (info.wellness_descriptor) lines.push(`Current wellness: ${info.wellness_descriptor}`); if (info.wellness_score_percent) lines.push(`Wellness score: ${info.wellness_score_percent}%`); if (info.last_location) lines.push(`Last seen in: ${info.last_location}`); return lines.join('. '); } catch (error) { return ''; } }; const sendToVoiceAsk = async (question: string): Promise => { const token = await SecureStore.getItemAsync('accessToken'); if (!token) throw new Error('Please log in to use voice assistant'); if (!currentBeneficiary?.id) throw new Error('Please select a beneficiary first'); const beneficiaryName = currentBeneficiary.name || 'the patient'; const deploymentId = currentBeneficiary.id.toString(); let activityContext = await getActivityContext(token, deploymentId); if (!activityContext) { activityContext = await getDashboardContext(token, deploymentId); } let enhancedQuestion: string; if (activityContext) { enhancedQuestion = `You are a caring assistant helping monitor ${beneficiaryName}'s wellbeing.\n\nHere is the current data about ${beneficiaryName}:\n${activityContext}\n\nBased on this data, please answer: ${question}`; } else { enhancedQuestion = `You are a caring assistant helping monitor ${beneficiaryName}'s wellbeing. Please answer: ${question}`; } const response = await fetch(OLD_API_URL, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ function: 'voice_ask', clientId: '001', token: token, question: enhancedQuestion, deployment_id: deploymentId, context: activityContext || '', }).toString(), }); const data: VoiceAskResponse = await response.json(); if (data.ok && data.response?.body) { return data.response.body; } else if (data.status === '401 Unauthorized') { throw new Error('Session expired. Please log in again.'); } else { throw new Error('Could not get response from voice assistant'); } }; const speakResponse = async (text: string, autoListenAfter: boolean = false) => { setIsSpeaking(true); const onSpeechComplete = () => { setIsSpeaking(false); if (autoListenAfter && isContinuousMode && currentBeneficiary?.id) { setTimeout(() => startListeningInternal(), 500); } }; try { if (useNeuralTTS && sherpaTTSReady && selectedVoice.language.startsWith('en')) { await SherpaTTS.speak(text, { speed: 1.0, onDone: onSpeechComplete, onError: () => speakWithSystemTTS(text, onSpeechComplete), }); } else { speakWithSystemTTS(text, onSpeechComplete); } } catch (error) { setIsSpeaking(false); } }; const speakWithSystemTTS = (text: string, onDone: () => void) => { const speechOptions: Speech.SpeechOptions = { language: selectedVoice.language, pitch: 1.0, rate: 0.9, onDone, onError: () => setIsSpeaking(false), }; if (selectedVoice.voice) speechOptions.voice = selectedVoice.voice; Speech.speak(text, speechOptions); }; const testVoice = (voice: VoiceOption) => { Speech.stop(); Speech.speak('Hello! I am Julia, your voice assistant.', { language: voice.language, voice: voice.voice, }); }; const handleSend = useCallback(async () => { const trimmedInput = input.trim(); if (!trimmedInput || isSending) return; if (!currentBeneficiary?.id) { Alert.alert('Select Beneficiary', 'Please select a beneficiary first.', [{ text: 'Select', onPress: () => setShowBeneficiaryPicker(true) }, { text: 'Cancel' }] ); return; } const now = Date.now(); if (now - lastSendTimeRef.current < SEND_COOLDOWN_MS) return; lastSendTimeRef.current = now; const userMessage: Message = { id: Date.now().toString(), role: 'user', content: trimmedInput, timestamp: new Date(), }; setMessages(prev => [...prev, userMessage]); setInput(''); setIsSending(true); try { const aiResponse = await sendToVoiceAsk(trimmedInput); const assistantMessage: Message = { id: (Date.now() + 1).toString(), role: 'assistant', content: aiResponse, timestamp: new Date(), }; setMessages(prev => [...prev, assistantMessage]); await speakResponse(aiResponse); } catch (error) { const errorMessage: Message = { id: (Date.now() + 1).toString(), role: 'assistant', content: `Sorry, I encountered an error: ${error instanceof Error ? error.message : 'Unknown error'}`, timestamp: new Date(), }; setMessages(prev => [...prev, errorMessage]); } finally { setIsSending(false); } }, [input, isSending, currentBeneficiary]); const selectBeneficiary = (beneficiary: Beneficiary) => { setCurrentBeneficiary(beneficiary); setShowBeneficiaryPicker(false); const welcomeMessage: Message = { id: Date.now().toString(), role: 'assistant', content: `Ready to answer questions about ${beneficiary.name}. ${beneficiary.wellness_descriptor ? `Status: ${beneficiary.wellness_descriptor}.` : ''} Ask me anything!`, timestamp: new Date(), }; setMessages(prev => [...prev, welcomeMessage]); speakResponse(`Ready to answer questions about ${beneficiary.name}`); }; const stopSpeaking = async () => { Speech.stop(); SherpaTTS.stop(); setIsSpeaking(false); setIsContinuousMode(false); }; const startListeningInternal = () => { if (!SPEECH_RECOGNITION_AVAILABLE || !ExpoSpeechRecognitionModule) return; if (isSending || isSpeaking) return; if (!currentBeneficiary?.id) return; Speech.stop(); setIsSpeaking(false); ExpoSpeechRecognitionModule.start({ lang: 'en-US', interimResults: true, maxAlternatives: 1, continuous: false, }); }; const startListening = async () => { if (!SPEECH_RECOGNITION_AVAILABLE || !ExpoSpeechRecognitionModule) { // Silent in Expo Go - voice recognition requires native build // User can still type messages manually return; } if (isSending || isSpeaking) return; if (!currentBeneficiary?.id) { Alert.alert('Select Beneficiary', 'Please select a beneficiary first.', [{ text: 'Select', onPress: () => setShowBeneficiaryPicker(true) }, { text: 'Cancel' }] ); return; } const result = await ExpoSpeechRecognitionModule.requestPermissionsAsync(); if (!result.granted) { Alert.alert('Microphone Permission Required', 'Please grant microphone permission.'); return; } setIsContinuousMode(true); Speech.stop(); setIsSpeaking(false); ExpoSpeechRecognitionModule.start({ lang: 'en-US', interimResults: true, maxAlternatives: 1, continuous: false, }); }; const stopListening = () => { if (ExpoSpeechRecognitionModule) { ExpoSpeechRecognitionModule.stop(); } setIsListening(false); setIsContinuousMode(false); }; const handleSendWithText = async (text: string) => { const trimmedInput = text.trim(); if (!trimmedInput || isSending) return; if (!currentBeneficiary?.id) return; const now = Date.now(); if (now - lastSendTimeRef.current < SEND_COOLDOWN_MS) return; lastSendTimeRef.current = now; const userMessage: Message = { id: Date.now().toString(), role: 'user', content: trimmedInput, timestamp: new Date(), }; setMessages(prev => [...prev, userMessage]); setInput(''); setRecognizedText(''); setIsSending(true); try { const aiResponse = await sendToVoiceAsk(trimmedInput); const assistantMessage: Message = { id: (Date.now() + 1).toString(), role: 'assistant', content: aiResponse, timestamp: new Date(), }; setMessages(prev => [...prev, assistantMessage]); await speakResponse(aiResponse, true); } catch (error) { const errorMessage: Message = { id: (Date.now() + 1).toString(), role: 'assistant', content: `Sorry, an error occurred: ${error instanceof Error ? error.message : 'Unknown error'}`, timestamp: new Date(), }; setMessages(prev => [...prev, errorMessage]); if (isContinuousMode && currentBeneficiary?.id) { setTimeout(() => startListeningInternal(), 500); } } finally { setIsSending(false); } }; const renderMessage = ({ item }: { item: Message }) => { const isUser = item.role === 'user'; return ( {!isUser && ( )} {item.content} {item.timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} ); }; return ( {/* Header */} Julia AI {isSending ? 'Thinking...' : isListening ? 'Listening...' : isSpeaking ? 'Speaking...' : currentBeneficiary ? `Monitoring ${currentBeneficiary.name}` : 'Select a beneficiary'} {DEV_MODE && ( setShowVoicePicker(true)}> )} setShowBeneficiaryPicker(true)}> {currentBeneficiary?.name?.split(' ')[0] || 'Select'} {/* Messages */} item.id} renderItem={renderMessage} contentContainerStyle={styles.messagesList} showsVerticalScrollIndicator={false} onContentSizeChange={() => flatListRef.current?.scrollToEnd({ animated: true })} /> {/* Listening indicator */} {isListening && ( {recognizedText || 'Listening... tap to stop'} )} {/* Speaking indicator */} {isSpeaking && !isListening && ( {isContinuousMode ? 'Live mode - Speaking...' : 'Speaking...'} tap to stop )} {/* Continuous mode indicator */} {isContinuousMode && !isListening && !isSpeaking && !isSending && ( setIsContinuousMode(false)}> Live chat active - tap to stop )} {/* Input */} {isSending ? ( ) : ( )} {/* Beneficiary Picker Modal */} setShowBeneficiaryPicker(false)} /> Select Beneficiary setShowBeneficiaryPicker(false)}> {beneficiaries.length === 0 ? ( Loading beneficiaries... ) : ( beneficiaries.map(beneficiary => ( selectBeneficiary(beneficiary)} > {beneficiary.name.charAt(0).toUpperCase()} {beneficiary.name} {beneficiary.wellness_descriptor || beneficiary.last_location || 'No data'} )) )} {/* Voice Picker Modal (DEV) */} {DEV_MODE && ( setShowVoicePicker(false)} /> Voice Settings DEV ONLY setShowVoicePicker(false)}> Current: {selectedVoice.name} testVoice(selectedVoice)}> Test English Voices {AVAILABLE_VOICES.filter(v => v.language.startsWith('en-')).map(voice => ( setSelectedVoice(voice)} > {voice.name} {voice.language} testVoice(voice)}> {selectedVoice.id === voice.id && ( )} ))} Other Languages {AVAILABLE_VOICES.filter(v => !v.language.startsWith('en-')).map(voice => ( setSelectedVoice(voice)} > {voice.name} {voice.language} testVoice(voice)}> {selectedVoice.id === voice.id && ( )} ))} { setShowVoicePicker(false); Speech.speak(`Voice changed to ${selectedVoice.name}`, { language: selectedVoice.language, voice: selectedVoice.voice, }); }} > Apply & Close )} ); } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: AppColors.background, }, // Header header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: Spacing.lg, paddingVertical: Spacing.md, borderBottomWidth: 1, borderBottomColor: AppColors.border, }, headerLeft: { flexDirection: 'row', alignItems: 'center', gap: Spacing.md, }, headerAvatar: { width: 44, height: 44, borderRadius: BorderRadius.lg, backgroundColor: AppColors.accent, justifyContent: 'center', alignItems: 'center', }, headerTitle: { fontSize: FontSizes.lg, fontWeight: FontWeights.semibold, color: AppColors.textPrimary, }, headerSubtitle: { fontSize: FontSizes.sm, color: AppColors.success, fontWeight: FontWeights.medium, }, headerRight: { flexDirection: 'row', alignItems: 'center', gap: Spacing.sm, }, voiceSettingsButton: { width: 36, height: 36, borderRadius: BorderRadius.md, backgroundColor: AppColors.accentLight, justifyContent: 'center', alignItems: 'center', }, beneficiaryButton: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: Spacing.md, paddingVertical: Spacing.sm, backgroundColor: AppColors.primarySubtle, borderRadius: BorderRadius.lg, gap: Spacing.xs, }, beneficiaryButtonText: { fontSize: FontSizes.sm, color: AppColors.primary, fontWeight: FontWeights.medium, }, // Chat chatContainer: { flex: 1, }, messagesList: { padding: Spacing.lg, paddingBottom: Spacing.xl, }, messageRow: { flexDirection: 'row', marginBottom: Spacing.md, alignItems: 'flex-end', }, userMessageRow: { justifyContent: 'flex-end', }, avatarContainer: { width: 32, height: 32, borderRadius: BorderRadius.md, backgroundColor: AppColors.accent, justifyContent: 'center', alignItems: 'center', marginRight: Spacing.sm, }, messageBubble: { maxWidth: '75%', padding: Spacing.md, borderRadius: BorderRadius.xl, }, userBubble: { backgroundColor: AppColors.primary, borderBottomRightRadius: BorderRadius.xs, ...Shadows.sm, }, assistantBubble: { backgroundColor: AppColors.surface, borderBottomLeftRadius: BorderRadius.xs, ...Shadows.xs, }, messageText: { fontSize: FontSizes.base, lineHeight: 22, color: AppColors.textPrimary, }, userMessageText: { color: AppColors.white, }, timestamp: { fontSize: FontSizes.xs, color: AppColors.textMuted, marginTop: Spacing.xs, alignSelf: 'flex-end', }, userTimestamp: { color: 'rgba(255,255,255,0.7)', }, // Indicators listeningIndicator: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', paddingVertical: Spacing.sm, paddingHorizontal: Spacing.md, backgroundColor: AppColors.errorLight, marginHorizontal: Spacing.lg, borderRadius: BorderRadius.lg, marginBottom: Spacing.sm, }, listeningText: { fontSize: FontSizes.sm, color: AppColors.error, fontWeight: FontWeights.medium, marginLeft: Spacing.sm, flex: 1, }, speakingIndicator: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', paddingVertical: Spacing.sm, paddingHorizontal: Spacing.md, backgroundColor: AppColors.accentLight, marginHorizontal: Spacing.lg, borderRadius: BorderRadius.lg, marginBottom: Spacing.sm, }, speakingText: { fontSize: FontSizes.sm, color: AppColors.accent, fontWeight: FontWeights.medium, marginLeft: Spacing.sm, }, continuousModeIndicator: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', paddingVertical: Spacing.sm, paddingHorizontal: Spacing.md, backgroundColor: AppColors.successLight, marginHorizontal: Spacing.lg, borderRadius: BorderRadius.lg, marginBottom: Spacing.sm, }, continuousModeText: { fontSize: FontSizes.sm, color: AppColors.success, fontWeight: FontWeights.medium, marginLeft: Spacing.sm, }, // Input inputContainer: { flexDirection: 'row', alignItems: 'flex-end', padding: Spacing.md, paddingHorizontal: Spacing.lg, backgroundColor: AppColors.surface, borderTopWidth: 1, borderTopColor: AppColors.border, gap: Spacing.sm, }, micButton: { width: 48, height: 48, borderRadius: BorderRadius.lg, backgroundColor: AppColors.primarySubtle, justifyContent: 'center', alignItems: 'center', borderWidth: 2, borderColor: AppColors.primary, }, micButtonActive: { backgroundColor: AppColors.error, borderColor: AppColors.error, }, micButtonContinuous: { borderColor: AppColors.success, backgroundColor: AppColors.successLight, }, micButtonDisabled: { borderColor: AppColors.borderLight, backgroundColor: AppColors.surfaceSecondary, opacity: 0.6, }, inputWrapper: { flex: 1, backgroundColor: AppColors.surfaceSecondary, borderRadius: BorderRadius.xl, borderWidth: 1.5, borderColor: AppColors.borderLight, }, input: { paddingHorizontal: Spacing.md, paddingVertical: Spacing.sm, fontSize: FontSizes.base, color: AppColors.textPrimary, maxHeight: 100, }, sendButton: { width: 48, height: 48, borderRadius: BorderRadius.lg, backgroundColor: AppColors.primary, justifyContent: 'center', alignItems: 'center', ...Shadows.primary, }, sendButtonDisabled: { backgroundColor: AppColors.surfaceSecondary, shadowOpacity: 0, }, // Modal modalOverlay: { flex: 1, justifyContent: 'flex-end', }, modalBackdrop: { ...StyleSheet.absoluteFillObject, backgroundColor: AppColors.overlay, }, modalContent: { backgroundColor: AppColors.background, borderTopLeftRadius: BorderRadius['2xl'], borderTopRightRadius: BorderRadius['2xl'], maxHeight: '70%', ...Shadows.xl, }, modalHeader: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: Spacing.lg, paddingVertical: Spacing.lg, borderBottomWidth: 1, borderBottomColor: AppColors.border, }, modalHeaderContent: { flexDirection: 'row', alignItems: 'center', gap: Spacing.md, }, modalIconContainer: { width: 40, height: 40, borderRadius: BorderRadius.lg, backgroundColor: AppColors.primaryLighter, justifyContent: 'center', alignItems: 'center', }, modalTitle: { fontSize: FontSizes.xl, fontWeight: FontWeights.bold, color: AppColors.textPrimary, }, modalCloseButton: { width: 36, height: 36, borderRadius: BorderRadius.md, backgroundColor: AppColors.surfaceSecondary, justifyContent: 'center', alignItems: 'center', }, devBadge: { fontSize: FontSizes.xs, color: AppColors.error, fontWeight: FontWeights.semibold, }, beneficiaryList: { padding: Spacing.lg, }, beneficiaryItem: { flexDirection: 'row', alignItems: 'center', padding: Spacing.md, backgroundColor: AppColors.surface, borderRadius: BorderRadius.xl, marginBottom: Spacing.sm, ...Shadows.xs, }, beneficiaryItemSelected: { backgroundColor: AppColors.primarySubtle, borderWidth: 2, borderColor: AppColors.primary, }, beneficiaryAvatar: { width: 44, height: 44, borderRadius: BorderRadius.lg, backgroundColor: AppColors.primaryLighter, justifyContent: 'center', alignItems: 'center', marginRight: Spacing.md, }, beneficiaryAvatarText: { fontSize: FontSizes.lg, fontWeight: FontWeights.bold, color: AppColors.primary, }, beneficiaryInfo: { flex: 1, }, beneficiaryName: { fontSize: FontSizes.base, fontWeight: FontWeights.semibold, color: AppColors.textPrimary, }, beneficiaryStatus: { fontSize: FontSizes.sm, color: AppColors.textMuted, marginTop: 2, }, statusDot: { width: 12, height: 12, borderRadius: 6, }, emptyState: { alignItems: 'center', padding: Spacing.xl, }, emptyStateText: { marginTop: Spacing.md, fontSize: FontSizes.base, color: AppColors.textMuted, }, // Voice Picker currentVoiceInfo: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', padding: Spacing.md, paddingHorizontal: Spacing.lg, backgroundColor: AppColors.accentLight, borderBottomWidth: 1, borderBottomColor: AppColors.border, }, currentVoiceLabel: { fontSize: FontSizes.base, color: AppColors.textPrimary, fontWeight: FontWeights.medium, flex: 1, }, testVoiceButton: { flexDirection: 'row', alignItems: 'center', backgroundColor: AppColors.accent, paddingHorizontal: Spacing.md, paddingVertical: Spacing.sm, borderRadius: BorderRadius.lg, gap: Spacing.xs, }, testVoiceButtonText: { color: AppColors.white, fontSize: FontSizes.sm, fontWeight: FontWeights.semibold, }, voiceList: { padding: Spacing.lg, }, voiceSectionTitle: { fontSize: FontSizes.xs, fontWeight: FontWeights.semibold, color: AppColors.textMuted, textTransform: 'uppercase', letterSpacing: 0.5, marginTop: Spacing.md, marginBottom: Spacing.sm, }, voiceItem: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', padding: Spacing.md, backgroundColor: AppColors.surface, borderRadius: BorderRadius.lg, marginBottom: Spacing.sm, ...Shadows.xs, }, voiceItemSelected: { backgroundColor: AppColors.accentLight, borderWidth: 1, borderColor: AppColors.accent, }, voiceItemInfo: { flex: 1, }, voiceItemName: { fontSize: FontSizes.base, color: AppColors.textPrimary, fontWeight: FontWeights.medium, }, voiceItemLang: { fontSize: FontSizes.xs, color: AppColors.textMuted, marginTop: 2, }, voiceItemActions: { flexDirection: 'row', alignItems: 'center', gap: Spacing.sm, }, playButton: { padding: Spacing.xs, }, applyButton: { backgroundColor: AppColors.accent, margin: Spacing.lg, padding: Spacing.md, borderRadius: BorderRadius.lg, alignItems: 'center', ...Shadows.primary, }, applyButtonText: { color: AppColors.white, fontSize: FontSizes.base, fontWeight: FontWeights.semibold, }, });