"use client";

import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import {
  LayoutDashboard,
  Briefcase,
  Users,
  MessageSquare,
  Settings,
  Building2,
  BarChart3,
  Plus,
} from "lucide-react";
import Link from "next/link";
import { usePathname } from "next/navigation";

interface CompanySidebarProps {
  className?: string;
}

export function CompanySidebar({ className }: CompanySidebarProps) {
  const pathname = usePathname();

  const routes = [
    {
      label: "Dashboard",
      icon: LayoutDashboard,
      href: "/dashboard/empresa",
      active: pathname === "/dashboard/empresa",
    },
    {
      label: "Minhas Vagas",
      icon: Briefcase,
      href: "/dashboard/empresa/vagas",
      active: pathname?.startsWith("/dashboard/empresa/vagas"),
    },
    {
      label: "Candidaturas",
      icon: Users,
      href: "/dashboard/empresa/candidaturas",
      active: pathname?.startsWith("/dashboard/empresa/candidaturas"),
    },
    {
      label: "Mensagens",
      icon: MessageSquare,
      href: "/dashboard/empresa/mensagens",
      active: pathname?.startsWith("/dashboard/empresa/mensagens"),
    },
    {
      label: "Relatórios",
      icon: BarChart3,
      href: "/dashboard/empresa/relatorios",
      active: pathname?.startsWith("/dashboard/empresa/relatorios"),
    },
    {
      label: "Perfil da Empresa",
      icon: Building2,
      href: "/dashboard/empresa/perfil",
      active: pathname?.startsWith("/dashboard/empresa/perfil"),
    },
    {
      label: "Configurações",
      icon: Settings,
      href: "/dashboard/empresa/configuracoes",
      active: pathname?.startsWith("/dashboard/empresa/configuracoes"),
    },
  ];

  return (
    <div className={cn("pb-12 min-h-screen border-r bg-muted/10", className)}>
      <div className="space-y-4 py-4">
        <div className="px-3 py-2">
          <div className="flex items-center gap-3 mb-6 px-3">
            <Avatar className="h-10 w-10">
              <AvatarImage src="" />
              <AvatarFallback className="bg-primary/10 text-primary">
                <Building2 className="h-5 w-5" />
              </AvatarFallback>
            </Avatar>
            <div className="flex-1 min-w-0">
              <h2 className="text-lg font-semibold truncate">TechCorp</h2>
              <p className="text-xs text-muted-foreground truncate">Empresa</p>
            </div>
          </div>

          <Link href="/dashboard/empresa/vagas/nova">
            <Button className="w-full mb-4" size="lg">
              <Plus className="h-4 w-4 mr-2" />
              Nova Vaga
            </Button>
          </Link>

          <div className="space-y-1">
            {routes.map((route) => (
              <Link key={route.href} href={route.href}>
                <Button
                  variant={route.active ? "secondary" : "ghost"}
                  className={cn(
                    "w-full justify-start",
                    route.active && "bg-secondary"
                  )}
                >
                  <route.icon className="mr-2 h-4 w-4" />
                  {route.label}
                </Button>
              </Link>
            ))}
          </div>
        </div>
      </div>
    </div>
  );
}
