"use client";

import { useState } from "react";

import { styleDefault } from "@/mui";
import ShareDI from "@/components/icons/ShareDI";
import { Box, Button, Modal } from "@mui/material";

// Icons
import CopyBlueD from "@/components/icons/CopyBlueD";
import CloseModalD from "@/components/icons/CloseModalD";
import WhatsappBlueD from "@/components/icons/WhatsappBlueD";
import TelegramBlueD from "@/components/icons/TelegramBlueD";
import LinkedingBlueD from "@/components/icons/LinkedingBlueD";

const listIcons = [
  { name: "واتساپ", icon: <WhatsappBlueD /> },
  { name: "تلگرام", icon: <TelegramBlueD /> },
  { name: "لینکدین", icon: <LinkedingBlueD /> },
  { name: "کپی لینک", icon: <CopyBlueD /> },
];

function Share() {
  const [open, setOpen] = useState(false);

  const handleOpen = () => setOpen(true);
  const handleClose = () => setOpen(false);

  return (
    <div className="w-full text-left">
      <Button
        className="!gap-1 !border-none lg:!border-[#EFEFEF] !p-2 !rounded-lg !text-[#525252] !text-[14px]"
        onClick={handleOpen}
        variant="outlined"
      >
        <ShareDI />
        <p className="hidden lg:flex">اشتراک گذاری</p>
      </Button>
      <Modal open={open} onClose={handleClose}>
        <Box
          sx={styleDefault}
          className="!pt-[12px] md:!pt-[14px] lg:!py-[16px]
                    !px-[12px] sm:!px-[16px] md:!px-[20px] lg:!px-[24px]
                    !pb-[12px] sm:!pb-[16px] lg:!pb-[20px]"
        >
          <div className="flex items-center justify-between w-full">
            <p className="text-[#3B3B3B] text-[14px] sm:text-[16px] md:text-[18px] lg:text-[20px] font-medium">
              اشتراک گذاری
            </p>
            <Button
              className="!min-w-0 !p-1"
              onClick={handleClose}
              variant="text"
            >
              <CloseModalD />
            </Button>
          </div>
          <span className="block h-px w-full bg-[#EFEFEF] mt-[8px] mb-[8px] sm:mb-[10px] md:mb-[12px] lg:mb-[14px]"></span>
          <p className="text-[#525252] text-[11px] md:text-[12px] lg:text-[14px] font-normal">
            شما می توانید این پزشک را با دیگران به اشتراک بگذارید:
          </p>
          <ul className="flex items-center mx-[60px] sm:mx-[86px] md:mx-[112px] lg:mx-[140px] justify-center mt-[8px] md:mt-[12px] lg:mt-[16px] gap-[24px] sm:gap-[26px] md:gap-[29px] lg:gap-[32px]">
            {listIcons.map((item, idx) => (
              <li
                key={idx}
                className="flex flex-col justify-center items-center w-fit gap-[2px]"
              >
                <Button
                  className="
                                        !p-[0px] !bg-[#EAECFA] !rounded-full !min-w-0 grid place-items-center
                                        !w-[24px] sm:!w-[28px] md:!w-[32px] lg:!w-[36px]
                                        !h-[24px] sm:!h-[28px] md:!h-[32px] lg:!h-[36px]
                                    "
                  variant="text"
                >
                  <div
                    className="grid place-items-center w-full-icon
                                        !w-[16px] md:!w-[17px] lg:!w-[18px]
                                        !h-[16px] md:!h-[17px] lg:!h-[18px]"
                  >
                    {item.icon}
                  </div>
                </Button>
              </li>
            ))}
          </ul>
        </Box>
      </Modal>
    </div>
  );
}

export default Share;
