// filterSortHelp.jsx — Filter Sort dedicated help page for new users

const FilterSortHelp = ({ lang, onNavigate }) => {
  const mobile = window.useIsMobile(768);
  const it = lang === 'it';
  const base = (window.__DOC_DIR || '') + '../../assets/';
  const imgs = [base + 'filtersort-1.jpg', base + 'filtersort-2.jpg'];
  const imgCaptions = [
    it ? 'Filter Sort — interfaccia a tre pannelli con griglia filtri e override inline' : 'Filter Sort — three-panel interface with filter grid and inline overrides',
    it ? 'Editor regole inline con gruppi logici AND/OR' : 'Inline rule editor with AND/OR logic groups',
  ];
  const [activeImg, setActiveImg] = React.useState(0);
  const [lightboxOpen, setLightboxOpen] = React.useState(false);
  const [lbVisible, setLbVisible] = React.useState(false);

  React.useEffect(() => {
    if (!lightboxOpen) return;
    const onKey = (e) => { if (e.key === 'Escape') closeLightbox(); };
    window.addEventListener('keydown', onKey);
    const prev = document.body.style.overflow;
    document.body.style.overflow = 'hidden';
    return () => { window.removeEventListener('keydown', onKey); document.body.style.overflow = prev; };
  }, [lightboxOpen]);
  React.useEffect(() => {
    if (lightboxOpen) { const id = requestAnimationFrame(() => setLbVisible(true)); return () => cancelAnimationFrame(id); }
  }, [lightboxOpen]);
  const closeLightbox = () => { setLbVisible(false); setTimeout(() => setLightboxOpen(false), 200); };

  const pad = mobile ? '48px 20px' : '72px 32px';
  const maxW = 1080;
  const eyebrow = { fontFamily: 'var(--font-mono)', fontSize: 11, color: 'var(--brand)', letterSpacing: '0.08em', textTransform: 'uppercase', marginBottom: 16 };
  const h2s = { fontFamily: 'var(--font-sans)', fontSize: mobile ? 22 : 28, fontWeight: 600, color: 'var(--fg-1)', letterSpacing: '-0.02em', lineHeight: 1.25, marginBottom: 16 };
  const body = { fontFamily: 'var(--font-sans)', fontSize: mobile ? 15 : 16, color: 'var(--fg-3)', lineHeight: 1.65 };
  const dot = { width: 5, height: 5, borderRadius: '50%', background: 'var(--brand)', flexShrink: 0, marginTop: 8 };

  /* ── Feature groups ── */
  const featureGroups = [
    {
      title: it ? 'Editing visuale in griglia' : 'Visual inline editing',
      icon: (
        <svg width="20" height="20" viewBox="0 0 20 20" fill="none"><rect x="2" y="2" width="7" height="7" rx="1.5" stroke="var(--brand)" strokeWidth="1.4"/><rect x="11" y="2" width="7" height="7" rx="1.5" stroke="var(--brand)" strokeWidth="1.4"/><rect x="2" y="11" width="7" height="7" rx="1.5" stroke="var(--brand)" strokeWidth="1.4"/><rect x="11" y="11" width="7" height="7" rx="1.5" stroke="var(--brand)" strokeWidth="1.4"/></svg>
      ),
      items: [
        it ? 'Campioni colore, anteprime pattern e pesi linea modificabili direttamente nella griglia' : 'Color swatches, pattern previews, and line weight dropdowns — all editable inline in the grid',
        it ? 'Anteprime pattern di riempimento con rendering FillGrid accurato' : 'Fill pattern previews with accurate FillGrid-based rendering matching Revit\'s native swatches',
        it ? 'Anteprime pattern di linea con tratteggio e spessore a scala corretta' : 'Line pattern previews — dash/dot patterns rendered at correct scale with line weight',
        it ? 'Contagocce colore con anteprima ingrandita in tempo reale' : 'Screen color eyedropper — pick any color from anywhere on screen with a live magnified preview',
      ],
    },
    {
      title: it ? 'Gestione filtri' : 'Filter management',
      icon: (
        <svg width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M3 4h14M3 4l5 5v6l2 1V9l5-5" stroke="var(--brand)" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/></svg>
      ),
      items: [
        it ? 'Drag-and-drop per riordinare i filtri e impostare la priorità di disegno' : 'Drag-and-drop reorder filters to set draw priority',
        it ? 'Crea, duplica, rinomina ed elimina filtri senza uscire dallo strumento' : 'Create, duplicate, rename, and delete filters without leaving the tool',
        it ? 'Duplica e rinomina view template direttamente dall\'interfaccia' : 'Duplicate and rename view templates directly from the interface',
        it ? 'Supporto filtri di selezione — le selezioni salvate appaiono accanto ai filtri parametrici' : 'Selection filter support — saved element selections appear alongside parameter filters',
      ],
    },
    {
      title: it ? 'Operazioni in blocco' : 'Bulk operations',
      icon: (
        <svg width="20" height="20" viewBox="0 0 20 20" fill="none"><rect x="3" y="3" width="8" height="8" rx="1.5" stroke="var(--brand)" strokeWidth="1.4"/><rect x="9" y="9" width="8" height="8" rx="1.5" stroke="var(--brand)" strokeWidth="1.4"/></svg>
      ),
      items: [
        it ? 'Multi-selezione: modifica un override e si applica a tutti i filtri selezionati' : 'Multi-select editing — select multiple filters, change one override, it applies to all selected',
        it ? 'Copia e incolla override tra filtri (singolo o incolla-su-tutti)' : 'Copy/paste overrides between filters — single or paste-to-all',
        it ? 'Applica a un singolo template o batch Apply All su tutti i template modificati' : 'Apply to a single template or batch Apply All modified templates at once',
      ],
    },
    {
      title: it ? 'Regole e categorie' : 'Rules & categories',
      icon: (
        <svg width="20" height="20" viewBox="0 0 20 20" fill="none"><circle cx="10" cy="10" r="7" stroke="var(--brand)" strokeWidth="1.4"/><path d="M7 10h6M10 7v6" stroke="var(--brand)" strokeWidth="1.4" strokeLinecap="round"/></svg>
      ),
      items: [
        it ? 'Editor regole inline in popup: aggiungi/rimuovi regole, cambia parametri, valutatori e valori' : 'Inline rule editor — edit filter rules in a popup: add/remove rules, change parameters, evaluators, values',
        it ? 'Supporto gruppi logici AND/OR per condizioni complesse' : 'Supports AND/OR logic groups for complex filter conditions',
        it ? 'Editor categorie con ricerca e toggle "nascondi deselezionate"' : 'Category editor — check/uncheck which Revit categories the filter applies to, with search and "hide unchecked" toggle',
      ],
    },
    {
      title: it ? 'Workflow e tracciamento' : 'Workflow & tracking',
      icon: (
        <svg width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M4 10a6 6 0 1012 0 6 6 0 10-12 0" stroke="var(--brand)" strokeWidth="1.4"/><path d="M10 6v4l2.5 2.5" stroke="var(--brand)" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/></svg>
      ),
      items: [
        it ? '50 livelli di undo/redo con cronologia a tendina per template' : '50-step undo/redo with dropdown history per template',
        it ? 'Badge ambra O/R/C sui template con modifiche non salvate (Override, Rules, Categories)' : 'Unsaved changes tracking — amber O/R/C badges on templates showing what\'s modified (Overrides, Rules, Categories)',
        it ? 'Prompt alla chiusura con riepilogo modifiche non salvate raggruppate per template' : 'Close prompt lists all unsaved work grouped by template',
        it ? 'Preferiti: stella per filtri e template, vista "solo preferiti" persistente tra sessioni' : 'Favourites — star frequently-used filters and templates, toggle "favourites only" view. Persists across sessions',
      ],
    },
    {
      title: it ? 'Sincronizzazione e persistenza' : 'Sync & persistence',
      icon: (
        <svg width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M14.5 5.5a5.5 5.5 0 10-1 8.5" stroke="var(--brand)" strokeWidth="1.4" strokeLinecap="round"/><path d="M14 3v3h3" stroke="var(--brand)" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/></svg>
      ),
      items: [
        it ? 'Sincronizzazione in tempo reale con Revit: filtri creati, eliminati o rinominati si aggiornano automaticamente' : 'Real-time sync with Revit — filters created, deleted, or renamed while the window is open update automatically',
        it ? 'Ricerca su template, filtri, filtri disponibili e categorie' : 'Search on templates, filters, available filters, and categories',
        it ? 'Posizione, dimensione finestra e larghezze colonne persistenti tra sessioni' : 'Window position/size and column width persistence across sessions',
      ],
    },
  ];

  const shortcuts = [
    { keys: 'Ctrl + Z', action: it ? 'Annulla' : 'Undo' },
    { keys: 'Ctrl + Y', action: it ? 'Ripristina' : 'Redo' },
    { keys: 'Ctrl + C', action: it ? 'Copia override' : 'Copy overrides' },
    { keys: 'Ctrl + V', action: it ? 'Incolla override' : 'Paste overrides' },
    { keys: 'Delete', action: it ? 'Rimuovi filtro selezionato' : 'Remove selected filter' },
  ];

  /* ── Layout panel data ── */
  const panels = [
    {
      label: it ? 'Pannello sinistro' : 'Left panel',
      title: it ? 'View Template' : 'View Templates',
      items: it
        ? ['Ricerca per nome', 'Preferiti con stella', 'Ordinamento A-Z o per disciplina', 'Filtro per disciplina e tipo vista']
        : ['Search by name', 'Favourites with star toggle', 'Sort A-Z or by discipline', 'Filter by discipline and view type'],
    },
    {
      label: it ? 'Pannello centrale' : 'Center panel',
      title: it ? 'Griglia filtri' : 'Filter grid',
      items: it
        ? ['Tutti i filtri del template selezionato', 'Colonne override inline (visibilità, halftone, trasparenza, colori, pesi, pattern)', 'Area di lavoro a schede: Overrides, Properties, Rules, Categories']
        : ['All filters applied to the selected template', 'Inline override columns (visibility, halftone, transparency, colors, weights, patterns)', 'Tabbed workspace: Overrides, Properties, Rules, Categories'],
    },
    {
      label: it ? 'Pannello destro' : 'Right panel',
      title: it ? 'Filtri disponibili' : 'Available filters',
      items: it
        ? ['Tutti i filtri nel progetto', 'Checkbox per aggiungere al template corrente', 'Ricerca e filtro per tipo']
        : ['All filters in the project', 'Checkboxes to add to the current template', 'Search and filter by type'],
    },
  ];

  const kbdStyle = {
    display: 'inline-block', fontFamily: 'var(--font-mono)', fontSize: 12, fontWeight: 500,
    color: 'var(--fg-2)', background: 'var(--bg-section)', border: '1px solid var(--border)',
    borderRadius: 'var(--radius-sm)', padding: '3px 8px', lineHeight: 1.4,
    boxShadow: '0 1px 0 var(--neutral-200)',
  };

  return (
    <div>
      {/* ── HERO ── */}
      <section style={{ background: 'var(--bg-page)', borderBottom: '1px solid var(--border)', padding: mobile ? '48px 20px 40px' : '72px 32px 56px' }}>
        <div style={{ maxWidth: maxW, margin: '0 auto' }}>
          {/* Back link */}
          <a href="/" onClick={e => { e.preventDefault(); onNavigate('home'); }}
            style={{ ...eyebrow, display: 'inline-flex', alignItems: 'center', gap: 6, textDecoration: 'none', marginBottom: 28 }}>
            <svg width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M9 3L5 7l4 4" stroke="var(--brand)" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round"/></svg>
            {it ? 'Torna alla home' : 'Back to home'}
          </a>

          <div style={{ display: 'flex', alignItems: 'center', gap: mobile ? 14 : 20, marginBottom: 24 }}>
            <img src={base + 'icon-filter-sort.png'} alt="" draggable={false}
              style={{ width: mobile ? 48 : 60, height: mobile ? 48 : 60, objectFit: 'contain', flexShrink: 0 }} />
            <h1 style={{ fontFamily: 'var(--font-sans)', fontSize: mobile ? 32 : 44, fontWeight: 600, color: 'var(--fg-1)', letterSpacing: '-0.02em', lineHeight: 1.1 }}>
                Filter Sort
            </h1>
          </div>

          <p style={{ ...body, maxWidth: 680, fontSize: mobile ? 16 : 18, marginBottom: 28 }}>
            {it
              ? 'Filter Sort sostituisce il dialogo Visibilità/Grafica nativo di Revit con un\'interfaccia visuale più potente per gestire i filtri dei view template. In Revit, gestire filtri su decine di view template è lento e ripetitivo — ma non più!'
              : 'Filter Sort replaces Revit\'s built-in Visibility/Graphics filter management with a more powerful, visual interface. In native Revit, managing filters across dozens of view templates is slow and repetitive — but not anymore!'}
          </p>


        </div>
      </section>

      {/* ── SCREENSHOT GALLERY ── */}
      <section style={{ background: 'var(--bg-section)', padding: pad }}>
        <div style={{ maxWidth: maxW, margin: '0 auto' }}>
          <div style={eyebrow}>{it ? 'Interfaccia' : 'Interface'}</div>
          <h2 style={{ ...h2s, marginBottom: 28 }}>
            {it ? 'Un\'interfaccia costruita per il controllo totale' : 'An interface built for total control'}
          </h2>

          {/* Main image */}
          <div style={{
            background: 'var(--neutral-100)', borderRadius: 'var(--radius-xl)',
            border: '1px solid var(--border)', overflow: 'hidden',
            boxShadow: 'var(--shadow-2)', lineHeight: 0, position: 'relative', marginBottom: 12,
          }}>
            <img src={imgs[activeImg]} alt={imgCaptions[activeImg]}
              onClick={() => setLightboxOpen(true)}
              style={{ width: '100%', height: 'auto', display: 'block', cursor: 'zoom-in' }} />
            {imgs.length > 1 && (
              <>
                <button onClick={() => setActiveImg((activeImg - 1 + imgs.length) % imgs.length)}
                  aria-label="Previous" style={{
                    position: 'absolute', top: '50%', left: 10, transform: 'translateY(-50%)',
                    width: 36, height: 36, borderRadius: '50%', border: 'none',
                    background: 'rgba(255,255,255,0.92)', color: 'var(--fg-1)',
                    cursor: 'pointer', fontSize: 18, fontWeight: 600, zIndex: 2,
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                    boxShadow: 'var(--shadow-1)',
                  }}>‹</button>
                <button onClick={() => setActiveImg((activeImg + 1) % imgs.length)}
                  aria-label="Next" style={{
                    position: 'absolute', top: '50%', right: 10, transform: 'translateY(-50%)',
                    width: 36, height: 36, borderRadius: '50%', border: 'none',
                    background: 'rgba(255,255,255,0.92)', color: 'var(--fg-1)',
                    cursor: 'pointer', fontSize: 18, fontWeight: 600, zIndex: 2,
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                    boxShadow: 'var(--shadow-1)',
                  }}>›</button>
              </>
            )}
          </div>
          {/* Caption + dots */}
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }}>
            <p style={{ fontFamily: 'var(--font-sans)', fontSize: 13, color: 'var(--fg-4)', lineHeight: 1.5 }}>
              {imgCaptions[activeImg]}
            </p>
            <div style={{ display: 'flex', gap: 6 }}>
              {imgs.map((_, i) => (
                <button key={i} onClick={() => setActiveImg(i)} aria-label={`Screenshot ${i + 1}`}
                  style={{
                    width: i === activeImg ? 20 : 7, height: 7, borderRadius: 4, border: 'none',
                    cursor: 'pointer', padding: 0,
                    background: i === activeImg ? 'var(--brand)' : 'var(--neutral-300)',
                    transition: 'width 150ms, background 150ms',
                  }} />
              ))}
            </div>
          </div>
        </div>
      </section>

      {/* ── LAYOUT OVERVIEW ── */}
      <section style={{ background: 'var(--bg-page)', padding: pad }}>
        <div style={{ maxWidth: maxW, margin: '0 auto' }}>
          <div style={eyebrow}>Layout</div>
          <h2 style={{ ...h2s, marginBottom: 8 }}>
            {it ? 'Tre pannelli, un flusso di lavoro' : 'Three panels, one workflow'}
          </h2>
          <p style={{ ...body, marginBottom: mobile ? 28 : 36, maxWidth: 600 }}>
            {it
              ? 'L\'interfaccia organizza tutto in tre aree affiancate: selezione del template, editing filtri, e aggiunta di nuovi filtri.'
              : 'The interface organizes everything into three side-by-side areas: template selection, filter editing, and adding new filters.'}
          </p>
          <div style={{
            display: 'grid',
            gridTemplateColumns: mobile ? '1fr' : '1fr 1.6fr 1fr',
            gap: mobile ? 12 : 16,
          }}>
            {panels.map((p, i) => (
              <div key={i} style={{
                background: 'var(--white)', border: '1px solid var(--border)',
                borderRadius: 'var(--radius-lg)', overflow: 'hidden',
                boxShadow: 'var(--shadow-1)',
              }}>
                {/* Top accent */}
                <div style={{ height: 3, background: i === 1 ? 'var(--brand)' : 'var(--neutral-300)' }}></div>
                <div style={{ padding: mobile ? '18px 16px' : '22px 20px' }}>
                  <span style={{ fontFamily: 'var(--font-mono)', fontSize: 10, color: 'var(--fg-4)', letterSpacing: '0.08em', textTransform: 'uppercase' }}>
                    {p.label}
                  </span>
                  <h3 style={{ fontFamily: 'var(--font-sans)', fontSize: mobile ? 16 : 17, fontWeight: 600, color: 'var(--fg-1)', marginTop: 8, marginBottom: 14 }}>
                    {p.title}
                  </h3>
                  <ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 8 }}>
                    {p.items.map((item, j) => (
                      <li key={j} style={{ display: 'flex', gap: 10, alignItems: 'flex-start' }}>
                        <span style={dot}></span>
                        <span style={{ fontFamily: 'var(--font-sans)', fontSize: 13, color: 'var(--fg-3)', lineHeight: 1.5 }}>{item}</span>
                      </li>
                    ))}
                  </ul>
                </div>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ── KEY FEATURES ── */}
      <section style={{ background: 'var(--bg-section)', padding: pad }}>
        <div style={{ maxWidth: maxW, margin: '0 auto' }}>
          <div style={eyebrow}>{it ? 'Funzionalità' : 'Features'}</div>
          <h2 style={{ ...h2s, marginBottom: mobile ? 28 : 36 }}>
            {it ? 'Tutto quello che puoi fare' : 'Everything you can do'}
          </h2>
          <div style={{
            display: 'grid',
            gridTemplateColumns: mobile ? '1fr' : '1fr 1fr',
            gap: mobile ? 16 : 20,
          }}>
            {featureGroups.map((group, gi) => (
              <div key={gi} style={{
                background: 'var(--white)', border: '1px solid var(--border)',
                borderRadius: 'var(--radius-lg)', padding: mobile ? '20px 18px' : '24px',
                boxShadow: 'var(--shadow-1)',
              }}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 16 }}>
                  <div style={{
                    width: 32, height: 32, borderRadius: 'var(--radius-md)',
                    background: 'var(--brand-subtle)', display: 'flex',
                    alignItems: 'center', justifyContent: 'center', flexShrink: 0,
                  }}>
                    {group.icon}
                  </div>
                  <h3 style={{ fontFamily: 'var(--font-sans)', fontSize: 15, fontWeight: 600, color: 'var(--fg-1)', lineHeight: 1.3 }}>
                    {group.title}
                  </h3>
                </div>
                <ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 10 }}>
                  {group.items.map((item, ii) => (
                    <li key={ii} style={{ display: 'flex', gap: 10, alignItems: 'flex-start' }}>
                      <span style={dot}></span>
                      <span style={{ fontFamily: 'var(--font-sans)', fontSize: 13, color: 'var(--fg-3)', lineHeight: 1.55 }}>{item}</span>
                    </li>
                  ))}
                </ul>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ── KEYBOARD SHORTCUTS ── */}
      <section style={{ background: 'var(--bg-page)', padding: pad }}>
        <div style={{ maxWidth: maxW, margin: '0 auto' }}>
          <div style={eyebrow}>{it ? 'Scorciatoie da tastiera' : 'Keyboard shortcuts'}</div>
          <h2 style={{ ...h2s, marginBottom: mobile ? 24 : 28 }}>
            {it ? 'Scorciatoie' : 'Shortcuts'}
          </h2>
          <div style={{
            display: 'grid',
            gridTemplateColumns: mobile ? '1fr' : '1fr 1fr',
            gap: 0, background: 'var(--white)', border: '1px solid var(--border)',
            borderRadius: 'var(--radius-lg)', overflow: 'hidden', boxShadow: 'var(--shadow-1)',
          }}>
            {shortcuts.map((s, i) => (
              <div key={i} style={{
                display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16,
                padding: mobile ? '14px 18px' : '14px 24px',
                borderBottom: i < shortcuts.length - 1 ? '1px solid var(--border)' : 'none',
                ...(!mobile && i % 2 === 0 && i < shortcuts.length - 1 ? { borderRight: '1px solid var(--border)' } : {}),
              }}>
                <span style={kbdStyle}>{s.keys}</span>
                <span style={{ fontFamily: 'var(--font-sans)', fontSize: 13, color: 'var(--fg-3)' }}>{s.action}</span>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* ── WHO IT'S FOR + TECHNICAL ── */}
      <section style={{ background: 'var(--bg-section)', padding: pad }}>
        <div style={{ maxWidth: maxW, margin: '0 auto' }}>
          <div style={{
            display: 'grid',
            gridTemplateColumns: mobile ? '1fr' : '1fr 1fr',
            gap: mobile ? 32 : 64,
          }}>
            {/* Who it's for */}
            <div>
              <div style={eyebrow}>{it ? 'Per chi è' : 'Who it\'s for'}</div>
              <h2 style={{ ...h2s, marginBottom: 12 }}>
                {it ? 'BIM manager e utenti Revit' : 'BIM managers and Revit users'}
              </h2>
              <p style={{ ...body, marginBottom: 0 }}>
                {it
                  ? 'Progettato per chi lavora con view template contenenti molti filtri — architettonici, strutturali, MEP. Particolarmente utile su progetti di grandi dimensioni con 50–200+ filtri per template, dove il dialogo nativo V/G di Revit diventa ingestibile.'
                  : 'Designed for those who work with view templates containing many filters — architectural, structural, MEP. Especially valuable on large projects with 50–200+ filters per template where Revit\'s native V/G dialog becomes unmanageable.'}
              </p>
            </div>

            {/* Technical notes */}
            <div>
              <div style={eyebrow}>{it ? 'Note tecniche' : 'Technical notes'}</div>
              <h2 style={{ ...h2s, marginBottom: 16 }}>
                {it ? 'Compatibilità' : 'Compatibility'}
              </h2>
              <ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 12 }}>
                {(it ? [
                  ['Finestra modeless', 'Resta aperta mentre lavori in Revit'],
                  ['Revit 2023–2026', 'Tutte le versioni supportate'],
                  ['Unità documento', 'Usa le unità del documento'],
                  ['Lingua', 'Solo inglese'],
                ] : [
                  ['Modeless window', 'Stays open while you work in Revit'],
                  ['Revit 2023–2026', 'All versions supported'],
                  ['Document units', 'Uses your document\'s units'],
                  ['Language', 'English only'],
                ]).map(([label, desc], i) => (
                  <li key={i} style={{ display: 'flex', gap: 12, alignItems: 'flex-start' }}>
                    <span style={{
                      width: 20, height: 20, borderRadius: '50%',
                      background: 'var(--brand-subtle)', color: 'var(--brand)',
                      fontSize: 11, fontWeight: 600, display: 'flex', alignItems: 'center',
                      justifyContent: 'center', flexShrink: 0, marginTop: 1,
                    }}>—</span>
                    <div>
                      <span style={{ fontFamily: 'var(--font-sans)', fontSize: 14, fontWeight: 500, color: 'var(--fg-1)' }}>{label}</span>
                      <span style={{ fontFamily: 'var(--font-sans)', fontSize: 13, color: 'var(--fg-4)', marginLeft: 6 }}>— {desc}</span>
                    </div>
                  </li>
                ))}
              </ul>
            </div>
          </div>
        </div>
      </section>

      {/* ── CTA ── */}
      <section style={{
        background: 'var(--neutral-800)', padding: mobile ? '48px 20px' : '72px 32px',
        textAlign: 'center',
      }}>
        <div style={{ maxWidth: 560, margin: '0 auto' }}>
          <h2 style={{ fontFamily: 'var(--font-sans)', fontSize: mobile ? 24 : 32, fontWeight: 600, color: 'var(--white)', letterSpacing: '-0.02em', lineHeight: 1.2, marginBottom: 14 }}>
            {it ? 'Pronto per gestire i filtri meglio?' : 'Ready to manage filters better?'}
          </h2>
          <p style={{ fontFamily: 'var(--font-sans)', fontSize: 15, color: 'var(--neutral-400)', lineHeight: 1.6, marginBottom: 28 }}>
            {it
              ? 'Filter Sort è incluso in Strato BIM. Scaricalo e inizia subito.'
              : 'Filter Sort is included in Strato BIM. Download it and get started.'}
          </p>
          <a href="/download" onClick={e => { e.preventDefault(); onNavigate('download'); }}
            style={{
              display: 'inline-block', background: 'var(--brand)', color: 'var(--white)',
              padding: '14px 32px', borderRadius: 'var(--radius-md)',
              fontSize: 16, fontWeight: 500, textDecoration: 'none',
              fontFamily: 'var(--font-sans)', transition: 'background 150ms',
            }}
            onMouseEnter={e => e.currentTarget.style.background = 'var(--brand-hover)'}
            onMouseLeave={e => e.currentTarget.style.background = 'var(--brand)'}
          >
            {it ? 'Scarica Strato BIM' : 'Download Strato BIM'}
          </a>
        </div>
      </section>

      {/* ── LIGHTBOX ── */}
      {lightboxOpen && (
        <div onClick={closeLightbox} style={{
          position: 'fixed', inset: 0, zIndex: 9998,
          background: 'rgba(10,10,10,0.88)', backdropFilter: 'blur(4px)',
          display: 'flex', alignItems: 'center', justifyContent: 'center',
          padding: mobile ? '20px' : '40px',
          opacity: lbVisible ? 1 : 0, transition: 'opacity 180ms ease-out',
          cursor: 'zoom-out',
        }}>
          <img src={imgs[activeImg]} alt={imgCaptions[activeImg]}
            onClick={e => e.stopPropagation()}
            style={{
              maxWidth: '95vw', maxHeight: '90vh', width: 'auto', height: 'auto',
              borderRadius: 'var(--radius-lg)', boxShadow: '0 24px 60px rgba(0,0,0,0.5)',
              cursor: 'default', transform: lbVisible ? 'scale(1)' : 'scale(0.97)',
              transition: 'transform 180ms ease-out',
            }} />
          <button onClick={closeLightbox} aria-label="Close" style={{
            position: 'absolute', top: 20, right: 20,
            width: 40, height: 40, borderRadius: '50%', border: 'none',
            background: 'rgba(255,255,255,0.95)', color: 'var(--fg-1)',
            cursor: 'pointer', fontSize: 18, fontWeight: 500,
            display: 'flex', alignItems: 'center', justifyContent: 'center',
            boxShadow: 'var(--shadow-2)',
          }}>×</button>
          {imgs.length > 1 && (
            <>
              <button onClick={e => { e.stopPropagation(); setActiveImg((activeImg - 1 + imgs.length) % imgs.length); }}
                aria-label="Previous" style={{
                  position: 'absolute', top: '50%', left: mobile ? 12 : 24, transform: 'translateY(-50%)',
                  width: 44, height: 44, borderRadius: '50%', border: 'none',
                  background: 'rgba(255,255,255,0.95)', color: 'var(--fg-1)',
                  cursor: 'pointer', fontSize: 22, fontWeight: 500,
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  boxShadow: 'var(--shadow-2)',
                }}>‹</button>
              <button onClick={e => { e.stopPropagation(); setActiveImg((activeImg + 1) % imgs.length); }}
                aria-label="Next" style={{
                  position: 'absolute', top: '50%', right: mobile ? 12 : 24, transform: 'translateY(-50%)',
                  width: 44, height: 44, borderRadius: '50%', border: 'none',
                  background: 'rgba(255,255,255,0.95)', color: 'var(--fg-1)',
                  cursor: 'pointer', fontSize: 22, fontWeight: 500,
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                  boxShadow: 'var(--shadow-2)',
                }}>›</button>
            </>
          )}
        </div>
      )}
    </div>
  );
};

Object.assign(window, { FilterSortHelp });
