/* global React, Icon, MLN */
const { useState: useStateInq, useEffect: useEffectInq } = React;

const PHONE_RE_INQ = /^0[2-9]\d[-\s]?\d{7}$|^05\d[-\s]?\d{7}$/;
const EMAIL_RE_INQ = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const ILS_INQ = (n) => '₪' + Number(n).toLocaleString('he-IL');

// Input character filters — strip "stupid" characters
const onlyPhoneChars = (v) => v.replace(/[^\d\-\s]/g, '');           // digits, dash, space
const onlyNameChars  = (v) => v.replace(/[^A-Za-z֐-׿\s'"׳״\-]/g, ''); // letters (heb/eng) + space
const onlyDigits     = (v) => v.replace(/[^\d]/g, '');               // house number

const ISRAELI_CITIES = [
  'אבו גוש','אבן יהודה','אופקים','אור יהודה','אור עקיבא','אילת','אלעד','אריאל',
  'אשדוד','אשקלון','באר שבע','בית שאן','בית שמש','ביתר עילית','בני ברק',
  'גבעת שמואל','גבעתיים','גדרה','הוד השרון','הרצלייה','חדרה','חולון','חיפה',
  'טבריה','טירה','טירת כרמל','טמרה','יבנה','יהוד-מונוסון','ירושלים',
  'כוכב יאיר','כפר יונה','כפר סבא','כפר קאסם','כרמיאל','לוד','מגדל העמק',
  'מודיעין-מכבים-רעות','מודיעין עילית','מעלה אדומים','מעלות-תרשיחא',
  'נהריה','נוף הגליל','נס ציונה','נצרת','נתיבות','נתניה','סח\'נין',
  'עכו','עפולה','ערד','פתח תקווה','צפת','קריית אונו','קריית אתא',
  'קריית ביאליק','קריית גת','קריית מוצקין','קריית מלאכי','קריית שמונה',
  'ראש העין','ראשון לציון','רהט','רחובות','רמלה','רמת גן','רמת השרון',
  'רעננה','שדרות','שפרעם','תל אביב-יפו','תל מונד','דימונה',
  'אום אל-פחם','גבעת זאב','דאלית אל-כרמל','מיתר','נשר','עומר',
  'פרדס חנה-כרכור','קצרין','רכסים','שוהם',
];

const InquiryModal = ({ data, onClose, onSubmit }) => {
  const emptyForm = {
    name: '', phone: '', email: '', message: '',
    organization: '', city: '', street: '', houseNumber: '',
    date1: '', date2: '', preferredTime: '', audienceType: '',
  };
  const [form, setForm] = useStateInq(emptyForm);
  const [topic, setTopic] = useStateInq('general');
  const [selectedProducts, setSelectedProducts] = useStateInq({}); // { id: qty }
  const [errors, setErrors] = useStateInq({});
  const [sent, setSent] = useStateInq(false);
  const [saving, setSaving] = useStateInq(false);
  const [record, setRecord] = useStateInq(null);

  useEffectInq(() => {
    if (data) {
      setTopic(data.topic || 'general');
      setForm({ ...emptyForm, message: data.message || '' });
      // Pre-select the product the user clicked, qty 1
      const initSel = (data.productId) ? { [data.productId]: 1 } : {};
      setSelectedProducts(initSel);
      setErrors({}); setSent(false); setRecord(null);
    }
  }, [data]);

  if (!data) return null;
  const t = MLN.TOPICS[topic] || MLN.TOPICS.general;
  const isLecture = topic === 'lecture';
  const isProduct = topic === 'product';

  // Available products for the checkbox list (passed from StoreSection)
  // מוצרים פעילים — ניתן לבחירה
  const activeProducts = (data.products || []).filter(
    p => p.active && !p.comingSoon && (!p.status || p.status === 'active')
  );
  // מוצרי בקרוב — מוצגים אך לא ניתן לבחירה
  const comingSoonProducts = (data.products || []).filter(
    p => p.active && (p.comingSoon || p.status === 'coming-soon')
  );
  // כולם ביחד לתצוגה
  const allDisplayProducts = [...activeProducts, ...comingSoonProducts];

  const toggleProduct = (id) => {
    setSelectedProducts(prev => {
      const next = { ...prev };
      if (next[id]) delete next[id];
      else next[id] = 1;
      return next;
    });
    setErrors(ev => ({ ...ev, products: '' }));
  };
  const setQty = (id, qty) => {
    const q = Math.max(1, parseInt(qty, 10) || 1);
    setSelectedProducts(prev => ({ ...prev, [id]: q }));
  };

  // ---- validation ----
  const validate = () => {
    const errs = {};
    if (!form.name.trim() || form.name.trim().length < 2)
      errs.name = 'נא להזין שם מלא';
    if (!PHONE_RE_INQ.test(form.phone.trim().replace(/\s/g, '')))
      errs.phone = 'מספר טלפון לא תקין (לדוגמה: 054-1234567)';
    if (form.email && !EMAIL_RE_INQ.test(form.email.trim()))
      errs.email = 'כתובת מייל לא תקינה';

    if (isLecture) {
      if (!form.city.trim()) errs.city = 'נא לציין עיר';
      if (!form.street.trim()) errs.street = 'נא להזין רחוב';
      if (!form.houseNumber.trim()) errs.houseNumber = 'מספר בית';
      if (!form.date1) errs.date1 = 'נא לבחור תאריך';
      else {
        const d = new Date(form.date1); const today = new Date(); today.setHours(0, 0, 0, 0);
        if (d < today) errs.date1 = 'התאריך חייב להיות בעתיד';
      }
    } else if (isProduct) {
      const selectedActive = Object.keys(selectedProducts).filter(id => activeProducts.find(p => p.id === id));
      if (selectedActive.length === 0)
        errs.products = 'יש לבחור לפחות מוצר אחד';
    } else {
      if (!form.message.trim()) errs.message = 'נא לכתוב הודעה';
    }
    return errs;
  };

  const buildProductSummary = () => {
    return Object.entries(selectedProducts).map(([id, qty]) => {
      const p = activeProducts.find(x => x.id === id);
      return p ? `${p.name} × ${qty} (${ILS_INQ(p.price)})` : '';
    }).filter(Boolean).join('\n');
  };

  const submit = async (e) => {
    e.preventDefault();
    const errs = validate();
    if (Object.keys(errs).length > 0) { setErrors(errs); return; }

    setSaving(true);
    const address = isLecture ? `${form.street} ${form.houseNumber}` : '';
    const productSummary = isProduct ? buildProductSummary() : '';

    const rec = {
      id: MLN.id(), topic, product: data.product || (isProduct ? productSummary.split('\n')[0] : null),
      name: form.name, phone: form.phone, email: form.email,
      message: isLecture
        ? `עיר: ${form.city}\nכתובת: ${address}\nתאריך: ${form.date1}${form.date2 ? ' / ' + form.date2 : ''}${form.preferredTime ? '\nשעה: ' + form.preferredTime : ''}${form.audienceType ? '\nקהל: ' + form.audienceType : ''}${form.message ? '\n\nהערות: ' + form.message : ''}`
        : isProduct
          ? `מוצרים שנבחרו:\n${productSummary}${form.message ? '\n\nהערות: ' + form.message : ''}`
          : form.message,
      organization: form.organization, city: form.city, address,
      date1: form.date1, date2: form.date2,
      preferredTime: form.preferredTime, audienceType: form.audienceType,
      date: new Date().toISOString(), read: false,
    };

    try {
      if (isLecture && typeof saveLectureRequest === 'function') {
        await saveLectureRequest({
          name: form.name, organization: form.organization,
          phone: form.phone, email: form.email,
          city: form.city, address,
          date1: form.date1, date2: form.date2 || null,
          preferredTime: form.preferredTime || null,
          audienceType: form.audienceType || null,
          notes: form.message || null,
        });
      } else if (typeof saveContactMessage === 'function') {
        await saveContactMessage({
          name: form.name, email: form.email, phone: form.phone,
          subject: t.label + (data.product ? ' — ' + data.product : ''),
          message: rec.message,
        });
      }
    } catch (err) {
      setSaving(false);
      setErrors({ form: err.message || 'אירעה שגיאה, נסה שוב' });
      return;
    }

    onSubmit(rec);
    setRecord(rec);
    setSaving(false);
    setSent(true);
  };

  // Generic text field helper (with optional char-filter)
  const field = (label, key, type, ph, required, filterFn) => (
    <label style={{ display: 'block' }}>
      <span style={lbl}>{label}{required && <span style={star}>*</span>}</span>
      <input type={type || 'text'} value={form[key]} placeholder={ph}
        inputMode={key === 'phone' || key === 'houseNumber' ? 'numeric' : undefined}
        onChange={e => {
          const v = filterFn ? filterFn(e.target.value) : e.target.value;
          setForm(fm => ({ ...fm, [key]: v }));
          setErrors(ev => ({ ...ev, [key]: '' }));
        }}
        style={{ ...inqInputStyle, borderColor: errors[key] ? 'var(--brand)' : 'var(--border)' }} />
      {errors[key] && <span style={errStyle}>{errors[key]}</span>}
    </label>
  );

  const wide = isLecture || isProduct;

  return (
    <div onClick={onClose} role="dialog" aria-modal="true" aria-label={data.title || t.label} style={{
      position: 'fixed', inset: 0, zIndex: 200, display: 'flex', alignItems: 'flex-start',
      justifyContent: 'center', padding: 'clamp(10px, 2vw, 20px)', paddingTop: 'clamp(10px, 3vh, 30px)',
      background: 'rgba(36,8,14,0.55)',
      backdropFilter: 'blur(6px)', WebkitBackdropFilter: 'blur(6px)',
      animation: 'mlnFade 240ms var(--ease-out)',
      overflowY: 'auto',
    }}>
      <div onClick={e => e.stopPropagation()} style={{
        width: wide ? 'min(680px, 100%)' : 'min(540px, 100%)',
        background: 'var(--paper)', borderRadius: 'var(--radius-xl)',
        boxShadow: '0 40px 100px rgba(74,14,24,0.4)', padding: 'clamp(18px, 4vw, 38px)',
        paddingTop: 'clamp(52px, 6vw, 52px)',
        animation: 'mlnPop 320ms var(--ease-out)', position: 'relative',
        marginBottom: 10,
      }}>
        <button onClick={onClose} aria-label="סגירה" style={inqCloseStyle}><Icon name="x" size={20} /></button>

        {!sent ? (
          <React.Fragment>
            <div style={{ display: 'inline-flex', alignItems: 'center', gap: 8, background: 'var(--surface-tint)', color: t.color, padding: '5px 13px', borderRadius: 'var(--radius-pill)', fontFamily: 'var(--font-body)', fontWeight: 700, fontSize: 13, marginBottom: 14 }}>
              <Icon name={data.icon || 'mail'} size={14} /> {data.title || t.label}
            </div>
            <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 'clamp(1.4rem, 3vw, 1.9rem)', margin: '0 0 6px', color: 'var(--ink-900)' }}>{data.heading || 'נשמח לשמוע ממך'}</h3>
            <p style={{ fontFamily: 'var(--font-body)', fontSize: 14.5, lineHeight: 1.65, color: 'var(--ink-500)', margin: '0 0 20px' }}>{data.sub || 'השאר/י פרטים ואחזור אליך בהקדם.'}</p>

            <form onSubmit={submit} noValidate style={{ display: 'flex', flexDirection: 'column', gap: 13 }}>
              {!data.lockTopic && (
                <label style={{ display: 'block' }}>
                  <span style={lbl}>נושא הפנייה</span>
                  <select value={topic} onChange={e => setTopic(e.target.value)} style={inqInputStyle}>
                    {Object.values(MLN.TOPICS).map(tp => <option key={tp.id} value={tp.id}>{tp.label}</option>)}
                  </select>
                </label>
              )}

              {/* base fields */}
              {field('שם מלא', 'name', 'text', 'איך לפנות אליך?', true, onlyNameChars)}
              <div className="mln-inq-phoneemail" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 13 }}>
                {field('טלפון', 'phone', 'tel', '054-1234567', true, onlyPhoneChars)}
                <label style={{ display: 'block' }}>
                  <span style={lbl}>מייל</span>
                  <input type="email" value={form.email} placeholder="name@email.com"
                    onChange={e => { setForm(fm => ({ ...fm, email: e.target.value })); setErrors(ev => ({ ...ev, email: '' })); }}
                    style={{ ...inqInputStyle, borderColor: errors.email ? 'var(--brand)' : 'var(--border)' }} />
                  {errors.email && <span style={errStyle}>{errors.email}</span>}
                </label>
              </div>

              {/* PRODUCT — checkbox selection */}
              {isProduct && (
                <div>
                  <span style={lbl}>בחר/י מוצרים<span style={star}>*</span></span>
                  <div style={{ display: 'flex', flexDirection: 'column', gap: 8, border: errors.products ? '1.5px solid var(--brand)' : '1.5px solid var(--border)', borderRadius: 'var(--radius-md)', padding: 12, background: 'var(--white)' }}>
                    {allDisplayProducts.length === 0 ? (
                      <span style={{ fontFamily: 'var(--font-body)', fontSize: 14, color: 'var(--ink-400)' }}>אין מוצרים זמינים כרגע.</span>
                    ) : allDisplayProducts.map(p => {
                      const isSoon = p.comingSoon || p.status === 'coming-soon';
                      const checked = !!selectedProducts[p.id];
                      return (
                        <div key={p.id} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 4px', borderRadius: 'var(--radius-sm)', background: checked ? 'var(--surface-tint)' : 'transparent', opacity: isSoon ? 0.45 : 1, cursor: isSoon ? 'not-allowed' : 'default' }}>
                          {isSoon ? (
                            <span style={{ display: 'inline-block', fontSize: 11, fontFamily: 'var(--font-body)', fontWeight: 700, color: 'var(--brand)', background: 'var(--red-50)', border: '1px solid var(--red-200)', borderRadius: 'var(--radius-pill)', padding: '2px 8px', whiteSpace: 'nowrap' }}>בקרוב</span>
                          ) : (
                            <input type="checkbox" checked={checked} onChange={() => toggleProduct(p.id)} style={{ cursor: 'pointer' }} />
                          )}
                          <label style={{ display: 'flex', alignItems: 'center', gap: 10, cursor: isSoon ? 'not-allowed' : 'pointer', flex: 1, pointerEvents: isSoon ? 'none' : 'auto' }}>
                            <span style={{ fontFamily: 'var(--font-body)', fontWeight: 600, fontSize: 14.5, color: 'var(--ink-900)' }}>אני מעוניינ/ת לרכוש {p.name}</span>
                            {!isSoon && <span style={{ fontFamily: 'var(--font-body)', fontSize: 13.5, color: 'var(--brand)', fontWeight: 700 }}>{ILS_INQ(p.price)}</span>}
                          </label>
                          {checked && !isSoon && (
                            <label style={{ display: 'flex', alignItems: 'center', gap: 5, fontFamily: 'var(--font-body)', fontSize: 12.5, color: 'var(--ink-500)' }}>
                              כמות
                              <input type="number" min="1" value={selectedProducts[p.id]} onChange={e => setQty(p.id, e.target.value)}
                                style={{ width: 56, ...inqInputStyle, padding: '6px 8px', textAlign: 'center' }} />
                            </label>
                          )}
                        </div>
                      );
                    })}
                  </div>
                  {errors.products && <span style={errStyle}>{errors.products}</span>}
                </div>
              )}

              {/* LECTURE fields */}
              {isLecture && (
                <React.Fragment>
                  {field('שם הארגון / המוסד', 'organization', 'text', 'לדוגמה: עיריית חיפה, בית ספר...', false, onlyNameChars)}
                  <div className="mln-inq-address-grid" style={{ display: 'grid', gridTemplateColumns: '1.4fr 1fr 0.7fr', gap: 13 }}>
                    <label style={{ display: 'block' }}>
                      <span style={lbl}>עיר / יישוב<span style={star}>*</span></span>
                      <input type="text" list="inq-city-list" value={form.city} placeholder="הקלד עיר..."
                        onChange={e => { setForm(fm => ({ ...fm, city: onlyNameChars(e.target.value) })); setErrors(ev => ({ ...ev, city: '' })); }}
                        style={{ ...inqInputStyle, borderColor: errors.city ? 'var(--brand)' : 'var(--border)' }} />
                      <datalist id="inq-city-list">
                        {ISRAELI_CITIES.map(c => <option key={c} value={c} />)}
                      </datalist>
                      {errors.city && <span style={errStyle}>{errors.city}</span>}
                    </label>
                    <label style={{ display: 'block' }}>
                      <span style={lbl}>רחוב<span style={star}>*</span></span>
                      <input type="text" value={form.street} placeholder="שם הרחוב"
                        onChange={e => { setForm(fm => ({ ...fm, street: onlyNameChars(e.target.value) })); setErrors(ev => ({ ...ev, street: '' })); }}
                        style={{ ...inqInputStyle, borderColor: errors.street ? 'var(--brand)' : 'var(--border)' }} />
                      {errors.street && <span style={errStyle}>{errors.street}</span>}
                    </label>
                    <label style={{ display: 'block' }}>
                      <span style={lbl}>מס׳ בית<span style={star}>*</span></span>
                      <input type="text" inputMode="numeric" value={form.houseNumber} placeholder="12"
                        onChange={e => { setForm(fm => ({ ...fm, houseNumber: onlyDigits(e.target.value) })); setErrors(ev => ({ ...ev, houseNumber: '' })); }}
                        style={{ ...inqInputStyle, borderColor: errors.houseNumber ? 'var(--brand)' : 'var(--border)' }} />
                      {errors.houseNumber && <span style={errStyle}>{errors.houseNumber}</span>}
                    </label>
                  </div>
                  <div className="mln-inq-datetime" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 13 }}>
                    <label style={{ display: 'block' }}>
                      <span style={lbl}>תאריך מועדף<span style={star}>*</span></span>
                      <input type="date" value={form.date1}
                        onChange={e => { setForm(fm => ({ ...fm, date1: e.target.value })); setErrors(ev => ({ ...ev, date1: '' })); }}
                        style={{ ...inqInputStyle, borderColor: errors.date1 ? 'var(--brand)' : 'var(--border)' }} />
                      {errors.date1 && <span style={errStyle}>{errors.date1}</span>}
                    </label>
                    <label style={{ display: 'block' }}>
                      <span style={lbl}>תאריך חלופי</span>
                      <input type="date" value={form.date2} onChange={e => setForm(fm => ({ ...fm, date2: e.target.value }))} style={inqInputStyle} />
                    </label>
                  </div>
                  <div className="mln-inq-datetime" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 13 }}>
                    <label style={{ display: 'block' }}>
                      <span style={lbl}>שעה מועדפת (24 שעות)</span>
                      <input type="time" step="60" lang="he-IL" value={form.preferredTime}
                        onChange={e => setForm(fm => ({ ...fm, preferredTime: e.target.value }))} style={inqInputStyle} />
                    </label>
                    <label style={{ display: 'block' }}>
                      <span style={lbl}>סוג קהל</span>
                      <select value={form.audienceType} onChange={e => setForm(fm => ({ ...fm, audienceType: e.target.value }))} style={inqInputStyle}>
                        <option value="">בחר...</option>
                        <option value="נשים">נשים</option>
                        <option value="גברים">גברים</option>
                        <option value="מעורב">מעורב</option>
                        <option value="בית ספר">בית ספר</option>
                        <option value="צבא">צבא</option>
                        <option value="ארגון / מוסד">ארגון / מוסד</option>
                        <option value="מרכז טיפולי">מרכז טיפולי</option>
                        <option value="התפתחות אישית">התפתחות אישית</option>
                        <option value="אחר">אחר</option>
                      </select>
                    </label>
                  </div>
                  <label style={{ display: 'block' }}>
                    <span style={lbl}>הערות נוספות</span>
                    <textarea value={form.message} rows={3} placeholder="גודל קהל, אופי האירוע, כל מה שחשוב שאדע..."
                      onChange={e => setForm(fm => ({ ...fm, message: e.target.value }))}
                      style={{ ...inqInputStyle, resize: 'vertical', minHeight: 80 }} />
                  </label>
                </React.Fragment>
              )}

              {/* PRODUCT extra notes */}
              {isProduct && (
                <label style={{ display: 'block' }}>
                  <span style={lbl}>הערות</span>
                  <textarea value={form.message} rows={2} placeholder="כתובת למשלוח, בקשות מיוחדות..."
                    onChange={e => setForm(fm => ({ ...fm, message: e.target.value }))}
                    style={{ ...inqInputStyle, resize: 'vertical', minHeight: 64 }} />
                </label>
              )}

              {/* GENERAL message */}
              {!isLecture && !isProduct && (
                <label style={{ display: 'block' }}>
                  <span style={lbl}>פרטי הבקשה<span style={star}>*</span></span>
                  <textarea value={form.message} rows={4} placeholder="ספר/י לי קצת..."
                    onChange={e => { setForm(fm => ({ ...fm, message: e.target.value })); setErrors(ev => ({ ...ev, message: '' })); }}
                    style={{ ...inqInputStyle, resize: 'vertical', minHeight: 96, borderColor: errors.message ? 'var(--brand)' : 'var(--border)' }} />
                  {errors.message && <span style={errStyle}>{errors.message}</span>}
                </label>
              )}

              {errors.form && <span style={{ ...errStyle, fontSize: 14, display: 'block', textAlign: 'center', marginBottom: 4 }}>{errors.form}</span>}
              <button type="submit" disabled={saving} className="mln-btn-primary" style={{ ...inqSubmitStyle, opacity: saving ? 0.7 : 1 }}>
                {saving ? 'שולח...' : isLecture ? 'שליחת בקשה להרצאה' : isProduct ? 'שליחת ההזמנה' : 'שליחת הפנייה'}
                {!saving && <Icon name="arrow" size={18} />}
              </button>
            </form>
          </React.Fragment>
        ) : (
          <div style={{ textAlign: 'center', padding: '20px 8px 8px' }}>
            <div style={{
              width: 80, height: 80, margin: '0 auto 22px', borderRadius: '50%',
              background: 'linear-gradient(135deg, var(--red-100), var(--red-50))',
              border: '2px solid var(--red-200)',
              display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'var(--brand)',
            }}>
              <Icon name="heart" size={38} />
            </div>
            <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 900, fontSize: 'clamp(1.7rem, 3vw, 2.2rem)', margin: '0 0 14px', color: 'var(--ink-900)' }}>
              {isLecture ? 'תודה על בקשת ההרצאה!' : isProduct ? 'תודה על ההזמנה!' : 'תודה על הפנייה!'}
            </h3>
            <p style={{ fontFamily: 'var(--font-body)', fontSize: 16.5, lineHeight: 1.75, color: 'var(--ink-500)', maxWidth: '38ch', margin: '0 auto 10px' }}>
              {isLecture ? 'קיבלתי את הפרטים ואחזור אליך בהקדם עם הצעת מחיר מותאמת.'
                : isProduct ? 'קיבלתי את ההזמנה ואחזור אליך בהקדם לתיאום ותשלום.'
                : 'קיבלתי את הפנייה ואחזור אליך בהקדם.'}
            </p>
            <p style={{ fontFamily: 'var(--font-poem)', fontSize: 15, color: 'var(--ink-300)', margin: '0 auto 32px', fontStyle: 'italic' }}>
              כל פנייה מגיעה אליי ישירות ❤️
            </p>
            <button onClick={onClose} style={{
              background: 'var(--brand)', color: '#fff', border: 'none', cursor: 'pointer',
              fontFamily: 'var(--font-body)', fontWeight: 700, fontSize: 16.5,
              padding: '14px 44px', borderRadius: 'var(--radius-pill)', boxShadow: 'var(--shadow-red)',
              transition: 'all 200ms var(--ease-soft)',
            }}
              onMouseEnter={e => e.currentTarget.style.background = 'var(--red-700)'}
              onMouseLeave={e => e.currentTarget.style.background = 'var(--brand)'}
            >סגירה</button>
          </div>
        )}
      </div>
    </div>
  );
};

