const tokens = {
  bg: '#0a0a0b',
  bg2: '#111114',
  panel: '#16161a',
  panelHi: '#1c1c22',
  border: 'rgba(255,255,255,0.08)',
  borderHi: 'rgba(255,255,255,0.14)',
  text: '#f4f4f5',
  textDim: 'rgba(244,244,245,0.62)',
  textMute: 'rgba(244,244,245,0.42)',
  amber: '#f5b544',
  amberHi: '#ffd373',
  green: '#7ee0a8',
  red: '#ff7a7a',
  font: "'Inter', system-ui, sans-serif",
  display: "'Space Grotesk', 'Inter', system-ui, sans-serif",
  mono: "'JetBrains Mono', ui-monospace, monospace",
};

const NAV_LINKS = [
  { label: 'Home', href: 'index.html' },
  { label: 'Sick Line', href: 'sick-line.html' },
  { label: 'Recruitment Automation', href: 'recruitment-ai.html' },
  { label: 'Receptionist', href: 'receptionist.html' },
  { label: 'Contact', href: 'index.html#contact' },
];

const HexGrid = ({ opacity = 0.07, id = 'hex' }) => (
  <svg width="100%" height="100%" style={{ position: 'absolute', inset: 0, pointerEvents: 'none', opacity }} aria-hidden>
    <defs>
      <pattern id={id} width="56" height="48.5" patternUnits="userSpaceOnUse">
        <path d="M14 0 L42 0 L56 24.25 L42 48.5 L14 48.5 L0 24.25 Z" fill="none" stroke={tokens.amber} strokeWidth="0.6" />
      </pattern>
    </defs>
    <rect width="100%" height="100%" fill={`url(#${id})`} />
  </svg>
);

const Logo = () => (
  <a href="index.html" style={{ display: 'flex', alignItems: 'center', gap: 10, textDecoration: 'none', color: 'inherit' }}>
    <svg width="22" height="22" viewBox="0 0 24 24" aria-hidden>
      <path d="M6 1 L18 1 L24 12 L18 23 L6 23 L0 12 Z" fill={tokens.amber} />
      <path d="M9 7 L15 7 L18 12 L15 17 L9 17 L6 12 Z" fill={tokens.bg} />
    </svg>
    <span style={{ fontFamily: tokens.display, fontWeight: 600, fontSize: 15, letterSpacing: -0.2 }}>G Solutions</span>
  </a>
);

const SiteNav = ({ active }) => (
  <div style={{
    position: 'sticky', top: 0, zIndex: 50,
    display: 'flex', alignItems: 'center', justifyContent: 'space-between',
    padding: '18px 56px',
    background: 'rgba(10,10,11,0.72)', backdropFilter: 'blur(16px)',
    borderBottom: `1px solid ${tokens.border}`,
  }}>
    <Logo />
    <nav style={{ display: 'flex', gap: 32, fontSize: 13.5 }}>
      {NAV_LINKS.map((link) => (
        <a
          key={link.href + link.label}
          href={link.href}
          style={{ color: active === link.label ? tokens.amberHi : tokens.textDim, textDecoration: 'none' }}
        >
          {link.label}
        </a>
      ))}
    </nav>
    <div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
      <a href="sick-line.html#transcript" style={{
        background: 'transparent', color: tokens.text,
        border: `1px solid ${tokens.borderHi}`, borderRadius: 999,
        padding: '9px 18px', fontSize: 13, fontWeight: 500, fontFamily: tokens.font,
        textDecoration: 'none',
      }}>
        Live demo
      </a>
      <a href="index.html#contact" style={{
        background: tokens.amber, color: '#1a1200',
        border: 'none', borderRadius: 999,
        padding: '9px 18px', fontSize: 13, fontWeight: 600, fontFamily: tokens.font,
        textDecoration: 'none',
      }}>
        Book consultation →
      </a>
    </div>
  </div>
);

const SectionLabel = ({ kicker, title }) => (
  <>
    <div style={{ fontFamily: tokens.mono, fontSize: 11.5, color: tokens.amber, textTransform: 'uppercase', letterSpacing: 1.5, marginBottom: 16 }}>
      {kicker}
    </div>
    <h2 style={{
      fontFamily: tokens.display, fontWeight: 600, fontSize: 48, lineHeight: 1.05,
      letterSpacing: -1.6, margin: 0, maxWidth: 760,
    }} dangerouslySetInnerHTML={{ __html: title }} />
  </>
);

