// Real-brand LLM logo marks (SVG)
// Used to identify the AI search engines in the live monitor + analytics.

const ChatGPTMark = ({ size = 18, mono = false }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill={mono ? "currentColor" : "#10A37F"} aria-label="ChatGPT">
    <path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.5093-2.6067-1.4997Z" />
  </svg>
);

// Anthropic / Claude mark — stylized starburst in their coral
const ClaudeMark = ({ size = 18, mono = false }) => {
  const color = mono ? "currentColor" : "#CC785C";
  // 7 thin parallelogram bars meeting at center — approximation of the Anthropic mark
  const bars = [];
  for (let i = 0; i < 7; i++) {
    const angle = (i * 180) / 7;
    bars.push(
      <rect
        key={i}
        x="11.1" y="2" width="1.8" height="20"
        rx="0.9"
        fill={color}
        transform={`rotate(${angle} 12 12)`}
      />
    );
  }
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" aria-label="Claude">
      {bars}
    </svg>
  );
};

// Google Gemini — 4-pointed star tuned to the site palette
const GeminiMark = ({ size = 18, mono = false }) => {
  const gid = "gem-" + Math.random().toString(36).slice(2, 7);
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" aria-label="Gemini">
      <defs>
        <linearGradient id={gid} x1="0" y1="0" x2="1" y2="1">
          <stop offset="0%" stopColor="#F5A524" />
          <stop offset="50%" stopColor="#FF8C42" />
          <stop offset="100%" stopColor="#FF3366" />
        </linearGradient>
      </defs>
      <path
        d="M12 1 C 12.6 6.8 17.2 11.4 23 12 C 17.2 12.6 12.6 17.2 12 23 C 11.4 17.2 6.8 12.6 1 12 C 6.8 11.4 11.4 6.8 12 1 Z"
        fill={mono ? "currentColor" : `url(#${gid})`}
      />
    </svg>
  );
};

// Perplexity — stylized rounded knot mark in their teal
const PerplexityMark = ({ size = 18, mono = false }) => {
  const color = mono ? "currentColor" : "#20B8CD";
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Perplexity">
      <path
        d="M12 2 L20 7 V17 L12 22 L4 17 V7 Z"
        stroke={color}
        strokeWidth="1.8"
        strokeLinejoin="round"
      />
      <path
        d="M12 2 V22 M4 12 H20"
        stroke={color}
        strokeWidth="1.6"
        opacity="0.85"
      />
      <circle cx="12" cy="12" r="2.4" fill={color} />
    </svg>
  );
};

