﻿// Saraya Events — Design Your Event builder + Partner page.

const { useState: useStateF, useEffect: useEffectF } = React;

/* ===== Design Your Event — multi-step builder ===== */
function DesignBuilder() {
  const { t, lang } = useLang();
  const { go } = useNav();
  const B = window.SARAYA.BUILDER;
  const [step, setStep] = useStateF(0);
  const [done, setDone] = useStateF(false);
  const [photos, setPhotos] = useStateF([]);
  const [d, setD] = useStateF({ type: '', location: '', services: [], budget: '', date: '', name: '', phone: '', email: '', message: '' });

  const steps = [
    { key: 'type',     label: lang === 'ar' ? 'المناسبة' : 'Occasion' },
    { key: 'location', label: lang === 'ar' ? 'المكان' : 'Venue' },
    { key: 'services', label: lang === 'ar' ? 'الخدمات' : 'Services' },
    { key: 'budget',   label: lang === 'ar' ? 'الميزانية' : 'Budget' },
    { key: 'details',  label: lang === 'ar' ? 'تفاصيلك' : 'Your details' },
  ];
  const toggleService = (id) => setD((p) => ({ ...p, services: p.services.includes(id) ? p.services.filter((x) => x !== id) : [...p.services, id] }));
  const canNext = [
    () => d.type, () => d.location, () => d.services.length > 0, () => d.budget, () => d.name && d.phone,
  ][step]();

  const onFiles = (e) => {
    const files = Array.from(e.target.files || []).slice(0, 6);
    setPhotos(files.map((f) => ({ name: f.name, url: URL.createObjectURL(f) })));
  };

  const labelOf = (arr, id, key) => { const o = arr.find((x) => (x.id === id)); return o ? (o[key] ? o[key][lang] || o[key] : o[lang]) : id; };
  const buildSummary = () => {
    const type = labelOf(B.eventTypes, d.type) || d.type;
    const loc  = labelOf(B.locations,  d.location) || d.location;
    const svc  = d.services.map((s) => labelOf(B.services, s)).join(', ');
    const bud  = labelOf(B.budgets,    d.budget) || d.budget;
    return (
      `Occasion: ${type}\n` +
      `Venue: ${loc}\n` +
      `Services Needed: ${svc}\n` +
      `Budget: ${bud}\n` +
      (d.date    ? `Event Date: ${d.date}\n`      : '') +
      `\nContact Details\n` +
      `Name: ${d.name}\n` +
      `Phone: ${d.phone}\n` +
      (d.email   ? `Email: ${d.email}\n`          : '') +
      (d.message ? `\nAdditional Notes:\n${d.message}\n` : '') +
      (photos.length ? `\nInspiration photos: ${photos.length} file${photos.length > 1 ? 's' : ''} attached separately.` : '')
    );
  };

  const buildMailto = () => {
    const type    = labelOf(B.eventTypes, d.type) || d.type;
    const subject = encodeURIComponent(`Event Quote Request — ${type}`);
    const body    = encodeURIComponent(
      `Hello Saraya Events,\n\nI would like to request a quote for my upcoming event.\n\n` +
      buildSummary() +
      `\n\nPlease contact me to discuss further.\n\nThank you.`
    );
    return `mailto:sales@sarayaevents.com?subject=${subject}&body=${body}`;
  };

  const submit = () => {
    // Save lead to Supabase (fails gracefully if DB not configured)
    if (window.saveLead) {
      window.saveLead({
        leadType:  'customer_quote',
        source:    'rfq_builder',
        name:      d.name,
        phone:     d.phone,
        email:     d.email || null,
        eventType: d.type  || null,
        eventDate: d.date  || null,
        message:   buildSummary(),
      });
    }
    setDone(true);
  };

  if (done) return <BuilderDone summary={buildSummary()} mailtoHref={buildMailto()} onHome={() => go('home')} onRestart={() => { setDone(false); setStep(0); setD({ type: '', location: '', services: [], budget: '', date: '', name: '', phone: '', email: '', message: '' }); }} />;

  return (
    <main style={{ minHeight: '100vh', background: 'var(--cream)' }}>
      {/* progress header */}
      <div style={{ position: 'sticky', top: 76, zIndex: 30, background: 'rgba(243,237,227,0.92)', backdropFilter: 'blur(12px)', WebkitBackdropFilter: 'blur(12px)', borderBottom: '1px solid var(--line)' }}>
        <Container narrow style={{ paddingBlock: 18 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
            {steps.map((s, i) => (
              <React.Fragment key={s.key}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 8, opacity: i <= step ? 1 : 0.4 }}>
                  <span style={{ width: 26, height: 26, borderRadius: 999, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 12.5, fontWeight: 600, background: i < step ? 'var(--gold)' : i === step ? 'var(--espresso)' : 'var(--sand)', color: i <= step ? 'var(--ivory)' : 'var(--fg-muted)' }}>
                    {i < step ? '✓' : i + 1}
                  </span>
                  <span className="saraya-step-label" style={{ fontSize: 13, fontWeight: i === step ? 600 : 400, color: 'var(--fg-primary)' }}>{s.label}</span>
                </div>
                {i < steps.length - 1 && <span style={{ flex: 1, height: 1, background: 'var(--line-strong)', minWidth: 8 }} />}
              </React.Fragment>
            ))}
          </div>
        </Container>
      </div>

      <Container narrow style={{ paddingBlock: 'clamp(36px,6vw,64px)' }}>
        <div key={step} style={{ animation: 'sarayaStep 360ms var(--ease-out)' }}>
          {step === 0 && (
            <StepShell title={lang === 'ar' ? 'ما المناسبة؟' : 'What are we celebrating?'} hint={lang === 'ar' ? 'اختر نوع المناسبة.' : 'Pick the type of event.'}>
              <div className="saraya-tilegrid">
                {B.eventTypes.map((e) => <OptionTile key={e.id} icon={e.icon} active={d.type === e.id} onClick={() => setD({ ...d, type: e.id })}>{e[lang]}</OptionTile>)}
              </div>
            </StepShell>
          )}
          {step === 1 && (
            <StepShell title={lang === 'ar' ? 'أين ستُقام؟' : 'Where will it be?'} hint={lang === 'ar' ? 'اختر نوع المكان.' : 'Choose a venue type.'}>
              <div className="saraya-tilegrid">
                {B.locations.map((l) => <OptionTile key={l.id} icon="map-pin" active={d.location === l.id} onClick={() => setD({ ...d, location: l.id })}>{l[lang]}</OptionTile>)}
              </div>
            </StepShell>
          )}
          {step === 2 && (
            <StepShell title={lang === 'ar' ? 'ما الذي تحتاجه؟' : 'What do you need?'} hint={lang === 'ar' ? 'اختر كل ما ينطبق.' : 'Select all that apply.'}>
              <div style={{ display: 'flex', flexWrap: 'wrap', gap: 11 }}>
                {B.services.map((s) => <Chip key={s.id} icon={s.icon} active={d.services.includes(s.id)} onClick={() => toggleService(s.id)}>{s[lang]}</Chip>)}
              </div>
            </StepShell>
          )}
          {step === 3 && (
            <StepShell title={lang === 'ar' ? 'الميزانية والتاريخ' : 'Budget & date'} hint={lang === 'ar' ? 'تقدير تقريبي يساعدنا على التنسيق.' : 'A rough range helps us plan.'}>
              <div className="saraya-tilegrid" style={{ marginBottom: 24 }}>
                {B.budgets.map((b) => <OptionTile key={b.id} icon="wallet" active={d.budget === b.id} onClick={() => setD({ ...d, budget: b.id })}>{b[lang]}</OptionTile>)}
              </div>
              <div style={{ maxWidth: 320 }}>
                <Field label={t('form.date')} optional><TextInput type="date" value={d.date} onChange={(e) => setD({ ...d, date: e.target.value })} /></Field>
              </div>
            </StepShell>
          )}
          {step === 4 && (
            <StepShell title={lang === 'ar' ? 'كيف نصل إليك؟' : 'How do we reach you?'} hint={lang === 'ar' ? 'سنعود إليك خلال ٢٤ ساعة.' : "We'll be in touch within 24 hours."}>
              <div style={{ display: 'grid', gap: 16, maxWidth: 520 }}>
                <Field label={t('form.name')}><TextInput value={d.name} onChange={(e) => setD({ ...d, name: e.target.value })} placeholder={lang === 'ar' ? 'اسمك الكامل' : 'Your full name'} /></Field>
                <Field label={t('form.phone')}><TextInput value={d.phone} onChange={(e) => setD({ ...d, phone: e.target.value })} placeholder="+971 5X XXX XXXX" /></Field>
                <Field label={lang === 'ar' ? 'البريد الإلكتروني' : 'Email'} hint={lang === 'ar' ? 'اختياري' : 'Optional'}><TextInput type="email" value={d.email} onChange={(e) => setD({ ...d, email: e.target.value })} placeholder={lang === 'ar' ? 'بريدك الإلكتروني' : 'your@email.com'} /></Field>
                <Field label={t('form.message')} optional><Textarea value={d.message} onChange={(e) => setD({ ...d, message: e.target.value })} placeholder={lang === 'ar' ? 'أي تفاصيل أخرى…' : 'Anything else we should know…'} /></Field>
                <Field label={t('form.inspo')} optional hint={lang === 'ar' ? 'أرفق ما يصل إلى ٦ صور.' : 'Attach up to 6 photos.'}>
                  <label style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 8, padding: '26px 18px', borderRadius: 12, border: '1.5px dashed var(--line-strong)', background: 'var(--white)', cursor: 'pointer', color: 'var(--fg-muted)', textAlign: 'center' }}>
                    <Icon name="image-plus" size={26} style={{ color: 'var(--gold-deep)' }} />
                    <span style={{ fontSize: 13.5 }}>{t('form.upload')}</span>
                    <input type="file" accept="image/*" multiple onChange={onFiles} style={{ display: 'none' }} />
                  </label>
                  {photos.length > 0 && (
                    <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap', marginTop: 12 }}>
                      {photos.map((p, i) => <img key={i} src={p.url} alt="" style={{ width: 64, height: 64, objectFit: 'cover', borderRadius: 8, border: '1px solid var(--line)' }} />)}
                    </div>
                  )}
                </Field>
              </div>
            </StepShell>
          )}
        </div>

        {/* footer nav */}
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginTop: 40, gap: 12 }}>
          <Button variant="ghost" icon="arrow-left" onClick={() => (step === 0 ? go('home') : setStep(step - 1))}>{t('cta.back')}</Button>
          {step < steps.length - 1
            ? <Button variant="primary" size="lg" iconRight="arrow-right" disabled={!canNext} onClick={() => canNext && setStep(step + 1)}>{t('cta.next')}</Button>
            : <Button variant="primary" size="lg" icon="send" disabled={!canNext} onClick={submit}>{lang === 'ar' ? 'إرسال الطلب' : 'Send Request'}</Button>}
        </div>
      </Container>
    </main>
  );
}