const PrimaryBtn = ({ children, href = 'index.html#contact' }) => (
  <a href={href} style={{
    background: tokens.amber, color: '#1a1200',
    border: 'none', borderRadius: 10, padding: '16px 26px',
    fontSize: 15, fontWeight: 600, fontFamily: tokens.font, cursor: 'pointer',
    boxShadow: '0 8px 32px rgba(245,181,68,0.25)', textDecoration: 'none', display: 'inline-block',
  }}>
    {children}
  </a>
);

const SecondaryBtn = ({ children, href = '#' }) => (
  <a href={href} style={{
    background: 'transparent', color: tokens.text,
    border: `1px solid ${tokens.borderHi}`, borderRadius: 10,
    padding: '16px 26px', fontSize: 15, fontWeight: 500, fontFamily: tokens.font,
    textDecoration: 'none', display: 'inline-flex', alignItems: 'center', gap: 8,
  }}>
    {children}
  </a>
);

const Bubble = ({ side, who, children, loading }) => {
  const isAI = side === 'ai';
  return (
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: isAI ? 'flex-start' : 'flex-end' }}>
      <div style={{ fontFamily: tokens.mono, fontSize: 10.5, color: tokens.textMute, marginBottom: 4, textTransform: 'uppercase', letterSpacing: 0.8 }}>{who}</div>
      <div style={{
        maxWidth: '88%',
        padding: '11px 15px',
        borderRadius: isAI ? '14px 14px 14px 4px' : '14px 14px 4px 14px',
        background: isAI ? 'rgba(245,181,68,0.08)' : 'rgba(255,255,255,0.05)',
        border: `1px solid ${isAI ? 'rgba(245,181,68,0.2)' : tokens.border}`,
        fontSize: 13.5, lineHeight: 1.5,
        color: isAI ? '#fff' : tokens.text,
        display: 'flex', alignItems: 'center', gap: 8,
      }}>
        {children}
        {loading && (
          <span style={{ display: 'inline-flex', gap: 3 }}>
            {[0, 1, 2].map((i) => (
              <span key={i} style={{ width: 4, height: 4, borderRadius: 999, background: tokens.amber, opacity: 0.7 - i * 0.2 }} />
            ))}
          </span>
        )}
      </div>
    </div>
  );
};