// Google search (for completeness)
const GoogleMark = ({ size = 18 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Google">
    <path d="M21.35 11.1H12v2.95h5.35c-.24 1.45-1.7 4.25-5.35 4.25-3.22 0-5.85-2.67-5.85-5.95s2.63-5.95 5.85-5.95c1.83 0 3.05.78 3.75 1.45l2.55-2.47C16.7 3.95 14.55 3 12 3 6.95 3 2.85 7.1 2.85 12.15S6.95 21.3 12 21.3c6.9 0 9.5-4.85 9.5-7.4 0-.5-.05-.95-.15-1.4z" fill="#fff" />
  </svg>
);

// ---------------------------------------------------------------
// Tech-stack vendor marks
// ---------------------------------------------------------------

// Google Analytics — stylized GA bar mark
const GoogleAnalyticsMark = ({ size = 18 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Google Analytics">
    <rect x="16.5" y="3" width="4.5" height="18" rx="2.25" fill="#F9AB00" />
    <rect x="9.75" y="9" width="4.5" height="12" rx="2.25" fill="#E37400" />
    <circle cx="5.25" cy="18.75" r="2.25" fill="#E37400" />
  </svg>
);

// SEMrush — orange S
const SEMrushMark = ({ size = 18 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="SEMrush">
    <rect x="2" y="2" width="20" height="20" rx="4" fill="#FF642D" />
    <path d="M9 8.5 c0 -1.4 1.6 -2 3 -2 c2 0 3 1 3 2 M15 12 c0 -1 -1 -1.4 -3 -1.6 c-2 -0.2 -3 -0.6 -3 -2 M9 15.5 c0 1.4 1.6 2 3 2 c2 0 3 -1 3 -2 c0 -1.4 -1 -1.6 -3 -2"
      stroke="#fff" strokeWidth="1.4" fill="none" strokeLinecap="round" />
  </svg>
);

// Ahrefs — warm A mark
const AhrefsMark = ({ size = 18, mono = false }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Ahrefs">
    <rect x="2" y="2" width="20" height="20" rx="4" fill={mono ? "currentColor" : "#FF3366"} />
    <path d="M7 17 L11 7 H13 L17 17 H14.6 L13.6 14.5 H10.4 L9.4 17 Z M11 12.7 H13 L12 10 Z"
      fill="#fff" />
  </svg>
);

// HubSpot — orange sprocket
const HubSpotMark = ({ size = 18 }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="HubSpot">
    <circle cx="15.5" cy="15.5" r="3.5" stroke="#FF7A59" strokeWidth="1.6" />
    <path d="M15.5 12 V8 a3 3 0 0 0 -3 -3" stroke="#FF7A59" strokeWidth="1.6" strokeLinecap="round" />
    <circle cx="9" cy="5.5" r="1.6" fill="#FF7A59" />
    <circle cx="15.5" cy="15.5" r="1.2" fill="#FF7A59" />
  </svg>
);

// Zapier — orange spark
const ZapierMark = ({ size = 18 }) => {
  const c = "#FF4F00";
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Zapier">
      {[0, 60, 120].map(a => (
        <rect key={a} x="11" y="3" width="2" height="18" rx="1" fill={c} transform={`rotate(${a} 12 12)`} />
      ))}
      <circle cx="12" cy="12" r="2.4" fill={c} />
    </svg>
  );
};

// n8n — pink dot-network
const N8nMark = ({ size = 18 }) => {
  const c = "#EA4B71";
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="n8n">
      <circle cx="5" cy="12" r="2.4" fill={c} />
      <circle cx="12" cy="7" r="2.4" fill={c} />
      <circle cx="12" cy="17" r="2.4" fill={c} />
      <circle cx="19" cy="12" r="2.4" fill={c} />
      <path d="M7 12 H10 M14 12 H17 M12 9.4 V14.6" stroke={c} strokeWidth="1.4" strokeLinecap="round" />
    </svg>
  );
};

// Meta — gradient infinity tuned to the site palette
const MetaMark = ({ size = 18 }) => {
  const gid = "meta-" + Math.random().toString(36).slice(2, 7);
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Meta Ads">
      <defs>
        <linearGradient id={gid} x1="0" y1="0" x2="1" y2="1">
          <stop offset="0%" stopColor="#F5A524" />
          <stop offset="50%" stopColor="#FF8C42" />
          <stop offset="100%" stopColor="#FF3366" />
        </linearGradient>
      </defs>
      <path d="M3 14 C 3 9, 6 7, 8.5 7 C 11.5 7, 13.5 11, 15.5 14 C 17 16.5, 18.5 17, 19.5 17 C 21 17, 21.5 15.5, 21.5 14 C 21.5 11, 19.5 9, 17.5 9 C 15 9, 13 12, 11 15 C 9 17.5, 7 17, 5.5 17 C 4 17, 3 16, 3 14 Z"
        stroke={`url(#${gid})`} strokeWidth="2.2" fill="none" strokeLinejoin="round" strokeLinecap="round" />
    </svg>
  );
};

// Google Search Console — warm magnifier
const GSCMark = ({ size = 18, mono = false }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Google Search Console">
    <circle cx="10" cy="10" r="5" stroke={mono ? "currentColor" : "#FF8C42"} strokeWidth="1.8" />
    <path d="M14 14 L19 19" stroke={mono ? "currentColor" : "#FF3366"} strokeWidth="2.2" strokeLinecap="round" />
    <path d="M5 10 A5 5 0 0 1 10 5" stroke={mono ? "currentColor" : "#F5A524"} strokeWidth="1.8" strokeLinecap="round" />
    <path d="M10 15 A5 5 0 0 1 5 10" stroke={mono ? "currentColor" : "#FF8C42"} strokeWidth="1.8" strokeLinecap="round" />
  </svg>
);