function StepShell({ title, hint, children }) {
  return (
    <div>
      <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(28px,4.5vw,46px)', fontWeight: 500, lineHeight: 1.1 }}>{title}</h1>
      {hint && <p style={{ marginTop: 12, fontSize: 16, color: 'var(--fg-secondary)' }}>{hint}</p>}
      <div style={{ marginTop: 32 }}>{children}</div>
    </div>
  );
}

function BuilderDone({ summary, mailtoHref, onHome, onRestart }) {
  const { lang } = useLang();
  const ar = lang === 'ar';
  const waMsg = `Hello Saraya Events, I would like to request a quote for my event.\n\n${summary}`;
  return (
    <main style={{ minHeight: '100vh', background: 'var(--cream)', display: 'flex', alignItems: 'center', paddingBlock: 120 }}>
      <Container narrow style={{ textAlign: 'center' }}>
        <span style={{ display: 'inline-flex', width: 72, height: 72, borderRadius: 999, alignItems: 'center', justifyContent: 'center', background: '#DCFCE7', color: '#16A34A' }}>
          <Icon name="check-circle-2" size={34} stroke={2} />
        </span>
        <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(28px,4.5vw,48px)', fontWeight: 500, margin: '24px 0 0' }}>
          {ar ? 'طلبك جاهز للإرسال' : 'Your request is ready'}
        </h1>
        <p style={{ marginTop: 14, fontSize: 16, lineHeight: 1.65, color: 'var(--fg-secondary)', maxWidth: 500, marginInline: 'auto' }}>
          {ar
            ? 'انقر على الزر أدناه لإرسال تفاصيل فعاليتك إلى فريق سرايا مباشرةً — سيتواصلون معك خلال 24 ساعة.'
            : 'Click the button below to send your event details directly to the Saraya team — they\'ll be in touch within 24 hours.'}
        </p>

        {/* Primary CTA — email */}
        <div style={{ marginTop: 28 }}>
          <a
            href={mailtoHref}
            style={{
              display: 'inline-flex', alignItems: 'center', gap: 10,
              padding: '15px 32px', borderRadius: 12,
              background: 'var(--espresso)', color: 'var(--ivory)',
              fontFamily: 'var(--font-body)', fontSize: 16, fontWeight: 700,
              textDecoration: 'none', transition: 'opacity 150ms',
            }}
          >
            <Icon name="mail" size={19} />
            {ar ? 'إرسال الطلب بالبريد الإلكتروني' : 'Send Request by Email'}
          </a>
          <p style={{ marginTop: 10, fontSize: 12.5, color: 'var(--fg-muted)' }}>
            {ar ? 'يُرسل إلى ' : 'Sends to '}
            <strong>sales@sarayaevents.com</strong>
          </p>
        </div>

        {/* Summary (copyable) */}
        <pre style={{ textAlign: 'start', whiteSpace: 'pre-wrap', background: 'var(--white)', borderRadius: 14, border: '1px solid var(--line)', padding: '18px 20px', marginTop: 24, fontFamily: 'var(--font-body)', fontSize: 13, lineHeight: 1.7, color: 'var(--fg-secondary)', maxWidth: 560, marginInline: 'auto' }}>{summary}</pre>

        <p style={{ marginTop: 14, fontSize: 13, color: 'var(--fg-muted)' }}>
          {ar ? 'أو تواصل معنا مباشرةً:' : 'Or reach us directly:'}
        </p>

        <div style={{ display: 'flex', gap: 12, justifyContent: 'center', marginTop: 10, flexWrap: 'wrap' }}>
          <Button variant="whatsapp" icon="message-circle" href={window.SARAYA.waLink(waMsg)}>
            {ar ? 'واتساب' : 'WhatsApp'}
          </Button>
          <Button variant="secondary" icon="rotate-ccw" onClick={onRestart}>
            {ar ? 'طلب جديد' : 'New request'}
          </Button>
          <Button variant="ghost" icon="home" onClick={onHome}>
            {ar ? 'الرئيسية' : 'Home'}
          </Button>
        </div>
      </Container>
    </main>
  );
}

