import { createContext, useContext, useState } from 'react';

const LanguageContext = createContext();

export const translations = {
    en: {
        nav: {
            pricing: 'Pricing',
            contact: 'Contact',
            login: 'Login',
            getInTouch: 'Get in touch'
        },
        home: {
            title: 'AI-powered',
            subtitle: 'brand growth',
            description: 'BYOM IS AN AI-POWERED PLATFORM FOCUSING ON HELPING INFLUENCERS GROW THEIR BRAND THROUGH ADVANCED ANALYTICS AND CREATIVE TOOLS.',
            explore: 'Explore features',
            features: {
                aiTrends: 'AI TRENDS',
                imageGen: 'IMAGE GENERATION',
                analytics: 'ANALYTICS',
                brandGrowth: 'BRAND GROWTH'
            }
        },
        pricing: {
            title: 'Pricing',
            subtitle: 'Scale your influence with AI',
            description: 'Choose the perfect plan for your brand\'s growth',
            mostPopular: 'Most popular',
            perMonth: '/month',
            getStarted: 'Get started with',
            trial: 'All plans include 14-day free trial. No credit card required'
        },
        login: {
            title: 'Welcome back',
            subtitle: 'Enter your email to continue',
            continue: 'Continue with email',
            noAccount: 'Don\'t have an account?',
            viewPricing: 'View pricing'
        }
    },
    fr: {
        nav: {
            pricing: 'Tarifs',
            contact: 'Contact',
            login: 'Connexion',
            getInTouch: 'Contactez-nous'
        },
        home: {
            title: 'AI-powered',
            subtitle: 'brand growth',
            description: 'BYOM EST UNE PLATEFORME ALIMENTÉE PAR L\'IA QUI AIDE LES INFLUENCEURS À DÉVELOPPER LEUR MARQUE GRÂCE À DES OUTILS D\'ANALYSE AVANCÉS ET CRÉATIFS.',
            explore: 'Explorer les fonctionnalités',
            features: {
                aiTrends: 'TENDANCES IA',
                imageGen: 'GÉNÉRATION D\'IMAGES',
                analytics: 'ANALYSES',
                brandGrowth: 'CROISSANCE DE MARQUE'
            }
        },
        pricing: {
            title: 'Tarifs',
            subtitle: 'Développez votre influence avec l\'IA',
            description: 'Choisissez le forfait parfait pour la croissance de votre marque',
            mostPopular: 'Plus populaire',
            perMonth: '/mois',
            getStarted: 'Commencer avec',
            trial: 'Tous les forfaits incluent un essai gratuit de 14 jours. Pas de carte bancaire requise'
        },
        login: {
            title: 'Bon retour',
            subtitle: 'Entrez votre email pour continuer',
            continue: 'Continuer avec email',
            noAccount: 'Vous n\'avez pas de compte ?',
            viewPricing: 'Voir les tarifs'
        }
    }
};

export function LanguageProvider({ children }) {
    const [language, setLanguage] = useState('en');

    const value = {
        language,
        setLanguage,
        t: (key) => {
            const keys = key.split('.');
            return keys.reduce((obj, k) => obj?.[k], translations[language]) || key;
        }
    };

    return (
        <LanguageContext.Provider value={value}>
            {children}
        </LanguageContext.Provider>
    );
}

export const useLanguage = () => {
    const context = useContext(LanguageContext);
    if (!context) {
        throw new Error('useLanguage must be used within a LanguageProvider');
    }
    return context;
}; 