import React, { useState, useEffect } from 'react';
import { createRoot } from 'react-dom/client';
import {
  Menu,
  X,
  Download,
  Users,
  CheckCheck,
  FileText,
  ShieldAlert,
  Heart,
  Calendar,
  Facebook,
  Mail,
  Play,
  Phone,
  User,
  CheckCircle,
  Info,
  Home,
  Search,
  MessageSquare,
  Instagram,
  Twitter,
  Youtube,
  Linkedin,
  Eye,
  UserPlus,
  Globe,
  Mic,
  Video,
  Sparkles,
  ArrowRight,
  Star
} from 'lucide-react';

// --- Data Constants ---
const PLAY_STORE_LINK = "https://play.google.com/store/apps/details?id=com.disomvlog.topol";
const FACEBOOK_LINK = "https://fb.me/disomvlog.online";
const INSTAGRAM_LINK = "https://instagram.com/disomvlog.online";
const YOUTUBE_LINK = "https://youtube.com/@disomvlog";
const TWITTER_LINK = "https://twitter.com/disomvlog";
const CONTACT_EMAIL = "topol@disomvlog.online";
const APP_VERSION = "1.4.6";

const PARTNER_INSTAGRAM_LINK_01 = "https://www.instagram.com/topol.online/";
const PARTNER_INSTAGRAM_LINK_02 = "https://www.instagram.com/adiwasi_kola_kuli_dp_fashion/";

const POLICIES = {
  terms: {
    title: "Terms & Conditions",
    content: `1. ELIGIBILITY
You must be of legal marriageable age as per the laws of India (21 for males, 18 for females). This service is specifically for Santali community members seeking a matrimonial alliance.

2. ACCOUNT SECURITY
You are responsible for maintaining the confidentiality of your account credentials and for all activities that occur under your account.

3. USER CONDUCT
You agree NOT to post any content that is harmful, threatening, abusive, defamatory, or otherwise objectionable. You will not use the service for commercial solicitation or spam.

4. CONTENT ACCURACY
We do not take responsibility for the accuracy of the information provided by users. You are advised to verify all details (identity, education, income) independently before making any life decisions.

5. TERMINATION
We reserve the right to suspend or terminate your account at our sole discretion, without notice, for conduct that we believe violates these Terms or is harmful to other users.`
  },
  privacy: {
    title: "Privacy Policy",
    content: `Last updated: November 24, 2025

1. DATA WE COLLECT
- Personal Data: Name, Phone number, Profile picture, Gender, DOB, Marital Status.
- Cultural Data: Religion, Mother Tongue, Clan/Parish.
- Professional & Family Data: Education, Income, Occupation, Family details.
- Usage Data: Device ID, IP address, interaction logs.

2. HOW WE USE YOUR DATA
- To provide and maintain the Service.
- To manage your Account and registration.
- To contact you regarding updates or security notices.

3. SHARING YOUR DATA
- With Service Providers: We share data with Google Firebase (backend) and Google AdMob (advertising) to maintain our service.
- With Law Enforcement: If required by law or valid requests by public authorities.`
  },
  csae: {
    title: "Child Safety (CSAE Policy)",
    content: `ZERO TOLERANCE STATEMENT: 
Topol has a strict ZERO-TOLERANCE policy against Child Sexual Abuse and Exploitation (CSAE).

1. PROHIBITED CONTENT
We strictly prohibit the uploading, sharing, or solicitation of:
- Child Sexual Abuse Material (CSAM).
- Grooming behavior intended to build trust with a minor for exploitation.
- Sexualization of minors in any form.
- Sextortion or trafficking content.

2. DETECTION & MONITORING
Topol employs automated scanning technologies and human moderation to detect and prevent the dissemination of illegal content.

3. REPORTING MECHANISMS
If you encounter violations:
- Use the "Report" button on any profile within the app.
- Email our safety team directly at topol@disomvlog.online.`
  }
};

// --- Custom Logo Component ---
const TopolLogo = ({ size = 40 }) => (
  <img
    src="/images/AppIcon-tp-1024.png"
    alt="Topol Logo"
    className="object-contain"
    style={{ width: size, height: size }}
  />
);

// --- Sub-Components ---