/* ===== Partner page ===== */
function PartnerPage() {
  const { lang } = useLang();
  const { go } = useNav();
  const auth = window.useAuth ? window.useAuth() : null;
  const ar = lang === 'ar';

  const handleCreateAccount = () => {
    window.sarayaTrack && window.sarayaTrack('join_vendor_click', { source: 'partner_page' });
    if (!window.supabaseConfigured) {
      alert(ar ? 'قاعدة البيانات غير مهيأة بعد.' : 'Database not configured yet.');
      return;
    }
    if (auth && auth.user) {
      go('vendor-dashboard');
    } else if (auth) {
      auth.openAuthModal('signup');
    }
  };

  const STEPS = [
    { n: '1', icon: 'user-plus',   en: 'Create your account',          ar: 'أنشئ حسابك',           den: 'Sign up as a vendor with your email. Takes less than 2 minutes.', dar: 'سجّل كمورد ببريدك الإلكتروني. يستغرق أقل من دقيقتين.' },
    { n: '2', icon: 'file-check',  en: 'Complete your business profile', ar: 'أكمل ملف شركتك',      den: 'Add your trade name, category, city, and business description.', dar: 'أضف اسم شركتك والفئة والمدينة ووصف نشاطك التجاري.' },
    { n: '3', icon: 'upload-cloud', en: 'Upload trade documents',       ar: 'ارفع الوثائق التجارية', den: 'Upload your UAE Trade License and Emirates ID for verification.', dar: 'ارفع رخصتك التجارية الإماراتية وهويتك للتحقق.' },
    { n: '4', icon: 'shield-check', en: 'Get approved (2–3 days)',      ar: 'احصل على الموافقة (2-3 أيام)', den: 'The Saraya team reviews your documents and activates your account.', dar: 'يراجع فريق سرايا وثائقك ويفعّل حسابك.' },
    { n: '5', icon: 'trending-up',  en: 'Start listing & receiving orders', ar: 'أدرج منتجاتك وابدأ الاستقبال', den: 'Add products, rentals, or services and receive orders from customers.', dar: 'أضف منتجاتك وإيجاراتك وخدماتك واستقبل الطلبات.' },
  ];

  const BENEFITS = [
    { icon: 'users',           en: 'Reach UAE-wide customers',        ar: 'وصول لعملاء الإمارات' },
    { icon: 'file-text',       en: 'Receive RFQ requests',            ar: 'استقبال طلبات عروض أسعار' },
    { icon: 'star',            en: 'Featured placement options',      ar: 'خيارات عرض مميز' },
    { icon: 'layout-dashboard', en: 'Vendor analytics dashboard',     ar: 'لوحة تحليلات الموردين' },
    { icon: 'layers',          en: 'List products, rentals & services', ar: 'إدراج منتجات وإيجار وخدمات' },
    { icon: 'shield-check',    en: 'Verified vendor badge',           ar: 'شارة مورد موثّق' },
    { icon: 'badge-check',     en: 'Secure payment handling',        ar: 'مدفوعات آمنة' },
    { icon: 'trending-up',     en: 'Growth subscription packages',   ar: 'باقات اشتراك للنمو' },
  ];

  const CATS = [
    { icon: 'flower-2',   en: 'Flowers & Floral',     ar: 'زهور وتنسيق' },
    { icon: 'armchair',   en: 'Furniture Rental',     ar: 'تأجير أثاث' },
    { icon: 'tent',       en: 'Tents & Structures',   ar: 'خيم وهياكل' },
    { icon: 'utensils',   en: 'Catering & Hospitality', ar: 'ضيافة وتموين' },
    { icon: 'camera',     en: 'Photography & Video',  ar: 'تصوير وفيديو' },
    { icon: 'music-2',    en: 'Entertainment',        ar: 'ترفيه وفنون' },
    { icon: 'monitor',    en: 'Screens & AV',         ar: 'شاشات وصوتيات' },
    { icon: 'sparkles',   en: 'Event Design',         ar: 'تصميم فعاليات' },
    { icon: 'gift',       en: 'Gifts & Décor',        ar: 'هدايا وديكور' },
  ];

  const FAQ = [
    { q: { en: 'How long does approval take?', ar: 'كم يستغرق وقت الموافقة؟' }, a: { en: '2–3 business days after you submit your trade license and Emirates ID.', ar: '2-3 أيام عمل بعد تقديم رخصتك التجارية وهويتك الإماراتية.' } },
    { q: { en: 'What documents do I need?', ar: 'ما الوثائق المطلوبة؟' }, a: { en: 'A valid UAE Trade License, Emirates ID of the authorised representative, and VAT certificate if registered.', ar: 'رخصة تجارية إماراتية سارية، وهوية إماراتية للممثل المفوَّض، وشهادة ضريبة القيمة المضافة إن وجدت.' } },
    { q: { en: 'Is there a subscription fee?', ar: 'هل هناك رسوم اشتراك؟' }, a: { en: 'Yes. Plans start from AED 99/month. View our full plans on the Vendor Packages page.', ar: 'نعم. تبدأ الخطط من 99 درهمًا شهريًا. راجع خطط الموردين لمزيد من التفاصيل.' } },
    { q: { en: 'Can I list rentals, products, and services together?', ar: 'هل يمكنني إدراج إيجار ومنتجات وخدمات معًا؟' }, a: { en: 'Yes — your vendor dashboard supports all three in one place.', ar: 'نعم — لوحة تحكم المورد تدعم الثلاثة في مكان واحد.' } },
    { q: { en: 'When do I receive payment?', ar: 'متى أستلم المدفوعات؟' }, a: { en: 'Payouts are released after the customer confirms delivery or the 3-day dispute window closes.', ar: 'تُصدَر المدفوعات بعد تأكيد العميل للاستلام أو انتهاء فترة النزاع (3 أيام).' } },
  ];

  const [openFaq, setOpenFaq] = useStateF(null);

  const btnStyle = {
    display: 'inline-flex', alignItems: 'center', gap: 9,
    padding: '14px 28px', borderRadius: 12, border: 'none',
    background: 'var(--gold)', color: 'var(--espresso)',
    fontFamily: 'var(--font-body)', fontSize: 16, fontWeight: 700,
    cursor: 'pointer', transition: 'opacity 150ms',
  };

  const isLoggedInVendor = auth && auth.user && auth.role === 'vendor';

  return (
    <main>
      {/* Hero */}
      <section style={{ background: 'var(--espresso)', color: 'var(--ivory)', paddingTop: 140, paddingBottom: 80 }}>
        <Container wide>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(280px,100%), 1fr))', gap: 52, alignItems: 'center' }}>
            <Reveal>
              <Eyebrow color="var(--gold-light)">{ar ? 'انضم كمورد' : 'Join as Vendor'}</Eyebrow>
              <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(36px,6vw,66px)', fontWeight: 500, lineHeight: 1.04, margin: '18px 0 0' }}>
                {ar ? 'بيع منتجاتك وخدماتك عبر سرايا' : 'Sell Your Products & Services Through Saraya'}
              </h1>
              <p style={{ fontSize: 'clamp(15px,1.7vw,19px)', lineHeight: 1.65, opacity: 0.82, marginTop: 20, maxWidth: 520 }}>
                {ar
                  ? 'وصول فوري لآلاف العملاء الذين يخططون لحفلات الزفاف والفعاليات الشركاتية والمناسبات الخاصة في أبوظبي والإمارات.'
                  : 'Instant access to thousands of customers planning weddings, corporate events, and special occasions across Abu Dhabi and the UAE.'}
              </p>
              <div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, marginTop: 30 }}>
                {isLoggedInVendor ? (
                  <button style={btnStyle} onClick={() => go('vendor-dashboard')}>
                    <Icon name="layout-dashboard" size={18} />
                    {ar ? 'لوحة تحكم المورد' : 'Go to Vendor Dashboard'}
                  </button>
                ) : (
                  <button style={btnStyle} onClick={handleCreateAccount}>
                    <Icon name="user-plus" size={18} />
                    {ar ? 'أنشئ حسابك الآن' : 'Create Your Account Now'}
                  </button>
                )}
                <button onClick={() => go('vendor-packages')} style={{ display: 'inline-flex', alignItems: 'center', gap: 8, padding: '14px 24px', borderRadius: 12, border: '1.5px solid rgba(250,246,240,0.35)', background: 'transparent', color: 'var(--ivory)', fontFamily: 'var(--font-body)', fontSize: 15, fontWeight: 600, cursor: 'pointer' }}>
                  {ar ? 'عرض الباقات والأسعار' : 'View Plans & Pricing'}
                </button>
              </div>
              <div style={{ display: 'flex', gap: 24, marginTop: 28, flexWrap: 'wrap' }}>
                {[
                  { icon: 'clock', en: 'Approved in 2–3 days', ar: 'موافقة خلال 2-3 أيام' },
                  { icon: 'shield-check', en: 'Verified vendor badge', ar: 'شارة مورد موثّق' },
                  { icon: 'zap', en: 'Start from AED 99/mo', ar: 'ابدأ من 99 درهم/شهر' },
                ].map((item, i) => (
                  <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 7, fontSize: 13.5, opacity: 0.8 }}>
                    <Icon name={item.icon} size={15} style={{ color: 'var(--gold-light)' }} />
                    {ar ? item.ar : item.en}
                  </div>
                ))}
              </div>
            </Reveal>

            {/* Steps card */}
            <Reveal delay={100}>
              <div style={{ background: 'rgba(255,255,255,0.06)', border: '1px solid rgba(255,255,255,0.12)', borderRadius: 20, padding: 'clamp(22px,4vw,32px)' }}>
                <p style={{ fontSize: 12, fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.12em', color: 'var(--gold-light)', margin: '0 0 20px' }}>
                  {ar ? 'كيف تبدأ' : 'How it works'}
                </p>
                {STEPS.map((step, i) => (
                  <div key={i} style={{ display: 'flex', gap: 14, marginBottom: i < STEPS.length - 1 ? 18 : 0, alignItems: 'flex-start' }}>
                    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', flexShrink: 0 }}>
                      <span style={{ width: 32, height: 32, borderRadius: '50%', background: 'var(--gold)', color: 'var(--espresso)', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 14, fontWeight: 700, fontFamily: 'var(--font-display)' }}>{step.n}</span>
                      {i < STEPS.length - 1 && <span style={{ width: 1, height: 18, background: 'rgba(255,255,255,0.15)', marginTop: 4 }} />}
                    </div>
                    <div style={{ paddingTop: 4 }}>
                      <p style={{ margin: 0, fontSize: 14.5, fontWeight: 600, color: 'var(--ivory)' }}>{ar ? step.ar : step.en}</p>
                      <p style={{ margin: '3px 0 0', fontSize: 13, opacity: 0.65, lineHeight: 1.5 }}>{ar ? step.dar : step.den}</p>
                    </div>
                  </div>
                ))}
                <button onClick={handleCreateAccount} style={{ ...btnStyle, width: '100%', justifyContent: 'center', marginTop: 24, fontSize: 15 }}>
                  <Icon name="user-plus" size={17} />
                  {ar ? 'ابدأ الآن — مجاناً' : 'Get Started — Free'}
                </button>
              </div>
            </Reveal>
          </div>
        </Container>
      </section>

      {/* Benefits */}
      <Section bg="canvas">
        <Container wide>
          <Reveal>
            <SectionHead center eyebrow={ar ? 'المزايا' : 'Why join'} title={ar ? 'كل ما تحتاجه لنمو أعمالك' : 'Everything you need to grow'} />
          </Reveal>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(230px, 1fr))', gap: 14, marginTop: 40 }}>
            {BENEFITS.map((b, i) => (
              <Reveal key={i} delay={i * 35}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 12, padding: '15px 18px', background: 'var(--white)', borderRadius: 12, border: '1px solid var(--line)' }}>
                  <Icon name={b.icon} size={18} style={{ color: 'var(--gold-deep)', flexShrink: 0 }} />
                  <span style={{ fontSize: 14, fontWeight: 500 }}>{ar ? b.ar : b.en}</span>
                </div>
              </Reveal>
            ))}
          </div>
        </Container>
      </Section>

      {/* Categories */}
      <Section bg="muted">
        <Container wide>
          <Reveal>
            <SectionHead center eyebrow={ar ? 'من يمكنه الانضمام' : 'Who can join'} title={ar ? 'كل فئات موردي الفعاليات' : 'All event vendor categories'} />
          </Reveal>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(150px, 1fr))', gap: 14, marginTop: 40 }}>
            {CATS.map((c, i) => (
              <Reveal key={i} delay={i * 30}>
                <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 10, padding: '20px 12px', background: 'var(--white)', borderRadius: 14, border: '1px solid var(--line)', textAlign: 'center' }}>
                  <span style={{ display: 'inline-flex', width: 44, height: 44, borderRadius: 12, background: 'var(--cream)', alignItems: 'center', justifyContent: 'center' }}>
                    <Icon name={c.icon} size={20} style={{ color: 'var(--gold-deep)' }} />
                  </span>
                  <span style={{ fontSize: 13.5, fontWeight: 500, lineHeight: 1.3 }}>{ar ? c.ar : c.en}</span>
                </div>
              </Reveal>
            ))}
          </div>
        </Container>
      </Section>

      {/* Pricing preview */}
      <Section bg="canvas">
        <Container wide>
          <Reveal>
            <div style={{ display: 'flex', flexWrap: 'wrap', gap: 16, alignItems: 'center', justifyContent: 'space-between', marginBottom: 36 }}>
              <SectionHead eyebrow={ar ? 'الأسعار' : 'Pricing'} title={ar ? 'باقات بسيطة وشفافة' : 'Simple, transparent plans'} />
              <Button variant="secondary" iconRight="arrow-right" onClick={() => go('vendor-packages')}>
                {ar ? 'عرض كل التفاصيل' : 'See full details'}
              </Button>
            </div>
          </Reveal>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: 20 }}>
            {[
              { name: { en: 'Starter', ar: 'مبتدئ' }, price: 99, highlight: false, tag: { en: 'Get started', ar: 'للبداية' } },
              { name: { en: 'Professional', ar: 'احترافي' }, price: 299, highlight: true, tag: { en: 'Most popular', ar: 'الأكثر شيوعًا' } },
              { name: { en: 'Premium', ar: 'مميز' }, price: 599, highlight: false, tag: { en: 'Max visibility', ar: 'أقصى ظهور' } },
            ].map((plan, i) => (
              <Reveal key={i} delay={i * 60}>
                <div onClick={() => go('vendor-packages')} style={{ background: plan.highlight ? 'var(--espresso)' : 'var(--white)', border: plan.highlight ? '2px solid var(--gold)' : '1px solid var(--line)', borderRadius: 16, padding: '24px 22px', color: plan.highlight ? 'var(--ivory)' : 'var(--fg-primary)', cursor: 'pointer', transition: 'transform 150ms' }}>
                  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }}>
                    <p style={{ fontSize: 13, fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.08em', opacity: 0.7, margin: 0 }}>{ar ? plan.name.ar : plan.name.en}</p>
                    <span style={{ fontSize: 11, fontWeight: 600, padding: '3px 10px', borderRadius: 20, background: plan.highlight ? 'var(--gold)' : 'var(--cream)', color: plan.highlight ? 'var(--espresso)' : 'var(--fg-secondary)' }}>
                      {ar ? plan.tag.ar : plan.tag.en}
                    </span>
                  </div>
                  <div style={{ display: 'flex', alignItems: 'baseline', gap: 5, marginBottom: 16 }}>
                    <span style={{ fontFamily: 'var(--font-display)', fontSize: 40, fontWeight: 500 }}>AED {plan.price}</span>
                    <span style={{ fontSize: 13, opacity: 0.6 }}>{ar ? '/شهر' : '/mo'}</span>
                  </div>
                  <div style={{ fontSize: 13, opacity: 0.7 }}>{ar ? 'اضغط لمشاهدة كل المزايا' : 'Tap to see all features'}</div>
                </div>
              </Reveal>
            ))}
          </div>
        </Container>
      </Section>

      {/* Virtual Showroom teaser */}
      <Section bg="canvas">
        <Container wide>
          <Reveal>
            <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit,minmax(min(280px,100%),1fr))', gap: 32, alignItems: 'center', background: 'var(--cream)', borderRadius: 20, padding: 'clamp(28px,4vw,48px)', border: '1px solid var(--line)' }}>
              <div>
                <Badge tone="gold">{ar ? 'مميزة' : 'Included in your plan'}</Badge>
                <h2 style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(24px,3.5vw,40px)', fontWeight: 500, margin: '14px 0 12px' }}>
                  {ar ? 'صفحة معرضك الرقمي' : 'Your Virtual Showroom Page'}
                </h2>
                <p style={{ fontSize: 14.5, color: 'var(--fg-secondary)', lineHeight: 1.7, marginBottom: 24 }}>
                  {ar
                    ? 'كل خطة موردين تشمل صفحة معرض رقمي خاصة بك — تعرض منتجاتك وخدماتك وإيجاراتك، مرتبطة مباشرةً بسوق سرايا وتتلقى طلبات عبر واتساب أو الدفع أونلاين.'
                    : 'Every vendor plan includes a dedicated Virtual Showroom page — showcasing your products, services, and rentals, connected directly to the Saraya marketplace, with orders via WhatsApp or online payment.'}
                </p>
                <div style={{ display: 'flex', flexWrap: 'wrap', gap: 10 }}>
                  <button onClick={() => go('showroom')} style={{ display: 'inline-flex', alignItems: 'center', gap: 8, padding: '11px 20px', borderRadius: 10, background: 'var(--espresso)', color: 'var(--ivory)', fontFamily: 'var(--font-body)', fontSize: 14, fontWeight: 600, border: 'none', cursor: 'pointer' }}>
                    <Icon name="layout-panel-left" size={16} />
                    {ar ? 'شاهد المعرض الرقمي' : 'See Virtual Showroom'}
                  </button>
                  <button onClick={() => go('vendor-agreement')} style={{ display: 'inline-flex', alignItems: 'center', gap: 8, padding: '11px 20px', borderRadius: 10, background: 'transparent', color: 'var(--fg-primary)', fontFamily: 'var(--font-body)', fontSize: 14, fontWeight: 500, border: '1.5px solid var(--line-strong)', cursor: 'pointer' }}>
                    <Icon name="file-text" size={16} />
                    {ar ? 'اتفاقية الموردين' : 'Vendor Agreement'}
                  </button>
                </div>
              </div>
              <div style={{ display: 'grid', gap: 12 }}>
                {[
                  { icon: 'layout-panel-left', en: 'Own branded showroom page', ar: 'صفحة معرض بهويتك' },
                  { icon: 'package', en: 'Products, rentals & services in one place', ar: 'منتجات وإيجار وخدمات في مكان واحد' },
                  { icon: 'message-circle', en: 'WhatsApp & online order buttons', ar: 'أزرار واتساب والطلب أونلاين' },
                  { icon: 'search', en: 'Appears in marketplace search', ar: 'يظهر في بحث السوق' },
                  { icon: 'bar-chart-3', en: 'Monthly analytics', ar: 'تحليلات شهرية' },
                  { icon: 'star', en: 'Customer reviews', ar: 'تقييمات العملاء' },
                ].map((item, i) => (
                  <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 12, padding: '12px 16px', background: 'var(--white)', borderRadius: 10, border: '1px solid var(--line)' }}>
                    <Icon name={item.icon} size={17} style={{ color: 'var(--gold-deep)', flexShrink: 0 }} />
                    <span style={{ fontSize: 14, fontWeight: 500 }}>{ar ? item.ar : item.en}</span>
                  </div>
                ))}
              </div>
            </div>
          </Reveal>
        </Container>
      </Section>

      {/* FAQ */}
      <Section bg="muted">
        <Container style={{ maxWidth: 680, margin: '0 auto' }}>
          <Reveal><SectionHead center eyebrow={ar ? 'الأسئلة الشائعة' : 'FAQ'} title={ar ? 'أسئلة الموردين' : 'Vendor questions'} /></Reveal>
          <div style={{ display: 'grid', gap: 10, marginTop: 36 }}>
            {FAQ.map((item, i) => (
              <div key={i} style={{ background: 'var(--white)', borderRadius: 12, border: '1px solid var(--line)', overflow: 'hidden' }}>
                <button onClick={() => setOpenFaq(openFaq === i ? null : i)}
                  style={{ width: '100%', padding: '15px 18px', background: 'none', border: 'none', cursor: 'pointer', display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 12, textAlign: 'start', fontFamily: 'var(--font-body)', fontSize: 14.5, fontWeight: 600, color: 'var(--fg-primary)' }}>
                  {ar ? item.q.ar : item.q.en}
                  <Icon name={openFaq === i ? 'chevron-up' : 'chevron-down'} size={17} style={{ color: 'var(--fg-muted)', flexShrink: 0 }} />
                </button>
                {openFaq === i && (
                  <div style={{ padding: '0 18px 16px', fontSize: 14, color: 'var(--fg-secondary)', lineHeight: 1.65 }}>
                    {ar ? item.a.ar : item.a.en}
                  </div>
                )}
              </div>
            ))}
          </div>
        </Container>
      </Section>

      {/* Final CTA */}
      <Section bg="canvas" style={{ textAlign: 'center' }}>
        <Container narrow>
          <Reveal>
            <h2 style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(28px,4.5vw,52px)', fontWeight: 500, lineHeight: 1.08 }}>
              {ar ? 'جاهز للانضمام؟' : 'Ready to join Saraya?'}
            </h2>
            <p style={{ color: 'var(--fg-secondary)', fontSize: 16, lineHeight: 1.65, marginTop: 14, marginBottom: 30, maxWidth: 480, margin: '14px auto 30px' }}>
              {ar
                ? 'سجّل حسابك، ارفع وثائقك، وابدأ البيع في غضون أيام.'
                : 'Create your account, upload your documents, and start selling within days.'}
            </p>
            <div style={{ display: 'flex', gap: 14, justifyContent: 'center', flexWrap: 'wrap' }}>
              <button style={btnStyle} onClick={handleCreateAccount}>
                <Icon name="user-plus" size={18} />
                {ar ? 'أنشئ حسابك الآن' : 'Create Your Account Now'}
              </button>
              <Button variant="secondary" size="lg" onClick={() => go('vendor-packages')}>
                {ar ? 'عرض الباقات' : 'View Packages'}
              </Button>
            </div>
            <p style={{ fontSize: 12.5, color: 'var(--fg-muted)', marginTop: 18 }}>
              {ar ? 'لديك سؤال؟ ' : 'Have a question? '}
              <a href={window.SARAYA && window.SARAYA.waLink("Hello Saraya, I have a question about joining as a vendor.")} target="_blank" rel="noopener noreferrer" style={{ color: 'var(--gold-deep)', fontWeight: 600 }}>
                {ar ? 'تواصل معنا عبر واتساب' : 'Chat with us on WhatsApp'}
              </a>
            </p>
          </Reveal>
        </Container>
      </Section>
    </main>
  );
}

