/* NEXABOT — i18n : contenu FR + EN, détection navigateur + sélecteur */

const CONTENT = {
  fr: {
    nav: { services: "Services", portfolio: "Portfolio", about: "À propos", cta: "Demander un devis" },
    hero: {
      badge: "Automatisation · Apps · Web",
      titleA: "Vos opérations,", titleB: "automatisées intelligemment.",
      sub: "Nexabot conçoit l'automatisation de vos réseaux et centres de données, des petites applications sur mesure et des sites web performants — pour que la technologie travaille pour vous.",
      start: "Démarrer un projet", discover: "Découvrir nos services",
      chips: ["Déploiement rapide", "Fiable & sécurisé", "Support continu"],
      scroll: "défiler",
    },
    services: {
      eyebrow: "Ce que nous faisons",
      h2a: "Trois leviers pour faire passer", h2b: "votre activité à la vitesse supérieure.",
      p: "Nexabot combine infrastructure, développement et présence en ligne dans une même équipe.",
      items: [
        { icon: "network", tag: "Infrastructure", title: "Automatisation des réseaux & centres de données",
          body: "Orchestration, surveillance et automatisation de vos configurations et réseaux. Moins de tâches manuelles, zéro temps d'arrêt, des alertes intelligentes.",
          points: ["Scripts & workflows automatisés", "Supervision 24/7", "Sauvegardes & reprise"] },
        { icon: "app", tag: "Développement", title: "Petites applications sur mesure",
          body: "Des outils internes, tableaux de bord et extensions web qui font gagner du temps à votre équipe. Conçus, livrés et maintenus par Nexabot.",
          points: ["Outils internes & dashboards", "Extensions web", "Automatisation de tâches"] },
        { icon: "web", tag: "Présence en ligne", title: "Sites web modernes & performants",
          body: "Des sites rapides, élégants et optimisés qui convertissent. Du design à la mise en ligne, vous restez concentré sur votre métier.",
          points: ["Design sur mesure", "Optimisé mobile & SEO", "Hébergement & maintenance"] },
      ],
    },
    portfolio: {
      eyebrow: "Nos réalisations", h2: "Portfolio.",
      p: "Nos projets récents — automatisations, applications et sites web. Contenu à venir.",
      badge: "Bientôt disponible", h3: "Contenu à venir",
      body: "Nous préparons une sélection de nos meilleurs projets. Revenez bientôt pour les découvrir — ou contactez-nous pour en discuter dès maintenant.",
      btn: "Discuter d'un projet",
    },
    about: {
      eyebrow: "À propos",
      h2a: "Une jeune entreprise techno,", h2b: "à taille humaine.",
      lead: "Nexabot est née d'une conviction simple : la plupart des entreprises perdent des heures sur des tâches que la technologie peut gérer. Notre mission est d'automatiser l'invisible pour libérer votre temps.",
      body: "Proximité, transparence et résultats concrets : nous travaillons comme un partenaire technique de confiance, pas comme un fournisseur de plus.",
      btn: "Travaillons ensemble",
      stats: [
        { v: 99.9, suffix: "%", label: "Disponibilité visée" },
        { v: 70, suffix: "%", label: "Tâches manuelles éliminées" },
        { v: 24, suffix: "/7", label: "Supervision" },
        { v: 100, suffix: "%", label: "Solutions sur mesure" },
      ],
    },
    contact: {
      eyebrow: "Parlons-en",
      h2a: "Un projet en tête ?", h2b: "Recevez un devis gratuit.",
      p: "Décrivez votre besoin — réseau, application ou site web. Nous revenons vers vous sous 48h avec une proposition claire.",
      info: ["Réponse sous 48h", "Devis gratuit & sans engagement", "Accompagnement continu"],
      fName: "Nom complet", fEmail: "Email", fService: "Service souhaité", fNeed: "Votre besoin",
      phName: "Marie Tremblay", phEmail: "marie@entreprise.com", phNeed: "Décrivez votre projet en quelques mots…",
      options: ["Automatisation réseaux / data center", "Petite application / extension web", "Site web", "Autre / je ne sais pas encore"],
      submit: "Envoyer ma demande",
      errName: "Votre nom est requis.", errEmail: "Email invalide.", errMsg: "Décrivez brièvement votre besoin.",
      sentTitle: "Message envoyé !", sentBody: (n) => `Merci ${n}. L'équipe Nexabot vous recontacte très vite.`,
      sentAgain: "Envoyer un autre message",
    },
    footer: {
      tagline: "L'automatisation, les apps et le web — réunis pour faire grandir votre entreprise.",
      colServices: "Services", colCompany: "Entreprise", colContact: "Contact",
      sAuto: "Automatisation réseaux", sApps: "Applications", sWeb: "Sites web",
      cAbout: "À propos", cPortfolio: "Portfolio", cContact: "Contact",
      quote: "Devis gratuit", legal: "Conçu pour automatiser l'invisible.",
    },
  },

  en: {
    nav: { services: "Services", portfolio: "Portfolio", about: "About", cta: "Request a quote" },
    hero: {
      badge: "Automation · Apps · Web",
      titleA: "Your operations,", titleB: "automated intelligently.",
      sub: "Nexabot builds automation for your networks and data centers, custom small applications, and high-performance websites — so technology works for you.",
      start: "Start a project", discover: "Explore our services",
      chips: ["Fast deployment", "Reliable & secure", "Ongoing support"],
      scroll: "scroll",
    },
    services: {
      eyebrow: "What we do",
      h2a: "Three levers to take your", h2b: "business to the next level.",
      p: "Nexabot brings infrastructure, development, and online presence together in one team.",
      items: [
        { icon: "network", tag: "Infrastructure", title: "Network & data-center automation",
          body: "Orchestration, monitoring, and automation of your configurations and networks. Fewer manual tasks, zero downtime, smart alerts.",
          points: ["Automated scripts & workflows", "24/7 monitoring", "Backups & recovery"] },
        { icon: "app", tag: "Development", title: "Custom small applications",
          body: "Internal tools, dashboards, and web extensions that save your team time. Designed, delivered, and maintained by Nexabot.",
          points: ["Internal tools & dashboards", "Web extensions", "Task automation"] },
        { icon: "web", tag: "Online presence", title: "Modern, high-performance websites",
          body: "Fast, elegant, optimized sites that convert. From design to launch, you stay focused on your business.",
          points: ["Custom design", "Mobile & SEO optimized", "Hosting & maintenance"] },
      ],
    },
    portfolio: {
      eyebrow: "Our work", h2: "Portfolio.",
      p: "Our recent projects — automations, applications, and websites. Coming soon.",
      badge: "Coming soon", h3: "Content coming soon",
      body: "We're putting together a selection of our best projects. Check back soon to discover them — or get in touch to discuss yours right now.",
      btn: "Discuss a project",
    },
    about: {
      eyebrow: "About",
      h2a: "A young tech company,", h2b: "on a human scale.",
      lead: "Nexabot was born from a simple belief: most companies lose hours on tasks technology can handle. Our mission is to automate the invisible and free up your time.",
      body: "Closeness, transparency, and real results: we work as a trusted technical partner, not just another vendor.",
      btn: "Let's work together",
      stats: [
        { v: 99.9, suffix: "%", label: "Target uptime" },
        { v: 70, suffix: "%", label: "Manual tasks eliminated" },
        { v: 24, suffix: "/7", label: "Monitoring" },
        { v: 100, suffix: "%", label: "Tailor-made solutions" },
      ],
    },
    contact: {
      eyebrow: "Let's talk",
      h2a: "Have a project in mind?", h2b: "Get a free quote.",
      p: "Describe your need — network, application, or website. We'll get back to you within 48h with a clear proposal.",
      info: ["Reply within 48h", "Free quote, no commitment", "Ongoing support"],
      fName: "Full name", fEmail: "Email", fService: "Desired service", fNeed: "Your need",
      phName: "Mary Thompson", phEmail: "mary@company.com", phNeed: "Describe your project in a few words…",
      options: ["Network / data-center automation", "Small app / web extension", "Website", "Other / not sure yet"],
      submit: "Send my request",
      errName: "Your name is required.", errEmail: "Invalid email.", errMsg: "Please briefly describe your need.",
      sentTitle: "Message sent!", sentBody: (n) => `Thank you ${n}. The Nexabot team will get back to you very soon.`,
      sentAgain: "Send another message",
    },
    footer: {
      tagline: "Automation, apps, and the web — together to grow your business.",
      colServices: "Services", colCompany: "Company", colContact: "Contact",
      sAuto: "Network automation", sApps: "Applications", sWeb: "Websites",
      cAbout: "About", cPortfolio: "Portfolio", cContact: "Contact",
      quote: "Free quote", legal: "Built to automate the invisible.",
    },
  },
};

function detectLang() {
  try {
    const saved = localStorage.getItem("nexa-lang");
    if (saved === "fr" || saved === "en") return saved;
  } catch (e) {}
  const nav = (navigator.language || navigator.userLanguage || "fr").toLowerCase();
  return nav.startsWith("fr") ? "fr" : "en";
}

const LangContext = React.createContext({ lang: "fr", c: CONTENT.fr, setLang: () => {} });

function LangProvider({ children }) {
  const [lang, setLangState] = React.useState(detectLang);
  React.useEffect(() => {
    document.documentElement.lang = lang;
    try { localStorage.setItem("nexa-lang", lang); } catch (e) {}
  }, [lang]);
  const setLang = (l) => setLangState(l);
  const value = { lang, c: CONTENT[lang], setLang };
  return React.createElement(LangContext.Provider, { value }, children);
}

function useLang() { return React.useContext(LangContext); }

window.NEXA_I18N = { CONTENT, LangProvider, useLang };
