/* ── Zafa — Guest advertiser: Post an Ad (intro → form → pay → thank you) ── */

/* duration options + pricing (one-time flat fee, AED) */
const AD_DURATIONS = [
{ id: 'week1', days: 7, fee: 15, en: '1 week', ar: 'أسبوع' },
{ id: 'days15', days: 15, fee: 100, en: '15 days', ar: '15 يوماً' },
{ id: 'month1', days: 30, fee: 279, en: '1 month', ar: 'شهر' },
{ id: 'custom', days: null, fee: null, en: 'Custom', ar: 'مخصّص' }];

const BOOST_FEE = 20;
const customFee = (days) => Math.max(1, Math.round(Number(days) || 0)) * 2; // AED 2/day

/* ── Intro / explainer ── */
function PostAdInfo() {
  const { lang, t, pop, push } = useZafa();
  const points = L(lang,
  ['Open to any user who isn\u2019t an active vendor', 'Choose 1 week, 15 days, or 1 month', 'One-time flat fee — never a subscription', 'Reviewed by our team before going live', 'Approved ads appear alongside vendor listings'],
  ['متاح لأي مستخدم ليس مزوّداً نشطاً', 'اختر أسبوعاً أو ١٥ يوماً أو شهراً', 'رسوم ثابتة لمرّة واحدة — بلا اشتراك', 'تتم مراجعته من فريقنا قبل النشر', 'تظهر الإعلانات المعتمدة بجانب المزوّدين']);
  return (
    <div style={{ height: '100%', display: 'flex', flexDirection: 'column', background: 'var(--bg)' }}>
      <div style={{ padding: '6px 18px 6px' }}><ScreenHeader title={t('postAd')} onBack={pop} /></div>
      <div className="z-scroll no-bar" style={{ flex: 1, padding: '8px 18px 20px' }}>
        <span className="eyebrow" style={{ display: 'block', marginTop: 6 }}>{t('forEveryone')}</span>
        <h1 className="h1" style={{ margin: '10px 0 10px' }}>{L(lang, 'Get your products seen', 'اجعل منتجاتك مرئية')}</h1>
        <p className="sec" style={{ margin: 0, fontSize: 14.5, lineHeight: 1.55, textWrap: 'pretty' }}>
          {L(lang,
          'Any registered user who isn\u2019t an active vendor can post a short-term advertisement — perfect for individuals or businesses who want temporary visibility without a subscription. Pay a one-time fee, and boost your ad for even more reach.',
          'يمكن لأي مستخدم مسجّل ليس مزوّداً نشطاً نشر إعلان قصير المدى — مثالي للأفراد أو الشركات الراغبين بظهور مؤقت دون اشتراك. ادفع رسماً واحداً، ويمكنك ترويج إعلانك لمزيد من الوصول.')}
        </p>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 13, marginTop: 22 }}>
          {points.map((p, i) =>
          <div key={i} style={{ display: 'flex', gap: 12, alignItems: 'flex-start' }}>
              <span style={{ width: 30, height: 30, borderRadius: 9, background: 'var(--rose)', color: 'var(--ink)', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0, marginTop: 1 }}><Icon name="check" size={17} stroke={2.4} /></span>
              <span style={{ fontSize: 14.5, fontWeight: 500, lineHeight: 1.4 }}>{p}</span>
            </div>
          )}
        </div>
      </div>
      <div style={{ padding: '12px 18px 26px', borderTop: '1px solid var(--line)', background: '#fff' }}>
        <Btn variant="rose" iconR="arrow" onClick={() => push({ name: 'postadform' })}>{t('startPosting')}</Btn>
      </div>
    </div>);

}

/* small labeled field */
function AdField({ label, hint, children }) {
  return (
    <label style={{ display: 'block' }}>
      <span className="lbl" style={{ display: 'block', marginBottom: 7 }}>{label}</span>
      {children}
      {hint && <span className="muted" style={{ display: 'block', fontSize: 11.5, marginTop: 5 }}>{hint}</span>}
    </label>);

}