const RQ_EVT   = ['Wedding/Engagement','Corporate Event','Birthday/Celebration','Graduation','Majlis/Gathering','Kids Party','Other'];
const RQ_EVT_AR= ['زفاف/خطوبة','فعالية شركات','عيد ميلاد/احتفال','تخرج','مجلس/تجمع','حفلة أطفال','أخرى'];
const RQ_BUD   = ['Under AED 5,000','AED 5,000–15,000','AED 15,000–50,000','AED 50,000+','Prefer to discuss'];
const RQ_BUD_AR= ['أقل من 5,000 درهم','5,000–15,000 درهم','15,000–50,000 درهم','50,000+ درهم','أفضل المناقشة'];
const RQ_NEEDS_EN = ['Full event package','Rental items','Event services','Flowers/décor/gifts','Corporate event','Wedding/engagement','Other'];
const RQ_NEEDS_AR = ['باقة فعالية كاملة','مستلزمات إيجار','خدمات فعاليات','زهور/ديكور/هدايا','فعالية شركات','زفاف/خطوبة','أخرى'];
const RQ_VBIZ_EN  = ['Event supplier','Rental furniture','Flowers/décor','Photography/media','Catering','Entertainment','Corporate services','Other'];
const RQ_VBIZ_AR  = ['مورد فعاليات','أثاث إيجار','زهور/ديكور','تصوير/إعلام','ضيافة/تموين','ترفيه','خدمات شركات','أخرى'];
const RQ_VWANT_EN = ['Join as vendor','Ask about vendor packages','Add rental items','Add services','Virtual showroom','Partnership inquiry'];
const RQ_VWANT_AR = ['الانضمام كمورد','الاستفسار عن الباقات','إضافة عناصر إيجار','إضافة خدمات','المعرض الرقمي','استفسار عن شراكة'];

