'use client';

import Link from "next/link";
import { usePathname } from "next/navigation";

type NavItem = {
  label: string;
  href: string;
};

const ADMIN_SIDEBAR_ITEMS: NavItem[] = [
  { label: "권한 설정", href: "/admin/id" },
  { label: "교육과정 관리", href: "/admin/courses" },
  { label: "강좌 관리", href: "/admin/lessons" },
  { label: "문제 은행", href: "/admin/questions" },
  { label: "수료증 발급/검증키 관리", href: "/admin/certificates" },
  { label: "공지사항", href: "/admin/notices" },
  { label: "학습 자료실", href: "/admin/resources" },
  { label: "로그/접속 기록", href: "/admin/logs" },
  { label: "배너 관리", href: "/admin/banner" },
];

export default function AdminSidebar() {
  const pathname = usePathname();

  return (
    <aside className="w-[320px] border-r border-[#dee1e6] bg-white flex-shrink-0 h-full">
      <nav className="p-4">
        <div className="flex flex-col gap-1">
          {ADMIN_SIDEBAR_ITEMS.map((item) => {
            const isActive = pathname === item.href || (item.href !== "#" && pathname.startsWith(item.href));
            return (
              <Link
                key={item.label}
                href={item.href}
                className={[
                  "flex h-12 items-center px-3 rounded-lg text-[16px] leading-[1.5] transition-colors",
                  isActive
                    ? "bg-[rgba(236,240,255,0.5)] font-bold text-[#1f2b91]"
                    : "font-medium text-[#333c47] hover:bg-[rgba(0,0,0,0.02)]",
                ].join(" ")}
              >
                {item.label}
              </Link>
            );
          })}
        </div>
      </nav>
    </aside>
  );
}

