// Nav + Hero for Sellatr landing (bilingual: AR/EN).

const { useState: useStateNH, useEffect: useEffectNH, useRef: useRefNH } = React;

/* ===================== NAV ===================== */
const Nav = () => {
  const t = useT();
  const { lang } = useLang();
  const [scrolled, setScrolled] = useStateNH(false);
  useEffectNH(() => {
    const onScroll = () => setScrolled(window.scrollY > 12);
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  const links = [
    t('القنوات', 'Channels'),
    t('الذكاء الاصطناعي', 'AI'),
    t('القطاعات', 'Industries'),
    t('الإضافات', 'Add-ons'),
    t('الأسعار', 'Pricing'),
  ];
  return (
    <nav style={{
      position: 'sticky', top: 0, zIndex: 80,
      backdropFilter: scrolled ? 'blur(20px) saturate(180%)' : 'none',
      WebkitBackdropFilter: scrolled ? 'blur(20px) saturate(180%)' : 'none',
      background: scrolled ? 'rgba(255,255,255,0.72)' : 'transparent',
      borderBottom: scrolled ? '1px solid var(--border)' : '1px solid transparent',
      transition: 'background 220ms var(--ease-out), border-color 220ms var(--ease-out), backdrop-filter 220ms var(--ease-out)',
    }}>
      <div style={{
        maxWidth: 1280, margin: '0 auto',
        height: 68, padding: '0 28px',
        display: 'flex', alignItems: 'center', justifyContent: 'space-between',
        gap: 24,
      }}>
        <a href="#top" style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
          <Logo height={22} />
        </a>
        <div style={{ display: 'flex', alignItems: 'center', gap: 6, padding: '4px 6px', background: 'rgba(255,255,255,0.6)', border: '1px solid var(--border)', borderRadius: 999 }}>
          {links.map(item => (
            <a key={item} href="#" style={{
              fontFamily: lang === 'ar' ? 'var(--font-arabic)' : 'var(--font-sans)',
              fontSize: 14, fontWeight: 500,
              color: 'var(--fg-muted)', padding: '8px 14px', borderRadius: 999,
              transition: 'all 120ms var(--ease-out)', whiteSpace: 'nowrap',
            }}
            onMouseEnter={e => { e.currentTarget.style.color = 'var(--fg)'; e.currentTarget.style.background = 'var(--bg-muted)'; }}
            onMouseLeave={e => { e.currentTarget.style.color = 'var(--fg-muted)'; e.currentTarget.style.background = 'transparent'; }}
            >{item}</a>
          ))}
        </div>
        <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
          <LangToggle />
          <a href="#" style={{ fontFamily: lang === 'ar' ? 'var(--font-arabic)' : 'var(--font-sans)', fontSize: 14, fontWeight: 500, color: 'var(--fg)', whiteSpace: 'nowrap' }}>{t('تسجيل الدخول', 'Sign in')}</a>
          <Button size="sm" variant="primary" iconRight={lang === 'ar' ? 'arrowLeft' : 'arrowRight'}>{t('ابدأ مجانًا', 'Start free')}</Button>
        </div>
      </div>
    </nav>
  );
};

/* ===================== HERO ===================== */
const Hero = () => {
  const t = useT();
  const { lang } = useLang();
  return (
    <section id="top" style={{ position: 'relative', overflow: 'hidden', paddingTop: 60, paddingBottom: 0 }}>
      <div aria-hidden style={{
        position: 'absolute', inset: '-100px 0 0 0', zIndex: 0,
        backgroundImage: `
          radial-gradient(ellipse 70% 50% at 75% 25%, rgba(91,91,247,0.30), transparent 60%),
          radial-gradient(ellipse 55% 45% at 25% 30%, rgba(6,182,212,0.22), transparent 60%),
          radial-gradient(ellipse 40% 35% at 50% 80%, rgba(37,211,102,0.12), transparent 60%)`,
        filter: 'blur(20px)', pointerEvents: 'none',
      }} />
      <div aria-hidden className="dots-bg" style={{
        position: 'absolute', inset: 0, zIndex: 0,
        maskImage: 'radial-gradient(ellipse 80% 70% at 50% 30%, black 30%, transparent 75%)',
        WebkitMaskImage: 'radial-gradient(ellipse 80% 70% at 50% 30%, black 30%, transparent 75%)',
        opacity: 0.5,
      }} />

      <div style={{ position: 'relative', zIndex: 1, maxWidth: 1280, margin: '0 auto', padding: '64px 28px 0', textAlign: 'center' }}>
        <div style={{ display: 'inline-flex', alignItems: 'center', gap: 8, padding: '6px 14px', borderRadius: 999, background: 'rgba(255,255,255,0.85)', border: '1px solid var(--border)', backdropFilter: 'blur(12px)', boxShadow: 'var(--shadow-1)', fontSize: 13, fontWeight: 500 }}>
          <span style={{ fontSize: 15 }}>🌍</span>
          <span>{t('مصمم للأعمال العربية', 'Built for Arabic businesses')}</span>
          <span style={{ color: 'var(--fg-subtle)' }}>·</span>
          <span style={{ color: 'var(--fg-muted)' }}>{t('مصر · السعودية · الإمارات · الكويت', 'KSA · UAE · Egypt · Kuwait')}</span>
        </div>

        <h1 style={{
          fontFamily: lang === 'ar' ? 'var(--font-arabic)' : 'var(--font-display)',
          fontSize: 'clamp(48px, 7.4vw, 104px)',
          fontWeight: 700, letterSpacing: '-0.035em', lineHeight: 1.02,
          margin: '24px 0 22px', textWrap: 'balance',
        }}>
          {lang === 'ar' ? (
            <>نظام تشغيل <span style={{ background: 'linear-gradient(135deg, #5B5BF7 0%, #2A6FFF 45%, #06B6D4 100%)', WebkitBackgroundClip: 'text', backgroundClip: 'text', WebkitTextFillColor: 'transparent', color: 'transparent' }}>ذكي</span><br/>للأعمال الحديثة</>
          ) : (
            <>The <span style={{ background: 'linear-gradient(135deg, #5B5BF7 0%, #2A6FFF 45%, #06B6D4 100%)', WebkitBackgroundClip: 'text', backgroundClip: 'text', WebkitTextFillColor: 'transparent', color: 'transparent' }}>intelligent</span><br/>operating system for modern business</>
          )}
        </h1>

        <p style={{ fontSize: 'clamp(16px, 1.4vw, 19px)', lineHeight: 1.7, color: 'var(--fg-muted)', maxWidth: 720, margin: '0 auto 36px', textWrap: 'pretty' }}>
          {t(
            'اجمع كل محادثاتك وعملياتك وفريقك في منصة واحدة مدعومة بالذكاء الاصطناعي — تعمل عبر واتساب وإنستجرام وماسنجر والبريد والموقع والتطبيقات.',
            'Unify every conversation, operation, and teammate in one AI-powered platform — across WhatsApp, Instagram, Messenger, Email, your site, and your apps.'
          )}
        </p>

        <div style={{ display: 'inline-flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', justifyContent: 'center' }}>
          <Button variant="primary" size="lg" iconRight={lang === 'ar' ? 'arrowLeft' : 'arrowRight'}>{t('ابدأ تجربتك المجانية', 'Start your free trial')}</Button>
          <Button variant="secondary" size="lg" icon="play">{t('شاهد كيف يعمل', 'See how it works')}</Button>
        </div>
        <div style={{ marginTop: 16, fontSize: 13, color: 'var(--fg-subtle)' }}>
          {t('تجربة ١٤ يومًا · بدون بطاقة ائتمان · ألغِ في أي وقت', '14-day trial · No credit card · Cancel anytime')}
        </div>

        <div style={{ marginTop: 56, display: 'flex', flexWrap: 'wrap', justifyContent: 'center', gap: 8 }}>
          {[
            ['whatsapp',  t('واتساب', 'WhatsApp')],
            ['messenger', t('ماسنجر', 'Messenger')],
            ['instagram', t('إنستجرام', 'Instagram')],
            ['email',     t('البريد الإلكتروني', 'Email')],
            ['web',       t('شات الموقع', 'Website chat')],
            ['telegram',  t('تيليجرام', 'Telegram')],
            ['api',       'APIs'],
          ].map(([key, name]) => (
            <div key={key} style={{
              display: 'inline-flex', alignItems: 'center', gap: 8,
              padding: '8px 14px', background: 'rgba(255,255,255,0.85)', border: '1px solid var(--border)',
              borderRadius: 999, fontSize: 13, fontWeight: 500, color: 'var(--fg)',
              backdropFilter: 'blur(8px)',
            }}>
              <span style={{ color: CHANNEL_META[key].color }}>
                <ChannelIcon channel={key} size={14} />
              </span>
              {name}
            </div>
          ))}
        </div>
      </div>

      <HeroShowcase />
    </section>
  );
};

/* ===== HeroShowcase ===== */
const HeroShowcase = () => {
  const t = useT();
  return (
    <div style={{ position: 'relative', maxWidth: 1280, margin: '76px auto 0', padding: '0 28px 80px' }}>
      <FloatingPill style={{ top: 20, insetInlineStart: -10 }} color="#25D366" channel="whatsapp" label={t('رسالة جديدة', 'New message')} sub={t('منذ ٤ ثوانٍ', '4s ago')} />
      <FloatingPill style={{ top: 100, insetInlineEnd: -20 }} color="#E4405F" channel="instagram" label={t('DM · سارة', 'DM · Sara')} sub={t('عبر إنستجرام', 'via Instagram')} />
      <FloatingPill style={{ bottom: 280, insetInlineStart: -30 }} color="#5B5BF7" channel="messenger" label={t('حجز عيادة', 'Clinic booking')} sub={t('ماسنجر', 'Messenger')} />
      <FloatingPill style={{ bottom: 160, insetInlineEnd: -10 }} color="#0B0B0E" channel="email" label={t('تذكرة دعم', 'Support ticket')} sub={t('البريد', 'Email')} />

      <div style={{
        position: 'relative', zIndex: 2,
        borderRadius: 28, background: '#fff',
        border: '1px solid var(--border)',
        boxShadow: '0 1px 0 rgba(255,255,255,1) inset, 0 30px 100px rgba(11,11,14,0.16), 0 8px 24px rgba(91,91,247,0.10)',
        padding: 14,
        overflow: 'hidden',
      }}>
        <InboxMock />
      </div>

      <SatelliteAI />
      <SatelliteStats />
    </div>
  );
};

const FloatingPill = ({ style, color, channel, label, sub }) => (
  <div className="float-y" style={{
    position: 'absolute', zIndex: 3,
    display: 'flex', alignItems: 'center', gap: 10,
    padding: '10px 14px', background: 'rgba(255,255,255,0.92)',
    border: '1px solid var(--border)', borderRadius: 16,
    boxShadow: 'var(--shadow-2)', backdropFilter: 'blur(16px)',
    ...style,
  }}>
    <div style={{ width: 32, height: 32, borderRadius: 10, background: color, color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
      <ChannelIcon channel={channel} size={16} />
    </div>
    <div>
      <div style={{ fontSize: 13, fontWeight: 600 }}>{label}</div>
      <div style={{ fontSize: 11, color: 'var(--fg-muted)' }}>{sub}</div>
    </div>
  </div>
);

/* ===== Inbox mock ===== */
const InboxMock = () => {
  const t = useT();
  const { lang } = useLang();
  const isEn = lang === 'en';
  const conversations = [
    { ch: 'whatsapp',  name: t('سارة العبدالله', 'Sara Al-Abdullah'),    preview: t('تمام أبغى أطلب اثنين', 'Great, I want two'),     time: t('الآن','now'),  unread: 1, active: true },
    { ch: 'instagram', name: t('محمد العتيبي', 'Mohammed Al-Otaibi'),     preview: t('متوفر بمقاس ٤٤؟', 'Available in size 44?'),     time: isEn ? '2m' : '٢د', unread: 2 },
    { ch: 'messenger', name: t('نورا حسن', 'Noura Hassan'),               preview: t('شكرًا، أؤكد الحجز', 'Thanks, confirming'),       time: isEn ? '7m' : '٧د' },
    { ch: 'email',     name: t('فيصل القحطاني', 'Faisal Al-Qahtani'),     preview: t('تذكرة #٢١٤٧ — تحديث', 'Ticket #2147 — update'),  time: isEn ? '15m' : '١٥د' },
    { ch: 'web',       name: t('زائر · موقع', 'Visitor · web'),           preview: t('كم سعر الباقة؟', 'How much is the plan?'),     time: isEn ? '22m' : '٢٢د' },
    { ch: 'whatsapp',  name: t('ليلى البدر', 'Layla Al-Badr'),            preview: t('تم الدفع ✓', 'Paid ✓'),                          time: isEn ? '34m' : '٣٤د' },
  ];

  return (
    <div style={{ display: 'grid', gridTemplateColumns: isEn ? '280px 1fr 260px' : '260px 1fr 280px', gap: 14, background: 'var(--bg-muted)', borderRadius: 18, overflow: 'hidden', minHeight: 540 }}>
      {/* List */}
      <div style={{ background: '#fff', padding: 14, borderInlineStart: '1px solid var(--border)' }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '8px 8px 14px' }}>
          <LogoMark size={26} />
          <div style={{ fontSize: 13, fontWeight: 600 }}>{t('متجر بسمة', 'Basma Store')}</div>
          <span style={{ marginInlineStart: 'auto', fontSize: 11, fontWeight: 600, color: 'var(--whatsapp-deep)', background: 'rgba(37,211,102,0.10)', padding: '3px 7px', borderRadius: 99 }}>
            <span className="live-dot" style={{ display: 'inline-block', width: 6, height: 6, borderRadius: 99, background: '#25D366', marginInlineEnd: 6, verticalAlign: 'middle' }} />
            {t('متصل', 'Live')}
          </span>
        </div>
        <div style={{ position: 'relative', marginBottom: 10 }}>
          <input placeholder={t('ابحث في المحادثات', 'Search conversations')} style={{ width: '100%', padding: '8px 32px 8px 12px', fontSize: 13, background: 'var(--bg-muted)', border: '1px solid var(--border)', borderRadius: 10, outline: 'none' }} />
          <span style={{ position: 'absolute', insetInlineEnd: 10, top: '50%', transform: 'translateY(-50%)', color: 'var(--fg-subtle)' }}><Icon name="search" size={14} /></span>
        </div>
        <div style={{ display: 'flex', gap: 6, fontSize: 11, marginBottom: 10 }}>
          {[t('الكل','All'), t('الذكاء الاصطناعي','AI'), t('فريقي','My team'), t('غير مقروء','Unread')].map((tt, i) => (
            <span key={tt} style={{ padding: '4px 10px', borderRadius: 99, fontWeight: 600, color: i === 0 ? '#fff' : 'var(--fg-muted)', background: i === 0 ? 'var(--black)' : 'var(--bg-muted)' }}>{tt}</span>
          ))}
        </div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
          {conversations.map((c, i) => (
            <div key={i} style={{ display: 'flex', alignItems: 'flex-start', gap: 10, padding: 10, borderRadius: 10, background: c.active ? 'var(--accent-bg)' : 'transparent', cursor: 'pointer' }}>
              <div style={{ position: 'relative' }}>
                <Avatar initials={c.name.slice(0,1)} color={CHANNEL_META[c.ch].color} size={32} />
                <span style={{ position: 'absolute', insetInlineEnd: -3, insetBlockEnd: -3, width: 14, height: 14, borderRadius: 99, background: CHANNEL_META[c.ch].color, color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', border: '2px solid #fff' }}>
                  <ChannelIcon channel={c.ch} size={7} />
                </span>
              </div>
              <div style={{ minWidth: 0, flex: 1 }}>
                <div style={{ display: 'flex', justifyContent: 'space-between', gap: 6 }}>
                  <span style={{ fontSize: 13, fontWeight: c.active ? 600 : 500, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{c.name}</span>
                  <span style={{ fontSize: 11, color: 'var(--fg-subtle)' }}>{c.time}</span>
                </div>
                <div style={{ fontSize: 12, color: 'var(--fg-muted)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', marginTop: 2 }}>{c.preview}</div>
              </div>
              {c.unread && <span style={{ background: 'var(--indigo)', color: '#fff', fontSize: 10, fontWeight: 700, padding: '1px 6px', borderRadius: 99 }}>{c.unread}</span>}
            </div>
          ))}
        </div>
      </div>

      {/* Thread */}
      <div style={{ padding: 22, background: '#fff', display: 'flex', flexDirection: 'column' }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 12, paddingBottom: 16, borderBottom: '1px solid var(--border)' }}>
          <Avatar initials={t('س','S')} color="#25D366" size={36} status="online" />
          <div>
            <div style={{ fontSize: 14, fontWeight: 600 }}>{t('سارة العبدالله','Sara Al-Abdullah')}</div>
            <div style={{ fontSize: 11, color: 'var(--fg-muted)' }}>{t('عبر واتساب · متصل الآن','via WhatsApp · online now')}</div>
          </div>
          <div style={{ marginInlineStart: 'auto', display: 'flex', gap: 6 }}>
            <Badge variant="whatsapp" icon="whatsapp">{t('واتساب','WhatsApp')}</Badge>
            <span style={{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: 30, height: 30, borderRadius: 10, color: 'var(--fg-muted)', cursor: 'pointer' }}><Icon name="more" size={16} /></span>
          </div>
        </div>

        <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: 12, padding: '18px 4px' }}>
          <Bubble side="them">{t('السلام عليكم، عندكم الحذاء الأبيض مقاس ٤٢؟','Hi, do you have the white shoe in size 42?')}</Bubble>
          <Bubble side="us" ai>{t(<>وعليكم السلام سارة. نعم متوفر بسعر <span className="num">٢٤٩</span> ر.س مع توصيل خلال يومين 🚚</>, <>Hi Sara — yes, in stock for <span className="num">SAR 249</span>, delivery in 2 days 🚚</>)}</Bubble>
          <Bubble side="them">{t('تمام، أبغى أطلب اثنين','Great, I want to order two')}</Bubble>
          <AIAction />
          <Bubble side="us" ai>{t('أرسلت رابط الدفع لك. سيتم تأكيد الطلب فور إتمام العملية.','I sent your payment link. The order is confirmed as soon as you pay.')}</Bubble>
        </div>

        <div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: 8, background: 'var(--bg-muted)', borderRadius: 14 }}>
          <span style={{ color: 'var(--fg-subtle)', padding: 6 }}><Icon name="sparkles" size={16} /></span>
          <input placeholder={t('اكتب ردًا أو دع الذكاء الاصطناعي يجيب…','Type a reply or let AI answer…')} style={{ flex: 1, border: 'none', background: 'transparent', outline: 'none', fontSize: 13 }} />
          <Button size="sm" variant="dark" iconRight="send">{t('إرسال','Send')}</Button>
        </div>
      </div>

      {/* Profile */}
      <div style={{ background: '#fff', borderInlineEnd: '1px solid var(--border)', padding: 16, display: 'flex', flexDirection: 'column', gap: 14 }}>
        <div style={{ textAlign: 'center', paddingTop: 6 }}>
          <Avatar initials={t('س.ع','S.A')} color="#25D366" size={56} />
          <div style={{ fontSize: 14, fontWeight: 600, marginTop: 8 }}>{t('سارة العبدالله','Sara Al-Abdullah')}</div>
          <div style={{ fontSize: 11, color: 'var(--fg-muted)' }}>{t('عميلة منذ ٢٠٢٤','Customer since 2024')}</div>
        </div>
        <Stat label={t('إجمالي المشتريات','Total spend')} value={t('٢,٤٨٠ ر.س','SAR 2,480')} />
        <Stat label={t('عدد الطلبات','Orders')} value={t('١٢','12')} />
        <Stat label={t('رضا العميل','CSAT')} value={t('★ ٤.٩','★ 4.9')} />
        <div style={{ borderTop: '1px solid var(--border)', paddingTop: 14 }}>
          <div style={{ fontSize: 11, fontWeight: 600, color: 'var(--fg-muted)', letterSpacing: '0.04em', textTransform: 'uppercase', marginBottom: 10 }}>{t('الخط الزمني','Timeline')}</div>
          <Timeline items={[
            { dot: '#5B5BF7', title: t('بدأت محادثة','Started chat'), when: t('الآن','Now') },
            { dot: '#25D366', title: t('أرسل AI رابط الدفع','AI sent payment link'), when: t('منذ ٣٠ث','30s ago') },
            { dot: '#10B981', title: t('طلب سابق #١٠٤٣','Past order #1043'), when: t('منذ ٣ أيام','3 days ago') },
            { dot: '#A1A1A8', title: t('سُجّلت كعميلة','Customer signed up'), when: t('٢٠٢٤/٠٣','2024-03') },
          ]} />
        </div>
      </div>
    </div>
  );
};

const Bubble = ({ side, children, ai }) => {
  const isUs = side === 'us';
  return (
    <div style={{ display: 'flex', justifyContent: isUs ? 'flex-end' : 'flex-start' }}>
      <div style={{
        position: 'relative', maxWidth: '76%',
        background: isUs ? 'linear-gradient(135deg, #DCF8C6 0%, #C5EFB0 100%)' : '#fff',
        border: isUs ? 'none' : '1px solid var(--border)',
        borderRadius: isUs ? '16px 16px 4px 16px' : '16px 16px 16px 4px',
        padding: '9px 13px', fontSize: 13.5, lineHeight: 1.55, color: 'var(--fg)',
        boxShadow: isUs ? 'none' : 'var(--shadow-1)',
      }}>
        {children}
        {ai && (
          <span style={{ position: 'absolute', insetInlineEnd: 6, insetBlockEnd: -8, background: 'var(--indigo)', color: '#fff', width: 18, height: 18, borderRadius: 99, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', border: '2px solid #fff', boxShadow: '0 2px 6px rgba(91,91,247,0.4)' }}>
            <Icon name="sparkles" size={10} />
          </span>
        )}
      </div>
    </div>
  );
};

const AIAction = () => {
  const t = useT();
  return (
    <div style={{
      alignSelf: 'flex-end', display: 'flex', alignItems: 'center', gap: 10,
      padding: '10px 14px', background: 'linear-gradient(135deg, rgba(91,91,247,0.10), rgba(6,182,212,0.10))',
      border: '1px solid rgba(91,91,247,0.20)', borderRadius: 14, fontSize: 12.5, color: 'var(--indigo-deep)', fontWeight: 500,
    }}>
      <span style={{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', width: 22, height: 22, borderRadius: 99, background: 'var(--indigo)', color: '#fff' }}>
        <Icon name="sparkles" size={11} />
      </span>
      <span>{t(
        <>إجراء AI · <b>أنشأ رابط دفع</b> بقيمة <span className="num">٤٩٨</span> ر.س — حجز المخزون لمدة ١٥ دقيقة</>,
        <>AI action · <b>Created payment link</b> for <span className="num">SAR 498</span> — held inventory for 15 minutes</>
      )}</span>
    </div>
  );
};

const Stat = ({ label, value }) => (
  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', fontSize: 12 }}>
    <span style={{ color: 'var(--fg-muted)' }}>{label}</span>
    <span style={{ fontWeight: 700, color: 'var(--fg)' }}>{value}</span>
  </div>
);

const Timeline = ({ items }) => (
  <div style={{ position: 'relative', paddingInlineStart: 14 }}>
    <div style={{ position: 'absolute', insetInlineStart: 5, top: 4, bottom: 4, width: 1, background: 'var(--border)' }} />
    <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
      {items.map((it, i) => (
        <div key={i} style={{ position: 'relative' }}>
          <span style={{ position: 'absolute', insetInlineStart: -14, top: 4, width: 9, height: 9, borderRadius: 99, background: it.dot, border: '2px solid #fff', boxShadow: '0 0 0 1px var(--border)' }} />
          <div style={{ fontSize: 12, fontWeight: 600 }}>{it.title}</div>
          <div style={{ fontSize: 11, color: 'var(--fg-muted)' }}>{it.when}</div>
        </div>
      ))}
    </div>
  </div>
);

const SatelliteAI = () => {
  const t = useT();
  return (
    <div className="float-y" style={{
      position: 'absolute', zIndex: 3, insetInlineEnd: -32, bottom: 8,
      width: 280, padding: 16, background: '#fff',
      border: '1px solid var(--border)', borderRadius: 20,
      boxShadow: 'var(--shadow-2)', backdropFilter: 'blur(8px)',
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 10 }}>
        <div style={{ width: 28, height: 28, borderRadius: 10, background: 'linear-gradient(135deg, #5B5BF7, #06B6D4)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#fff' }}>
          <Icon name="bot" size={16} />
        </div>
        <div style={{ fontSize: 13, fontWeight: 600 }}>{t('وكيل AI','AI agent')}</div>
        <span style={{ marginInlineStart: 'auto', fontSize: 10, fontWeight: 700, padding: '3px 7px', borderRadius: 99, background: 'rgba(16,185,129,0.12)', color: '#047857' }}>{t('يعمل الآن','Active')}</span>
      </div>
      {[
        [t('تصنيف الرسالة','Message intent'), t('استفسار + نية شراء','Inquiry + purchase intent')],
        [t('اللهجة المكتشفة','Detected dialect'), t('سعودية','Saudi')],
        [t('الإجراء المقترح','Suggested action'), t('إرسال رابط الدفع','Send payment link')],
      ].map(([k, v]) => (
        <div key={k} style={{ display: 'flex', justifyContent: 'space-between', fontSize: 12, padding: '6px 0', borderTop: '1px solid var(--border)', gap: 8 }}>
          <span style={{ color: 'var(--fg-muted)' }}>{k}</span>
          <span style={{ fontWeight: 600, textAlign: 'end' }}>{v}</span>
        </div>
      ))}
      <div style={{ marginTop: 8, display: 'flex', gap: 6 }}>
        <span style={{ flex: 1, textAlign: 'center', padding: '7px', fontSize: 12, fontWeight: 600, borderRadius: 10, background: 'var(--black)', color: '#fff' }}>{t('ينفذ','Execute')}</span>
        <span style={{ flex: 1, textAlign: 'center', padding: '7px', fontSize: 12, fontWeight: 500, borderRadius: 10, background: 'var(--bg-muted)', color: 'var(--fg-muted)' }}>{t('تحويل للبشر','Hand off')}</span>
      </div>
    </div>
  );
};

const SatelliteStats = () => {
  const t = useT();
  return (
    <div className="float-y" style={{
      position: 'absolute', zIndex: 3, insetInlineStart: -28, bottom: 30,
      width: 240, padding: 16, background: '#0B0B0E', color: '#fff',
      border: '1px solid rgba(255,255,255,0.08)', borderRadius: 20,
      boxShadow: 'var(--shadow-2)', animationDelay: '-3s',
    }}>
      <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
        <span style={{ fontSize: 11, fontWeight: 600, opacity: 0.6, letterSpacing: '0.04em', textTransform: 'uppercase' }}>{t('اليوم','Today')}</span>
        <Icon name="trending" size={14} style={{ color: '#25D366' }} />
      </div>
      <div style={{ fontSize: 32, fontWeight: 700, letterSpacing: '-0.02em', lineHeight: 1, marginBottom: 4 }} className="num">
        {t(<>١٢,٤٨٠ <span style={{ fontSize: 14, color: 'rgba(255,255,255,0.5)' }}>ر.س</span></>, <>12,480 <span style={{ fontSize: 14, color: 'rgba(255,255,255,0.5)' }}>SAR</span></>)}
      </div>
      <div style={{ fontSize: 11, color: '#25D366', fontWeight: 600 }}>{t('↑ ٣٢٪ من أمس · ٤٢ محادثة','↑ 32% vs. yesterday · 42 chats')}</div>
      <div style={{ marginTop: 14, display: 'flex', alignItems: 'flex-end', gap: 4, height: 36 }}>
        {[40, 65, 50, 80, 70, 95, 88].map((h, i) => (
          <div key={i} style={{ flex: 1, height: `${h}%`, borderRadius: 4, background: i === 5 || i === 6 ? 'linear-gradient(180deg, #06B6D4, #5B5BF7)' : 'rgba(255,255,255,0.18)' }} />
        ))}
      </div>
    </div>
  );
};

window.Nav = Nav;
window.Hero = Hero;