/* ── The form (+ pay + thank you states) ── */
function PostAdForm() {
  const { lang, t, pop, setTab } = useZafa();
  const rtl = lang === 'ar';
  const [state, setState] = React.useState('form'); // form | pay | processing | thankyou
  const [outcome, setOutcome] = React.useState('success');

  // fields
  const [name, setName] = React.useState('');
  const [details, setDetails] = React.useState('');
  const [loc, setLoc] = React.useState('Dubai');
  const [contact, setContact] = React.useState('');
  const [waToggle, setWaToggle] = React.useState(true);
  const [area, setArea] = React.useState(['Dubai']);
  const [langs, setLangs] = React.useState(['English']);
  const [avail, setAvail] = React.useState('');
  const [services, setServices] = React.useState('');
  const [dur, setDur] = React.useState('week1');
  const [customDays, setCustomDays] = React.useState('');
  const [boost, setBoost] = React.useState('regular');
  const [photos, setPhotos] = React.useState([false, false, false, false]); // filled flags (slots droppable regardless)
  const [extraPhotos, setExtraPhotos] = React.useState(0); // additional photo slots beyond the cover

  // payment fields
  const [card, setCard] = React.useState('');const [exp, setExp] = React.useState('');const [cvv, setCvv] = React.useState('');const [cName, setCName] = React.useState('');

  const durObj = AD_DURATIONS.find((d) => d.id === dur);
  const listingFee = dur === 'custom' ? customFee(customDays) : durObj.fee;
  const boostFee = boost === 'boost' ? BOOST_FEE : 0;
  const total = listingFee + boostFee;

  const langOpts = ['English', 'العربية'];
  const formValid = name.trim() && details.trim() && contact.trim() && (dur !== 'custom' || Number(customDays) > 0);

  const fmtCard = (s) => s.replace(/\D/g, '').slice(0, 16).replace(/(.{4})/g, '$1 ').trim();
  const fmtExp = (s) => {const d = s.replace(/\D/g, '').slice(0, 4);return d.length > 2 ? d.slice(0, 2) + '/' + d.slice(2) : d;};
  const payValid = card.replace(/\s/g, '').length >= 16 && exp.length === 5 && cvv.length >= 3 && cName.length > 1;
  const pay = () => {setState('processing');setTimeout(() => setState(outcome === 'success' ? 'thankyou' : 'payfail'), 1700);};

  /* ---------- THANK YOU ---------- */
  if (state === 'thankyou') {
    return (
      <div style={{ height: '100%', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', padding: '30px 28px 40px', background: 'var(--bg)', textAlign: 'center', position: 'relative', overflow: 'hidden' }}>
        <img src={window.ASSET('floral')} alt="" aria-hidden="true" style={{ position: 'absolute', top: '50%', insetInlineEnd: -56, transform: rtl ? 'translateY(-50%) scaleX(-1)' : 'translateY(-50%)', width: 220, height: 'auto', opacity: .4, pointerEvents: 'none', zIndex: 0 }} />
        <div style={{ position: 'relative', zIndex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', width: '100%' }}>
        <div style={{ width: 104, height: 104, borderRadius: '50%', display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'var(--rose-100)', color: '#2E9E6B', animation: 'pop .5s' }}>
          <Icon name="check" size={52} stroke={2.6} />
        </div>
        <h1 className="h1" style={{ margin: '24px 0 10px' }}>{t('adThankYou')}</h1>
        <p className="sec" style={{ margin: 0, fontSize: 15, lineHeight: 1.55, maxWidth: 300 }}>{t('adThankSub')}</p>
        <div className="z-card" style={{ marginTop: 22, padding: '14px 18px', width: '100%', maxWidth: 320, display: 'flex', flexDirection: 'column', gap: 10 }}>
          <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
            <span className="sec" style={{ fontSize: 13.5 }}>{name || L(lang, 'Your ad', 'إعلانك')}</span>
            <span style={{ fontWeight: 700 }}>AED {total.toLocaleString()}</span>
          </div>
          <div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '9px 12px', borderRadius: 11, background: '#FBF3DC', color: '#8A6D1F' }}>
            <Icon name="spark" size={15} /><span style={{ fontSize: 12.5, fontWeight: 600 }}>{t('underReview')}</span>
          </div>
        </div>
        <div style={{ marginTop: 28, width: '100%', maxWidth: 320, display: 'flex', flexDirection: 'column', gap: 10 }}>
          <Btn variant="rose" icon="home" onClick={() => {setTab('home');}}>{L(lang, 'Back to home', 'العودة للرئيسية')}</Btn>
          <Btn variant="outline" onClick={() => {setTab('profile');}}>{t('backToProfile')}</Btn>
        </div>
        </div>
      </div>);

  }

  /* ---------- PAY FAIL ---------- */
  if (state === 'payfail') {
    return (
      <div style={{ height: '100%', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', padding: '30px 28px 40px', background: 'var(--bg)', textAlign: 'center' }}>
        <div style={{ width: 104, height: 104, borderRadius: '50%', display: 'flex', alignItems: 'center', justifyContent: 'center', background: '#FBEAE7', color: '#C0392B', animation: 'pop .5s' }}>
          <Icon name="x" size={52} stroke={2.6} />
        </div>
        <h1 className="h1" style={{ margin: '24px 0 10px' }}>{t('payFailed')}</h1>
        <p className="sec" style={{ margin: 0, fontSize: 15, lineHeight: 1.5, maxWidth: 280 }}>{t('payFailedSub')}</p>
        <div style={{ marginTop: 28, width: '100%', maxWidth: 320 }}><Btn variant="rose" onClick={() => setState('pay')}>{t('tryAgain')}</Btn></div>
      </div>);

  }

  /* ---------- PAYMENT ---------- */
  if (state === 'pay' || state === 'processing') {
    return (
      <div style={{ height: '100%', display: 'flex', flexDirection: 'column', background: 'var(--bg)' }}>
        <div style={{ padding: '6px 18px 8px' }}><ScreenHeader title={t('reviewPay')} onBack={() => setState('form')} /></div>
        <div className="z-scroll no-bar" style={{ flex: 1, padding: '8px 18px 20px' }}>
          {/* summary */}
          <div className="z-card" style={{ padding: 16, marginBottom: 20 }}>
            <p className="lbl" style={{ margin: '0 0 12px' }}>{t('adSummary')}</p>
            <Row k={`${t('listingFee')} · ${dur === 'custom' ? `${customDays || 0} ${L(lang, 'days', 'يوم')}` : L(lang, durObj.en, durObj.ar)}`} v={`AED ${listingFee.toLocaleString()}`} />
            {boostFee > 0 && <Row k={t('boostFee')} v={`AED ${boostFee.toLocaleString()}`} />}
            <div className="z-hr" style={{ margin: '12px 0' }} />
            <Row k={<b>{t('total')}</b>} v={<b style={{ fontSize: 17 }}>AED {total.toLocaleString()}</b>} />
            <p className="muted" style={{ fontSize: 11.5, margin: '8px 0 0' }}>{t('oneTime')}</p>
          </div>

          {/* card */}
          <div style={{ display: 'flex', flexDirection: 'column', gap: 13 }}>
            <Field label={t('cardNumber')}><input className="z-input" inputMode="numeric" value={card} onChange={(e) => setCard(fmtCard(e.target.value))} placeholder="1234 5678 9012 3456" style={{ direction: 'ltr' }} /></Field>
            <div style={{ display: 'flex', gap: 12 }}>
              <Field label={t('expiry')} flex><input className="z-input" inputMode="numeric" value={exp} onChange={(e) => setExp(fmtExp(e.target.value))} placeholder="MM/YY" style={{ direction: 'ltr' }} /></Field>
              <Field label={t('cvv')} flex><input className="z-input" inputMode="numeric" value={cvv} onChange={(e) => setCvv(e.target.value.replace(/\D/g, '').slice(0, 4))} placeholder="•••" style={{ direction: 'ltr' }} /></Field>
            </div>
            <Field label={t('nameOnCard')}><input className="z-input" value={cName} onChange={(e) => setCName(e.target.value)} placeholder={L(lang, 'Full name', 'الاسم الكامل')} /></Field>
          </div>

          <div style={{ marginTop: 18, padding: 12, borderRadius: 14, background: 'var(--rose-soft)', border: '1px dashed var(--rose-200)' }}>
            <p style={{ margin: '0 0 8px', fontSize: 12, fontWeight: 700, color: 'var(--rose-deep)', letterSpacing: '.04em' }}>{L(lang, 'DEMO · simulate outcome', 'تجربة · محاكاة النتيجة')}</p>
            <div style={{ display: 'flex', gap: 8 }}>
              <Chip on={outcome === 'success'} onClick={() => setOutcome('success')}>{L(lang, 'Success', 'نجاح')}</Chip>
              <Chip on={outcome === 'failed'} onClick={() => setOutcome('failed')}>{L(lang, 'Decline', 'رفض')}</Chip>
            </div>
          </div>
        </div>
        <div style={{ padding: '12px 18px 26px', borderTop: '1px solid var(--line)', background: '#fff' }}>
          <Btn variant="rose" disabled={!payValid || state === 'processing'} onClick={pay}>
            {state === 'processing' ? <span className="z-spin" /> : <><Icon name="shield" size={18} />{t('payNow')} AED {total.toLocaleString()}</>}
          </Btn>
        </div>
      </div>);

  }

  /* ---------- FORM ---------- */
  return (
    <div style={{ height: '100%', display: 'flex', flexDirection: 'column', background: 'var(--bg)' }}>
      <div style={{ padding: '6px 18px 6px' }}><ScreenHeader title={t('postAd')} onBack={pop} /></div>
      <div className="z-scroll no-bar" style={{ flex: 1, padding: '8px 18px 20px' }}>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
          <AdField label={t('adServiceName')}><input className="z-input" value={name} onChange={(e) => setName(e.target.value)} placeholder={L(lang, 'e.g. Handmade favors & dates kiosk', 'مثال: كشك هدايا وتمور يدوية')} /></AdField>

          <AdField label={t('adServiceDetails')}>
            <textarea value={details} onChange={(e) => setDetails(e.target.value)} placeholder={L(lang, 'Describe what you\u2019re offering…', 'صف ما تقدّمه…')} rows={4}
            className="z-input" style={{ height: 'auto', padding: '13px 16px', resize: 'none', lineHeight: 1.5 }} />
          </AdField>

          <AdField label={t('cityLabel')}>
            <div className="no-bar" style={{ display: 'flex', gap: 9, overflowX: 'auto', paddingBottom: 4 }}>
              {CITIES.map((c) => <Chip key={c} on={loc === c} onClick={() => setLoc(c)}>{c}</Chip>)}
            </div>
          </AdField>

          <div>
            <AdField label={L(lang, 'Phone number', 'رقم الهاتف')}><input className="z-input" inputMode="tel" value={contact} onChange={(e) => setContact(e.target.value)} placeholder="+971 50 123 4567" style={{ direction: 'ltr', textAlign: lang === 'ar' ? 'right' : 'left' }} /></AdField>
            <button onClick={() => setWaToggle((v) => !v)} style={{ display: 'flex', alignItems: 'center', gap: 11, background: 'none', border: 'none', cursor: 'pointer', textAlign: 'start', padding: 0, marginTop: 10, width: '100%' }}>
              <span style={{ width: 30, height: 30, borderRadius: 9, background: '#25D366', color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}><Icon name="whatsapp" size={17} style={{ color: '#ffffff' }} /></span>
              <span style={{ flex: 1, fontSize: 13.5, fontWeight: 500, color: 'var(--ink-2)' }}>{L(lang, 'Use this number as my WhatsApp', 'استخدم هذا الرقم كواتساب')}</span>
              <span style={{ width: 46, height: 27, borderRadius: 99, background: waToggle ? 'var(--rose)' : 'var(--line)', position: 'relative', transition: 'background .15s', flexShrink: 0 }}>
                <span style={{ position: 'absolute', top: 3, insetInlineStart: waToggle ? 22 : 3, width: 21, height: 21, borderRadius: '50%', background: '#fff', transition: 'inset-inline-start .15s', boxShadow: '0 1px 3px rgba(0,0,0,.2)' }} />
              </span>
            </button>
          </div>

          <AdField label={t('adServiceArea')} hint={L(lang, 'Select one or more areas you serve', 'اختر مناطق الخدمة')}>
            <div style={{ display: 'flex', flexWrap: 'wrap', gap: 9 }}>
              {CITIES.map((c) => <Chip key={c} on={area.includes(c)} icon={area.includes(c) ? 'check' : null} onClick={() => setArea((s) => s.includes(c) ? s.filter((x) => x !== c) : [...s, c])}>{c}</Chip>)}
            </div>
          </AdField>

          <AdField label={t('adServicesOffered')} hint={t('adServicesHint')}><input className="z-input" value={services} onChange={(e) => setServices(e.target.value)} placeholder={L(lang, 'Setup, Delivery, Styling', 'التركيب، التوصيل، التنسيق')} /></AdField>

          {/* duration */}
          <div>
            <p className="lbl" style={{ marginBottom: 4 }}>{t('adDuration')}</p>
            <p className="muted" style={{ fontSize: 11.5, margin: '0 0 10px' }}>{t('adDurationHint')}</p>
            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 10 }}>
              {AD_DURATIONS.map((d) => {
                const on = dur === d.id;
                return (
                  <button key={d.id} onClick={() => setDur(d.id)} style={{ textAlign: 'start', cursor: 'pointer', borderRadius: 14, padding: '13px 14px', background: '#fff', border: on ? '2px solid var(--ink)' : '1.5px solid var(--line)' }}>
                    <span style={{ display: 'block', fontWeight: 700, fontSize: 15 }}>{L(lang, d.en, d.ar)}</span>
                    <span style={{ display: 'block', fontSize: 12.5, color: on ? 'var(--rose-deep)' : 'var(--muted)', fontWeight: 600, marginTop: 3 }}>
                      {d.id === 'custom' ? t('customDuration') : `AED ${d.fee}`}
                    </span>
                  </button>);

              })}
            </div>
            {dur === 'custom' &&
            <div className="fade-up" style={{ marginTop: 10, display: 'flex', alignItems: 'center', gap: 10 }}>
                <input className="z-input" inputMode="numeric" value={customDays} onChange={(e) => setCustomDays(e.target.value.replace(/\D/g, '').slice(0, 3))} placeholder={t('customDuration')} style={{ flex: 1 }} />
                <span className="sec" style={{ fontSize: 13.5, whiteSpace: 'nowrap' }}>= AED {customFee(customDays).toLocaleString()} <span className="muted">({L(lang, 'AED 2/day', '٢ درهم/يوم')})</span></span>
              </div>
            }
          </div>

          {/* gallery upload */}
          <div>
            <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', marginBottom: 4 }}>
              <p className="lbl" style={{ margin: 0 }}>{t('adGallery')}</p>
              <span style={{ fontSize: 11.5, fontWeight: 600, color: 'var(--muted)' }}>{L(lang, 'up to 4', 'حتى ٤')}</span>
            </div>
            <p className="muted" style={{ fontSize: 11.5, margin: '0 0 12px' }}>{t('adGalleryHint')}</p>

            {/* primary large drop area */}
            <div style={{ position: 'relative', height: 150, borderRadius: 18, overflow: 'hidden', border: '2px dashed var(--rose-200)', background: 'var(--rose-soft)', marginBottom: 10 }}>
              <Img id="adphoto-0" radius={18} ph="" />
              <div style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 8, pointerEvents: 'none' }}>
                <span style={{ width: 48, height: 48, borderRadius: 14, background: '#fff', color: 'var(--rose-deep)', display: 'flex', alignItems: 'center', justifyContent: 'center', boxShadow: 'var(--sh-sm)' }}><Icon name="image" size={24} stroke={1.8} /></span>
                <span style={{ fontSize: 13.5, fontWeight: 600, color: 'var(--ink)' }}>{L(lang, 'Add a cover photo', 'أضف صورة الغلاف')}</span>
                <span style={{ fontSize: 11.5, color: 'var(--muted)' }}>{L(lang, 'Drag & drop or tap to upload', 'اسحب وأفلت أو اضغط للرفع')}</span>
              </div>
            </div>

            {/* secondary thumbnails — added via "Add more" */}
            {extraPhotos > 0 &&
            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 10 }}>
                {Array.from({ length: extraPhotos }).map((_, k) => {
                const i = k + 1;
                return (
                  <div key={i} style={{ position: 'relative', aspectRatio: '1', borderRadius: 14, overflow: 'hidden', border: '1.5px dashed var(--line)', background: '#fff' }}>
                      <Img id={`adphoto-${i}`} radius={14} ph="" />
                      <div style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 4, color: 'var(--muted)', pointerEvents: 'none' }}>
                        <Icon name="plus" size={20} stroke={2.2} />
                        <span style={{ fontSize: 10.5, fontWeight: 600 }}>{L(lang, 'Photo', 'صورة')} {i + 1}</span>
                      </div>
                    </div>);

              })}
              </div>
            }
          </div>

          {/* boost */}
          <div>
            <p className="lbl" style={{ marginBottom: 10 }}>{t('boostTitle')}</p>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
              <BoostOption on={boost === 'boost'} onClick={() => setBoost('boost')}
              icon="spark" title={t('boostNow')} desc={t('boostDesc')} price={`+ AED ${BOOST_FEE}`} gold />
              <BoostOption on={boost === 'regular'} onClick={() => setBoost('regular')}
              icon="list" title={t('regularPost')} desc={t('regularDesc')} price={L(lang, 'Included', 'مشمول')} />
            </div>
          </div>
        </div>
      </div>

      {/* pay now */}
      <div style={{ padding: '12px 18px 26px', borderTop: '1px solid var(--line)', background: '#fff' }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 10 }}>
          <span className="sec" style={{ fontSize: 13.5, fontWeight: 600 }}>{t('total')}</span>
          <span className="serif" style={{ fontSize: 20, fontWeight: 700 }}>AED {total.toLocaleString()}</span>
        </div>
        <div style={{ display: 'flex', gap: 10 }}>
          <button onClick={() => setExtraPhotos((n) => Math.min(n + 1, 5))} className="z-btn z-btn--outline" style={{ flex: '0 0 auto', width: 'auto', padding: '0 18px', gap: 7 }}>
            <Icon name="plus" size={18} stroke={2.2} />{L(lang, 'Add more', 'أضف المزيد')}
          </button>
          <Btn variant="rose" icon="card" disabled={!formValid} onClick={() => setState('pay')}>{L(lang, 'Pay now', 'ادفع الآن')}</Btn>
        </div>
      </div>
    </div>);

}

