/* global React */
/* Abstract, on-brand vector illustrations for the Solutions panel.
   No people, no stock — pure geometric SVG tuned to the site palette. */

const SOL_C = {
  ink: '#0a1628', ink2: '#0f1d35', line: '#e3e7ee',
  blue: '#3b82f6', blue2: '#60a5fa', dim: '#1d4ed8', soft: '#dbeafe', paper: '#f7f8fa',
};

// shared 480x140 band viewBox
const band = { viewBox: '0 0 480 140', preserveAspectRatio: 'xMidYMid slice', width: '100%', height: '100%' };

function BandBG({ from = SOL_C.ink, to = SOL_C.ink2, id }) {
  return (
    <defs>
      <linearGradient id={id} x1="0" y1="0" x2="1" y2="1">
        <stop offset="0" stopColor={from} />
        <stop offset="1" stopColor={to} />
      </linearGradient>
      <pattern id={id + '-grid'} width="24" height="24" patternUnits="userSpaceOnUse">
        <path d="M24 0H0V24" fill="none" stroke="#ffffff" strokeOpacity="0.05" strokeWidth="1" />
      </pattern>
    </defs>
  );
}

const SolVisuals = {
  // Managed IT — network of nodes / named pod
  managed: () => (
    <svg {...band} xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Managed IT — connected pod">
      <BandBG id="g-managed" />
      <rect width="480" height="140" fill="url(#g-managed)" />
      <rect width="480" height="140" fill="url(#g-managed-grid)" />
      {[[110,40],[200,90],[300,42],[380,96],[240,32],[150,104]].map((p,i)=>(
        <line key={i} x1="240" y1="70" x2={p[0]} y2={p[1]} stroke={SOL_C.blue2} strokeOpacity="0.35" strokeWidth="1.5" />
      ))}
      <circle cx="240" cy="70" r="26" fill={SOL_C.blue} fillOpacity="0.18" stroke={SOL_C.blue2} strokeWidth="1.5" />
      <circle cx="240" cy="70" r="9" fill={SOL_C.blue2} />
      {[[110,40],[200,90],[300,42],[380,96],[150,104]].map((p,i)=>(
        <g key={i}>
          <circle cx={p[0]} cy={p[1]} r="14" fill={SOL_C.ink2} stroke={SOL_C.blue2} strokeOpacity="0.5" strokeWidth="1.5" />
          <circle cx={p[0]} cy={p[1]} r="4" fill={SOL_C.blue2} fillOpacity="0.8" />
        </g>
      ))}
    </svg>
  ),

  // Intune — device enrolment / shield over laptop
  intune: () => (
    <svg {...band} xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Intune — managed devices">
      <BandBG id="g-intune" />
      <rect width="480" height="140" fill="url(#g-intune)" />
      <rect width="480" height="140" fill="url(#g-intune-grid)" />
      {[130,240,350].map((cx,i)=>(
        <g key={i} opacity={i===1?1:0.55}>
          <rect x={cx-38} y="40" width="76" height="48" rx="5" fill={SOL_C.ink2} stroke={SOL_C.blue2} strokeOpacity="0.5" strokeWidth="1.5" />
          <rect x={cx-30} y="48" width="60" height="32" rx="2" fill={SOL_C.blue} fillOpacity="0.14" />
          <rect x={cx-48} y="90" width="96" height="7" rx="3" fill={SOL_C.ink2} stroke={SOL_C.blue2} strokeOpacity="0.4" strokeWidth="1" />
        </g>
      ))}
      <path d="M240 34 l20 7 v14 c0 13 -9 22 -20 27 c-11 -5 -20 -14 -20 -27 v-14 z" fill={SOL_C.blue} fillOpacity="0.9" />
      <path d="M231 57 l6 6 l12 -13" fill="none" stroke="#fff" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" />
    </svg>
  ),

  // Cloud & M365 — cloud + orbiting service tiles
  cloud: () => (
    <svg {...band} xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Cloud and Microsoft 365">
      <BandBG id="g-cloud" />
      <rect width="480" height="140" fill="url(#g-cloud)" />
      <rect width="480" height="140" fill="url(#g-cloud-grid)" />
      <ellipse cx="240" cy="72" rx="120" ry="40" fill="none" stroke={SOL_C.blue2} strokeOpacity="0.22" strokeWidth="1.5" />
      <path d="M198 84 a22 22 0 0 1 3 -43 a30 30 0 0 1 57 6 a20 20 0 0 1 -4 40 z" fill={SOL_C.blue} fillOpacity="0.16" stroke={SOL_C.blue2} strokeWidth="1.8" />
      {[[120,50],[360,52],[130,104],[352,100]].map((p,i)=>(
        <rect key={i} x={p[0]-14} y={p[1]-14} width="28" height="28" rx="6" fill={SOL_C.ink2} stroke={SOL_C.blue2} strokeOpacity="0.55" strokeWidth="1.5" />
      ))}
      {[[120,50],[360,52],[130,104],[352,100]].map((p,i)=>(
        <circle key={i} cx={p[0]} cy={p[1]} r="4" fill={SOL_C.blue2} />
      ))}
    </svg>
  ),

  // Security — layered shield + lock
  security: () => (
    <svg {...band} xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Security and compliance">
      <BandBG id="g-security" from="#0a1628" to="#101f14" />
      <rect width="480" height="140" fill="url(#g-security)" />
      <rect width="480" height="140" fill="url(#g-security-grid)" />
      {[46,34,22].map((s,i)=>(
        <path key={i} d={`M240 ${24+i*6} l${s} ${s*0.32} v${s*0.62} c0 ${s*0.7} -${s*0.46} ${s} -${s} ${s*1.28} c-${s*0.54} -${s*0.28} -${s} -${s*0.58} -${s} -${s*1.28} v-${s*0.62} z`}
            fill={i===2?SOL_C.blue:'none'} fillOpacity={i===2?0.9:1} stroke={SOL_C.blue2} strokeOpacity={0.35+i*0.2} strokeWidth="1.6" />
      ))}
      <rect x="231" y="66" width="18" height="14" rx="2.5" fill="#fff" />
      <path d="M234 66 v-4 a6 6 0 0 1 12 0 v4" fill="none" stroke="#fff" strokeWidth="2.2" />
      <line x1="72" y1="70" x2="150" y2="70" stroke={SOL_C.blue2} strokeOpacity="0.3" strokeWidth="1.5" strokeDasharray="4 6" />
      <line x1="330" y1="70" x2="408" y2="70" stroke={SOL_C.blue2} strokeOpacity="0.3" strokeWidth="1.5" strokeDasharray="4 6" />
    </svg>
  ),

  // AI — neural / node graph feeding a spark
  ai: () => (
    <svg {...band} xmlns="http://www.w3.org/2000/svg" role="img" aria-label="AI adoption">
      <BandBG id="g-ai" />
      <rect width="480" height="140" fill="url(#g-ai)" />
      <rect width="480" height="140" fill="url(#g-ai-grid)" />
      {(() => {
        const L=[ [110,44],[110,96] ], M=[ [200,32],[200,70],[200,108] ], R=[ [290,44],[290,96] ];
        const lines=[]; L.forEach((a,i)=>M.forEach((b,j)=>lines.push(<line key={'lm'+i+j} x1={a[0]} y1={a[1]} x2={b[0]} y2={b[1]} stroke={SOL_C.blue2} strokeOpacity="0.22" strokeWidth="1"/>)));
        M.forEach((a,i)=>R.forEach((b,j)=>lines.push(<line key={'mr'+i+j} x1={a[0]} y1={a[1]} x2={b[0]} y2={b[1]} stroke={SOL_C.blue2} strokeOpacity="0.22" strokeWidth="1"/>)));
        R.forEach((a,i)=>lines.push(<line key={'ro'+i} x1={a[0]} y1={a[1]} x2="360" y2="70" stroke={SOL_C.blue2} strokeOpacity="0.3" strokeWidth="1.2"/>));
        const dots=[...L,...M,...R].map((p,i)=><circle key={'d'+i} cx={p[0]} cy={p[1]} r="6" fill={SOL_C.ink2} stroke={SOL_C.blue2} strokeWidth="1.4"/>);
        return [...lines,...dots];
      })()}
      <path d="M360 52 l6 14 l14 4 l-14 4 l-6 14 l-6 -14 l-14 -4 l14 -4 z" fill={SOL_C.blue} />
    </svg>
  ),
};

function SolVisual({ id }) {
  const V = SolVisuals[id] || SolVisuals.managed;
  return <V />;
}

Object.assign(window, { SolVisual, SolVisuals });
