// Saraya Events — Quote Request Wizard (5 steps)
// Exported: window.QuoteWizard

(function () {
  const { useState, useCallback } = React;

  /* ── SVG icons (stroke-only line icons, matches original design) ─── */
  const Icons = {
    wedding:    (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M12 2l2.09 6.26L21 9.27l-5 4.87 1.18 6.88L12 17.77l-5.18 3.25L8 14.14 3 9.27l6.91-1.01z"/></svg>),
    engagement: (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78L12 21.23l8.84-8.84a5.5 5.5 0 0 0 0-7.78z"/></svg>),
    corporate:  (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><rect x="2" y="7" width="20" height="14" rx="2"/><path d="M16 7V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2"/></svg>),
    graduation: (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M22 10v6M2 10l10-5 10 5-10 5z"/><path d="M6 12v5c3 3 9 3 12 0v-5"/></svg>),
    birthday:   (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8"/><path d="M4 16s.5-1 2-1 2.5 2 4 2 2.5-2 4-2 2.5 2 4 2 2-1 2-1"/><line x1="2" y1="21" x2="22" y2="21"/><line x1="7" y1="8" x2="7" y2="11"/><line x1="12" y1="8" x2="12" y2="11"/><line x1="17" y1="8" x2="17" y2="11"/></svg>),
    kids:       (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>),
    majlis:     (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>),
    other:      (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>),
    ballroom:   (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/></svg>),
    home:       (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>),
    outdoor:    (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>),
    gov:        (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><line x1="3" y1="22" x2="21" y2="22"/><line x1="6" y1="18" x2="6" y2="11"/><line x1="10" y1="18" x2="10" y2="11"/><line x1="14" y1="18" x2="14" y2="11"/><line x1="18" y1="18" x2="18" y2="11"/><polygon points="12 2 20 7 4 7"/></svg>),
    majlisv:    (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg>),
    none:       (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>),
    decor:      (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>),
    furniture:  (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M20 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v3"/><path d="M2 11v5a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5a2 2 0 0 0-4 0v2H6v-2a2 2 0 0 0-4 0z"/><line x1="6" y1="18" x2="6" y2="22"/><line x1="18" y1="18" x2="18" y2="22"/></svg>),
    flowers:    (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M12 22V12m0 0C12 7 7 4 7 4s1 5 5 8zm0 0c0-5 5-8 5-8s-1 5-5 8zM12 12C7 12 4 7 4 7s5 1 8 5zm0 0c5 0 8-5 8-5s-5 1-8 5z"/></svg>),
    catering:   (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><path d="M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2"/><line x1="7" y1="2" x2="7" y2="22"/><path d="M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3zm0 0v7"/></svg>),
    stage:      (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><polygon points="23 7 16 12 23 17 23 7"/><rect x="1" y="5" width="15" height="14" rx="2"/></svg>),
    lighting:   (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>),
    balloons:   (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><circle cx="9" cy="8" r="5"/><circle cx="15" cy="6" r="4"/><path d="M9 13v9M9 22l-2-2M9 22l2-2"/></svg>),
    full:       (<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" width="32" height="32"><rect x="2" y="3" width="20" height="14" rx="2"/><polyline points="8 21 12 17 16 21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>),
  };

  const OCCASIONS = [
    { id: 'wedding',    icon: 'wedding',    en: 'Wedding',        ar: 'زفاف' },
    { id: 'engagement', icon: 'engagement', en: 'Engagement',     ar: 'خطوبة' },
    { id: 'corporate',  icon: 'corporate',  en: 'Corporate',      ar: 'شركات' },
    { id: 'graduation', icon: 'graduation', en: 'Graduation',     ar: 'تخرّج' },
    { id: 'birthday',   icon: 'birthday',   en: 'Birthday',       ar: 'عيد ميلاد' },
    { id: 'kids',       icon: 'kids',       en: 'Kids Party',     ar: 'حفلة أطفال' },
    { id: 'majlis',     icon: 'majlis',     en: 'Home / Majlis',  ar: 'منزل / مجلس' },
    { id: 'other',      icon: 'other',      en: 'Something else', ar: 'شيء آخر' },
  ];

  const VENUES = [
    { id: 'ballroom', icon: 'ballroom', en: 'Hotel Ballroom',  ar: 'قاعة فندق' },
    { id: 'home',     icon: 'home',     en: 'Home',            ar: 'المنزل' },
    { id: 'outdoor',  icon: 'outdoor',  en: 'Outdoor Venue',   ar: 'مكان خارجي' },
    { id: 'gov',      icon: 'gov',      en: 'Government Hall', ar: 'قاعة حكومية' },
    { id: 'majlis',   icon: 'majlisv',  en: 'Majlis',          ar: 'مجلس' },
    { id: 'none',     icon: 'none',     en: 'Not booked yet',  ar: 'لم يُحجز بعد' },
  ];

  const SERVICES = [
    { id: 'decor',     icon: 'decor',     en: 'Decor',      ar: 'ديكور' },
    { id: 'furniture', icon: 'furniture', en: 'Furniture',  ar: 'أثاث' },
    { id: 'flowers',   icon: 'flowers',   en: 'Flowers',    ar: 'زهور' },
    { id: 'catering',  icon: 'catering',  en: 'Catering',   ar: 'ضيافة' },
    { id: 'stage',     icon: 'stage',     en: 'Stage',      ar: 'منصة' },
    { id: 'lighting',  icon: 'lighting',  en: 'Lighting',   ar: 'إضاءة' },
    { id: 'balloons',  icon: 'balloons',  en: 'Balloons',   ar: 'بالونات' },
    { id: 'full',      icon: 'full',      en: 'Full Setup', ar: 'تجهيز كامل' },
  ];

  const BUDGETS = [
    { id: 'b1', en: 'Under AED 10,000',      ar: 'أقل من 10,000 درهم' },
    { id: 'b2', en: 'AED 10,000 – 25,000',   ar: '10,000 – 25,000 درهم' },
    { id: 'b3', en: 'AED 25,000 – 50,000',   ar: '25,000 – 50,000 درهم' },
    { id: 'b4', en: 'AED 50,000 – 100,000',  ar: '50,000 – 100,000 درهم' },
    { id: 'b5', en: 'AED 100,000+',           ar: 'أكثر من 100,000 درهم' },
  ];

  const STEPS = [
    { key: 'occasion', en: 'Occasion',     ar: 'المناسبة' },
    { key: 'venue',    en: 'Venue',        ar: 'المكان' },
    { key: 'services', en: 'Services',     ar: 'الخدمات' },
    { key: 'budget',   en: 'Budget',       ar: 'الميزانية' },
    { key: 'details',  en: 'Your details', ar: 'تفاصيلك' },
  ];

  const getLang = () => { try { return localStorage.getItem('saraya_lang') || 'en'; } catch { return 'en'; } };

  /* ── Step progress bar ───────────────────────────────────── */
  function StepBar({ step, lang }) {
    return (
      <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '20px 32px', gap: 0, flexWrap: 'nowrap', overflowX: 'auto' }}>
        {STEPS.map((s, i) => (
          <React.Fragment key={s.key}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 7, flexShrink: 0 }}>
              <div style={{
                width: 28, height: 28, borderRadius: '50%', flexShrink: 0,
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                fontSize: 12, fontWeight: 700,
                background: i <= step ? '#2A1F1A' : 'transparent',
                color: i <= step ? '#fff' : '#bbb',
                border: i > step ? '1.5px solid #ccc' : 'none',
              }}>
                {i < step ? '✓' : i + 1}
              </div>
              <span style={{ fontSize: 13, fontWeight: i === step ? 600 : 400, color: i === step ? '#2A1F1A' : i < step ? '#6b5c4e' : '#bbb', whiteSpace: 'nowrap' }}>
                {s[lang] || s.en}
              </span>
            </div>
            {i < STEPS.length - 1 && (
              <div style={{ flex: '1 1 20px', minWidth: 20, maxWidth: 60, height: 1, background: i < step ? '#8a7060' : '#ddd', margin: '0 8px' }} />
            )}
          </React.Fragment>
        ))}
      </div>
    );
  }

  /* ── Icon tile card ──────────────────────────────────────── */
  function Tile({ iconKey, label, active, onClick }) {
    return (
      <button type="button" onClick={onClick} style={{
        display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
        gap: 14, padding: '28px 12px 22px', borderRadius: 12, cursor: 'pointer',
        border: active ? '2px solid var(--gold, #C9A961)' : '1.5px solid #e2ddd6',
        background: '#fff',
        color: active ? 'var(--gold, #C9A961)' : '#6b5c4e',
        fontFamily: 'inherit', width: '100%',
        transition: 'border-color 150ms, color 150ms',
        outline: 'none',
      }}>
        {Icons[iconKey]}
        <span style={{ fontSize: 13.5, fontWeight: active ? 600 : 400, color: active ? 'var(--gold, #C9A961)' : '#2A1F1A', textAlign: 'center', lineHeight: 1.3 }}>
          {label}
        </span>
      </button>
    );
  }

  /* ── Budget row ──────────────────────────────────────────── */
  function BudgetRow({ label, active, onClick }) {
    return (
      <button type="button" onClick={onClick} style={{
        padding: '16px 22px', borderRadius: 10, cursor: 'pointer', textAlign: 'left', width: '100%',
        border: active ? '2px solid var(--gold, #C9A961)' : '1.5px solid #e2ddd6',
        background: '#fff', fontFamily: 'inherit', fontSize: 14.5,
        fontWeight: active ? 600 : 400,
        color: active ? 'var(--gold, #C9A961)' : '#2A1F1A',
        transition: 'all 150ms', outline: 'none',
      }}>
        {label}
      </button>
    );
  }

  /* ── Input field wrapper ─────────────────────────────────── */
  function Field({ label, children }) {
    return (
      <div>
        <label style={{ display: 'block', fontSize: 12, fontWeight: 700, color: '#9a8a7a', marginBottom: 7, textTransform: 'uppercase', letterSpacing: '0.07em' }}>{label}</label>
        {children}
      </div>
    );
  }

  const inp = { width: '100%', padding: '12px 16px', borderRadius: 10, border: '1.5px solid #e2ddd6', fontFamily: 'inherit', fontSize: 14, background: '#fff', color: '#2A1F1A', boxSizing: 'border-box', outline: 'none' };

  /* ── Done screen ─────────────────────────────────────────── */
  function DoneScreen({ lang, data, onHome }) {
    const ar = lang === 'ar';
    const occ = OCCASIONS.find(o => o.id === data.occasion);
    const bud = BUDGETS.find(b => b.id === data.budget);
    const waText = encodeURIComponent(`Hello Saraya Events!\n\nI'd like a quote for:\nOccasion: ${occ?.[lang]||data.occasion}\nServices: ${data.services.join(', ')}\nBudget: ${bud?.[lang]||''}\nName: ${data.name}\nPhone: ${data.phone}`);
    return (
      <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', minHeight: '60vh', textAlign: 'center', padding: '60px 24px' }}>
        <div style={{ width: 60, height: 60, borderRadius: '50%', background: 'rgba(201,169,97,0.12)', display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: 24 }}>
          <svg viewBox="0 0 24 24" fill="none" stroke="var(--gold,#C9A961)" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" width="28" height="28"><polyline points="20 6 9 17 4 12"/></svg>
        </div>
        <h2 style={{ fontFamily: 'var(--font-display, Georgia)', fontSize: 36, fontWeight: 400, color: '#2A1F1A', margin: '0 0 12px' }}>{ar ? 'تم إرسال طلبك!' : 'Request received!'}</h2>
        <p style={{ fontSize: 15, color: '#7a6a5a', maxWidth: 380, lineHeight: 1.7, margin: '0 0 36px' }}>{ar ? 'سيتواصل معك فريق سرايا خلال 24 ساعة.' : 'The Saraya team will be in touch within 24 hours.'}</p>
        <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', justifyContent: 'center' }}>
          <a href={`https://wa.me/971529692965?text=${waText}`} target="_blank" rel="noopener noreferrer"
            style={{ display: 'inline-flex', alignItems: 'center', gap: 8, padding: '13px 26px', borderRadius: 10, background: '#25D366', color: '#fff', textDecoration: 'none', fontFamily: 'inherit', fontSize: 14, fontWeight: 600 }}>
            💬 {ar ? 'واتساب' : 'WhatsApp us'}
          </a>
          <button onClick={onHome} style={{ padding: '13px 26px', borderRadius: 10, border: '1.5px solid #e2ddd6', background: '#fff', color: '#2A1F1A', fontFamily: 'inherit', fontSize: 14, fontWeight: 500, cursor: 'pointer' }}>
            {ar ? 'العودة للرئيسية' : 'Back to home'}
          </button>
        </div>
      </div>
    );
  }

  /* ── Main wizard ─────────────────────────────────────────── */
  function QuoteWizard() {
    const lang = getLang();
    const ar = lang === 'ar';

    const [step, setStep]      = useState(0);
    const [done, setDone]      = useState(false);
    const [submitting, setSub] = useState(false);
    const [data, setData]      = useState({ occasion: '', venue: '', services: [], budget: '', name: '', phone: '', email: '', date: '', notes: '' });

    const set = useCallback((k, v) => setData(p => ({ ...p, [k]: v })), []);
    const toggleSvc = useCallback((id) => setData(p => ({ ...p, services: p.services.includes(id) ? p.services.filter(x => x !== id) : [...p.services, id] })), []);

    const canNext = [
      () => !!data.occasion,
      () => !!data.venue,
      () => data.services.length > 0,
      () => !!data.budget,
      () => !!data.name && !!data.phone,
    ][step]?.() ?? false;

    const goHome = () => { location.hash = '#home'; };
    const goBack = () => { if (step === 0) goHome(); else setStep(s => s - 1); };

    const submit = async () => {
      setSub(true);
      try {
        if (window.SarayaDB) {
          const occ = OCCASIONS.find(o => o.id === data.occasion);
          const bud = BUDGETS.find(b => b.id === data.budget);
          await window.SarayaDB.from('leads').insert({ name: data.name, phone: data.phone, email: data.email || null, service: occ?.en || data.occasion, event_date: data.date || null, budget: bud?.en || '', notes: `Venue: ${data.venue}\nServices: ${data.services.join(', ')}\n${data.notes}`, source: 'quote_wizard', status: 'new' });
        }
      } catch (_) {}
      try { if (typeof gtag === 'function') gtag('event', 'generate_lead', { event_label: data.occasion }); } catch (_) {}
      setSub(false);
      setDone(true);
    };

    if (done) return (
      <div style={{ background: 'var(--cream,#FAF6F0)', minHeight: '100vh' }}>
        <StepBar step={5} lang={lang} />
        <div style={{ maxWidth: 760, margin: '0 auto', padding: '0 24px' }}>
          <DoneScreen lang={lang} data={data} onHome={goHome} />
        </div>
      </div>
    );

    const H1   = { fontFamily: 'var(--font-display, Georgia, serif)', fontSize: 'clamp(30px,4vw,46px)', fontWeight: 400, color: '#2A1F1A', margin: '36px 0 6px', lineHeight: 1.15 };
    const SUB  = { fontSize: 14, color: 'var(--gold,#C9A961)', margin: '0 0 32px', fontWeight: 500 };
    const G4   = { display: 'grid', gridTemplateColumns: 'repeat(4,1fr)', gap: 12 };
    const G3   = { display: 'grid', gridTemplateColumns: 'repeat(3,1fr)', gap: 12 };

    function NavBar() {
      return (
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginTop: 44 }}>
          <button type="button" onClick={goBack}
            style={{ display: 'inline-flex', alignItems: 'center', gap: 6, padding: '11px 22px', borderRadius: 10, border: '1.5px solid #d8d1c8', background: 'transparent', color: '#2A1F1A', fontFamily: 'inherit', fontSize: 14, fontWeight: 500, cursor: 'pointer' }}>
            ← {ar ? 'رجوع' : 'Back'}
          </button>
          {step < STEPS.length - 1 ? (
            <button type="button" onClick={() => canNext && setStep(s => s + 1)} disabled={!canNext}
              style={{ padding: '12px 36px', borderRadius: 10, border: 'none', background: canNext ? '#4a3c34' : '#c8c0b6', color: '#fff', fontFamily: 'inherit', fontSize: 14, fontWeight: 600, cursor: canNext ? 'pointer' : 'default', transition: 'background 150ms' }}>
              {ar ? 'التالي →' : 'Next →'}
            </button>
          ) : (
            <button type="button" onClick={submit} disabled={!canNext || submitting}
              style={{ padding: '12px 36px', borderRadius: 10, border: 'none', background: canNext ? 'var(--gold,#C9A961)' : '#c8c0b6', color: '#2A1F1A', fontFamily: 'inherit', fontSize: 14, fontWeight: 700, cursor: canNext ? 'pointer' : 'default', transition: 'background 150ms' }}>
              {submitting ? '...' : (ar ? 'إرسال الطلب' : 'Send Request')}
            </button>
          )}
        </div>
      );
    }

    return (
      <div style={{ background: 'var(--cream,#FAF6F0)', minHeight: '100vh' }} dir={ar ? 'rtl' : 'ltr'}>
        <StepBar step={step} lang={lang} />
        <div style={{ maxWidth: 900, margin: '0 auto', padding: '0 32px 80px' }}>

          {step === 0 && (<>
            <h1 style={H1}>{ar ? 'ما المناسبة؟' : 'What are we celebrating?'}</h1>
            <p style={SUB}>{ar ? 'اختر نوع المناسبة.' : 'Pick the type of event.'}</p>
            <div style={G4}>{OCCASIONS.map(o => <Tile key={o.id} iconKey={o.icon} label={o[lang]||o.en} active={data.occasion===o.id} onClick={()=>set('occasion',o.id)} />)}</div>
            <NavBar />
          </>)}

          {step === 1 && (<>
            <h1 style={H1}>{ar ? 'أين ستُقام؟' : 'Where will it be?'}</h1>
            <p style={SUB}>{ar ? 'اختر نوع المكان.' : 'Choose a venue type.'}</p>
            <div style={G3}>{VENUES.map(v => <Tile key={v.id} iconKey={v.icon} label={v[lang]||v.en} active={data.venue===v.id} onClick={()=>set('venue',v.id)} />)}</div>
            <NavBar />
          </>)}

          {step === 2 && (<>
            <h1 style={H1}>{ar ? 'ماذا تحتاج؟' : 'What do you need?'}</h1>
            <p style={SUB}>{ar ? 'اختر كل ما ينطبق.' : 'Select all that apply.'}</p>
            <div style={G4}>{SERVICES.map(s => <Tile key={s.id} iconKey={s.icon} label={s[lang]||s.en} active={data.services.includes(s.id)} onClick={()=>toggleSvc(s.id)} />)}</div>
            <NavBar />
          </>)}

          {step === 3 && (<>
            <h1 style={H1}>{ar ? 'الميزانية والتاريخ' : 'Budget & date'}</h1>
            <p style={SUB}>{ar ? 'تقدير تقريبي يساعدنا على التخطيط.' : 'A rough range helps us plan.'}</p>
            <div style={{ display: 'grid', gap: 10, maxWidth: 500, marginBottom: 28 }}>
              {BUDGETS.map(b => <BudgetRow key={b.id} label={b[lang]||b.en} active={data.budget===b.id} onClick={()=>set('budget',b.id)} />)}
            </div>
            <div style={{ maxWidth: 340 }}>
              <Field label={ar ? 'تاريخ الفعالية (اختياري)' : 'Event date (optional)'}>
                <input type="date" value={data.date} onChange={e=>set('date',e.target.value)} style={inp} />
              </Field>
            </div>
            <NavBar />
          </>)}

          {step === 4 && (<>
            <h1 style={H1}>{ar ? 'كيف نصل إليك؟' : 'Your details'}</h1>
            <p style={SUB}>{ar ? 'سنعود إليك خلال 24 ساعة.' : "We'll be in touch within 24 hours."}</p>
            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 20, maxWidth: 620 }}>
              <Field label={ar ? 'الاسم الكامل *' : 'Full name *'}>
                <input type="text" value={data.name} onChange={e=>set('name',e.target.value)} placeholder={ar ? 'اسمك الكامل' : 'Your full name'} style={inp} />
              </Field>
              <Field label={ar ? 'الهاتف / واتساب *' : 'Phone / WhatsApp *'}>
                <input type="tel" value={data.phone} onChange={e=>set('phone',e.target.value)} placeholder="+971 5X XXX XXXX" style={inp} />
              </Field>
              <Field label={ar ? 'البريد الإلكتروني' : 'Email (optional)'}>
                <input type="email" value={data.email} onChange={e=>set('email',e.target.value)} placeholder={ar ? 'بريدك@مثال.com' : 'your@email.com'} style={inp} />
              </Field>
              <Field label={ar ? 'تاريخ الفعالية' : 'Event date'}>
                <input type="date" value={data.date} onChange={e=>set('date',e.target.value)} style={inp} />
              </Field>
              <div style={{ gridColumn: '1/-1' }}>
                <Field label={ar ? 'ملاحظات إضافية' : 'Additional notes'}>
                  <textarea value={data.notes} onChange={e=>set('notes',e.target.value)} rows={3} placeholder={ar ? 'أي تفاصيل أخرى...' : 'Anything else we should know...'} style={{ ...inp, resize: 'vertical' }} />
                </Field>
              </div>
            </div>
            <NavBar />
          </>)}

        </div>
      </div>
    );
  }

  window.QuoteWizard = QuoteWizard;
})();
