"use client";

import { useState } from "react";

const modalData = {
    contact: `
        <h2>Connect With Us</h2>
        <p>For any inquiries, technical assistance, or content-related questions, please reach out to our dedicated support team. We are here to ensure your experience is seamless and delightful.</p>
        <p>Email: <a href="mailto:dmcareportmail@gmail.com">dmcareportmail@gmail.com</a></p>
        <p>We endeavor to respond to all messages with care and efficiency, typically within 24–48 business hours.</p>
        <p>To help us assist you more effectively, kindly include the exact document title or URL when reporting an issue.</p>
    `,
    dmca: `
        <h2>DMCA & Copyright Information</h2>
        <p>We hold intellectual property rights in high regard and strictly adhere to the Digital Millennium Copyright Act (DMCA). Our commitment is to respect creators and their work.</p>
        <p>If you believe that any content accessible through our platform infringes upon your copyright, we invite you to submit a formal written notification. Please include:</p>
        <ul>
            <li>Clear identification of the copyrighted work you claim has been infringed.</li>
            <li>The precise URL(s) of the material on our site that you allege is infringing.</li>
            <li>Your complete contact information (name, address, telephone number, and email address).</li>
            <li>A statement affirming your good-faith belief that the use of the material is not authorized by the copyright owner, its agent, or the law.</li>
            <li>A statement, made under penalty of perjury, that the information in your notice is accurate and that you are the copyright owner or authorized to act on the copyright owner's behalf.</li>
            <li>Your electronic or physical signature.</li>
        </ul>
        <p>Please direct all DMCA notices to:</p>
        <p><a href="mailto:dmcareportmail@gmail.com">dmcareportmail@gmail.com</a></p>
        <p>Upon receipt of a valid notification, we will promptly review and take appropriate action in accordance with DMCA guidelines, ensuring fairness and compliance.</p>
    `,
    about: `
        <h2>About Our Curated Space</h2>
        <p>This platform is thoughtfully designed as an automated document indexing and reference system, dedicated to gracefully organizing publicly accessible materials. Our aim is to create a serene and efficient gateway to knowledge.</p>
        <p>Our mission is to enhance the discoverability and provide structured access to a world of educational and informational documents across diverse topics, presented with an aesthetic touch that inspires.</p>
        <p>We do not claim ownership of third-party materials; all rights remain with their respective authors and publishers. We are simply a conduit, connecting you to valuable resources.</p>
        <p>Should you be a rights holder with any concerns regarding a listing, please do not hesitate to contact us directly. Your peace of mind and intellectual property are of utmost importance to us.</p>
    `,
    privacy: `
        <h2>Your Privacy, Our Priority</h2>
        <p>Your privacy is a cornerstone of our philosophy. We operate this site with a commitment to minimal data collection, ensuring a tranquil and secure browsing experience for all our visitors.</p>
        <ul>
            <li>No account registration is ever required – explore freely and anonymously!</li>
            <li>Your personal data is never sold, shared, or exploited for any purpose.</li>
            <li>We consciously avoid invasive tracking technologies, respecting your digital footprint and personal space.</li>
        </ul>
        <p>Basic server logs may be recorded for essential security, performance monitoring, and abuse prevention. These practices are solely to maintain the integrity and smooth operation of our service.</p>
        <p>By embracing our site, you agree to standard web server logging practices necessary for a seamless and secure experience. For any privacy concerns or questions, please connect with us at: <a href="mailto:dmcareportmail@gmail.com">dmcareportmail@gmail.com</a></p>
    `
};

export default function Footer({ domain }: { domain: string }) {
  const [isOpen, setIsOpen] = useState(false);
  const [content, setContent] = useState("");

  const openModal = (type: keyof typeof modalData) => {
    setContent(modalData[type]);
    setIsOpen(true);
  };

  return (
    <>
      <footer className="bg-white border-t py-8 mt-12 w-full">
        <div className="max-w-6xl mx-auto px-6 flex flex-col items-center">
          <div className="flex flex-wrap justify-center gap-4 mb-6 text-sm font-semibold text-gray-500 uppercase tracking-widest">
            <button onClick={() => openModal('about')} className="hover:text-blue-600 transition cursor-pointer">About</button>
            <button onClick={() => openModal('contact')} className="hover:text-blue-600 transition cursor-pointer">Contact</button>
            <button onClick={() => openModal('privacy')} className="hover:text-blue-600 transition cursor-pointer">Privacy</button>
            <button onClick={() => openModal('dmca')} className="hover:text-blue-600 transition cursor-pointer">DMCA</button>
          </div>
          <div className="text-sm text-gray-400 text-center">
            &copy; {new Date().getFullYear()} {domain}. All rights reserved.
          </div>
        </div>
      </footer>

      {isOpen && (
        <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-gray-900/60 backdrop-blur-sm transition-opacity">
          <div className="bg-white rounded-2xl shadow-2xl w-full max-w-2xl p-8 md:p-10 relative max-h-[90vh] overflow-y-auto transform transition-all scale-100 opacity-100">
            <button 
              onClick={() => setIsOpen(false)}
              className="absolute top-5 right-5 p-2 text-gray-400 hover:text-gray-900 bg-gray-100 rounded-full transition cursor-pointer"
            >
              <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M6 18L18 6M6 6l12 12"></path>
              </svg>
            </button>
            
            <div 
              className="prose prose-blue max-w-none prose-h2:mt-0 prose-h2:text-2xl prose-h2:mb-6 prose-p:text-gray-600 prose-li:text-gray-600"
              dangerouslySetInnerHTML={{ __html: content }} 
            />
          </div>
        </div>
      )}
    </>
  );
}
