import React from 'react';
import './TitleBar.css';

const TitleBar: React.FC = () => {
	const handleMinimize = () => {
		window.electronAPI?.minimize();
	};

	const handleMaximize = () => {
		window.electronAPI?.maximize();
	};

	const handleClose = () => {
		window.electronAPI?.close();
	};

	return (
		<div className="titlebar draggable">
			<div className="titlebar-left">
				<div className="logo">
					<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor">
						<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" />
					</svg>
				</div>
				<span className="titlebar-title">柔性敏捷智能测试体系平台</span>
			</div>

			<div className="titlebar-controls no-drag">
				<button className="control-btn" onClick={handleMinimize} title="最小化">
					<svg viewBox="0 0 16 16" width="12" height="12">
						<rect x="3" y="7" width="10" height="2" fill="currentColor" />
					</svg>
				</button>
				<button className="control-btn" onClick={handleMaximize} title="最大化">
					<svg viewBox="0 0 16 16" width="12" height="12">
						<rect x="3" y="3" width="10" height="10" stroke="currentColor" strokeWidth="2" fill="none" />
					</svg>
				</button>
				<button className="control-btn close-btn" onClick={handleClose} title="关闭">
					<svg viewBox="0 0 16 16" width="12" height="12">
						<path d="M3 3l10 10M13 3l-10 10" stroke="currentColor" strokeWidth="2" />
					</svg>
				</button>
			</div>
		</div>
	);
};

export default TitleBar;
