"use client";

import * as React from "react";
import { Buildings } from '@/lib/icons';

import { CommandSearch } from "@/components/command-search";
import { ModeToggle } from "@/components/mode-toggle";
import { Separator } from "@/components/ui/separator";
import { SidebarTrigger } from "@/components/ui/sidebar";

import type { ShellCompany } from "@/app/(dashboard)/dashboard-shell";

export function SiteHeader({ company }: { company?: ShellCompany }) {
  return (
    <header className="flex h-(--header-height) shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-(--header-height)">
      <div className="flex w-full items-center gap-1 px-4 py-3 lg:gap-2 lg:px-6">
        <SidebarTrigger className="-ml-1" />
        <Separator
          orientation="vertical"
          className="mx-2 data-[orientation=vertical]:h-4"
        />

        {company && (
          <div className="text-muted-foreground hidden items-center gap-1.5 text-sm md:flex">
            <Buildings className="size-3.5" />
            <span className="max-w-[260px] truncate">{company.name}</span>
          </div>
        )}

        <div className="ml-auto flex items-center gap-2">
          <div className="hidden w-full max-w-sm md:block">
            <CommandSearch />
          </div>
          <ModeToggle />
        </div>
      </div>
    </header>
  );
}