const Navbar = ({ onNavigate }) => {
  const [isScrolled, setIsScrolled] = useState(false);
  const [mobileMenuOpen, setMobileMenuOpen] = useState(false);

  useEffect(() => {
    const handleScroll = () => setIsScrolled(window.scrollY > 20);
    window.addEventListener('scroll', handleScroll);
    return () => window.removeEventListener('scroll', handleScroll);
  }, []);

  return (
    <nav className={`fixed w-full z-50 transition-all duration-500 ${isScrolled ? 'bg-white/90 backdrop-blur-xl shadow-lg py-3' : 'bg-transparent py-5'}`}>
      <div className="container mx-auto px-6 flex justify-between items-center">
        <div className="flex items-center space-x-3 cursor-pointer group" onClick={() => onNavigate('home')}>
          <div className="bg-gradient-to-br from-teal-400 to-cyan-500 p-2 rounded-2xl shadow-lg group-hover:shadow-xl transition-all duration-300 group-hover:scale-105">
            <TopolLogo size={48} />
          </div>
          <div>
            <h1 className={`text-2xl font-black bg-gradient-to-r from-teal-600 to-cyan-600 bg-clip-text text-transparent`}>
              Topol
            </h1>
            <p className="text-[10px] text-slate-500 font-semibold tracking-widest -mt-1 hidden sm:block">SANTALI MATCHMAKING</p>
          </div>
        </div>

        {/* Desktop Menu */}
        <div className="hidden md:flex items-center space-x-6">
          <button onClick={() => onNavigate('features')} className="font-semibold text-slate-700 hover:text-teal-600 transition-colors relative group">
            Features
            <span className="absolute bottom-0 left-0 w-0 h-0.5 bg-teal-600 group-hover:w-full transition-all duration-300"></span>
          </button>
          <button onClick={() => onNavigate('policies')} className="font-semibold text-slate-700 hover:text-teal-600 transition-colors relative group">
            Legal & Policies
            <span className="absolute bottom-0 left-0 w-0 h-0.5 bg-teal-600 group-hover:w-full transition-all duration-300"></span>
          </button>
          <a href={PLAY_STORE_LINK} target="_blank" rel="noopener noreferrer" className="bg-gradient-to-r from-teal-600 to-cyan-600 hover:from-teal-700 hover:to-cyan-700 text-white px-6 py-2.5 rounded-full font-bold transition-all duration-300 shadow-lg hover:shadow-2xl flex items-center gap-2 group transform hover:scale-105">
            <Download size={18} className="group-hover:animate-bounce" /> 
            Download
          </a>
        </div>

        {/* Mobile Menu Button */}
        <button className="md:hidden text-teal-700 bg-teal-50 p-2 rounded-lg hover:bg-teal-100 transition" onClick={() => setMobileMenuOpen(!mobileMenuOpen)}>
          {mobileMenuOpen ? <X size={24} /> : <Menu size={24} />}
        </button>
      </div>

      {/* Mobile Menu */}
      {mobileMenuOpen && (
        <div className="md:hidden absolute top-full left-0 w-full bg-white/95 backdrop-blur-xl shadow-2xl py-6 px-6 flex flex-col space-y-4 border-t border-slate-100 animate-slideDown">
          <button onClick={() => { onNavigate('features'); setMobileMenuOpen(false) }} className="text-left font-semibold text-slate-700 py-3 hover:text-teal-600 transition-colors border-b border-slate-100">Features</button>
          <button onClick={() => { onNavigate('policies'); setMobileMenuOpen(false) }} className="text-left font-semibold text-slate-700 py-3 hover:text-teal-600 transition-colors border-b border-slate-100">Legal & Policies</button>
          <a href={PLAY_STORE_LINK} target="_blank" rel="noopener noreferrer" className="bg-gradient-to-r from-teal-600 to-cyan-600 text-white text-center py-4 rounded-2xl font-bold shadow-lg hover:shadow-xl transition-all">
            Download App
          </a>
        </div>
      )}
    </nav>
  );
};