const CallVisual = () => (
  <div id="transcript" style={{
    position: 'relative',
    background: `linear-gradient(180deg, ${tokens.panel} 0%, ${tokens.bg2} 100%)`,
    border: `1px solid ${tokens.borderHi}`,
    borderRadius: 18, padding: 28,
    boxShadow: '0 40px 80px -20px rgba(0,0,0,0.6)',
  }}>
    <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 20 }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8, fontFamily: tokens.mono, fontSize: 11.5, color: tokens.textMute }}>
        <span style={{ width: 8, height: 8, borderRadius: 999, background: tokens.red }} />
        <span>● LIVE CALL · 00:14</span>
      </div>
      <span style={{ fontFamily: tokens.mono, fontSize: 11.5, color: tokens.amber }}>sickline.gsolutions.ai</span>
    </div>
    <div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
      <Bubble side="in" who="Sarah · Care Worker">
        Hi, it&apos;s Sarah Whitfield. I won&apos;t be in for my Eastview shift today, I&apos;ve come down with flu.
      </Bubble>
      <Bubble side="ai" who="Automated system">
        Sorry to hear that, Sarah. I&apos;ve logged your absence for today&apos;s <b style={{ color: tokens.amberHi }}>07:00–15:00 Eastview shift</b>. Do you need a fit note for anything over 7 days?
      </Bubble>
      <Bubble side="in" who="Sarah">Just today for now, thanks.</Bubble>
      <Bubble side="ai" who="Automated system" loading>Got it. Finding cover from your roster…</Bubble>
    </div>
    <div style={{
      marginTop: 22, padding: '14px 16px',
      background: 'rgba(126,224,168,0.08)',
      border: '1px solid rgba(126,224,168,0.3)',
      borderRadius: 12,
      display: 'flex', alignItems: 'center', justifyContent: 'space-between',
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
        <div style={{
          width: 32, height: 32, borderRadius: 999,
          background: 'rgba(126,224,168,0.2)', display: 'grid', placeItems: 'center',
          color: tokens.green, fontSize: 16,
        }}>✓</div>
        <div>
          <div style={{ fontSize: 13.5, fontWeight: 600 }}>Cover confirmed — James M.</div>
          <div style={{ fontSize: 12, color: tokens.textMute, fontFamily: tokens.mono, marginTop: 2 }}>
            arrives 06:45 · qualified · synced to rota
          </div>
        </div>
      </div>
      <div style={{ fontFamily: tokens.mono, fontSize: 11, color: tokens.green }}>+1.2s</div>
    </div>
  </div>
);

const LogoStrip = () => (
  <section style={{ padding: '24px 56px 48px', borderTop: `1px solid ${tokens.border}`, borderBottom: `1px solid ${tokens.border}` }}>
    <div style={{ fontFamily: tokens.mono, fontSize: 11, color: tokens.textMute, textTransform: 'uppercase', letterSpacing: 1.5, marginBottom: 24 }}>
      Built on infrastructure trusted by
    </div>
    <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 24, opacity: 0.55 }}>
      {['Twilio', 'OpenAI', 'Salesforce', 'Microsoft', 'AWS', 'PolyAI', 'HubSpot'].map((n) => (
        <span key={n} style={{ fontFamily: tokens.display, fontSize: 18, fontWeight: 600, letterSpacing: -0.3, color: tokens.textDim }}>{n}</span>
      ))}
    </div>
  </section>
);

const ProcessSection = () => (
  <section id="process" style={{ padding: '96px 56px', background: tokens.bg2, borderTop: `1px solid ${tokens.border}`, borderBottom: `1px solid ${tokens.border}` }}>
    <SectionLabel kicker="How it works" title="Live in days, not months." />
    <p style={{ fontSize: 17, lineHeight: 1.55, color: tokens.textDim, maxWidth: 640, marginTop: 16 }}>
      We map your call flows, connect to your existing phone number and systems, and go live with minimal disruption.
    </p>
    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: 16, marginTop: 48 }}>
      {[
        { n: '01', t: 'Discovery', d: 'We map your absence flows, roster logic, and tools.' },
        { n: '02', t: 'Integration', d: 'Connected to your phone number, calendar, CRM, and ATS.' },
        { n: '03', t: 'Testing', d: 'Live test calls. Voice, tone, and responses fine-tuned.' },
        { n: '04', t: 'Analytics', d: 'Every call logged with insights for ongoing improvement.' },
        { n: '05', t: 'Go live', d: 'Most agencies are up and running within days.' },
      ].map((s) => (
        <div key={s.n} style={{
          padding: 24, background: tokens.panel,
          border: `1px solid ${tokens.border}`, borderRadius: 14, minHeight: 180,
        }}>
          <div style={{ fontFamily: tokens.mono, fontSize: 12, color: tokens.amber, marginBottom: 14 }}>{s.n}</div>
          <div style={{ fontFamily: tokens.display, fontSize: 18, fontWeight: 600, marginBottom: 8 }}>{s.t}</div>
          <div style={{ fontSize: 13.5, lineHeight: 1.55, color: tokens.textDim }}>{s.d}</div>
        </div>
      ))}
    </div>
  </section>
);

const TrustSection = () => (
  <section style={{ padding: '96px 56px', position: 'relative', overflow: 'hidden' }}>
    <HexGrid opacity={0.04} id="hex-trust" />
    <div style={{ position: 'relative' }}>
      <SectionLabel kicker="Security & reliability" title="Enterprise-grade from day one." />
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16, marginTop: 48 }}>
        {[
          ['Data handling', 'Data is protected end-to-end with AES-256 encryption, secured in transit with TLS, and governed by strict access controls.'],
          ['Secure storage', 'Every client runs on a dedicated, access-controlled server. Data at rest is locked and safeguarded by ISO 27001, SOC 2, and GDPR compliance.'],
          ['Uptime', 'Uninterrupted performance with 24/7 monitoring and autoscaling. Engineered for 99.99% uptime.'],
        ].map(([title, body]) => (
          <div key={title} style={{
            padding: 28, background: tokens.panel,
            border: `1px solid ${tokens.border}`, borderRadius: 14,
          }}>
            <div style={{ fontFamily: tokens.display, fontSize: 18, fontWeight: 600, marginBottom: 12 }}>{title}</div>
            <div style={{ fontSize: 14, lineHeight: 1.6, color: tokens.textDim }}>{body}</div>
          </div>
        ))}
      </div>
    </div>
  </section>
);

