import { useState } from 'react';
import Link from 'next/link';
import { Menu } from 'lucide-react';
import Sidebar from './Sidebar';

export default function Navbar() {
  const [open, setOpen] = useState(false);

  return (
    <header className="fixed top-0 left-0 w-full bg-background shadow-sm z-50">
      <div className="container mx-auto flex items-center justify-between h-16 px-4">
        {/* 左侧 Logo + 导航 */}
        <div className="flex items-center space-x-4">
          {/* 移动端菜单按钮 */}
          <button className="md:hidden p-2 focus:outline-none" onClick={() => setOpen(true)}>
            <Menu className="h-6 w-6 text-primary" />
          </button>
          <Link href="/">
            <img src="/logo.png" alt="CloudProxy" className="h-8 w-8" />
          </Link>
          {/* 桌面端导航链接 */}
          <nav className="hidden md:flex items-center space-x-4">
            <Link href="/" className="text-primary font-semibold">首页</Link>
            <Link href="/features" className="text-gray-600 hover:text-primary">产品与服务</Link>
            <Link href="/news" className="text-gray-600 hover:text-primary">新闻资讯</Link>
            <Link href="/cases" className="text-gray-600 hover:text-primary">客户案例</Link>
            <Link href="/about" className="text-gray-600 hover:text-primary">关于我们</Link>
          </nav>
        </div>

        {/* 右侧操作入口 */}
        <div className="flex items-center space-x-4">
          <Link href="/login" className="px-4 py-1 border border-primary rounded-full text-primary hover:bg-primary hover:text-white transition">
            Log in
          </Link>
          <a href="https://instagram.com" target="_blank" rel="noopener noreferrer">
            <i className="fab fa-instagram text-gray-600 hover:text-primary" />
          </a>
          <a href="https://facebook.com" target="_blank" rel="noopener noreferrer">
            <i className="fab fa-facebook text-gray-600 hover:text-primary" />
          </a>
          <a href="https://twitter.com" target="_blank" rel="noopener noreferrer">
            <i className="fab fa-twitter text-gray-600 hover:text-primary" />
          </a>
        </div>
      </div>

      {/* 侧边栏 */}
      <Sidebar open={open} onClose={() => setOpen(false)} />
    </header>
  )}