const Hero = () => (
  <div id="home" className="relative pt-32 pb-24 lg:pt-44 lg:pb-32 overflow-hidden">
    {/* Animated Background */}
    <div className="absolute inset-0 bg-gradient-to-br from-teal-50 via-cyan-50 to-purple-50 -z-20"></div>
    
    {/* Floating Orbs */}
    <div className="absolute top-20 right-10 w-72 h-72 bg-gradient-to-br from-teal-400/30 to-cyan-500/30 rounded-full blur-3xl animate-float -z-10"></div>
    <div className="absolute bottom-20 left-10 w-96 h-96 bg-gradient-to-br from-purple-400/20 to-pink-500/20 rounded-full blur-3xl animate-float-delayed -z-10"></div>
    <div className="absolute top-1/2 left-1/3 w-64 h-64 bg-gradient-to-br from-cyan-400/20 to-teal-500/20 rounded-full blur-3xl animate-pulse -z-10"></div>

    <div className="container mx-auto px-6 flex flex-col lg:flex-row items-center gap-12">
      {/* LEFT SIDE: Text Content */}
      <div className="lg:w-1/2 text-center lg:text-left space-y-8">
        {/* Badge */}
        <div className="inline-flex items-center gap-2 px-5 py-2.5 bg-gradient-to-r from-teal-500 to-cyan-500 text-white rounded-full text-sm font-bold shadow-lg animate-pulse-subtle">
          <Sparkles size={16} className="animate-spin-slow" />
          <span>ᱛᱚᱯᱚᱞ (Topol) v{APP_VERSION} Live Now!</span>
        </div>

        {/* Main Heading */}
        <h1 className="text-5xl lg:text-7xl font-black leading-tight">
          <span className="bg-gradient-to-r from-slate-900 via-teal-700 to-cyan-700 bg-clip-text text-transparent animate-gradient">
            Where souls are bound,
          </span>
          <br />
          <span className="bg-gradient-to-r from-teal-600 to-cyan-600 bg-clip-text text-transparent">
            and stories begin ✨
          </span>
        </h1>

        {/* Subtitle */}
        <p className="text-xl text-slate-600 leading-relaxed max-w-xl mx-auto lg:mx-0">
          The <span className="font-bold text-teal-700">modern matchmaking platform</span> dedicated to the Santali community. 
          Find your perfect match with <span className="font-semibold">safety</span>, <span className="font-semibold">cultural respect</span>, and <span className="font-semibold">ease</span>.
        </p>

        {/* CTA Buttons */}
        <div className="flex flex-col sm:flex-row gap-4 justify-center lg:justify-start">
          <a href={PLAY_STORE_LINK} target="_blank" rel="noopener noreferrer" className="group flex items-center justify-center bg-gradient-to-r from-slate-900 to-slate-800 text-white px-8 py-5 rounded-2xl hover:shadow-2xl transition-all duration-300 transform hover:-translate-y-1 hover:scale-105">
            <Play size={24} className="mr-3 fill-current group-hover:scale-110 transition-transform" />
            <div className="text-left">
              <div className="text-xs uppercase text-slate-400 font-semibold">Get it on</div>
              <div className="text-lg font-black">Google Play</div>
            </div>
          </a>
          
          <button onClick={() => document.getElementById('features').scrollIntoView({ behavior: 'smooth' })} className="group flex items-center justify-center bg-white text-teal-700 border-2 border-teal-200 px-8 py-5 rounded-2xl hover:bg-teal-50 hover:border-teal-300 transition-all duration-300 transform hover:-translate-y-1 font-bold shadow-lg">
            Explore Features
            <ArrowRight size={20} className="ml-2 group-hover:translate-x-1 transition-transform" />
          </button>
        </div>

        {/* Trust Indicators */}
        <div className="flex flex-wrap gap-6 justify-center lg:justify-start pt-4">
          <div className="flex items-center gap-2 text-slate-600">
            <div className="w-10 h-10 bg-green-100 rounded-full flex items-center justify-center">
              <CheckCircle size={20} className="text-green-600" />
            </div>
            <div className="text-left">
              <div className="font-bold text-slate-800">100% Safe</div>
              <div className="text-xs text-slate-500">Verified Profiles</div>
            </div>
          </div>
          <div className="flex items-center gap-2 text-slate-600">
            <div className="w-10 h-10 bg-purple-100 rounded-full flex items-center justify-center">
              <Users size={20} className="text-purple-600" />
            </div>
            <div className="text-left">
              <div className="font-bold text-slate-800">10K+ Users</div>
              <div className="text-xs text-slate-500">Active Community</div>
            </div>
          </div>
        </div>
      </div>

      {/* RIGHT SIDE: Phone Mockup */}
      <div className="lg:w-1/2 flex justify-center relative">
        {/* Glow Effect */}
        <div className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-[400px] h-[400px] bg-gradient-to-br from-teal-400/40 to-cyan-500/40 rounded-full blur-[100px] animate-pulse-slow"></div>

        {/* Phone Clickable Wrapper */}
        <a 
          href={PLAY_STORE_LINK} 
          target="_blank" 
          rel="noopener noreferrer"
          className="relative w-[320px] h-[640px] group cursor-pointer block transform transition-all duration-500 hover:scale-105 hover:rotate-1"
        >
          {/* Phone Frame with Gradient Border */}
          <div className="relative w-full h-full bg-gradient-to-br from-slate-800 to-slate-900 rounded-[3.5rem] p-3 shadow-2xl group-hover:shadow-[0_30px_60px_-15px_rgba(0,0,0,0.4)] transition-shadow duration-500">
            
            {/* Inner Screen */}
            <div className="relative w-full h-full bg-white rounded-[3rem] overflow-hidden">
              
              {/* Status Bar */}
              <div className="absolute top-0 w-full h-8 bg-slate-900 z-20 flex justify-between px-6 items-center">
                <div className="text-white text-[11px] font-semibold">9:41</div>
                <div className="flex gap-1.5 items-center">
                  <div className="w-1.5 h-1.5 bg-white rounded-full"></div>
                  <div className="w-1.5 h-1.5 bg-white rounded-full"></div>
                  <div className="w-5 h-2 bg-white rounded-full"></div>
                </div>
              </div>

              {/* App Screen Content */}
              <div className="w-full h-full bg-gradient-to-br from-teal-50 via-white to-cyan-50 relative flex flex-col items-center justify-center px-6 pt-10">

                {/* Logo with Animated Ring */}
                <div className="mb-8 relative group-hover:scale-110 transition-transform duration-500">
                  <div className="absolute inset-0 bg-gradient-to-br from-teal-400 to-cyan-500 rounded-full blur-xl opacity-40 group-hover:opacity-60 transition-opacity animate-pulse"></div>
                  <div className="absolute inset-0 border-4 border-teal-400/30 rounded-full animate-ping-slow"></div>
                  <img
                    src="/images/AppIcon-tp-1024.png"
                    alt="App Icon"
                    className="w-36 h-36 object-contain relative z-10 drop-shadow-2xl"
                  />
                </div>

                {/* Title */}
                <h2 className="text-5xl font-black bg-gradient-to-r from-teal-700 to-cyan-700 bg-clip-text text-transparent mb-3 tracking-tight">
                  Topol
                </h2>
                <p className="text-center text-slate-600 italic text-sm font-medium mb-10 px-4 max-w-xs">
                  "Where souls are bound, and stories begin."
                </p>

                {/* Login Card */}
                <div className="w-full bg-white/80 backdrop-blur-sm rounded-3xl p-6 shadow-[0_20px_60px_-15px_rgba(0,0,0,0.2)] border border-white/50 group-hover:shadow-[0_25px_70px_-15px_rgba(0,0,0,0.3)] transition-all duration-500">
                  <div className="text-2xl font-bold text-slate-900 text-center mb-1">Get Started</div>
                  <div className="text-slate-500 text-xs text-center mb-6">Sign in securely to continue</div>

                  {/* Button */}
                  <div className="w-full bg-gradient-to-r from-teal-600 to-cyan-600 group-hover:from-teal-700 group-hover:to-cyan-700 text-white py-4 rounded-xl flex items-center justify-center shadow-lg transition-all duration-300">
                    <Phone size={20} className="mr-2" />
                    <span className="font-bold text-sm">Sign in with Phone</span>
                  </div>
                </div>

                {/* Footer Terms */}
                <div className="absolute bottom-8 text-center w-full px-8">
                  <p className="text-[10px] text-slate-400 mb-1">By continuing, you agree to our</p>
                  <div className="flex justify-center gap-1.5 text-[10px] text-slate-500 font-semibold">
                    <span>Terms of Service</span> <span className="text-slate-300">•</span> <span>Privacy Policy</span>
                  </div>
                </div>

              </div>
            </div>
          </div>
        </a>
      </div>
    </div>
  </div>
);

