// SecureSystems — additional sections: Services, Pricing, Process, FAQ
const { useState: __useState } = React;

// Service icons
const ServiceIcon = {
  globe: () => (
    <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="12" cy="12" r="10"/>
      <path d="M2 12h20M12 2a15 15 0 0 1 0 20M12 2a15 15 0 0 0 0 20"/>
    </svg>
  ),
  gear: () => (
    <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="12" cy="12" r="3"/>
      <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>
    </svg>
  ),
  shield: () => (
    <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round">
      <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
      <path d="m9 12 2 2 4-4"/>
    </svg>
  ),
  check: () => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
      <polyline points="20 6 9 17 4 12"/>
    </svg>
  ),
  x: () => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
    </svg>
  ),
  plus: () => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
      <line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
    </svg>
  ),
};

// ─── Services (3 cards) ──────────────────────────────────────────────────────
function Services({ t, lang, onContact, onPricing }) {
  const titleFontStyle = { fontFamily: "var(--font-heading)", fontStyle: lang === "ar" ? "normal" : "italic" };
  return (
    <section className="section" id="services-section" style={{ position: "relative", overflow: "hidden" }}>
      <div className="container">
        <div style={{ marginBottom: 64, maxWidth: 880 }}>
          <span className="glass pill" style={{ marginBottom: 20 }}>
            <span className="eyebrow">{t.services.eyebrow}</span>
          </span>
          <h2 className="h-section" style={{ ...titleFontStyle, fontSize: "clamp(2.2rem, 5vw, 4rem)", margin: 0 }}>
            {t.services.title.map((l, i) => <span key={i} style={{ display: "block" }}>{l}</span>)}
          </h2>
          <p className="body-text" style={{ marginTop: 24, fontSize: 16, maxWidth: 620 }}>{t.services.sub}</p>
        </div>
        <div data-mobile-stack="1" style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 24 }}>
          {t.services.items.map((s, i) => {
            const I = ServiceIcon[s.icon] || ServiceIcon.globe;
            const handle = i === 0 ? onPricing : onContact;
            return (
              <div key={i} className="glass" style={{
                borderRadius: 24, padding: 32, display: "flex", flexDirection: "column",
                minHeight: 380, gap: 16,
              }}>
                <div className="glass-strong" style={{
                  width: 56, height: 56, borderRadius: 16, display: "grid", placeItems: "center",
                  color: "var(--accent)", marginBottom: 8,
                }}>
                  <I />
                </div>
                <h3 style={{ ...titleFontStyle, fontSize: 26, margin: 0, letterSpacing: "-0.02em", lineHeight: 1.15 }}>{s.title}</h3>
                <p className="body-text" style={{ fontSize: 14, margin: 0, flex: 1 }}>{s.body}</p>
                {s.note && <div style={{ fontSize: 12, color: "var(--ink-mute)", fontStyle: "italic" }}>{s.note}</div>}
                <button onClick={handle} className="btn glass-strong" style={{ alignSelf: "flex-start", marginTop: 4 }}>
                  {s.cta}
                  <span className="mirror-x"><Icon.ArrowUR size={14} /></span>
                </button>
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
}

// ─── Pricing (3 tiers, middle highlighted) ───────────────────────────────────
function Pricing({ t, lang, onContact }) {
  const titleFontStyle = { fontFamily: "var(--font-heading)", fontStyle: lang === "ar" ? "normal" : "italic" };
  return (
    <section className="section" id="pricing-section" style={{ position: "relative" }}>
      <div className="container">
        <div style={{ marginBottom: 64, maxWidth: 880 }}>
          <span className="glass pill" style={{ marginBottom: 20 }}>
            <span className="eyebrow">{t.pricing.eyebrow}</span>
          </span>
          <h2 className="h-section" style={{ ...titleFontStyle, fontSize: "clamp(2.2rem, 5vw, 4rem)", margin: 0 }}>
            {t.pricing.title.map((l, i) => <span key={i} style={{ display: "block" }}>{l}</span>)}
          </h2>
          <p className="body-text" style={{ marginTop: 24, fontSize: 16, maxWidth: 620 }}>{t.pricing.sub}</p>
        </div>
        <div data-mobile-stack="pricing" style={{ display: "grid", gridTemplateColumns: "1fr 1.08fr 1fr", gap: 20, alignItems: "stretch", paddingTop: 24 }}>
          {t.pricing.tiers.map((tier, i) => {
            const isPop = !!tier.badge;
            return (
              <div key={i} className={isPop ? "glass-strong" : "glass"} style={{
                borderRadius: 28, padding: 36, display: "flex", flexDirection: "column",
                position: "relative",
                overflow: "visible",
                border: isPop ? "1px solid rgba(201,169,106,0.55)" : "1px solid var(--line)",
                boxShadow: isPop ? "0 30px 80px rgba(201,169,106,0.12), 0 0 0 1px rgba(201,169,106,0.18) inset" : "none",
                transform: isPop ? "translateY(-8px)" : "none",
              }}>
                {isPop && (
                  <div data-popular-badge style={{
                    position: "absolute", top: -16, left: "50%", transform: "translateX(-50%)",
                    background: "var(--accent)", color: "#0a0a0a",
                    fontSize: 12, fontWeight: 700, letterSpacing: "0.18em",
                    padding: "8px 18px", borderRadius: 9999, whiteSpace: "nowrap",
                    fontFamily: "var(--font-mono)", textTransform: "uppercase",
                    boxShadow: "0 6px 24px rgba(201,169,106,0.45), 0 0 0 4px rgba(201,169,106,0.12)",
                    zIndex: 2,
                  }}>
                    {tier.badge}
                  </div>
                )}
                <div style={{ ...titleFontStyle, fontSize: 28, letterSpacing: "-0.02em" }}>{tier.name}</div>
                <p className="body-text" style={{ fontSize: 13, marginTop: 8, opacity: 0.75, minHeight: 38 }}>{tier.tag}</p>

                <div style={{ marginTop: 20, paddingTop: 20, borderTop: "1px solid var(--line)" }}>
                  <div>
                    <div className="ltr-inline" style={{ ...titleFontStyle, fontSize: 38, letterSpacing: "-0.03em", color: isPop ? "var(--accent)" : "var(--ink)", lineHeight: 1.1, whiteSpace: "nowrap" }}>{tier.setup}</div>
                    <div style={{ fontSize: 12, color: "var(--ink-mute)", marginTop: 2 }}>{lang === "ar" ? "إعداد لمرة واحدة" : "one-time setup"}</div>
                  </div>
                  <div style={{ marginTop: 14 }}>
                    <div style={{ display: "flex", alignItems: "baseline", gap: 6, flexWrap: "nowrap" }}>
                      <span className="ltr-inline" style={{ ...titleFontStyle, fontSize: 22, whiteSpace: "nowrap" }}>{tier.monthly}</span>
                      <span style={{ fontSize: 12, color: "var(--ink-mute)", whiteSpace: "nowrap" }}>{lang === "ar" ? "/ شهرياً" : "/ month"}</span>
                    </div>
                  </div>
                  {tier.upsell && (
                    <div style={{ marginTop: 10, fontSize: 11, color: "var(--accent)", fontFamily: "var(--font-mono)", letterSpacing: "0.04em" }}>
                      {tier.upsell}
                    </div>
                  )}
                </div>

                <ul style={{ listStyle: "none", padding: 0, margin: "24px 0 0", display: "grid", gap: 10, flex: 1 }}>
                  {tier.features.map((f, j) => (
                    <li key={j} style={{ display: "flex", gap: 10, alignItems: "flex-start", fontSize: 13, lineHeight: 1.5 }}>
                      <span style={{ color: isPop ? "var(--accent)" : "var(--ink)", marginTop: 3, flexShrink: 0 }}><ServiceIcon.check /></span>
                      <span style={{ color: "var(--ink-soft)" }}>{f}</span>
                    </li>
                  ))}
                  {tier.missing && tier.missing.map((f, j) => (
                    <li key={"m"+j} style={{ display: "flex", gap: 10, alignItems: "flex-start", fontSize: 13, lineHeight: 1.5, opacity: 0.4 }}>
                      <span style={{ color: "var(--ink-mute)", marginTop: 3, flexShrink: 0 }}><ServiceIcon.x /></span>
                      <span style={{ color: "var(--ink-mute)", textDecoration: "line-through" }}>{f}</span>
                    </li>
                  ))}
                </ul>

                <button onClick={onContact} className={isPop ? "btn btn-primary" : "btn glass"} style={{
                  marginTop: 28, justifyContent: "center", width: "100%",
                  ...(isPop ? {} : { background: "transparent", border: "1px solid var(--line)" }),
                }}>
                  {lang === "ar" ? "تواصل معنا" : "Contact Us"}
                  <span className="mirror-x"><Icon.ArrowUR size={14} /></span>
                </button>
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
}

// ─── Process (4 steps) ───────────────────────────────────────────────────────
function Process({ t, lang }) {
  const titleFontStyle = { fontFamily: "var(--font-heading)", fontStyle: lang === "ar" ? "normal" : "italic" };
  return (
    <section className="section" style={{ position: "relative", overflow: "hidden" }}>
      <div className="container">
        <div style={{ marginBottom: 56, maxWidth: 880 }}>
          <span className="glass pill" style={{ marginBottom: 20 }}>
            <span className="eyebrow">{t.process.eyebrow}</span>
          </span>
          <h2 className="h-section" style={{ ...titleFontStyle, fontSize: "clamp(2.2rem, 5vw, 4rem)", margin: 0 }}>
            {t.process.title.map((l, i) => <span key={i} style={{ display: "block" }}>{l}</span>)}
          </h2>
        </div>
        <div data-mobile-stack="process" style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 20 }}>
          {t.process.steps.map((s, i) => (
            <div key={i} className="glass" style={{ borderRadius: 20, padding: 28, minHeight: 200 }}>
              <div className="eyebrow" style={{ color: "var(--accent)", marginBottom: 14 }}>{s.n}</div>
              <h3 style={{ ...titleFontStyle, fontSize: 22, margin: 0, lineHeight: 1.2, letterSpacing: "-0.02em" }}>{s.t}</h3>
              <p className="body-text" style={{ marginTop: 12, fontSize: 13 }}>{s.d}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─── FAQ (accordion) ─────────────────────────────────────────────────────────
function Faq({ t, lang }) {
  const titleFontStyle = { fontFamily: "var(--font-heading)", fontStyle: lang === "ar" ? "normal" : "italic" };
  const [open, setOpen] = __useState(0);
  return (
    <section className="section" style={{ position: "relative", overflow: "hidden" }}>
      <div className="container" style={{ maxWidth: 1100 }}>
        <div data-mobile-stack="faq" style={{ display: "grid", gridTemplateColumns: "1fr 1.4fr", gap: 80, alignItems: "start" }}>
          <div>
            <span className="glass pill" style={{ marginBottom: 20 }}>
              <span className="eyebrow">{t.faq.eyebrow}</span>
            </span>
            <h2 className="h-section" style={{ ...titleFontStyle, fontSize: "clamp(2rem, 4.4vw, 3.4rem)", margin: 0 }}>
              {t.faq.title.map((l, i) => <span key={i} style={{ display: "block" }}>{l}</span>)}
            </h2>
          </div>
          <div style={{ display: "grid", gap: 12 }}>
            {t.faq.items.map((it, i) => {
              const isOpen = open === i;
              return (
                <div key={i} className="glass" style={{ borderRadius: 18, padding: "20px 24px", cursor: "pointer" }} onClick={() => setOpen(isOpen ? -1 : i)}>
                  <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", gap: 16 }}>
                    <span style={{ ...titleFontStyle, fontSize: 18, letterSpacing: "-0.01em" }}>{it.q}</span>
                    <span style={{ color: "var(--accent)", flexShrink: 0, transform: isOpen ? "rotate(45deg)" : "none", transition: "transform 200ms" }}>
                      <ServiceIcon.plus />
                    </span>
                  </div>
                  {isOpen && (
                    <p className="body-text" style={{ fontSize: 14, marginTop: 14, marginBottom: 0, opacity: 0.85 }}>{it.a}</p>
                  )}
                </div>
              );
            })}
          </div>
        </div>
      </div>
    </section>
  );
}

Object.assign(window, { Services, Pricing, Process, Faq, ServiceIcon });