// BigQuery — warm cube
const BigQueryMark = ({ size = 18, mono = false }) => (
  <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="BigQuery">
    <circle cx="11" cy="11" r="6.5" stroke={mono ? "currentColor" : "#FF8C42"} strokeWidth="1.6" />
    <path d="M11 7 V11 L13.5 13" stroke={mono ? "currentColor" : "#FF8C42"} strokeWidth="1.6" strokeLinecap="round" />
    <path d="M15.6 15.6 L19 19" stroke={mono ? "currentColor" : "#FF3366"} strokeWidth="2.2" strokeLinecap="round" />
  </svg>
);

// Segment — green concentric arcs
const SegmentMark = ({ size = 18 }) => {
  const c = "#52BD94";
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Segment">
      <path d="M3 9 H14 A3 3 0 0 1 14 9" stroke={c} strokeWidth="2" strokeLinecap="round" />
      <path d="M21 15 H10 A3 3 0 0 0 10 15" stroke={c} strokeWidth="2" strokeLinecap="round" />
      <circle cx="18.5" cy="9" r="1.4" fill={c} />
      <circle cx="5.5" cy="15" r="1.4" fill={c} />
    </svg>
  );
};

// Mixpanel — warm dot-circle
const MixpanelMark = ({ size = 18 }) => {
  const c = "#FF3366";
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Mixpanel">
      <circle cx="12" cy="12" r="9" stroke={c} strokeWidth="1.6" />
      <circle cx="6.5" cy="12" r="1.6" fill={c} />
      <circle cx="12" cy="12" r="2.4" fill={c} />
      <circle cx="17.5" cy="12" r="1.6" fill={c} />
    </svg>
  );
};

// Brave Search — orange lion-flame
const BraveMark = ({ size = 18 }) => {
  const c = "#FB542B";
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" aria-label="Brave Search">
      <path d="M12 2.5 L17 5 L20 4 L21 7.5 L18.5 10 L19 14 L15 19 L12 21.5 L9 19 L5 14 L5.5 10 L3 7.5 L4 4 L7 5 Z"
        stroke={c} strokeWidth="1.5" fill="none" strokeLinejoin="round" />
      <path d="M12 9 L14 13 L12 14.5 L10 13 Z" fill={c} />
    </svg>
  );
};

// Replacement EngineGlyph that dispatches to the brand marks
const EngineMark = ({ engine, size = 18, mono = false }) => {
  switch (engine) {
    case "gpt":
    case "chatgpt":
    case "openai": return <ChatGPTMark size={size} mono={mono} />;
    case "perplexity": return <PerplexityMark size={size} mono={mono} />;
    case "gemini":
    case "google-gemini": return <GeminiMark size={size} mono={mono} />;
    case "claude":
    case "anthropic": return <ClaudeMark size={size} mono={mono} />;
    case "google": return <GoogleMark size={size} />;
    case "ga":
    case "google-analytics": return <GoogleAnalyticsMark size={size} />;
    case "semrush": return <SEMrushMark size={size} />;
    case "ahrefs": return <AhrefsMark size={size} mono={mono} />;
    case "hubspot": return <HubSpotMark size={size} />;
    case "zapier": return <ZapierMark size={size} />;
    case "n8n": return <N8nMark size={size} />;
    case "meta":
    case "meta-ads": return <MetaMark size={size} />;
    case "gsc":
    case "google-search-console": return <GSCMark size={size} mono={mono} />;
    case "bigquery": return <BigQueryMark size={size} mono={mono} />;
    case "segment": return <SegmentMark size={size} />;
    case "mixpanel": return <MixpanelMark size={size} />;
    case "brave":
    case "brave-search": return <BraveMark size={size} />;
    default: return null;
  }
};

Object.assign(window, {
  ChatGPTMark, ClaudeMark, GeminiMark, PerplexityMark, GoogleMark,
  GoogleAnalyticsMark, SEMrushMark, AhrefsMark, HubSpotMark,
  ZapierMark, N8nMark, MetaMark, GSCMark,
  BigQueryMark, SegmentMark, MixpanelMark, BraveMark,
  EngineMark,
});