const RQ_BLANK_C = { name:'', phone:'', email:'', eventType:'', eventDate:'', location:'', guests:'', budget:'', needs:[], contact:'whatsapp', message:'' };
const RQ_BLANK_V = { bizName:'', person:'', phone:'', email:'', bizType:'', wants:[], message:'' };

function RequestQuoteModal() {
  const { lang } = useLang();
  const ar = lang === 'ar';
  const [open,  setOpen]  = useStateF(false);
  const [screen,setScreen]= useStateF('type');
  const [done,  setDone]  = useStateF(false);
  const [err,   setErr]   = useStateF('');
  const [mailto,setMailto]= useStateF('');
  const [waText,setWaText]= useStateF('');
  const [cf,    setCf]    = useStateF(RQ_BLANK_C);
  const [vf,    setVf]    = useStateF(RQ_BLANK_V);

  useEffectF(function() {
    window.openRequestQuoteModal = function(opts) {
      setOpen(true); setScreen('type'); setDone(false); setErr('');
      setCf(RQ_BLANK_C); setVf(RQ_BLANK_V);
    };
    return function() { window.openRequestQuoteModal = null; };
  }, []);

  function close() {
    setOpen(false);
  }

  function toggleNeed(v) {
    setCf(function(p) { return Object.assign({}, p, { needs: p.needs.includes(v) ? p.needs.filter(function(x){return x!==v;}) : p.needs.concat([v]) }); });
  }
  function toggleWant(v) {
    setVf(function(p) { return Object.assign({}, p, { wants: p.wants.includes(v) ? p.wants.filter(function(x){return x!==v;}) : p.wants.concat([v]) }); });
  }

  function buildAndSubmit(isVendor, summary, name) {
    if (window.saveLead) {
      try { window.saveLead({ leadType: isVendor ? 'vendor_application' : 'customer_quote', source: 'request_quote_modal', name: name, message: summary }); } catch(_) {}
    }
    var subj = encodeURIComponent(isVendor ? 'New Vendor Request from Saraya Events Website' : 'New Quote Request from Saraya Events Website');
    var body = encodeURIComponent(summary + '\n\n---\nSubmitted via Saraya Events website.');
    setMailto('mailto:sales@sarayaevents.com?subject=' + subj + '&body=' + body);
    setWaText('Hello Saraya Events. ' + summary);
    setDone(true);
  }

  function submitCustomer(e) {
    e.preventDefault();
    if (!cf.name.trim()) { setErr(ar ? 'الاسم الكامل مطلوب' : 'Full name is required'); return; }
    if (!cf.phone.trim()) { setErr(ar ? 'رقم الهاتف مطلوب' : 'Phone number is required'); return; }
    setErr('');
    var needLabels = cf.needs.map(function(i) { return ar ? RQ_NEEDS_AR[i] : RQ_NEEDS_EN[i]; }).join(', ');
    var lines = [
      'Full Name: ' + cf.name,
      'Phone: ' + cf.phone,
      cf.email ? 'Email: ' + cf.email : '',
      cf.eventType !== '' ? 'Event Type: ' + (ar ? RQ_EVT_AR[cf.eventType] : RQ_EVT[cf.eventType]) : '',
      cf.eventDate ? 'Event Date: ' + cf.eventDate : '',
      cf.location ? 'Location: ' + cf.location : '',
      cf.guests ? 'Guests: ' + cf.guests : '',
      cf.budget !== '' ? 'Budget: ' + (ar ? RQ_BUD_AR[cf.budget] : RQ_BUD[cf.budget]) : '',
      needLabels ? 'Needs: ' + needLabels : '',
      cf.message ? 'Message: ' + cf.message : '',
      'Preferred contact: ' + cf.contact,
    ].filter(function(x){return x;}).join('\n');
    buildAndSubmit(false, lines, cf.name);
  }

  function submitVendor(e) {
    e.preventDefault();
    if (!vf.bizName.trim()) { setErr(ar ? 'اسم الشركة مطلوب' : 'Business name is required'); return; }
    if (!vf.phone.trim()) { setErr(ar ? 'رقم الهاتف مطلوب' : 'Phone number is required'); return; }
    setErr('');
    var wantLabels = vf.wants.map(function(i) { return ar ? RQ_VWANT_AR[i] : RQ_VWANT_EN[i]; }).join(', ');
    var lines = [
      'Business: ' + vf.bizName,
      vf.person ? 'Contact: ' + vf.person : '',
      'Phone: ' + vf.phone,
      vf.email ? 'Email: ' + vf.email : '',
      vf.bizType !== '' ? 'Business Type: ' + (ar ? RQ_VBIZ_AR[vf.bizType] : RQ_VBIZ_EN[vf.bizType]) : '',
      wantLabels ? 'Interested in: ' + wantLabels : '',
      vf.message ? 'Message: ' + vf.message : '',
    ].filter(function(x){return x;}).join('\n');
    buildAndSubmit(true, lines, vf.person || vf.bizName);
  }

  if (!open) return null;

  var INP = { width:'100%', padding:'10px 13px', borderRadius:9, border:'1.5px solid var(--line)', fontFamily:'var(--font-body)', fontSize:14, outline:'none', background:'var(--white)', boxSizing:'border-box', color:'var(--fg-primary)' };
  var LBL = { display:'block', fontSize:11, fontWeight:700, color:'var(--fg-secondary)', marginBottom:5, textTransform:'uppercase', letterSpacing:'0.07em' };
  var CHIP_BASE = { padding:'7px 13px', borderRadius:20, fontSize:13, fontFamily:'var(--font-body)', cursor:'pointer', border:'1.5px solid var(--line)', background:'var(--white)', color:'var(--fg-primary)', fontWeight:400 };
  var CHIP_ON   = { padding:'7px 13px', borderRadius:20, fontSize:13, fontFamily:'var(--font-body)', cursor:'pointer', border:'2px solid var(--gold)', background:'rgba(201,169,97,0.12)', color:'var(--gold-deep)', fontWeight:600 };
  var SUBMIT_BTN = { padding:'13px 0', borderRadius:12, border:'none', cursor:'pointer', background:'var(--espresso)', color:'var(--ivory)', fontFamily:'var(--font-body)', fontSize:15, fontWeight:600, width:'100%' };
  var BACK_BTN = { background:'none', border:'none', cursor:'pointer', color:'var(--fg-secondary)', display:'flex', padding:4, borderRadius:6 };

  var overlayStyle = { position:'fixed', inset:0, zIndex:500, display:'flex', alignItems:'center', justifyContent:'center', padding:'12px', background:'rgba(42,31,26,0.62)' };
  var modalStyle   = { position:'relative', width:'min(600px,100%)', maxHeight:'92vh', overflowY:'auto', background:'var(--bg-canvas)', borderRadius:20, boxShadow:'0 28px 72px rgba(42,31,26,0.34)' };
  var closeBtnStyle = { position:'absolute', top:12, right:12, zIndex:2, background:'var(--bg-canvas)', border:'none', cursor:'pointer', color:'var(--fg-secondary)', display:'flex', padding:6, borderRadius:8 };

  if (done) {
    return (
      <div style={overlayStyle} onClick={close}>
        <div style={modalStyle} onClick={function(e){e.stopPropagation();}}>
          <button onClick={close} style={closeBtnStyle}><Icon name="x" size={20} /></button>
          <div className="saraya-modal-body" style={{ padding:'40px 32px 36px', textAlign:'center' }}>
            <div style={{ display:'inline-flex', width:68, height:68, borderRadius:'50%', background:'#DCFCE7', alignItems:'center', justifyContent:'center', marginBottom:16 }}>
              <Icon name="check-circle-2" size={32} style={{ color:'#16A34A' }} />
            </div>
            <h2 style={{ fontFamily:'var(--font-display)', fontSize:24, fontWeight:500, margin:'0 0 10px' }}>
              {ar ? 'شكراً! تم استلام طلبك.' : 'Thank you. Your request has been received.'}
            </h2>
            <p style={{ fontSize:14, color:'var(--fg-secondary)', lineHeight:1.6, maxWidth:400, margin:'0 auto 28px' }}>
              {ar ? 'سيتواصل معك فريق سرايا قريبًا.' : 'Saraya Events will contact you shortly.'}
            </p>
            <div style={{ display:'flex', gap:10, justifyContent:'center', flexWrap:'wrap' }}>
              <a href={mailto} style={{ display:'inline-flex', alignItems:'center', gap:8, padding:'12px 22px', borderRadius:10, background:'var(--espresso)', color:'var(--ivory)', fontFamily:'var(--font-body)', fontSize:14, fontWeight:600, textDecoration:'none' }}>
                <Icon name="mail" size={16} />{ar ? 'إرسال بالبريد' : 'Send by Email'}
              </a>
              <a href={window.SARAYA.waLink(waText)} target="_blank" rel="noopener noreferrer" style={{ display:'inline-flex', alignItems:'center', gap:8, padding:'12px 22px', borderRadius:10, background:'#25D366', color:'#fff', fontFamily:'var(--font-body)', fontSize:14, fontWeight:600, textDecoration:'none' }}>
                <Icon name="message-circle" size={16} />{ar ? 'واتساب' : 'WhatsApp'}
              </a>
              <button onClick={close} style={{ padding:'12px 20px', borderRadius:10, border:'1.5px solid var(--line)', background:'var(--white)', fontFamily:'var(--font-body)', fontSize:14, cursor:'pointer' }}>
                {ar ? 'إغلاق' : 'Close'}
              </button>
            </div>
          </div>
        </div>
      </div>
    );
  }

  if (screen === 'type') {
    return (
      <div style={overlayStyle} onClick={close}>
        <div style={modalStyle} onClick={function(e){e.stopPropagation();}}>
          <button onClick={close} style={closeBtnStyle}><Icon name="x" size={20} /></button>
          <div className="saraya-modal-body" style={{ padding:'36px 32px 32px' }}>
            <div style={{ textAlign:'center', marginBottom:28 }}>
              <h2 style={{ fontFamily:'var(--font-display)', fontSize:26, fontWeight:500, margin:'0 0 8px' }}>
                {ar ? 'اطلب عرض سعر' : 'Request a Quote'}
              </h2>
              <p style={{ fontSize:14, color:'var(--fg-secondary)', margin:0 }}>
                {ar ? 'أخبرنا بما تحتاجه' : 'Tell us what you need'}
              </p>
            </div>
            <div style={{ display:'grid', gap:12 }}>
              <button onClick={function(){setScreen('customer');}} style={{ display:'flex', alignItems:'center', gap:16, padding:'20px 18px', borderRadius:14, border:'1.5px solid var(--line)', background:'var(--white)', cursor:'pointer', width:'100%', fontFamily:'var(--font-body)', textAlign:'left' }}>
                <div style={{ width:44, height:44, borderRadius:12, background:'var(--cream)', display:'flex', alignItems:'center', justifyContent:'center', flexShrink:0 }}>
                  <Icon name="calendar" size={22} style={{ color:'var(--gold-deep)' }} />
                </div>
                <div style={{ flex:1 }}>
                  <div style={{ fontSize:15, fontWeight:700, marginBottom:3 }}>{ar ? 'طلب عميل' : 'Customer Request'}</div>
                  <div style={{ fontSize:13, color:'var(--fg-secondary)' }}>{ar ? 'خطّط فعالية أو اطلب عرض سعر' : 'Plan an event or request a quote'}</div>
                </div>
                <Icon name="chevron-right" size={18} style={{ color:'var(--fg-muted)', flexShrink:0 }} />
              </button>
              <button onClick={function(){setScreen('vendor');}} style={{ display:'flex', alignItems:'center', gap:16, padding:'20px 18px', borderRadius:14, border:'1.5px solid var(--line)', background:'var(--white)', cursor:'pointer', width:'100%', fontFamily:'var(--font-body)', textAlign:'left' }}>
                <div style={{ width:44, height:44, borderRadius:12, background:'var(--cream)', display:'flex', alignItems:'center', justifyContent:'center', flexShrink:0 }}>
                  <Icon name="briefcase" size={22} style={{ color:'var(--gold-deep)' }} />
                </div>
                <div style={{ flex:1 }}>
                  <div style={{ fontSize:15, fontWeight:700, marginBottom:3 }}>{ar ? 'طلب مورد' : 'Vendor Request'}</div>
                  <div style={{ fontSize:13, color:'var(--fg-secondary)' }}>{ar ? 'انضم كمورد أو استفسر عن شراكة' : 'Join as vendor or partnership inquiry'}</div>
                </div>
                <Icon name="chevron-right" size={18} style={{ color:'var(--fg-muted)', flexShrink:0 }} />
              </button>
            </div>
          </div>
        </div>
      </div>
    );
  }

  if (screen === 'customer') {
    return (
      <div style={overlayStyle} onClick={close}>
        <div style={modalStyle} onClick={function(e){e.stopPropagation();}}>
          <button onClick={close} style={closeBtnStyle}><Icon name="x" size={20} /></button>
          <div className="saraya-modal-body" style={{ padding:'28px 32px 32px' }}>
            <div style={{ display:'flex', alignItems:'center', gap:10, marginBottom:22 }}>
              <button type="button" style={BACK_BTN} onClick={function(){setScreen('type');setErr('');}}>
                <Icon name="arrow-left" size={20} />
              </button>
              <div>
                <h2 style={{ fontFamily:'var(--font-display)', fontSize:21, fontWeight:500, margin:0 }}>{ar ? 'طلب عرض سعر' : 'Request a Quote'}</h2>
                <p style={{ fontSize:12.5, color:'var(--fg-secondary)', margin:'2px 0 0' }}>{ar ? 'أخبرنا بتفاصيل فعاليتك' : 'Tell us about your event'}</p>
              </div>
            </div>
            <form onSubmit={submitCustomer} style={{ display:'grid', gap:14 }}>
              <div className="saraya-form-2col" style={{ display:'grid', gridTemplateColumns:'1fr 1fr', gap:12 }}>
                <div>
                  <label style={LBL}>{ar ? 'الاسم الكامل *' : 'Full Name *'}</label>
                  <input style={INP} value={cf.name} onChange={function(e){setCf(function(p){return Object.assign({},p,{name:e.target.value});});}} placeholder={ar ? 'اسمك الكامل' : 'Your full name'} />
                </div>
                <div>
                  <label style={LBL}>{ar ? 'الهاتف / واتساب *' : 'Phone / WhatsApp *'}</label>
                  <input style={INP} type="tel" value={cf.phone} onChange={function(e){setCf(function(p){return Object.assign({},p,{phone:e.target.value});});}} placeholder="+971 5X XXX XXXX" />
                </div>
              </div>
              <div>
                <label style={LBL}>{ar ? 'البريد الإلكتروني' : 'Email (optional)'}</label>
                <input style={INP} type="email" value={cf.email} onChange={function(e){setCf(function(p){return Object.assign({},p,{email:e.target.value});});}} placeholder="your@email.com" />
              </div>
              <div className="saraya-form-2col" style={{ display:'grid', gridTemplateColumns:'1fr 1fr', gap:12 }}>
                <div>
                  <label style={LBL}>{ar ? 'نوع الفعالية' : 'Event Type'}</label>
                  <select style={INP} value={cf.eventType} onChange={function(e){setCf(function(p){return Object.assign({},p,{eventType:e.target.value});});}}>
                    <option value="">{ar ? '— اختر —' : '— Select —'}</option>
                    {RQ_EVT.map(function(t,i){ return <option key={i} value={i}>{ar ? RQ_EVT_AR[i] : t}</option>; })}
                  </select>
                </div>
                <div>
                  <label style={LBL}>{ar ? 'تاريخ الفعالية' : 'Event Date'}</label>
                  <input style={INP} type="date" value={cf.eventDate} onChange={function(e){setCf(function(p){return Object.assign({},p,{eventDate:e.target.value});});}} />
                </div>
              </div>
              <div className="saraya-form-2col" style={{ display:'grid', gridTemplateColumns:'1fr 1fr', gap:12 }}>
                <div>
                  <label style={LBL}>{ar ? 'الموقع / المدينة' : 'Location / City'}</label>
                  <input style={INP} value={cf.location} onChange={function(e){setCf(function(p){return Object.assign({},p,{location:e.target.value});});}} placeholder={ar ? 'أبوظبي، دبي...' : 'Abu Dhabi, Dubai...'} />
                </div>
                <div>
                  <label style={LBL}>{ar ? 'عدد الضيوف' : 'Number of Guests'}</label>
                  <input style={INP} type="number" min="1" value={cf.guests} onChange={function(e){setCf(function(p){return Object.assign({},p,{guests:e.target.value});});}} placeholder="e.g. 100" />
                </div>
              </div>
              <div>
                <label style={LBL}>{ar ? 'الميزانية' : 'Budget Range'}</label>
                <select style={INP} value={cf.budget} onChange={function(e){setCf(function(p){return Object.assign({},p,{budget:e.target.value});});}}>
                  <option value="">{ar ? '— اختر —' : '— Select —'}</option>
                  {RQ_BUD.map(function(b,i){ return <option key={i} value={i}>{ar ? RQ_BUD_AR[i] : b}</option>; })}
                </select>
              </div>
              <div>
                <label style={LBL}>{ar ? 'ماذا تحتاج؟' : 'What do you need?'}</label>
                <div style={{ display:'flex', flexWrap:'wrap', gap:8 }}>
                  {RQ_NEEDS_EN.map(function(n,i){
                    var on = cf.needs.includes(i);
                    return <button type="button" key={i} style={on ? CHIP_ON : CHIP_BASE} onClick={function(){toggleNeed(i);}}>{ar ? RQ_NEEDS_AR[i] : n}</button>;
                  })}
                </div>
              </div>
              <div>
                <label style={LBL}>{ar ? 'رسالة' : 'Message'}</label>
                <textarea style={Object.assign({},INP,{resize:'vertical'})} rows={3} value={cf.message} onChange={function(e){setCf(function(p){return Object.assign({},p,{message:e.target.value});});}} placeholder={ar ? 'أي تفاصيل إضافية...' : 'Any additional details...'} />
              </div>
              {err && <div style={{ padding:'10px 13px', borderRadius:8, background:'#FEF2F2', color:'#B91C1C', fontSize:13 }}>{err}</div>}
              <button type="submit" style={SUBMIT_BTN}>{ar ? 'إرسال الطلب' : 'Send Request'}</button>
            </form>
          </div>
        </div>
      </div>
    );
  }

  return (
    <div style={overlayStyle} onClick={close}>
      <div style={modalStyle} onClick={function(e){e.stopPropagation();}}>
        <button onClick={close} style={closeBtnStyle}><Icon name="x" size={20} /></button>
        <div style={{ padding:'28px 32px 32px' }}>
          <div style={{ display:'flex', alignItems:'center', gap:10, marginBottom:22 }}>
            <button type="button" style={BACK_BTN} onClick={function(){setScreen('type');setErr('');}}>
              <Icon name="arrow-left" size={20} />
            </button>
            <div>
              <h2 style={{ fontFamily:'var(--font-display)', fontSize:21, fontWeight:500, margin:0 }}>{ar ? 'طلب مورد' : 'Vendor Request'}</h2>
              <p style={{ fontSize:12.5, color:'var(--fg-secondary)', margin:'2px 0 0' }}>{ar ? 'انضم أو تواصل معنا' : 'Join or contact us'}</p>
            </div>
          </div>
          <form onSubmit={submitVendor} style={{ display:'grid', gap:14 }}>
            <div style={{ display:'grid', gridTemplateColumns:'1fr 1fr', gap:12 }}>
              <div>
                <label style={LBL}>{ar ? 'اسم الشركة *' : 'Business Name *'}</label>
                <input style={INP} value={vf.bizName} onChange={function(e){setVf(function(p){return Object.assign({},p,{bizName:e.target.value});});}} placeholder={ar ? 'اسم شركتك' : 'Your business name'} />
              </div>
              <div>
                <label style={LBL}>{ar ? 'الشخص المسؤول' : 'Contact Person'}</label>
                <input style={INP} value={vf.person} onChange={function(e){setVf(function(p){return Object.assign({},p,{person:e.target.value});});}} placeholder={ar ? 'اسمك الكامل' : 'Your name'} />
              </div>
            </div>
            <div style={{ display:'grid', gridTemplateColumns:'1fr 1fr', gap:12 }}>
              <div>
                <label style={LBL}>{ar ? 'الهاتف / واتساب *' : 'Phone / WhatsApp *'}</label>
                <input style={INP} type="tel" value={vf.phone} onChange={function(e){setVf(function(p){return Object.assign({},p,{phone:e.target.value});});}} placeholder="+971 5X XXX XXXX" />
              </div>
              <div>
                <label style={LBL}>{ar ? 'البريد الإلكتروني' : 'Email'}</label>
                <input style={INP} type="email" value={vf.email} onChange={function(e){setVf(function(p){return Object.assign({},p,{email:e.target.value});});}} placeholder="your@email.com" />
              </div>
            </div>
            <div>
              <label style={LBL}>{ar ? 'نوع النشاط التجاري' : 'Business Type'}</label>
              <select style={INP} value={vf.bizType} onChange={function(e){setVf(function(p){return Object.assign({},p,{bizType:e.target.value});});}}>
                <option value="">{ar ? '— اختر —' : '— Select —'}</option>
                {RQ_VBIZ_EN.map(function(b,i){ return <option key={i} value={i}>{ar ? RQ_VBIZ_AR[i] : b}</option>; })}
              </select>
            </div>
            <div>
              <label style={LBL}>{ar ? 'ماذا تريد؟' : 'What do you want?'}</label>
              <div style={{ display:'flex', flexWrap:'wrap', gap:8 }}>
                {RQ_VWANT_EN.map(function(w,i){
                  var on = vf.wants.includes(i);
                  return <button type="button" key={i} style={on ? CHIP_ON : CHIP_BASE} onClick={function(){toggleWant(i);}}>{ar ? RQ_VWANT_AR[i] : w}</button>;
                })}
              </div>
            </div>
            <div>
              <label style={LBL}>{ar ? 'رسالة' : 'Message'}</label>
              <textarea style={Object.assign({},INP,{resize:'vertical'})} rows={3} value={vf.message} onChange={function(e){setVf(function(p){return Object.assign({},p,{message:e.target.value});});}} placeholder={ar ? 'أي تفاصيل إضافية...' : 'Any additional details...'} />
            </div>
            {err && <div style={{ padding:'10px 13px', borderRadius:8, background:'#FEF2F2', color:'#B91C1C', fontSize:13 }}>{err}</div>}
            <button type="submit" style={SUBMIT_BTN}>{ar ? 'إرسال طلب المورد' : 'Send Vendor Request'}</button>
          </form>
        </div>
      </div>
    </div>
  );
}

Object.assign(window, { DesignBuilder, BuilderDone, StepShell, PartnerPage, RequestQuoteModal });
