"use client";

import { X } from "lucide-react";

import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";

interface PanelHeaderProps {
  title: string;
  description?: string;
  onClose: () => void;
  className?: string;
}

export function PanelHeader({
  title,
  description,
  onClose,
  className,
}: PanelHeaderProps) {
  return (
    <div
      className={cn(
        "flex shrink-0 items-start justify-between gap-3 border-b border-border px-4 py-3",
        className,
      )}
    >
      <div className="min-w-0 flex-1">
        <h2 className="truncate text-sm font-semibold leading-tight text-foreground">
          {title}
        </h2>
        {description ? (
          <p className="mt-0.5 text-xs text-muted-foreground">{description}</p>
        ) : null}
      </div>
      <Button
        type="button"
        variant="ghost"
        size="icon"
        className="size-8 shrink-0"
        onClick={onClose}
        aria-label="Close panel"
      >
        <X className="size-4" />
      </Button>
    </div>
  );
}