const FeatureCard = ({ icon, title, desc, gradient, iconColor }) => (
  <div className="group relative bg-white p-8 rounded-3xl shadow-md hover:shadow-2xl transition-all duration-500 border border-slate-100 hover:border-transparent overflow-hidden transform hover:-translate-y-2">
    {/* Gradient Overlay on Hover */}
    <div className={`absolute inset-0 bg-gradient-to-br ${gradient} opacity-0 group-hover:opacity-5 transition-opacity duration-500 rounded-3xl`}></div>
    
    <div className="relative z-10">
      <div className={`w-16 h-16 bg-gradient-to-br ${gradient} rounded-2xl flex items-center justify-center mb-6 shadow-lg group-hover:shadow-xl group-hover:scale-110 transition-all duration-300`}>
        {React.cloneElement(icon, { size: 28, className: "text-white" })}
      </div>
      <h3 className="text-xl font-bold text-slate-900 mb-3 group-hover:text-teal-700 transition-colors">{title}</h3>
      <p className="text-slate-600 leading-relaxed">{desc}</p>
    </div>
  </div>
);

const Features = () => (
  <div id="features" className="py-24 bg-gradient-to-b from-white to-slate-50">
    <div className="container mx-auto px-6">
      {/* Section Header */}
      <div className="text-center mb-20">
        <div className="inline-flex items-center gap-2 px-4 py-2 bg-teal-100 text-teal-700 rounded-full text-sm font-bold mb-4">
          <Star size={16} className="fill-current" />
          Why Choose Topol?
        </div>
        <h2 className="text-4xl md:text-5xl font-black text-slate-900 mb-4">
          Designed for the <span className="bg-gradient-to-r from-teal-600 to-cyan-600 bg-clip-text text-transparent">Community</span>
        </h2>
        <p className="text-lg text-slate-600 max-w-2xl mx-auto">
          Experience matrimonial matchmaking reimagined with modern technology and cultural sensitivity.
        </p>
      </div>

      {/* Feature Grid */}
      <div className="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
        <FeatureCard
          icon={<Users />}
          title="Santali Culture First"
          desc="We respect traditions. Our 'Paris' (Clan) checker helps prevent same-clan matches, adhering to social norms."
          gradient="from-teal-500 to-cyan-500"
        />
        <FeatureCard
          icon={<CheckCheck />}
          title="Verified Profiles"
          desc="Safety is our priority. Look for the Blue Tick (Phone Verified) and Pink Tick (ID Verified) for trusted profiles."
          gradient="from-pink-500 to-rose-500"
        />
        <FeatureCard
          icon={<FileText />}
          title="Instant Bio-Data"
          desc="Generate a beautiful, shareable Bio-Data card of any profile instantly to share with family on WhatsApp."
          gradient="from-blue-500 to-indigo-500"
        />
        <FeatureCard
          icon={<Mic />}
          title="Voice Intro"
          desc="Hear the person behind the profile. Record a short audio intro (Ror-Land) to showcase your dialect and tone."
          gradient="from-purple-500 to-violet-500"
        />
        <FeatureCard
          icon={<Video />}
          title="Video Bio"
          desc="Video Reels allow you to express your personality better than static photos. Show your smile and vibe!"
          gradient="from-rose-500 to-pink-500"
        />
        <FeatureCard
          icon={<ShieldAlert />}
          title="Screenshot Protection"
          desc="Your privacy matters. We block screenshots on profile screens to prevent unauthorized sharing of your photos."
          gradient="from-slate-600 to-slate-700"
        />
        <FeatureCard
          icon={<Heart />}
          title="Smart Matching"
          desc="Our algorithm calculates compatibility scores based on age, location, and preferences to find your best match."
          gradient="from-red-400 to-rose-500"
        />
        <FeatureCard
          icon={<Phone />}
          title="Audio/Video Call"
          desc="Connect safely with high-quality in-app audio and video calling. Get to know your match without sharing your personal phone number."
          gradient="from-green-500 to-emerald-500"
        />
        <FeatureCard
          icon={<Calendar />}
          title="Community Events"
          desc="Stay updated with local community events and gatherings directly through the app."
          gradient="from-orange-400 to-amber-500"
        />
        <FeatureCard
          icon={<Globe />}
          title="Ol Chiki Support"
          desc="Proudly Santali. Switch the entire app interface to Ol Chiki script instantly with one tap."
          gradient="from-amber-500 to-yellow-500"
        />
      </div>
    </div>
  </div>
);

