"use client";

import Link from "next/link";
import { useState } from "react";

const logoImage = "http://localhost:3845/assets/89fda8e949171025b1232bae70fc9d442e4e70c8.png";
const chevronIcon = "http://localhost:3845/assets/6abc26b721560f9d3c51cf552531775f54f2f86a.svg";

export default function Home() {
  const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
  const [isUserMenuOpen, setIsUserMenuOpen] = useState(false);

  return (
    <div className="flex flex-col flex-1 bg-white">
      {/* 헤더 */}
      <header className="bg-white shadow-sm sticky top-0 z-50">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-16">
          <div className="flex flex-row justify-between items-center gap-4 py-6">
            {/* 로고/메뉴 그룹 */}
            <div className="flex items-center gap-9 flex-1">
              {/* Company 로고 */}
              <div className="flex items-center gap-2">
                <div className="h-9 relative w-[46.703px]">
                  <img 
                    alt="XR LMS Logo" 
                    className="h-full w-full object-contain" 
                    src={logoImage} 
                  />
                </div>
                <h1 className="text-2xl font-bold text-black leading-[1.45] whitespace-pre">XR LMS</h1>
              </div>
              
              {/* 네비게이션 메뉴 */}
              <nav className="hidden md:flex items-center">
                <div className="flex gap-0.5">
                  <Link href="#" className="px-4 py-2 text-[#111111] font-bold text-base hover:text-blue-600 transition">
                    과목 목록
                  </Link>
                  <Link href="#" className="px-4 py-2 text-[#111111] font-bold text-base hover:text-blue-600 transition">
                    학습 자료실
                  </Link>
                  <Link href="#" className="px-4 py-2 text-[#111111] font-bold text-base hover:text-blue-600 transition">
                    공지사항
                  </Link>
                  <Link href="#" className="px-4 py-2 text-[#111111] font-bold text-base hover:text-blue-600 transition">
                    기관소개
                  </Link>
                  <Link href="#" className="px-4 py-2 text-[#111111] font-bold text-base hover:text-blue-600 transition">
                    교육소개
                  </Link>
                </div>
              </nav>
            </div>
            
            {/* 사용자 메뉴 그룹 */}
            <nav className="flex items-center gap-6 shrink-0">
              <div className="hidden md:flex items-center gap-6">
                <Link
                  href="#"
                  className="px-4 py-2 text-[#5f5f5f] font-bold text-base hover:text-blue-600 transition h-9 flex items-center"
                >
                  내 강의실
                </Link>
                <div className="relative">
                  <button
                    onClick={() => setIsUserMenuOpen(!isUserMenuOpen)}
                    className="flex items-center gap-1 px-4 py-2 text-[#5f5f5f] font-bold text-base hover:text-blue-600 transition h-9"
                  >
                    <span>조유주</span>
                    <div className="rotate-180">
                      <img 
                        src={chevronIcon} 
                        alt="chevron" 
                        className="w-6 h-6"
                      />
                    </div>
                  </button>
                  {/* 사용자 메뉴 드롭다운 */}
                  {isUserMenuOpen && (
                    <div className="absolute right-0 mt-2 bg-white border border-gray-200 rounded-md shadow-lg py-2 min-w-[120px]">
                      <Link href="#" className="block px-4 py-2 text-gray-700 hover:bg-gray-100">프로필</Link>
                      <Link href="#" className="block px-4 py-2 text-gray-700 hover:bg-gray-100">설정</Link>
                      <Link href="#" className="block px-4 py-2 text-gray-700 hover:bg-gray-100">로그아웃</Link>
                    </div>
                  )}
                </div>
              </div>
              
              {/* 모바일 햄버거 메뉴 아이콘 */}
              <button
                className="md:hidden p-2 text-gray-700 hover:text-blue-600 transition"
                onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
                aria-label="메뉴"
              >
                <svg
                  className="w-6 h-6"
                  fill="none"
                  stroke="currentColor"
                  viewBox="0 0 24 24"
                >
                  {isMobileMenuOpen ? (
                    <path
                      strokeLinecap="round"
                      strokeLinejoin="round"
                      strokeWidth={2}
                      d="M6 18L18 6M6 6l12 12"
                    />
                  ) : (
                    <path
                      strokeLinecap="round"
                      strokeLinejoin="round"
                      strokeWidth={2}
                      d="M4 6h16M4 12h16M4 18h16"
                    />
                  )}
                </svg>
              </button>
            </nav>
          </div>
          
          {/* 모바일 메뉴 */}
          {isMobileMenuOpen && (
            <div className="md:hidden border-t border-gray-200 py-4">
              <nav className="flex flex-col space-y-4">
                <Link href="#" className="text-gray-700 hover:text-blue-600 transition px-2 font-bold">과목 목록</Link>
                <Link href="#" className="text-gray-700 hover:text-blue-600 transition px-2 font-bold">학습 자료실</Link>
                <Link href="#" className="text-gray-700 hover:text-blue-600 transition px-2 font-bold">공지사항</Link>
                <Link href="#" className="text-gray-700 hover:text-blue-600 transition px-2 font-bold">기관소개</Link>
                <Link href="#" className="text-gray-700 hover:text-blue-600 transition px-2 font-bold">교육소개</Link>
                <div className="pt-4 border-t border-gray-200 flex flex-col space-y-2">
                  <Link
                    href="#"
                    className="px-4 py-2 text-gray-700 hover:text-blue-600 transition font-bold"
                  >
                    내 강의실
                  </Link>
                  <Link 
                    href="#"
                    className="px-4 py-2 text-gray-700 hover:text-blue-600 transition font-bold"
                  >
                    조유주
                  </Link>
                </div>
              </nav>
            </div>
          )}
        </div>
      </header>

      {/* 히어로 섹션 */}
      <section className="bg-gradient-to-r from-blue-600 to-purple-600 text-white py-20">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
          <h2 className="text-5xl font-bold mb-6">
            혁신적인 XR 학습 플랫폼
          </h2>
          <p className="text-xl mb-8 text-blue-100">
            몰입형 경험을 통해 새로운 차원의 학습을 시작하세요
          </p>
          <div className="flex justify-center space-x-4">
            <Link
              href="/login"
              className="px-8 py-3 bg-white text-blue-600 rounded-lg font-semibold hover:bg-gray-100 transition"
            >
              시작하기
            </Link>
            <button className="px-8 py-3 bg-transparent border-2 border-white text-white rounded-lg font-semibold hover:bg-white hover:text-blue-600 transition">
              알아보기
            </button>
          </div>
        </div>
      </section>

      {/* 주요 기능 */}
      <section className="py-20 bg-gray-50">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <h3 className="text-3xl font-bold text-center mb-12">주요 기능</h3>
          <div className="grid md:grid-cols-3 gap-8">
            <div className="bg-white p-6 rounded-lg shadow-md hover:shadow-lg transition">
              <div className="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mb-4">
                <svg className="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" />
                </svg>
              </div>
              <h4 className="text-xl font-semibold mb-2">다양한 강의</h4>
              <p className="text-gray-600">
                XR 기술을 활용한 몰입형 학습 경험을 제공합니다
              </p>
            </div>
            <div className="bg-white p-6 rounded-lg shadow-md hover:shadow-lg transition">
              <div className="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mb-4">
                <svg className="w-6 h-6 text-purple-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
                </svg>
              </div>
              <h4 className="text-xl font-semibold mb-2">커뮤니티</h4>
              <p className="text-gray-600">
                학습자들과 함께 소통하고 경험을 공유하세요
              </p>
            </div>
            <div className="bg-white p-6 rounded-lg shadow-md hover:shadow-lg transition">
              <div className="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mb-4">
                <svg className="w-6 h-6 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
                </svg>
              </div>
              <h4 className="text-xl font-semibold mb-2">학습 추적</h4>
              <p className="text-gray-600">
                진도율과 성취도를 한눈에 확인하고 관리하세요
              </p>
            </div>
          </div>
        </div>
      </section>

      {/* 인기 강의 */}
      <section className="py-20">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <h3 className="text-3xl font-bold text-center mb-12">인기 강의</h3>
          <div className="grid md:grid-cols-4 gap-6">
            {[1, 2, 3, 4].map((item) => (
              <div key={item} className="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-lg transition cursor-pointer">
                <div className="h-48 bg-gradient-to-br from-blue-400 to-purple-500"></div>
                <div className="p-4">
                  <h4 className="font-semibold mb-2">XR 기초 강의 {item}</h4>
                  <p className="text-sm text-gray-600 mb-2">강사명 • {item * 10}명 수강</p>
                  <div className="flex items-center justify-between">
                    <span className="text-blue-600 font-semibold">무료</span>
                    <span className="text-yellow-500">⭐ 4.{item + 5}</span>
                  </div>
                </div>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* 푸터 */}
      <footer className="bg-gray-900 text-white py-12">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <div className="grid md:grid-cols-4 gap-8">
            <div>
              <h4 className="text-xl font-bold mb-4">XR LMS</h4>
              <p className="text-gray-400 text-sm">
                혁신적인 학습 경험을 제공하는 플랫폼
              </p>
            </div>
            <div>
              <h5 className="font-semibold mb-4">학습</h5>
              <ul className="space-y-2 text-sm text-gray-400">
                <li><Link href="#" className="hover:text-white transition">강의 목록</Link></li>
                <li><Link href="#" className="hover:text-white transition">카테고리</Link></li>
                <li><Link href="#" className="hover:text-white transition">신규 강의</Link></li>
              </ul>
            </div>
            <div>
              <h5 className="font-semibold mb-4">지원</h5>
              <ul className="space-y-2 text-sm text-gray-400">
                <li><Link href="#" className="hover:text-white transition">공지사항</Link></li>
                <li><Link href="#" className="hover:text-white transition">FAQ</Link></li>
                <li><Link href="#" className="hover:text-white transition">문의하기</Link></li>
              </ul>
            </div>
            <div>
              <h5 className="font-semibold mb-4">회사</h5>
              <ul className="space-y-2 text-sm text-gray-400">
                <li><Link href="#" className="hover:text-white transition">소개</Link></li>
                <li><Link href="#" className="hover:text-white transition">이용약관</Link></li>
                <li><Link href="#" className="hover:text-white transition">개인정보처리방침</Link></li>
              </ul>
            </div>
          </div>
          <div className="mt-8 pt-8 border-t border-gray-800 text-center text-sm text-gray-400">
            © 2024 XR LMS. All rights reserved.
          </div>
        </div>
      </footer>
    </div>
  );
}