const FAQSection = () => {
  const faqs = [
    ['How fast can we go live?', 'Our integrations team typically completes setup within 24–48 hours. Most recruitment agencies go live within days of the discovery call.'],
    ['Will this replace my coordinators?', 'No. It removes repetitive firefighting — sick calls, roster chasing, CRM updates — so your team can focus on placements and client relationships.'],
    ['Will this replace my existing tools?', 'No. We connect to your phone number, ATS, calendar, and CRM. Plug-and-play with zero disruption to your stack.'],
    ['Can I claim this as a tax write-off?', 'Yes. Custom architecture and integration often qualifies as R&D under HMRC guidelines, lowering the true cost of adoption.'],
    ['What about support?', '24/7 system monitoring, performance analytics, regular reports, and scheduled check-ins to ensure the system evolves with your agency.'],
    ['How do you price?', 'Pricing is tailored to your call volume, roster size, and workflow complexity. We provide a quote after a brief consultation.'],
    ['Can you handle payments?', 'Yes. Our systems can securely take deposits and process payments, integrating directly with your existing payment gateway.'],
  ];
  return (
    <section id="faq" style={{ padding: '96px 56px', background: tokens.bg2, borderTop: `1px solid ${tokens.border}`, borderBottom: `1px solid ${tokens.border}` }}>
      <SectionLabel kicker="FAQ" title="Common questions." />
      <div style={{ display: 'flex', flexDirection: 'column', gap: 0, marginTop: 48, maxWidth: 800 }}>
        {faqs.map(([q, a], i) => (
          <div key={i} style={{ padding: '24px 0', borderTop: `1px solid ${tokens.borderHi}`, borderBottom: i === faqs.length - 1 ? `1px solid ${tokens.borderHi}` : 'none' }}>
            <div style={{ fontFamily: tokens.display, fontSize: 20, fontWeight: 600, marginBottom: 10 }}>{q}</div>
            <div style={{ fontSize: 15, lineHeight: 1.6, color: tokens.textDim }}>{a}</div>
          </div>
        ))}
      </div>
    </section>
  );
};

const ContactSection = () => (
  <section id="contact" style={{ padding: '96px 56px', position: 'relative', overflow: 'hidden' }}>
    <HexGrid opacity={0.03} id="hex-contact" />
    <div style={{ position: 'relative', display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 56 }}>
      <div>
        <SectionLabel kicker="Contact" title="Tell us about your agency." />
        <p style={{ fontSize: 16, lineHeight: 1.6, color: tokens.textDim, marginTop: 16 }}>
          Have questions or ready to get started? Tell us about your workflows, team size, and systems — we&apos;ll be in touch shortly.
        </p>
        <form onSubmit={(e) => e.preventDefault()} style={{ marginTop: 32, display: 'flex', flexDirection: 'column', gap: 12 }}>
          {['Name', 'Email', 'Company'].map((label) => (
            <input
              key={label}
              type={label === 'Email' ? 'email' : 'text'}
              placeholder={label}
              style={{
                background: tokens.panel, border: `1px solid ${tokens.borderHi}`,
                borderRadius: 10, padding: '14px 16px', color: tokens.text, fontFamily: tokens.font, fontSize: 14,
              }}
            />
          ))}
          <textarea
            placeholder="What challenge can we solve for you?"
            rows={4}
            style={{
              background: tokens.panel, border: `1px solid ${tokens.borderHi}`,
              borderRadius: 10, padding: '14px 16px', color: tokens.text, fontFamily: tokens.font, fontSize: 14, resize: 'vertical',
            }}
          />
          <button type="submit" style={{
            background: tokens.amber, color: '#1a1200', border: 'none',
            borderRadius: 10, padding: '16px 26px', fontSize: 15, fontWeight: 600,
            fontFamily: tokens.font, cursor: 'pointer', alignSelf: 'flex-start',
          }}>
            Send Request
          </button>
        </form>
      </div>
      <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
        {[
          ['📧', 'Email', 'cam@gsolutions.org.uk', 'For all enquiries'],
          ['📞', 'Phone', '+44 75070 64216', 'Contact our sales team'],
          ['📍', 'Location', '124-128 City Road, London EC1V 2NX', 'Serving agencies globally'],
        ].map(([icon, title, value, sub]) => (
          <div key={title} style={{
            padding: 24, background: tokens.panel,
            border: `1px solid ${tokens.border}`, borderRadius: 14,
          }}>
            <div style={{ fontSize: 20, marginBottom: 8 }}>{icon}</div>
            <div style={{ fontFamily: tokens.mono, fontSize: 11, color: tokens.textMute, textTransform: 'uppercase', letterSpacing: 1.2 }}>{title}</div>
            <div style={{ fontSize: 16, marginTop: 8, fontWeight: 500 }}>{value}</div>
            <div style={{ fontSize: 13, color: tokens.textMute, marginTop: 4 }}>{sub}</div>
          </div>
        ))}
      </div>
    </div>
  </section>
);