// --- Social Network Cards Section ---
const SocialCard = ({ icon, name, handle, link, gradient, ringColor }) => (
  <a href={link} target="_blank" rel="noopener noreferrer" className={`group relative flex items-center p-5 bg-white rounded-2xl shadow-md hover:shadow-2xl border-2 ${ringColor} transition-all duration-300 transform hover:-translate-y-2 overflow-hidden`}>
    {/* Background Gradient on Hover */}
    <div className={`absolute inset-0 bg-gradient-to-br ${gradient} opacity-0 group-hover:opacity-10 transition-opacity duration-300`}></div>
    
    <div className="relative z-10 flex items-center w-full">
      <div className={`w-14 h-14 bg-gradient-to-br ${gradient} rounded-xl flex items-center justify-center text-white mr-4 group-hover:scale-110 group-hover:rotate-6 transition-all duration-300 shadow-lg`}>
        {icon}
      </div>
      <div className="flex-1">
        <h4 className="font-bold text-slate-900 group-hover:text-teal-700 transition-colors text-lg">{name}</h4>
        <p className="text-sm text-slate-500 font-medium">{handle}</p>
      </div>
      <ArrowRight size={20} className="text-slate-400 group-hover:text-teal-600 group-hover:translate-x-1 transition-all" />
    </div>
  </a>
);

