"use client";

import Link from "next/link";
import { usePathname } from "next/navigation";
import { useTranslation } from "@/lib/i18n";

export default function BottomNav() {
  const pathname = usePathname();
  const { t } = useTranslation();

  const NAV_ITEMS = [
    {
      href: "/tasks",
      label: t("nav.tasks"),
      icon: (
        <svg className="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}>
          <path strokeLinecap="round" strokeLinejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" />
        </svg>
      ),
    },
    {
      href: "/calendar",
      label: t("nav.calendar"),
      icon: (
        <svg className="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}>
          <path strokeLinecap="round" strokeLinejoin="round" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
        </svg>
      ),
    },
    {
      href: "/projects",
      label: t("nav.projects"),
      icon: (
        <svg className="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}>
          <path strokeLinecap="round" strokeLinejoin="round" d="M2 12.5V3.5C2 2.67 2.67 2 3.5 2H8.5C9.33 2 10 2.67 10 3.5V12.5C10 13.33 9.33 14 8.5 14H3.5C2.67 14 2 13.33 2 12.5Z" />
          <path strokeLinecap="round" strokeLinejoin="round" d="M14 20.5V11.5C14 10.67 14.67 10 15.5 10H20.5C21.33 10 22 10.67 22 11.5V20.5C22 21.33 21.33 22 20.5 22H15.5C14.67 22 14 21.33 14 20.5Z" />
          <path strokeLinecap="round" strokeLinejoin="round" d="M14 5.5V3.5C14 2.67 14.67 2 15.5 2H20.5C21.33 2 22 2.67 22 3.5V5.5C22 6.33 21.33 7 20.5 7H15.5C14.67 7 14 6.33 14 5.5Z" />
          <path strokeLinecap="round" strokeLinejoin="round" d="M2 20.5V18.5C2 17.67 2.67 17 3.5 17H8.5C9.33 17 10 17.67 10 18.5V20.5C10 21.33 9.33 22 8.5 22H3.5C2.67 22 2 21.33 2 20.5Z" />
        </svg>
      ),
    },
    {
      href: "/goals",
      label: t("nav.goals"),
      icon: (
        <svg className="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}>
          <path strokeLinecap="round" strokeLinejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" />
        </svg>
      ),
    },
    {
      href: "/chat",
      label: t("nav.chat"),
      icon: (
        <svg className="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={1.5}>
          <path strokeLinecap="round" strokeLinejoin="round" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" />
        </svg>
      ),
    },
  ];

  return (
    <nav className="bottom-nav fixed bottom-0 left-0 right-0 z-50 bg-white/90 dark:bg-gray-950/90 backdrop-blur-lg border-t border-gray-200 dark:border-gray-800 safe-area-bottom">
      <div className="flex items-center justify-around h-16 max-w-lg mx-auto px-2">
        {NAV_ITEMS.map((item) => {
          const isActive = pathname?.startsWith(item.href);
          return (
            <Link
              key={item.href}
              href={item.href}
              className={`flex flex-col items-center justify-center gap-0.5 flex-1 h-full min-w-[56px] min-h-[48px] rounded-lg transition-colors ${
                isActive
                  ? "text-blue-600 dark:text-blue-400"
                  : "text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300"
              }`}
            >
              {item.icon}
              <span className="text-[10px] font-medium leading-none">{item.label}</span>
            </Link>
          );
        })}
      </div>
    </nav>
  );
}
