// app/page.tsx

'use client';

import Link from 'next/link';
import { useState } from 'react';
import { FaFacebookSquare, FaInstagram } from "react-icons/fa";
import { IoIosMail } from "react-icons/io";

export default function Home() {
  const [isMedlemOpen, setIsMedlemOpen] = useState(false);
  const [isPrenumereraOpen, setIsPrenumereraOpen] = useState(false);

  return (
    <div className="min-h-screen flex flex-col font-sans bg-white text-black">

      {/* Header */}
      <header className="bg-black flex justify-center">
        <div className="w-85 mx-auto text-center">
          <Link href="/">
            <img
              src="/images/logo.svg"
              alt="Lerbergets Volleybollsällskap"
              className="max-h-45 min-h-20 my-5.75 mx-auto block"
            />
          </Link>
        </div>
      </header>

      {/* Main Content */}
      <main className="grow flex flex-col">

        {/* Promo Section (Hidden) */}
        <section className="bg-[#fdb84b] justify-center">
          <div className="p-2.5">
            <h2 className="font-beachday text-black text-center text-[clamp(1.5rem,8vw,2.25rem)] uppercase leading-[1.1]">
              Kolla in vår <Link href="/beach" className="text-[#406185] underline">Beachturnering</Link>
            </h2>
          </div>
        </section>

        {/* Hero / Info Section */}
        <section className="bg-[#406185] flex justify-center text-white">
          <div className="flex flex-col md:flex-row max-w-300 my-12.5 mx-5 w-full">

            <div className="flex flex-col justify-center flex-1">
              <div className="w-fit">
                <h1 className="uppercase text-[2.5rem] font-bold leading-[1.1] mb-2.5">LVS</h1>
                <div className="bg-white w-full h-1.5"></div>
              </div>

              <h4 className="italic text-xl my-2.5 leading-[1.2] font-bold">Lerbergets Volleybollsällskap</h4>
              <p className="max-w-200 leading-[1.1]">
                Klubben startade den 1 mars 2018 och har i snabb takt utvecklats med både kidsvolley,
                4-mannavolley och ett gott gäng killar och tjejer som tränar tillsammans minst två gånger i
                veckan och på sommaren spelas det beachvolley
              </p>

              <div className="flex flex-col gap-2.5 mt-10">
                <button
                  onClick={() => setIsMedlemOpen(true)}
                  className="text-[#406185] bg-white border-none py-3.5 px-7.5 text-center font-bold uppercase w-fit text-[1.1rem]"
                >
                  Bli Medlem
                </button>
                <Link
                  href="#traningstider"
                  className="text-[#406185] bg-white border-none py-3.5 px-7.5 text-center font-bold uppercase w-fit text-[1.1rem]"
                >
                  Träningstider
                </Link>
                <a
                  target="_blank"
                  rel="noreferrer"
                  href="https://www.basesport.se/category/lerbergets-vbk"
                  className="text-[#406185] bg-white border-none py-3.5 px-7.5 text-center font-bold uppercase w-fit text-[1.1rem]"
                >
                  Klubbkollektion
                </a>
              </div>
            </div>

            {/* Player Image with restored animation class */}
            <div className="hidden md:flex items-center p-2.5 justify-end max-h-full">
              <img
                src="/images/player.webp"
                alt="Volleyboll spelare"
                className="max-h-112.5 player-animation"
              />
            </div>
          </div>
        </section>

        {/* Träningstider Section - Restored to vertical stacking */}
        <section id="traningstider" className="bg-white flex justify-center">
          <div className="flex flex-col items-center w-full my-7.5 gap-2">

            <div className="bg-[#406185] text-white w-full max-w-180 py-5 px-2.5 text-center">
              <h2 className="uppercase text-[clamp(1.5rem,8vw,2.25rem)] font-bold">Träningstider</h2>
              <p className="my-3.75 text-[1rem] leading-[1.1]">Här hittar du alltid uppdaterade träningstider från Laget.se</p>
              <a
                target="_blank"
                rel="noreferrer"
                href="https://www.laget.se/LVS/Event/Month"
                className="text-[#f1c50e] border-b-2 border-[#f1c50e] font-bold uppercase"
              >
                Se nästa träningstid
              </a>
            </div>

            <div className="bg-[#406185] text-white w-full max-w-180 py-5 px-2.5 text-center">
              <h2 className="uppercase text-[clamp(1.5rem,8vw,2.25rem)] font-bold">Prenumerera på träningstider</h2>
              <p className="my-3.75 text-[1rem] leading-[1.1]">Våra träningstider finns som en kalender man kan prenumerera på genom knappen nedan</p>
              <button
                onClick={() => setIsPrenumereraOpen(true)}
                className="text-[#f1c50e] border-b-2 border-[#f1c50e] font-bold uppercase pb-0.5 cursor-pointer"
              >
                Prenumerera
              </button>
            </div>

          </div>
        </section>

        {/* Kontakt Section */}
        <section className="bg-[#406185] flex justify-center text-white">
          <div className="flex flex-wrap-reverse justify-center gap-7.5 w-full max-w-300 my-10 px-5">

            <div className="flex flex-wrap justify-center items-center gap-7.5 mx-5">
              <a target="_blank" rel="noreferrer" title="Instagram" href="https://www.instagram.com/lerbergets_volleyboll/">
                <FaInstagram className='h-20 w-20' />
              </a>
              <a target="_blank" rel="noreferrer" title="Facebook" href="https://www.facebook.com/lerbergetsvolleyboll">
                <FaFacebookSquare className='h-20 w-20' />
              </a>
              <a target="_blank" rel="noreferrer" title="Laget.se" href="https://www.laget.se/LVS">
                <img src="/images/laget.se.svg" alt="Laget.se" className="h-18 w-18" />
              </a>
            </div>

            <div className="text-center p-2.5 flex flex-col justify-center items-center">
              <h3 className="uppercase font-bold text-[1.875rem] leading-[1.2]">Kontakta oss</h3>
              <p className="text-[1rem] leading-[1.6] my-1.25">Vi finns på Instagram, Facebook och laget.se</p>
              <p className="text-[1rem] leading-[1.6] my-1.25">Höganäs Sportcenter, Friluftsvägen 10, 263 54 Lerberget</p>
              <a
                href="mailto:info@lerbergetsvolleyboll.se?subject=Kontakta%20oss"
                className="flex justify-center items-center text-[#f1c50e] font-bold text-[1rem] leading-[1.6] my-1.25"
              >
                <IoIosMail color='#f1c50e' className='h-6 w-6' />
                info@lerbergetsvolleyboll.se
              </a>
            </div>

          </div>
        </section>

      </main>

      {/* Footer */}
      <footer className="bg-black text-[#lightgrey] text-center py-3.75">
        <p className="font-bold text-[#d3d3d3]">LVS - Lerbergets Volleybollsällskap {new Date().getFullYear()} ®</p>
      </footer>

      {/* --- MODALS --- */}
      {/* Medlem Modal */}
      {isMedlemOpen && (
        <div
          className="fixed inset-0 z-50 bg-black/60 flex justify-center items-center overflow-auto"
          onClick={() => setIsMedlemOpen(false)}
        >
          <div
            className="bg-white p-5 w-[80vw] max-w-max min-w-75 rounded-[15px] relative flex flex-col items-center text-center font-semibold text-[#406185]"
            onClick={(e) => e.stopPropagation()}
          >
            <button
              className="absolute right-3.75 top-3.75 w-5 h-5 block mx-auto"
              onClick={() => setIsMedlemOpen(false)}
            >
              <svg viewBox="0 0 413.348 413.348" className="fill-black">
                <path d="m413.348 24.354-24.354-24.354-182.32 182.32-182.32-182.32-24.354 24.354 182.32 182.32-182.32 182.32 24.354 24.354 182.32-182.32 182.32 182.32 24.354-24.354-182.32-182.32z" />
              </svg>
            </button>

            <img src="/images/logo-black.svg" alt="Logo" className="h-25" />
            <h2 className="text-[#406185] my-2.5 text-2xl font-bold uppercase">Registrera dig</h2>
            <p className="text-[#406185] my-2.5">Trycka på knappen nedan för att starta registreringen. Du kommer att skickas till laget.se</p>
            <a
              href="https://www.laget.se/LVS/Member"
              target="_blank"
              rel="noreferrer"
              className="text-white bg-[#406185] uppercase font-bold py-2.25 px-11.5 mt-5 rounded-[50px] text-[1rem]"
            >
              Bli medlem
            </a>
          </div>
        </div>
      )}

      {/* Prenumerera Modal */}
      {isPrenumereraOpen && (
        <div
          className="fixed inset-0 z-50 bg-black/60 flex justify-center items-center overflow-auto"
          onClick={() => setIsPrenumereraOpen(false)}
        >
          <div
            className="bg-white p-5 w-[80vw] max-w-max min-w-75 rounded-[15px] relative flex flex-col items-center text-center font-semibold text-[#406185]"
            onClick={(e) => e.stopPropagation()}
          >
            <button
              className="absolute right-3.75 top-3.75 w-5 h-5 block mx-auto"
              onClick={() => setIsPrenumereraOpen(false)}
            >
              <svg viewBox="0 0 413.348 413.348" className="fill-black">
                <path d="m413.348 24.354-24.354-24.354-182.32 182.32-182.32-182.32-24.354 24.354 182.32 182.32-182.32 182.32 24.354 24.354 182.32-182.32 182.32 182.32 24.354-24.354-182.32-182.32z" />
              </svg>
            </button>

            <h2 className="text-[#406185] my-2.5 text-2xl font-bold uppercase">Prenumerera</h2>
            <p className="text-[#406185] my-2.5">Välj vilken LEVEL du vill prenumerera på.</p>

            <div className="flex flex-row flex-wrap justify-center gap-6.25 mt-5 max-w-162.5">
              <a href="webcal://cal.laget.se/lvs-level-5-6.ics" className="text-white bg-[#406185] uppercase font-bold py-2.25 px-11.5 rounded-[50px] text-[1rem]">Level 5-6</a>
              <a href="webcal://cal.laget.se/lvs-level-7-8.ics" className="text-white bg-[#406185] uppercase font-bold py-2.25 px-11.5 rounded-[50px] text-[1rem]">level 7-8</a>
              <a href="webcal://cal.laget.se/lvs-level-8-9.ics" className="text-white bg-[#406185] uppercase font-bold py-2.25 px-11.5 rounded-[50px] text-[1rem]">Level 8-9</a>
              <a href="webcal://cal.laget.se/lvs-level-10.ics" className="text-white bg-[#406185] uppercase font-bold py-2.25 px-11.5 rounded-[50px] text-[1rem]">Level 10</a>
              <a href="webcal://cal.laget.se/LVS.ics" className="text-white bg-[#406185] uppercase font-bold py-2.25 px-11.5 rounded-[50px] text-[1rem]">Hela klubben</a>
            </div>
          </div>
        </div>
      )}

    </div>
  );
}