import React, { useState } from 'react';
import Link from 'next/link';
import { mdiMenu, mdiClose } from '@mdi/js';
import BaseIcon from './BaseIcon';
import Logo from './Logo';
import { webPagesNavBar } from '../menuNavBar';

interface Props {
  projectName: string;
}

export default function WebHeader({ projectName }: Props) {
  const [isMenuOpen, setIsMenuOpen] = useState(false);

  return (
    <header className="bg-white dark:bg-slate-900 border-b border-gray-100 dark:border-slate-800 sticky top-0 z-50">
      <div className="container mx-auto px-6 h-16 flex items-center justify-between">
        <Link href="/" className="flex items-center gap-2">
          <Logo className="w-8 h-8 text-indigo-600" />
          <span className="text-xl font-bold tracking-tight text-gray-900 dark:text-white uppercase">{projectName}</span>
        </Link>

        {/* Desktop Nav */}
        <nav className="hidden md:flex items-center gap-8">
          {webPagesNavBar.map((item, idx) => (
            <Link 
              key={idx} 
              href={item.href} 
              className="text-sm font-semibold text-gray-600 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors"
            >
              {item.label}
            </Link>
          ))}
        </nav>

        {/* Mobile Toggle */}
        <button 
          className="md:hidden text-gray-600 dark:text-gray-400"
          onClick={() => setIsMenuOpen(!isMenuOpen)}
        >
          <BaseIcon path={isMenuOpen ? mdiClose : mdiMenu} size={24} />
        </button>
      </div>

      {/* Mobile Menu */}
      {isMenuOpen && (
        <div className="md:hidden bg-white dark:bg-slate-900 border-b border-gray-100 dark:border-slate-800 px-6 py-4 space-y-4 shadow-lg">
          {webPagesNavBar.map((item, idx) => (
            <Link 
              key={idx} 
              href={item.href} 
              className="block text-base font-semibold text-gray-600 dark:text-gray-400 hover:text-indigo-600"
              onClick={() => setIsMenuOpen(false)}
            >
              {item.label}
            </Link>
          ))}
        </div>
      )}
    </header>
  );
}