const SiteCTA = ({ title, sub }) => (
  <section style={{ padding: '120px 56px', position: 'relative', overflow: 'hidden' }}>
    <div style={{
      position: 'absolute', inset: 0,
      background: 'radial-gradient(ellipse at 50% 100%, rgba(245,181,68,0.18) 0%, rgba(245,181,68,0) 60%)',
    }} />
    <div style={{ position: 'relative', textAlign: 'center', maxWidth: 760, margin: '0 auto' }}>
      <div style={{ fontFamily: tokens.mono, fontSize: 11, color: tokens.amber, textTransform: 'uppercase', letterSpacing: 1.5, marginBottom: 20 }}>
        15-min discovery call · no commitment
      </div>
      <h2 style={{
        fontFamily: tokens.display, fontWeight: 600, fontSize: 60, lineHeight: 1,
        letterSpacing: -2, margin: 0,
      }} dangerouslySetInnerHTML={{ __html: title }} />
      {sub && <p style={{ fontSize: 18, color: tokens.textDim, maxWidth: 560, margin: '24px auto 36px', lineHeight: 1.5 }}>{sub}</p>}
      <PrimaryBtn href="index.html#contact">Book free consultation →</PrimaryBtn>
    </div>
  </section>
);

const SiteFooter = () => (
  <footer style={{ padding: '48px 56px', borderTop: `1px solid ${tokens.border}`, display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 16 }}>
    <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
      <svg width="18" height="18" viewBox="0 0 24 24" aria-hidden>
        <path d="M6 1 L18 1 L24 12 L18 23 L6 23 L0 12 Z" fill={tokens.amber} />
      </svg>
      <span style={{ fontFamily: tokens.display, fontWeight: 600, fontSize: 13 }}>G Solutions</span>
      <span style={{ color: tokens.textMute, fontSize: 12, marginLeft: 12 }}>© 2026</span>
    </div>
    <div style={{ display: 'flex', gap: 28, fontSize: 12.5, color: tokens.textMute, flexWrap: 'wrap' }}>
      <span>cam@gsolutions.org.uk</span>
      <span>+44 75070 64216</span>
      <span>London, EC1V 2NX</span>
    </div>
  </footer>
);

const PageShell = ({ children }) => (
  <div className="ab-scroll" style={{
    width: '100%', minHeight: '100vh', overflowY: 'auto',
    background: tokens.bg, color: tokens.text, fontFamily: tokens.font,
  }}>
    {children}
  </div>
);

window.GS = {
  tokens,
  HexGrid,
  SiteNav,
  SectionLabel,
  PrimaryBtn,
  SecondaryBtn,
  CallVisual,
  LogoStrip,
  ProcessSection,
  TrustSection,
  FAQSection,
  ContactSection,
  SiteCTA,
  SiteFooter,
  PageShell,
};