function Row({ k, v }) {
  return <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', fontSize: 14, color: 'var(--ink-2)', padding: '3px 0' }}><span>{k}</span><span style={{ color: 'var(--ink)' }}>{v}</span></div>;
}

function BoostOption({ on, onClick, icon, title, desc, price, gold }) {
  return (
    <button onClick={onClick} style={{ width: '100%', textAlign: 'start', cursor: 'pointer', display: 'flex', gap: 13, alignItems: 'flex-start', padding: 15, borderRadius: 16, background: on ? gold ? '#FBF3DC' : 'var(--rose-soft)' : '#fff', border: on ? `2px solid ${gold ? '#C8A24A' : 'var(--ink)'}` : '1.5px solid var(--line)' }}>
      <span style={{ width: 38, height: 38, borderRadius: 11, flexShrink: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', background: gold ? '#C8A24A' : 'var(--rose)', color: gold ? '#fff' : 'var(--ink)' }}><Icon name={icon} size={20} stroke={2} /></span>
      <div style={{ flex: 1, minWidth: 0 }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline', gap: 8 }}>
          <span style={{ fontWeight: 700, fontSize: 15 }}>{title}</span>
          <span style={{ fontWeight: 700, fontSize: 13, color: gold ? '#8A6D1F' : 'var(--rose-deep)', whiteSpace: 'nowrap' }}>{price}</span>
        </div>
        <p className="sec" style={{ margin: '4px 0 0', fontSize: 12.5, lineHeight: 1.45, textWrap: 'pretty' }}>{desc}</p>
      </div>
      <span style={{ width: 22, height: 22, borderRadius: '50%', flexShrink: 0, border: on ? 'none' : '2px solid var(--line)', background: on ? gold ? '#C8A24A' : 'var(--ink)' : 'transparent', display: 'flex', alignItems: 'center', justifyContent: 'center', marginTop: 2 }}>
        {on && <Icon name="check" size={14} stroke={3} style={{ color: '#fff' }} />}
      </span>
    </button>);

}

Object.assign(window, { PostAdInfo, PostAdForm, AD_DURATIONS });