import React, { useState } from "react";
import SearchIcon from "@mui/icons-material/Search";

const Header = () => {
  const [isSearchVisible, setIsSearchVisible] = useState(false);

  const toggleSearchVisibility = () => {
    setIsSearchVisible(!isSearchVisible);
  };

  return (
    <header className="bg-white shadow">
      <div className="container mx-auto px-4 py-6 flex justify-between items-center">
        <h1 className="text-4xl font-medium">headlines</h1>
        <nav className="space-x-4 flex items-center">
          <button
            className="text-gray-700 hover:text-gray-900 ml-4"
            onClick={toggleSearchVisibility}
            aria-label="Search"
          >
            <SearchIcon style={{ fontSize: "24px", color: "black" }} />
          </button>
          {isSearchVisible && (
            <input
              type="text"
              placeholder="Search..."
              className="ml-4 p-2 border border-gray-300 rounded-md"
            />
          )}
          <a
            href="#"
            className="text-lg font-medium text-gray-700 hover:text-gray-900"
          >
            World
          </a>
          <a
            href="#"
            className="text-lg font-medium text-gray-700 hover:text-gray-900"
          >
            Local{" "}
            <span className="text-sm bg-yellow-300 text-yellow-800 rounded-full px-2 py-1">
              Beta
            </span>
          </a>
          <a
            href="#"
            className="text-lg font-medium text-gray-700 hover:text-gray-900"
          >
            Business
          </a>
          <a
            href="#"
            className="text-lg font-medium text-gray-700 hover:text-gray-900"
          >
            Tech
          </a>
          <a
            href="#"
            className="text-lg font-medium text-gray-700 hover:text-gray-900"
          >
            Culture
          </a>
        </nav>
      </div>
    </header>
  );
};

export default Header;
