import * as React from "react";
import { Button } from "./button";
import { cn } from "../../lib/utils";

interface TopBarProps {
  className?: string;
  onDownloadClick?: () => void;
  onAccountClick?: () => void;
}

const TopBar = React.forwardRef<HTMLElement, TopBarProps>(
  ({ className, onDownloadClick, onAccountClick, ...props }, ref) => {
    return (
      <header
        ref={ref}
        className={cn(
          "sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",
          className,
        )}
        {...props}
      >
        <div className="container flex h-16 items-center justify-between">
          {/* Logo */}
          <div className="flex items-center">
            <div className="flex items-center space-x-2">
              <div className="flex h-8 w-8 items-center justify-center rounded-lg bg-gradient-to-r from-green-500 to-blue-600">
                <span className="text-sm font-bold text-white">📊</span>
              </div>
              <span className="text-xl font-bold bg-gradient-to-r from-green-600 to-blue-600 bg-clip-text text-transparent">
                sheetEasy AI
              </span>
            </div>
          </div>

          {/* Actions */}
          <div className="flex items-center space-x-4">
            <Button
              variant="outline"
              size="sm"
              onClick={onDownloadClick}
              className="hidden sm:inline-flex"
              aria-label="파일 다운로드"
            >
              <svg
                className="mr-2 h-4 w-4"
                fill="none"
                stroke="currentColor"
                viewBox="0 0 24 24"
                xmlns="http://www.w3.org/2000/svg"
              >
                <path
                  strokeLinecap="round"
                  strokeLinejoin="round"
                  strokeWidth={2}
                  d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
                />
              </svg>
              Download
            </Button>

            <Button
              variant="ghost"
              size="sm"
              onClick={onAccountClick}
              className="flex items-center space-x-2"
              aria-label="계정 설정"
            >
              <div className="h-8 w-8 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 flex items-center justify-center">
                <span className="text-xs font-medium text-white">User</span>
              </div>
              <span className="hidden sm:inline-block text-sm font-medium">
                Account
              </span>
            </Button>
          </div>
        </div>
      </header>
    );
  },
);

TopBar.displayName = "TopBar";

export { TopBar };
