'use client';

import { ReactNode } from "react";

interface BotaoFlutuanteProps {
    label: string;
    icon: ReactNode;
    href?: string;
    onClick?: () => void;
    cor?: string;
}

export default function BotaoFlutuante({ label, icon, href, onClick, cor = "bg-[--primary] text-white" }: BotaoFlutuanteProps) {
    const classeBotao = `flex h-[40px] items-center rounded-full ${cor} shadow-lg transition-all duration-300 hover:shadow-xl md:h-[48px]`;

    const conteudo = (
        <>
            <span className="whitespace-nowrap pl-5 font-poppins text-[12px] font-semibold md:pl-6 md:text-[14px]">
                {label}
            </span>
            <span className="flex h-[40px] w-[44px] shrink-0 items-center justify-center md:h-[48px] md:w-[52px]">
                {icon}
            </span>
        </>
    );

    if (href) {
        return (
            <a href={href} target="_blank" rel="noopener noreferrer" className={classeBotao}>
                {conteudo}
            </a>
        );
    }

    return (
        <button type="button" onClick={onClick} className={classeBotao}>
            {conteudo}
        </button>
    );
}
