import React from "react";
import { Icon } from "./icon";

interface MobileTerminalHeaderProps {
  instanceName?: string;
  onBack?: () => void;
  onMenuToggle?: () => void;
  onClose?: () => void;
  isVisible: boolean;
  connectionStatus?: "connecting" | "connected" | "disconnected" | "error";
}

export const MobileTerminalHeader: React.FC<MobileTerminalHeaderProps> = ({
  instanceName,
  onBack,
  onMenuToggle,
  onClose,
  isVisible,
  connectionStatus = "connecting",
}) => {
  return (
    <div
      className={`mobile-terminal-header ${isVisible ? "visible" : "hidden"}`}
    >
      <div className="mobile-terminal-header-left">
        {onBack && (
          <button
            className="mobile-terminal-header-button"
            onClick={onBack}
            type="button"
            aria-label="Go back"
          >
            <Icon name="arrow-left" size="sm" />
          </button>
        )}
        {onMenuToggle && (
          <button
            className="mobile-terminal-header-button"
            onClick={onMenuToggle}
            type="button"
            aria-label="Toggle menu"
          >
            <Icon name="menu" size="sm" />
          </button>
        )}
      </div>

      <div className="mobile-terminal-header-center">
        <span className="mobile-terminal-header-title">
          {instanceName || "Terminal"}
        </span>
        <span
          className={`mobile-terminal-header-status ${connectionStatus}`}
          aria-label={`Connection status: ${connectionStatus}`}
        />
      </div>

      <div className="mobile-terminal-header-right">
        {onClose && (
          <button
            className="mobile-terminal-header-button"
            onClick={onClose}
            type="button"
            aria-label="Close terminal"
          >
            <Icon name="close" size="sm" />
          </button>
        )}
      </div>
    </div>
  );
};
