"use client"

import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { AnimatedCard } from "@/components/ui/animated-card"
import { Header } from "@/components/ui/header"
import { Footer } from "@/components/ui/footer"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import {
  FileText,
  Calendar,
  AlertCircle,
  Shield,
  Scale,
  Users,
  Building,
  CreditCard,
  Mail,
  Download,
  Printer as Print
} from "lucide-react"
import Link from "next/link"
import { motion } from "framer-motion"

export default function TermsOfServicePage() {
  const lastUpdated = "January 15, 2024"
  const effectiveDate = "January 15, 2024"

  const sections = [
    {
      id: "acceptance",
      title: "1. Acceptance of Terms",
      icon: FileText,
      content: `By accessing and using Geezer Guide ("we," "our," or "us"), you accept and agree to be bound by the terms and provision of this agreement. If you do not agree to abide by the above, please do not use this service.

These Terms of Service apply to all users of the service, including without limitation users who are browsers, vendors, customers, merchants, and contributors of content.`
    },
    {
      id: "services",
      title: "2. Description of Services",
      icon: Building,
      content: `Geezer Guide is an online platform that connects families with senior living facilities. Our services include:

• Facility search and comparison tools
• Reviews and ratings from verified users
• Direct communication with facility representatives
• Educational resources and guides
• Tour scheduling assistance

We reserve the right to withdraw or amend this service, and any service or material we provide, in our sole discretion without notice.`
    },
    {
      id: "user-accounts",
      title: "3. User Accounts and Registration",
      icon: Users,
      content: `To access certain features of our service, you may be required to create an account. You agree to:

• Provide accurate, current, and complete information during registration
• Maintain the security of your password and identification
• Notify us immediately of any unauthorized use of your account
• Accept all risks of unauthorized access to your account

You are responsible for all activities that occur under your account, whether or not you authorized such activities.`
    },
    {
      id: "user-conduct",
      title: "4. User Conduct and Prohibited Uses",
      icon: Shield,
      content: `You may not use our service:

• For any unlawful purpose or to solicit others to unlawful acts
• To violate any international, federal, provincial, or state regulations, rules, laws, or local ordinances
• To transmit, or procure the sending of, any advertising or promotional material or spam
• To impersonate or attempt to impersonate the company, employees, other users, or any other person
• To engage in any other conduct that restricts or inhibits anyone's use of the website

We reserve the right to terminate your use of the service for violating any of the prohibited uses.`
    },
    {
      id: "content",
      title: "5. User Content and Reviews",
      icon: Scale,
      content: `Our service allows you to post, link, store, share and otherwise make available certain information, text, graphics, videos, or other material ("Content"). You are responsible for Content that you post to the service, including its legality, reliability, and appropriateness.

By posting Content to the service, you grant us the right and license to use, modify, publicly perform, publicly display, reproduce, and distribute such Content on and through the service.

All reviews must be:
• Based on genuine experiences
• Truthful and accurate
• Free from offensive language
• Respectful of privacy rights

We reserve the right to remove any Content that violates these terms.`
    },
    {
      id: "facility-owners",
      title: "6. Facility Owner Terms",
      icon: Building,
      content: `If you are a facility owner using our platform:

• You must provide accurate and up-to-date information about your facility
• You are responsible for maintaining current pricing, availability, and service information
• You agree to respond to inquiries in a timely and professional manner
• You understand that reviews are opinions of users and may not reflect your view
• You may respond to reviews but may not ask for removal of legitimate reviews

Premium subscription services are subject to additional terms and conditions provided at the time of purchase.`
    },
    {
      id: "payment",
      title: "7. Payment Terms",
      icon: CreditCard,
      content: `For paid services:

• All fees are due in advance and are non-refundable unless otherwise specified
• Prices may change at any time, but changes will not affect existing subscriptions until renewal
• You are responsible for all taxes associated with your use of the service
• Failure to pay may result in suspension or termination of services
• Refunds are handled on a case-by-case basis according to our refund policy

Subscription services will automatically renew unless cancelled before the renewal date.`
    },
    {
      id: "privacy",
      title: "8. Privacy and Data Protection",
      icon: Shield,
      content: `Your privacy is important to us. Our collection and use of personal information is governed by our Privacy Policy, which is incorporated into these Terms by reference.

We are committed to:
• Protecting your personal information
• Using data only for legitimate business purposes
• Complying with applicable privacy laws
• Providing you with control over your data

By using our service, you consent to the collection and use of information in accordance with our Privacy Policy.`
    },
    {
      id: "intellectual-property",
      title: "9. Intellectual Property Rights",
      icon: Scale,
      content: `The service and its original content, features, and functionality are and will remain the exclusive property of Geezer Guide and its licensors. The service is protected by copyright, trademark, and other laws. Our trademarks and trade dress may not be used in connection with any product or service without our prior written consent.

Users retain ownership of content they create but grant us a license to use such content in connection with the service.`
    },
    {
      id: "disclaimers",
      title: "10. Disclaimers and Limitation of Liability",
      icon: AlertCircle,
      content: `The information on this website is provided on an "as is" basis. To the fullest extent permitted by law, this Company:

• Excludes all representations and warranties relating to this website and its contents
• Does not warrant the accuracy, completeness, or timeliness of facility information
• Is not responsible for decisions made based on information provided on the platform
• Does not guarantee the quality of services provided by listed facilities

In no event shall Geezer Guide be liable for any indirect, incidental, special, consequential, or punitive damages, including lost profits, arising out of your use of the service.`
    },
    {
      id: "termination",
      title: "11. Termination",
      icon: AlertCircle,
      content: `We may terminate or suspend your account and bar access to the service immediately, without prior notice or liability, under our sole discretion, for any reason whatsoever, including but not limited to a breach of the Terms.

If you wish to terminate your account, you may simply discontinue using the service or contact us to request account deletion.

Upon termination, your right to use the service will cease immediately.`
    },
    {
      id: "changes",
      title: "12. Changes to Terms",
      icon: Calendar,
      content: `We reserve the right, at our sole discretion, to modify or replace these Terms at any time. If a revision is material, we will provide at least 30 days notice prior to any new terms taking effect.

What constitutes a material change will be determined at our sole discretion. By continuing to access or use our service after any revisions become effective, you agree to be bound by the revised terms.`
    },
    {
      id: "governing-law",
      title: "13. Governing Law and Dispute Resolution",
      icon: Scale,
      content: `These Terms shall be interpreted and governed by the laws of the State of Illinois, without regard to its conflict of law provisions.

Any legal suit, action, or proceeding arising out of or related to these Terms or the service shall be instituted exclusively in the federal or state courts located in Springfield, Illinois.

We encourage users to contact us first to resolve any disputes before pursuing legal action.`
    },
    {
      id: "contact",
      title: "14. Contact Information",
      icon: Mail,
      content: `If you have any questions about these Terms of Service, please contact us:

Email: legal@geezerguide.com
Phone: (555) 123-LEGAL
Address: 123 Business Center Dr, Springfield, IL 62701

For general support inquiries, please use our help center or contact support@geezerguide.com.`
    }
  ]

  return (
    <div className="min-h-screen bg-gradient-to-br from-slate-50 via-white to-blue-50/30">
      <Header />

      <div className="container mx-auto px-4 py-8">
        <div className="max-w-4xl mx-auto">
          {/* Header */}
          <motion.div
            initial={{ opacity: 0, y: 20 }}
            animate={{ opacity: 1, y: 0 }}
            transition={{ duration: 0.6 }}
            className="text-center mb-12"
          >
            <h1 className="font-primary text-3xl md:text-4xl font-bold text-gray-900 mb-4">
              Terms of Service
            </h1>
            <p className="font-body text-lg text-gray-600 max-w-2xl mx-auto mb-6">
              Please read these terms carefully before using Geezer Guide. By using our service, you agree to these terms.
            </p>

            <div className="flex flex-col sm:flex-row items-center justify-center gap-4 mb-8">
              <div className="flex items-center gap-2">
                <Calendar className="h-5 w-5 text-gray-500" />
                <span className="font-body text-sm text-gray-600">
                  Last updated: {lastUpdated}
                </span>
              </div>
              <div className="flex items-center gap-2">
                <AlertCircle className="h-5 w-5 text-gray-500" />
                <span className="font-body text-sm text-gray-600">
                  Effective: {effectiveDate}
                </span>
              </div>
            </div>

            <div className="flex gap-3 justify-center">
              <Button variant="outline" className="border-gray-300 text-gray-700 hover:bg-gray-50">
                <Download className="h-4 w-4 mr-2" />
                Download PDF
              </Button>
              <Button variant="outline" className="border-gray-300 text-gray-700 hover:bg-gray-50">
                <Print className="h-4 w-4 mr-2" />
                Print
              </Button>
            </div>
          </motion.div>

          {/* Quick Navigation */}
          <AnimatedCard className="mb-8">
            <CardHeader>
              <CardTitle className="font-primary text-xl text-gray-900">Quick Navigation</CardTitle>
            </CardHeader>
            <CardContent>
              <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">
                {sections.map((section) => (
                  <a
                    key={section.id}
                    href={`#${section.id}`}
                    className="flex items-center gap-2 p-3 rounded-lg hover:bg-gray-50 transition-colors group"
                  >
                    <section.icon className="h-4 w-4 text-[#3F5CEA] group-hover:text-[#09183D]" />
                    <span className="font-body text-sm text-gray-700 group-hover:text-gray-900">
                      {section.title}
                    </span>
                  </a>
                ))}
              </div>
            </CardContent>
          </AnimatedCard>

          {/* Terms Sections */}
          <div className="space-y-8">
            {sections.map((section, index) => (
              <motion.div
                key={section.id}
                initial={{ opacity: 0, y: 20 }}
                animate={{ opacity: 1, y: 0 }}
                transition={{ duration: 0.6, delay: index * 0.1 }}
                id={section.id}
              >
                <AnimatedCard>
                  <CardHeader>
                    <div className="flex items-center gap-3">
                      <div className="w-10 h-10 bg-[#3F5CEA]/10 rounded-lg flex items-center justify-center">
                        <section.icon className="h-5 w-5 text-[#3F5CEA]" />
                      </div>
                      <CardTitle className="font-primary text-xl text-gray-900">
                        {section.title}
                      </CardTitle>
                    </div>
                  </CardHeader>
                  <CardContent>
                    <div className="prose prose-gray max-w-none">
                      {section.content.split('\n').map((paragraph, pIndex) => {
                        if (paragraph.trim() === '') return null

                        if (paragraph.startsWith('•')) {
                          return (
                            <div key={pIndex} className="flex items-start gap-2 mb-2">
                              <div className="w-2 h-2 bg-[#3F5CEA] rounded-full mt-2"></div>
                              <span className="font-body text-gray-700">{paragraph.slice(1).trim()}</span>
                            </div>
                          )
                        }

                        return (
                          <p key={pIndex} className="font-body text-gray-700 leading-relaxed mb-4">
                            {paragraph}
                          </p>
                        )
                      })}
                    </div>
                  </CardContent>
                </AnimatedCard>
              </motion.div>
            ))}
          </div>

          {/* Important Notice */}
          <AnimatedCard className="mt-12 bg-gradient-to-r from-yellow-50 to-orange-50 border-yellow-200">
            <CardContent className="p-8">
              <div className="flex items-start gap-4">
                <AlertCircle className="h-6 w-6 text-yellow-600 mt-1" />
                <div>
                  <h3 className="font-body font-semibold text-yellow-900 mb-2">
                    Important Notice
                  </h3>
                  <p className="font-body text-yellow-800 leading-relaxed mb-4">
                    These terms constitute the entire agreement between you and Geezer Guide regarding
                    the use of our service. If any provision of these terms is found to be unenforceable,
                    the remaining provisions will remain in full force and effect.
                  </p>
                  <p className="font-body text-yellow-800 leading-relaxed">
                    By continuing to use our service, you acknowledge that you have read, understood,
                    and agree to be bound by these Terms of Service.
                  </p>
                </div>
              </div>
            </CardContent>
          </AnimatedCard>

          {/* Footer Actions */}
          <div className="mt-12 text-center">
            <div className="space-y-4">
              <p className="font-body text-gray-600">
                Have questions about these terms?
              </p>
              <div className="flex flex-col sm:flex-row gap-4 justify-center">
                <Link href="/help">
                  <Button variant="outline" className="border-[#3F5CEA] text-[#3F5CEA] hover:bg-[#3F5CEA] hover:text-white">
                    Visit Help Center
                  </Button>
                </Link>
                <Link href="/privacy">
                  <Button variant="outline" className="border-gray-300 text-gray-700 hover:bg-gray-50">
                    View Privacy Policy
                  </Button>
                </Link>
                <Button className="bg-gradient-to-r from-[#3F5CEA] to-[#5B73F0] hover:from-[#09183D] hover:to-[#3F5CEA] text-white">
                  <Mail className="h-4 w-4 mr-2" />
                  Contact Legal Team
                </Button>
              </div>
            </div>
          </div>
        </div>
      </div>

      <Footer />
    </div>
  )
}
