/* global React, ReactDOM,
   Nav, Hero, Metrics, ProblemSolution, Capabilities, Phases, Sectors,
   Deployment, References, CTA, Footer,
   useTweaks, TweaksPanel, TweakSection, TweakRadio, TweakToggle, TweakColor */

const { useState, useEffect } = React;

// ─── Content (TR + EN) ─────────────────────────────────────────────
const CONTENT = {
  tr: {
    demoCta: "Demo Talep Et",
    navLinks: [
      { label: "Platform",      href: "#solution" },
      { label: "Modüller",      href: "#phases" },
      { label: "Yetenekler",    href: "#capabilities" },
      { label: "Sektörler",     href: "#sectors" },
      // { label: "Referanslar",   href: "#references" },
    ],
    hero: {
      badge: "powered by Infus",
      h1a: "Kurumsal AI Agent",
      h1b: "Platformu.",
      sub: "Kognitera; müşteri iletişimini, operasyonel süreçleri ve kurum içi iş akışlarını tek bir akıllı çekirdek altında, çok kanallı AI agent'lar ile yönetir.",
      cta1: "Demo Talep Et",
      cta2: "Ürün Turunu İzle",
      meta: ["Cloud veya On-Prem", "Kurumsal uyumluluk"],
      trustLabel: "Kanıtlanmış kurumsal kullanım",
      trustList: ["MAPFRE", "TCDD Taşımacılık", "NDK", "Pusula CX", "Runitas"]
    },
    engine: {
      channels: ["WhatsApp", "Web Chat", "Instagram", "E-posta", "Çağrı Merkezi"],
      caps:     ["Analitik", "Karşılama", "Bilgi Bankası", "Randevu", "Satış"]
    },
    metrics: {
      tag: "Hedeflenen / Pilot Metrikler",
      items: [
        { value: "24/7", label: "Dijital iş gücü, kesintisiz",  accent: true },
        { value: 80,     prefix: "~", suffix: "%", label: "Daha hızlı ilk yanıt süresi" },
        { value: 70,     prefix: "~", suffix: "%", label: "Otomatize edilen tekrarlı etkileşim" },
        { value: 45,     prefix: "~", suffix: "%", label: "Daha düşük operasyon maliyeti" }
      ]
    },
    ps: {
      eyebrow: "// PLATFORM",
      title: "Dağınık kanallardan, tek akıllı çekirdeğe.",
      sub: "Klasik operasyonun darboğazlarını, rol bazlı AI ajanları ve sistem entegrasyonlarıyla değiştiriyoruz.",
      problemsLabel: "Bugünün sorunları",
      solutionsLabel: "Kognitera'nın yanıtı",
      problems: [
        "Dağılmış müşteri iletişim kanalları",
        "Manuel operasyon yükü ve tekrarlı görevler",
        "Yavaş yanıt ve geri dönüş süreleri",
        "Tutarsız müşteri deneyimi ve veri kaybı"
      ],
      solutions: [
        "Tek akıllı çekirdek, çok kanal yönetimi",
        "Rol bazlı AI ajanları — karşılama, satış, takip",
        "CRM, helpdesk ve operasyon sistem entegrasyonları",
        "Kontrollü insan devri ve denetlenebilir akışlar"
      ]
    },
    caps: {
      eyebrow: "// ROL BAZLI AJANLAR",
      title: "Rol Bazlı Ajan Yapısı",
      sub: "Her ajan tek başına değer üretir; birlikte ise uçtan uca dijital iş gücü katmanını oluşturur.",
      items: [
        { title: "Çağrı Merkezi Copilot",  desc: "Operatöre yanıt önerir, görüşmeyi özetler, hız kazandırır." },
        { title: "Karşılama & Yönlendirme", desc: "Gelen talebi anlar, doğru akışa ve senaryoya yönlendirir." },
        { title: "Bilgi Toplama & Kayıt", desc: "Gerekli bilgileri toplar, kaydı veya talebi sistem üzerinde açar." },
        { title: "Operasyon Takibi",       desc: "Dosya, süreç ve akışları izler, günceller ve raporlar." },
        { title: "Randevu & Planlama",     desc: "Uygunluk kontrolünü yapar, müşteri onayıyla planı oluşturur." },
        { title: "Satış & Lead Takibi",    desc: "Potansiyel müşterileri izler, teklif ve dönüşümü destekler." }
      ],
      summary: "Tek bir AI çekirdeği, tüm kanal ve ajanları tek bir zeka katmanında birleştirir.",
      cta: "Mimariye Bak"
    },
    phases: {
      eyebrow: "// 3-FAZLI BENİMSEME",
      title: "Agentic AI Onboarding Modeli",
      sub: "Önce dinleriz, sonra birlikte çalışırız, sonra otonom işleyişe geçeriz. Üç adımda kontrollü dönüşüm.",
      items: [
        { kicker: "MODÜL · ANALİTİK", title: "Speech Analytics", tag: "Temel katman",
          desc: "Mevcut süreç, kanal ve manuel iş yükü, ses ve metin verisinden çıkarılır; AI ile çözülecek darboğaz ve hedef KPI'lar netleşir." },
        { kicker: "MODÜL · HİBRİT", title: "Hybrid Assistant", tag: "İnsan kontrolünde",
          desc: "Ajanlar ekibin yanında çalışır; özetleme ve takip yükünü üzerlerine alır. Temsilciye anlık yardımcı olurken insan kontrolü ve son söz tamamen sizde kalır." },
        { kicker: "MODÜL · OTONOM", title: "Full Autonomous Agent", tag: "Dijital iş gücü",
          desc: "Seçilen operasyon rolleri ajanlara devredilir. Dijital iş gücü; tüm kanallarda otonom ölçeklenir, ekipler ise yüksek değerli ve stratejik işlere odaklanır." }
      ]
    },
    sectors: {
      eyebrow: "// SEKTÖRLER",
      title: "Düzenlenmiş, yüksek hacimli sektörler için.",
      sub: "Kanıtlanmış kurumsal entegrasyonlar — uyumluluk, ölçek ve denetim ön planda.",
      items: [
        { name: "Sigorta",        use: "Hasar bildirimi, poliçe soruları, FNOL yönlendirme." },
        { name: "Filo & Otomotiv", use: "Servis randevusu, dosya takibi, durum güncellemeleri." },
        { name: "E-Ticaret",       use: "Sipariş / iade yönetimi, ön-satış, lead dönüşümü." },
        { name: "Sağlık",          use: "Randevu planlama, hasta triyaj yönlendirmesi, bilgi talepleri." },
        { name: "Finans",          use: "Başvuru alma, KYC veri toplama, destek deflection." },
        { name: "Telekom",         use: "Yüksek hacimli destek, retention, çağrı merkezi copilot." }
      ]
    },
    deploy: {
      eyebrow: "// DEPLOYMENT",
      title: "Keşiften canlıya, ölçülebilir bir yolculuk.",
      sub: "Hibrit kurulum, kanıtlanmış POC akışı ve denetlenebilir KPI yapısı ile kontrollü geçiş.",
      steps: [
        { title: "Keşif & Tasarım", desc: "Süreç, kanal ve KPI haritası çıkarılır." },
        { title: "Entegrasyon",     desc: "CRM, helpdesk ve operasyon sistemleri bağlanır." },
        { title: "Pilot / POC",     desc: "Seçilen rol veya kanalda canlı doğrulama." },
        { title: "Rollout",         desc: "Ölçeklendirme, izleme ve sürekli iyileştirme." }
      ],
      chips: [
        { t: "Cloud veya On-Prem",     d: "Esnek dağıtım, kurumsal altyapıya uyum." },
        { t: "Ölçülebilir KPI",         d: "Yanıt süresi, otomasyon oranı, verimlilik." },
        { t: "Kurumsal Uyumluluk",     d: "Roller, kayıt, süreç yönetişimi." }
      ]
    },
    refs: {
      eyebrow: "// REFERANSLAR",
      title: "Bize Güvenen Kurumlar.",
      sub: "Düzenlenmiş sektörlerde kurumsal ölçekte, üretimde çalışan referanslar.",
      list: [
        { name: "MAPFRE Sigorta",         sub: "Sigorta" },
        { name: "NDK",                    sub: "Operasyon" },
        { name: "Enerji Bakanlığı",       sub: "Kamu" },
        { name: "TCDD Taşımacılık",       sub: "Ulaşım" },
        { name: "Runitas Technologies",   sub: "Teknoloji" },
        { name: "PusulaCX",               sub: "CX Platformu" },
        { name: "Yön Pazarlama",          sub: "Pazarlama" },
        { name: "Infus AI",               sub: "Yapımcı" }
      ],
      quote: "Kognitera ajanları, çağrı merkezinde aldığı yük ile ekibin odağını yüksek değerli işlere kaydırdı — kontrolü kaybetmeden.",
      attrib: "Pilot · Sigorta Sektörü"
    },
    cta: {
      eyebrow: "// HAZIR MISINIZ?",
      title: "Dijital iş gücünüzü Kognitera ile kurun.",
      sub: "30 dakikalık bir keşif görüşmesiyle, sizin operasyonunuza özel POC haritasını birlikte çıkaralım.",
      cta1: "Demo Talep Et",
      cta2: "Çözüm Mimarına Ulaş"
    },
    foot: {
      tag: "Kurumsal AI Agent Platformu. Infus tarafından geliştirildi, regüle sektörler için tasarlandı.",
      product: "Platform",
      productLinks: ["Mimari", "Ajanlar", "Entegrasyonlar", "Güvenlik", "Fiyatlandırma"],
      company: "Kurum",
      companyLinks: ["Infus Hakkında", "Referanslar", "Basın & Medya", "İletişim", "Kariyer"],
      contact: "İletişim",
      address: [
        "Teknopark Ankara, İvedik OSB Mah.",
        "2224. Cad. No:1/124 (B-136),",
        "B Blok Kat:1, Yenimahalle / Ankara"
      ]
    }
  },
  en: {
    demoCta: "Request a Demo",
    navLinks: [
      { label: "Platform",      href: "#solution" },
      { label: "Modules",       href: "#phases" },
      { label: "Capabilities",  href: "#capabilities" },
      { label: "Sectors",       href: "#sectors" },
      // { label: "References",    href: "#references" },
    ],
    hero: {
      badge: "powered by Infus",
      h1a: "Enterprise AI",
      h1b: "Agent Platform.",
      sub: "Kognitera runs customer communication, operational processes and workflows under a single intelligent core, through multi-channel AI agents.",
      cta1: "Request a Demo",
      cta2: "Watch Product Tour",
      meta: ["Cloud or On-Prem", "Enterprise-grade compliance"],
      trustLabel: "Proven in regulated enterprise",
      trustList: ["MAPFRE", "TCDD Taşımacılık", "NDK", "Pusula CX", "Runitas"]
    },
    engine: {
      channels: ["WhatsApp", "Web Chat", "Instagram", "Email", "Call Center"],
      caps:     ["Analytics", "Welcome", "Knowledge Base", "Appointment", "Sales"]
    },
    metrics: {
      tag: "Indicative / Pilot benchmarks",
      items: [
        { value: "24/7", label: "Always-on digital workforce", accent: true },
        { value: 80,     prefix: "~", suffix: "%", label: "Faster first-response time" },
        { value: 70,     prefix: "~", suffix: "%", label: "Repetitive interactions automated" },
        { value: 45,     prefix: "~", suffix: "%", label: "Lower operational cost" }
      ]
    },
    ps: {
      eyebrow: "// PLATFORM",
      title: "From scattered channels, to one intelligent core.",
      sub: "We replace the bottlenecks of classical operations with role-based AI agents and deep system integrations.",
      problemsLabel: "Today's problems",
      solutionsLabel: "Kognitera's answer",
      problems: [
        "Fragmented customer communication channels",
        "Manual operational load and repetitive work",
        "Slow response and turnaround times",
        "Inconsistent customer experience, lost context"
      ],
      solutions: [
        "Single intelligent core, multi-channel orchestration",
        "Role-based AI agents — greeting, sales, follow-up",
        "Native CRM, helpdesk and operations integrations",
        "Controlled human handoff with auditable flows"
      ]
    },
    caps: {
      eyebrow: "// ROLE-BASED AGENTS",
      title: "Role-Based Agent Architecture",
      sub: "Each agent delivers value alone; together they form an end-to-end digital workforce layer.",
      items: [
        { title: "Call Center Copilot",         desc: "Suggests replies, summarizes the conversation, adds speed." },
        { title: "Welcome & Routing",          desc: "Understands the request, routes it to the right flow and scenario." },
        { title: "Information Gathering",       desc: "Collects required data, opens the ticket or case on your stack." },
        { title: "Operation Tracking",          desc: "Monitors, updates and reports on files, processes and workflows." },
        { title: "Appointment & Planning",      desc: "Checks availability and creates the plan with customer approval." },
        { title: "Sales & Lead Tracking",       desc: "Follows prospects, supports quoting and conversion." }
      ],
      summary: "One AI core unifies every channel and agent into a single layer of intelligence.",
      cta: "See the architecture"
    },
    phases: {
      eyebrow: "// 3-PHASE ADOPTION",
      title: "Agentic AI Onboarding Model",
      sub: "First we listen, then we collaborate, then we autonomously operate. A controlled, three-step transformation.",
      items: [
        { kicker: "MODULE · ANALYTICS",  title: "Speech Analytics", tag: "Foundation layer",
          desc: "Existing processes, channels and manual workload are mapped from voice & text data; the bottlenecks and target KPIs to be solved with AI become clear." },
        { kicker: "MODULE · HYBRID",     title: "Hybrid Assistant", tag: "Human-in-the-loop",
          desc: "Agents work alongside your teams — taking load on greeting, summarizing and follow-up. Human control is fully retained throughout." },
        { kicker: "MODULE · AUTONOMY",   title: "Full Autonomous Agent", tag: "Digital workforce",
          desc: "Selected operational roles are delegated to agents. The digital workforce scales autonomously across voice and written channels." }
      ]
    },
    sectors: {
      eyebrow: "// SECTORS",
      title: "Built for regulated, high-volume industries.",
      sub: "Proven enterprise integrations with compliance, scale and auditability at the core.",
      items: [
        { name: "Insurance",         use: "Claims intake, policy questions, FNOL routing." },
        { name: "Fleet & Automotive", use: "Service appointments, case tracking, status updates." },
        { name: "E-Commerce",         use: "Order / return handling, pre-sales, lead conversion." },
        { name: "Healthcare",         use: "Appointment scheduling, patient triage routing." },
        { name: "Finance",            use: "Application intake, KYC info-gathering, deflection." },
        { name: "Telecom",            use: "High-volume support, retention, call-center copilot." }
      ]
    },
    deploy: {
      eyebrow: "// DEPLOYMENT",
      title: "From discovery to live, a measurable journey.",
      sub: "Hybrid setup, a proven POC flow and an auditable KPI structure for a controlled transition.",
      steps: [
        { title: "Discovery & Design", desc: "Process, channel and KPI map drawn together." },
        { title: "Integration",         desc: "CRM, helpdesk and operation systems connected." },
        { title: "Pilot / POC",         desc: "Live validation on a selected role or channel." },
        { title: "Rollout",             desc: "Scale, monitoring, continuous improvement." }
      ],
      chips: [
        { t: "Cloud or On-Prem",       d: "Flexible deployment fits enterprise infra." },
        { t: "Measurable KPIs",         d: "Response time, automation rate, efficiency." },
        { t: "Enterprise Compliance",   d: "Roles, logging, governance throughout." }
      ]
    },
    refs: {
      eyebrow: "// REFERENCES",
      title: "Trusted By.",
      sub: "Production-grade references operating at enterprise scale across regulated sectors.",
      list: [
        { name: "MAPFRE Sigorta",         sub: "Insurance" },
        { name: "NDK",                    sub: "Operations" },
        { name: "Ministry of Energy",     sub: "Public" },
        { name: "TCDD Taşımacılık",       sub: "Transport" },
        { name: "Runitas Technologies",   sub: "Technology" },
        { name: "PusulaCX",               sub: "CX Platform" },
        { name: "Yön Pazarlama",          sub: "Marketing" },
        { name: "Infus AI",               sub: "Builder" }
      ],
      quote: "Kognitera's agents shifted our call-center focus toward higher-value work — by absorbing the repetitive load, without giving up control.",
      attrib: "Pilot · Insurance Sector"
    },
    cta: {
      eyebrow: "// READY?",
      title: "Build your digital workforce with Kognitera.",
      sub: "In a 30-minute discovery call, we'll map a tailored POC for your specific operation.",
      cta1: "Request a Demo",
      cta2: "Talk to Solutions"
    },
    foot: {
      tag: "The enterprise AI agent platform. Built by Infus, designed for regulated, high-volume sectors.",
      product: "Platform",
      productLinks: ["Architecture", "Agents", "Integrations", "Security", "Pricing"],
      company: "Company",
      companyLinks: ["About Infus", "References", "Press & Media", "Contact", "Careers"],
      contact: "Contact",
      address: [
        "Teknopark Ankara, İvedik OSB Mah.",
        "2224. Cad. No:1/124 (B-136),",
        "B Blok Kat:1, Yenimahalle / Ankara"
      ]
    }
  }
};