const Socials = () => (
  <div id="socials" className="py-24 bg-gradient-to-b from-slate-50 to-white">
    <div className="container mx-auto px-6">
      {/* Section Header */}
      <div className="text-center mb-16">
        <div className="inline-flex items-center gap-2 px-4 py-2 bg-purple-100 text-purple-700 rounded-full text-sm font-bold mb-4">
          <Heart size={16} className="fill-current animate-pulse" />
          Join Our Community
        </div>
        <h2 className="text-4xl md:text-5xl font-black text-slate-900 mb-4">
          Connect With <span className="bg-gradient-to-r from-pink-600 to-purple-600 bg-clip-text text-transparent">Us & Partners</span>
        </h2>
        <p className="text-lg text-slate-600 max-w-2xl mx-auto">
          Follow our journey and stay updated with the latest news, success stories, and community events.
        </p>
      </div>

      {/* Social Cards Grid */}
      <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto">
        <SocialCard
          icon={<Instagram size={24} />}
          name="Instagram"
          handle="@topol.online"
          link={PARTNER_INSTAGRAM_LINK_01}
          gradient="from-pink-500 to-rose-600"
          ringColor="border-pink-100"
        />
        <SocialCard
          icon={<Facebook size={24} />}
          name="Facebook"
          handle="@disomvlog.online"
          link={FACEBOOK_LINK}
          gradient="from-blue-500 to-blue-700"
          ringColor="border-blue-100"
        />
        <SocialCard
          icon={<Instagram size={24} />}
          name="Instagram"
          handle="@disomvlog.online"
          link={INSTAGRAM_LINK}
          gradient="from-pink-500 to-purple-600"
          ringColor="border-purple-100"
        />
        <SocialCard
          icon={<Instagram size={24} />}
          name="Instagram"
          handle="@adiwasi_kola_kuli"
          link={PARTNER_INSTAGRAM_LINK_02}
          gradient="from-rose-500 to-pink-600"
          ringColor="border-rose-100"
        />
      </div>
    </div>
  </div>
);

const PolicyViewer = () => {
  const [activeTab, setActiveTab] = useState('terms');

  return (
    <div id="policies" className="py-24 bg-gradient-to-b from-white to-slate-50">
      <div className="container mx-auto px-6 max-w-5xl">
        {/* Section Header */}
        <div className="text-center mb-16">
          <div className="inline-flex items-center gap-2 px-4 py-2 bg-blue-100 text-blue-700 rounded-full text-sm font-bold mb-4">
            <ShieldAlert size={16} />
            Legal & Policies
          </div>
          <h2 className="text-4xl md:text-5xl font-black text-slate-900 mb-4">
            Transparency & <span className="bg-gradient-to-r from-blue-600 to-cyan-600 bg-clip-text text-transparent">Safety</span>
          </h2>
          <p className="text-lg text-slate-600 max-w-2xl mx-auto">
            Your trust and security are at the core of everything we do. Read our policies to understand how we protect you.
          </p>
        </div>

        {/* Policy Container */}
        <div className="bg-white rounded-3xl shadow-2xl overflow-hidden border border-slate-200">
          {/* Tabs */}
          <div className="flex flex-wrap border-b border-slate-200 bg-slate-50">
            {Object.keys(POLICIES).map((key) => (
              <button
                key={key}
                onClick={() => setActiveTab(key)}
                className={`flex-1 py-5 px-6 text-sm md:text-base font-bold transition-all duration-300 ${
                  activeTab === key
                    ? 'bg-white text-teal-700 border-b-4 border-teal-600 shadow-sm -mb-px'
                    : 'text-slate-500 hover:text-slate-800 hover:bg-slate-100'
                }`}
              >
                {POLICIES[key].title}
              </button>
            ))}
          </div>

          {/* Content */}
          <div className="p-10 md:p-14 h-[500px] overflow-y-auto custom-scrollbar bg-gradient-to-b from-white to-slate-50">
            <h3 className="text-3xl font-black mb-6 text-slate-900">{POLICIES[activeTab].title}</h3>
            <div className="prose prose-slate prose-lg max-w-none whitespace-pre-line text-slate-700 leading-8">
              {POLICIES[activeTab].content}
            </div>
          </div>

          {/* Footer */}
          <div className="bg-slate-50 p-6 border-t border-slate-200 text-center">
            <p className="text-sm text-slate-600">
              For further inquiries, email us at{' '}
              <a href={`mailto:${CONTACT_EMAIL}?subject=Query%20about%20Topol%20App`} className="text-teal-600 font-bold hover:text-teal-700 transition-colors">
                {CONTACT_EMAIL}
              </a>
            </p>
          </div>
        </div>
      </div>
    </div>
  );
};

