"use client";

import { cn } from "@/lib/utils";
import { useSidebarStore } from "@/lib/stores/sidebar-store";

import { NavTree } from "./nav-tree";
import { SidebarHeader } from "./sidebar-header";

export function Sidebar({
  onOpenSearch,
  onQuickAction,
}: {
  onOpenSearch?: () => void;
  onQuickAction?: (type: string) => void;
}) {
  const collapsed = useSidebarStore((s) => s.isCollapsed);

  return (
    <aside
      className={cn(
        "flex h-full shrink-0 flex-col overflow-hidden border-r border-sidebar-border bg-sidebar text-sidebar-foreground transition-[width] duration-200 ease-out",
        collapsed ? "w-12" : "w-[240px]",
      )}
    >
      <SidebarHeader
        collapsed={collapsed}
        onOpenSearch={onOpenSearch}
        onQuickAction={onQuickAction}
      />
      <div className="min-h-0 flex-1 overflow-hidden">
        <NavTree collapsed={collapsed} />
      </div>
    </aside>
  );
}