// ─── App ───────────────────────────────────────────────────────────
function App() {
  const [t, setTweak] = useTweaks(TWEAK_DEFAULTS);
  const theme = t.theme;
  const lang = t.lang;

  // Apply theme + accent to document
  useEffect(() => {
    document.documentElement.dataset.theme = theme;
  }, [theme]);

  useEffect(() => {
    const root = document.documentElement;
    const palette = ACCENT_PRESETS[t.accent] || ACCENT_PRESETS.turquoise;
    root.style.setProperty("--accent", palette.accent);
    root.style.setProperty("--accent-bright", palette.bright);
    root.style.setProperty("--accent-deep", palette.deep);
    root.style.setProperty("--accent-cyan", palette.cyan);
    root.style.setProperty("--border-accent", palette.borderAccent);
  }, [t.accent]);

  const content = CONTENT[lang];

  return (
    <React.Fragment>
      <Nav
        theme={theme}
        onToggleTheme={() => setTweak("theme", theme === "dark" ? "light" : "dark")}
        lang={lang}
        onToggleLang={() => setTweak("lang", lang === "tr" ? "en" : "tr")}
        content={content}
      />
      <main>
        <Hero content={content} />
        <Metrics content={content} />
        <ProblemSolution content={content} />
        <Phases content={content} />
        <Capabilities content={content} />
        <Sectors content={content} />
        <Deployment content={content} />
        {/* <References content={content} /> */}
        <CTA content={content} />
      </main>
      <Footer content={content} />

      <TweaksPanel title="Tweaks">
        <TweakSection label="Theme">
          <TweakRadio
            label="Mode"
            value={t.theme}
            options={[
              { value: "dark", label: "Dark" },
              { value: "light", label: "Light" }
            ]}
            onChange={(v) => setTweak("theme", v)}
          />
          <TweakRadio
            label="Language"
            value={t.lang}
            options={[
              { value: "tr", label: "Türkçe" },
              { value: "en", label: "English" }
            ]}
            onChange={(v) => setTweak("lang", v)}
          />
        </TweakSection>
        <TweakSection label="Accent palette">
          <TweakColor
            label="Accent"
            value={ACCENT_PRESETS[t.accent]?.swatches || ACCENT_PRESETS.turquoise.swatches}
            options={Object.values(ACCENT_PRESETS).map(p => p.swatches)}
            onChange={(v) => {
              const first = (Array.isArray(v) ? v[0] : v).toLowerCase();
              const key = Object.keys(ACCENT_PRESETS).find(k => ACCENT_PRESETS[k].swatches[0].toLowerCase() === first);
              setTweak("accent", key || "turquoise");
            }}
          />
        </TweakSection>
      </TweaksPanel>
    </React.Fragment>
  );
}

