"use client";

// Kleine Client-Component für den ⌘K-Button im Header.
// Dispatcht ein Synthetic-KeyboardEvent, das der Command-Palette-Listener fängt.
export function CommandBarButton({ ariaLabel = "Command palette öffnen" }: { ariaLabel?: string }) {
  return (
    <button
      type="button"
      aria-label={ariaLabel}
      data-cursor="hover"
      onClick={() => {
        window.dispatchEvent(new KeyboardEvent("keydown", { key: "k", metaKey: true }));
      }}
      className="flex items-center gap-1.5 rounded border border-hairline bg-[color-mix(in_oklab,var(--panel)_50%,transparent)] px-2.5 py-1.5 font-mono text-xs text-muted transition-colors hover:border-accent hover:text-[var(--fg)]"
    >
      <span className="font-mono text-base leading-none">⌘</span>
      <span>K</span>
    </button>
  );
}