const Footer = () => (
  <footer className="relative bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 text-white pt-20 pb-10 overflow-hidden">
    {/* Decorative Gradient Orbs */}
    <div className="absolute top-0 right-0 w-96 h-96 bg-teal-500/10 rounded-full blur-3xl"></div>
    <div className="absolute bottom-0 left-0 w-96 h-96 bg-cyan-500/10 rounded-full blur-3xl"></div>

    <div className="container mx-auto px-6 relative z-10">
      {/* Top Section */}
      <div className="flex flex-col md:flex-row justify-between items-center mb-16 gap-8">
        <div className="flex items-center space-x-4">
          <div className="bg-gradient-to-br from-teal-500 to-cyan-500 p-3 rounded-2xl shadow-2xl">
            <TopolLogo size={64} />
          </div>
          <div>
            <span className="text-3xl font-black bg-gradient-to-r from-teal-400 to-cyan-400 bg-clip-text text-transparent">Topol</span>
            <p className="text-xs text-slate-400 font-semibold tracking-wider">SANTALI MATCHMAKING APP</p>
          </div>
        </div>

        {/* Social Icons */}
        <div className="flex gap-4">
          <a href={FACEBOOK_LINK} target="_blank" rel="noopener noreferrer" className="w-12 h-12 rounded-xl bg-slate-800/50 backdrop-blur-sm flex items-center justify-center hover:bg-gradient-to-br hover:from-blue-600 hover:to-blue-700 transition-all duration-300 text-slate-300 hover:text-white shadow-lg hover:shadow-xl transform hover:scale-110">
            <Facebook size={20} />
          </a>
          <a href={INSTAGRAM_LINK} target="_blank" rel="noopener noreferrer" className="w-12 h-12 rounded-xl bg-slate-800/50 backdrop-blur-sm flex items-center justify-center hover:bg-gradient-to-br hover:from-pink-600 hover:to-purple-600 transition-all duration-300 text-slate-300 hover:text-white shadow-lg hover:shadow-xl transform hover:scale-110">
            <Instagram size={20} />
          </a>
          <a href={`mailto:${CONTACT_EMAIL}?subject=Query%20about%20Topol%20App`} className="w-12 h-12 rounded-xl bg-slate-800/50 backdrop-blur-sm flex items-center justify-center hover:bg-gradient-to-br hover:from-teal-600 hover:to-cyan-600 transition-all duration-300 text-slate-300 hover:text-white shadow-lg hover:shadow-xl transform hover:scale-110">
            <Mail size={20} />
          </a>
          <a href={PLAY_STORE_LINK} target="_blank" rel="noopener noreferrer" className="w-12 h-12 rounded-xl bg-slate-800/50 backdrop-blur-sm flex items-center justify-center hover:bg-gradient-to-br hover:from-green-600 hover:to-emerald-600 transition-all duration-300 text-slate-300 hover:text-white shadow-lg hover:shadow-xl transform hover:scale-110">
            <Play size={18} className="fill-current ml-0.5" />
          </a>
        </div>
      </div>

      {/* Divider */}
      <div className="border-t border-slate-700/50 mb-8"></div>

      {/* Bottom Section */}
      <div className="flex flex-col md:flex-row justify-between items-center gap-6 text-sm text-slate-400">
        <p className="font-medium">
          © 2025 <span className="text-teal-400 font-bold">Disom Vlog</span>. All rights reserved.
        </p>

        {/* Visit Counter */}
        {/* <div className="flex items-center gap-2 bg-slate-800/50 backdrop-blur-sm px-5 py-2.5 rounded-full border border-slate-700/50 shadow-lg">
          <Eye size={16} className="text-cyan-400" />
          <span className="text-sm font-mono font-bold text-white">
            {visitCount !== null ? visitCount.toLocaleString() : '...'} 
          </span>
          <span className="text-xs text-slate-400">Visits</span>
        </div> */}

        {/* Meta Info */}
        <div className="flex flex-wrap gap-4 items-center text-xs">
          <span className="px-3 py-1 bg-slate-800/50 rounded-full border border-slate-700/50 font-semibold">
            v{APP_VERSION}
          </span>
          <span className="flex items-center gap-1">
            Made with <Heart size={12} className="text-red-500 fill-current animate-pulse" /> in Mayurbhanj, Odisha
          </span>
        </div>
      </div>
    </div>
  </footer>
);