// Tweak defaults block — host can rewrite this on disk
const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "theme": "dark",
  "lang": "tr",
  "accent": "turquoise"
}/*EDITMODE-END*/;

const ACCENT_PRESETS = {
  turquoise: { accent: "#8B5CFF", bright: "#A580FF", deep: "#6A3FE0", cyan: "#00B8FF", borderAccent: "rgba(139, 92, 255,0.5)", swatches: ["#8B5CFF", "#00B8FF", "#6A3FE0"] },
  cyan:      { accent: "#22D3EE", bright: "#67E8F9", deep: "#0369A1", cyan: "#7DD3FC", borderAccent: "rgba(34,211,238,0.5)", swatches: ["#22D3EE", "#7DD3FC", "#0369A1"] },
  violet:    { accent: "#8B5CFF", bright: "#A580FF", deep: "#4D24B3", cyan: "#00B8FF", borderAccent: "rgba(139, 92, 255,0.5)", swatches: ["#8B5CFF", "#A580FF", "#00B8FF"] },
  emerald:   { accent: "#10B981", bright: "#34D399", deep: "#047857", cyan: "#22D3EE", borderAccent: "rgba(16,185,129,0.5)", swatches: ["#10B981", "#34D399", "#047857"] }
};

ReactDOM.createRoot(document.getElementById("root")).render(<App />);
