/* eslint-disable @next/next/no-img-element */
"use client";

import { cn } from "@/lib/utils";
import { useTranslations } from "next-intl";

type ScopeItem = {
  key: string;
  variant: "yellow" | "blue";
  icon?: string;
};

export default function OurScope() {
  const t = useTranslations("aboutUs.scope");

  const SCOPE_ITEMS: ScopeItem[] = [
    {
      key: "item1",
      variant: "yellow",
    },
    {
      key: "item2",
      variant: "blue",
    },
    {
      key: "item3",
      variant: "yellow",
    },
    {
      key: "item4",
      variant: "blue",
    },
    {
      key: "item5",
      variant: "blue",
    },
    {
      key: "item6",
      variant: "yellow",
    },
    {
      key: "item7",
      variant: "blue",
    },
    {
      key: "item8",
      variant: "yellow",
    },
  ];
  return (
    <section className="w-full bg-white px-4 py-16 sm:px-6 md:px-8 lg:px-12 lg:py-16 xl:px-[120px]">
      <div className="mx-auto max-w-[1280px]">
        {/* Desktop Layout (lg and up) */}
        <div className="hidden lg:block">
          {/* Container matching Figma's 1200px width layout but responsive */}
          <div className="relative mx-auto w-full max-w-[1200px] lg:h-[420px] xl:h-[470px] 2xl:h-[500px]">
            {/* Left Column */}
            <div className="absolute left-0 top-0 flex lg:w-[330px] xl:w-[360px] 2xl:w-[391.875px] flex-col lg:gap-8 xl:gap-9 2xl:gap-10">
              {SCOPE_ITEMS.slice(0, 4).map((item, index) => (
                <ScopeCard key={index} item={item} t={t} />
              ))}
            </div>

            {/* Center Circle */}
            <div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2">
              <div className="relative flex lg:h-[190px] lg:w-[190px] xl:h-[215px] xl:w-[215px] 2xl:h-[236px] 2xl:w-[236px] items-center justify-center">
                {/* Outer circle - solid light blue */}
                <div className="absolute inset-0 rounded-full bg-muted" />
                {/* Inner circle - blue gradient */}
                <div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex items-center justify-center rounded-full bg-primary-800 lg:h-[154px] lg:w-[157px] xl:h-[175px] xl:w-[178px] 2xl:h-[191.912px] 2xl:w-[195.154px]">
                  <p className="text-center font-bold leading-[1.25] text-white lg:text-[26px] xl:text-[30px] 2xl:text-[32px]">
                    {t("title")}
                  </p>
                </div>
              </div>
            </div>

            {/* Right Column */}
            <div className="absolute right-0 top-0 flex lg:w-[330px] xl:w-[360px] 2xl:w-[391.875px] flex-col lg:gap-8 xl:gap-9 2xl:gap-10">
              {SCOPE_ITEMS.slice(4, 8).map((item, index) => (
                <ScopeCard key={index + 4} item={item} t={t} />
              ))}
            </div>

            {/* Decorative Arrows (Desktop only) - Using actual Figma assets */}
            <div className="pointer-events-none absolute inset-0">
              {/* Arrow_07 - from القانون */}
              <div className="absolute overflow-hidden lg:left-[340px] lg:top-[115px] lg:h-[47px] lg:w-[44px] xl:left-[370px] xl:top-[128px] xl:h-[52px] xl:w-[49px] 2xl:left-[402.19px] 2xl:top-[139px] 2xl:h-[57px] 2xl:w-[53.438px]">
                <img
                  src="/images/about-us/arrow-07.svg"
                  alt=""
                  className="h-full w-full"
                />
              </div>

              {/* Arrow_12 - from الاقتصاد */}
              <div className="absolute overflow-hidden lg:left-[605px] lg:top-[33px] lg:h-[67px] lg:w-[63px] xl:left-[663px] xl:top-[37px] xl:h-[74px] xl:w-[69px] 2xl:left-[721.88px] 2xl:top-[40px] 2xl:h-[80px] 2xl:w-[75px]">
                <img
                  src="/images/about-us/arrow-12.svg"
                  alt=""
                  className="h-full w-full"
                />
              </div>

              {/* Arrow_12 - flipped (from الرياضات) */}
              <div className="absolute flex items-center justify-center overflow-hidden lg:left-[342px] lg:top-[33px] lg:h-[67px] lg:w-[63px] xl:left-[374px] xl:top-[37px] xl:h-[74px] xl:w-[69px] 2xl:left-[406.88px] 2xl:top-[40px] 2xl:h-[80px] 2xl:w-[75px]">
                <div className="rotate-180 scale-y-[-1]">
                  <img
                    src="/images/about-us/arrow-12-flipped.svg"
                    alt=""
                    className="lg:h-[67px] lg:w-[63px] xl:h-[74px] xl:w-[69px] 2xl:h-[80px] 2xl:w-[75px]"
                  />
                </div>
              </div>

              {/* Arrow_12 - rotated variant 1 (from الدراسات) */}
              <div className="absolute flex items-center justify-center overflow-hidden lg:left-[574px] lg:top-[262px] lg:h-[97px] lg:w-[91px] xl:left-[629px] xl:top-[287px] xl:h-[107px] xl:w-[100px] 2xl:left-[683.73px] 2xl:top-[312.32px] 2xl:h-[116.395px] 2xl:w-[109.121px]">
                <div className="rotate-[2.594deg] skew-x-[359.686deg] scale-y-[-1]">
                  <img
                    src="/images/about-us/arrow-12-rotated-1.svg"
                    alt=""
                    className="lg:h-[93px] lg:w-[87px] xl:h-[103px] xl:w-[96px] 2xl:h-[111.741px] 2xl:w-[104.782px]"
                  />
                </div>
              </div>

              {/* Arrow_12 - rotated variant 2 (from الحوكمة) */}
              <div className="absolute flex items-center justify-center overflow-hidden lg:left-[342px] lg:top-[262px] lg:h-[97px] lg:w-[91px] xl:left-[374px] xl:top-[287px] xl:h-[107px] xl:w-[100px] 2xl:left-[406.87px] 2xl:top-[312.32px] 2xl:h-[116.395px] 2xl:w-[109.121px]">
                <div className="rotate-[177.406deg] skew-x-[359.686deg]">
                  <img
                    src="/images/about-us/arrow-12-rotated-2.svg"
                    alt=""
                    className="lg:h-[93px] lg:w-[87px] xl:h-[103px] xl:w-[96px] 2xl:h-[111.741px] 2xl:w-[104.782px]"
                  />
                </div>
              </div>

              {/* Arrow_04 - from البيئة */}
              <div className="absolute flex items-center justify-center overflow-hidden lg:left-[620px] lg:top-[199px] lg:h-[41px] lg:w-[38px] xl:left-[679px] xl:top-[218px] xl:h-[45px] xl:w-[42px] 2xl:left-[738.75px] 2xl:top-[237px] 2xl:h-[49px] 2xl:w-[45.938px]">
                <div className="scale-y-[-1]">
                  <img
                    src="/images/about-us/arrow-04.svg"
                    alt=""
                    className="lg:h-[41px] lg:w-[38px] xl:h-[45px] xl:w-[42px] 2xl:h-[49px] 2xl:w-[45.938px]"
                  />
                </div>
              </div>

              {/* Arrow_04 - rotated (from إدارة السمعة) */}
              <div className="absolute flex items-center justify-center overflow-hidden lg:left-[342px] lg:top-[214px] lg:h-[41px] lg:w-[38px] xl:left-[374px] xl:top-[234px] xl:h-[45px] xl:w-[42px] 2xl:left-[406.88px] 2xl:top-[255px] 2xl:h-[49px] 2xl:w-[45.938px]">
                <div className="rotate-180">
                  <img
                    src="/images/about-us/arrow-04-rotated.svg"
                    alt=""
                    className="lg:h-[41px] lg:w-[38px] xl:h-[45px] xl:w-[42px] 2xl:h-[49px] 2xl:w-[45.938px]"
                  />
                </div>
              </div>

              {/* Arrow_09 */}
              <div className="absolute overflow-hidden lg:left-[623px] lg:top-[124px] lg:h-[36px] lg:w-[34px] xl:left-[682px] xl:top-[136px] xl:h-[40px] xl:w-[37px] 2xl:left-[741.56px] 2xl:top-[148px] 2xl:h-[43px] 2xl:w-[40.313px]">
                <img
                  src="/images/about-us/arrow-09.svg"
                  alt=""
                  className="h-full w-full"
                />
              </div>
            </div>
          </div>
        </div>

        {/* Mobile/Tablet Layout (below lg) */}
        <div className="lg:hidden">
          {/* Center Circle */}
          <div className="mb-12 flex justify-center">
            <div className="relative flex h-[180px] w-[180px] items-center justify-center sm:h-[200px] sm:w-[200px]">
              {/* Outer circle - solid light blue */}
              <div className="absolute inset-0 rounded-full bg-muted" />
              {/* Inner circle */}
              <div className="relative z-10 flex h-[150px] w-[150px] items-center justify-center rounded-full bg-primary-800 sm:h-[165px] sm:w-[165px]">
                <p className="px-6 text-center text-[24px] font-bold leading-[1.4] text-white sm:text-[28px]">
                  {t("title")}
                </p>
              </div>
            </div>
          </div>

          {/* Grid Layout */}
          <div className="grid grid-cols-1 gap-6 sm:grid-cols-2 md:gap-8">
            {SCOPE_ITEMS.map((item, index) => (
              <ScopeCard key={index} item={item} t={t} />
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

function ScopeCard({ item, t }: { item: ScopeItem; t: (key: string) => string }) {
  return (
    <div
      className={cn(
        "flex flex-row-reverse items-center gap-4 overflow-hidden rounded-2xl border border-border px-6 py-3",
        item.variant === "yellow" ? "bg-primary-50" : "bg-muted"
      )}
    >
      <p className="text-start flex-1 text-[18px] leading-normal text-foreground sm:text-[20px]">
        {t(item.key)}
      </p>
      {item.icon && (
        <div className="relative h-14 w-14 shrink-0">
          {/* Background circle - solid color matching outer circle */}
          <div className="absolute inset-0 rounded-full bg-white" />
          {/* Icon container */}
          <div className="absolute left-1/2 top-1/2 flex h-8 w-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-white">
            <img
              src={item.icon}
              alt=""
              className="h-8 w-8 object-contain"
              loading="lazy"
            />
          </div>
        </div>
      )}
    </div>
  );
}