// --- App Entry Point ---

function App() {
  // const [visitCount, setVisitCount] = useState(0);

  // useEffect(() => {
  //   // Fetch visit count from Flask backend API
  //   fetch('/api/visit')
  //     .then(response => response.json())
  //     .then(data => setVisitCount(data.count))
  //     .catch(error => console.error("Error fetching visit count:", error));
  // }, []);

  const scrollToSection = (id) => {
    const element = document.getElementById(id);
    if (element) {
      element.scrollIntoView({ behavior: 'smooth' });
    }
  };

  return (
    <div className="min-h-screen bg-white text-slate-800 font-sans antialiased">
      <style>{`
        @keyframes float {
          0%, 100% { transform: translateY(0px); }
          50% { transform: translateY(-20px); }
        }
        @keyframes float-delayed {
          0%, 100% { transform: translateY(0px); }
          50% { transform: translateY(-30px); }
        }
        @keyframes pulse-slow {
          0%, 100% { opacity: 0.3; }
          50% { opacity: 0.6; }
        }
        @keyframes pulse-subtle {
          0%, 100% { opacity: 1; }
          50% { opacity: 0.9; }
        }
        @keyframes spin-slow {
          from { transform: rotate(0deg); }
          to { transform: rotate(360deg); }
        }
        @keyframes ping-slow {
          0% { transform: scale(1); opacity: 1; }
          100% { transform: scale(1.5); opacity: 0; }
        }
        @keyframes gradient {
          0%, 100% { background-position: 0% 50%; }
          50% { background-position: 100% 50%; }
        }
        @keyframes slideDown {
          from { opacity: 0; transform: translateY(-20px); }
          to { opacity: 1; transform: translateY(0); }
        }
        .animate-float { animation: float 6s ease-in-out infinite; }
        .animate-float-delayed { animation: float-delayed 8s ease-in-out infinite; }
        .animate-pulse-slow { animation: pulse-slow 4s ease-in-out infinite; }
        .animate-pulse-subtle { animation: pulse-subtle 2s ease-in-out infinite; }
        .animate-spin-slow { animation: spin-slow 3s linear infinite; }
        .animate-ping-slow { animation: ping-slow 2s cubic-bezier(0, 0, 0.2, 1) infinite; }
        .animate-gradient { 
          background-size: 200% 200%; 
          animation: gradient 3s ease infinite; 
        }
        .animate-slideDown { animation: slideDown 0.3s ease-out; }
        
        /* Custom Scrollbar */
        .custom-scrollbar::-webkit-scrollbar { width: 8px; }
        .custom-scrollbar::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 10px; }
        .custom-scrollbar::-webkit-scrollbar-thumb { 
          background: linear-gradient(to bottom, #0d9488, #0891b2); 
          border-radius: 10px; 
        }
        .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: linear-gradient(to bottom, #0f766e, #0e7490); }
      `}</style>
      
      <Navbar onNavigate={scrollToSection} />
      <Hero />
      <Features />
      <Socials />
      <PolicyViewer />
      <Footer />
      
    </div>
  );
}

// Render the App
const root = createRoot(document.getElementById('root'));
root.render(<App />);