const lbl = { display: 'block', fontFamily: 'var(--font-body)', fontWeight: 600, fontSize: 13.5, color: 'var(--ink-700)', marginBottom: 5 };
const star = { color: 'var(--brand)', marginRight: 2 };
const errStyle = { color: 'var(--brand)', fontSize: 12.5, marginTop: 4, display: 'block' };
const inqInputStyle = {
  width: '100%', boxSizing: 'border-box', fontFamily: 'var(--font-body)', fontSize: 15,
  padding: '11px 13px', borderRadius: 'var(--radius-md)', color: 'var(--ink-900)',
  background: 'var(--white)', border: '1.5px solid var(--border)', outline: 'none', direction: 'rtl',
};
const inqSubmitStyle = {
  marginTop: 4, background: 'var(--brand)', color: '#fff', border: 'none', cursor: 'pointer',
  fontFamily: 'var(--font-body)', fontWeight: 700, fontSize: 16, padding: '14px',
  borderRadius: 'var(--radius-pill)', display: 'inline-flex', alignItems: 'center',
  justifyContent: 'center', gap: 9, boxShadow: 'var(--shadow-red)', width: '100%',
};
const inqCloseStyle = {
  position: 'absolute', top: 14, insetInlineStart: 14, width: 40, height: 40, borderRadius: '50%',
  border: '1px solid var(--border)', background: 'var(--white)', color: 'var(--ink-500)',
  cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center',
  flexShrink: 0,
};
window.InquiryModal = InquiryModal;
