import { SITE } from "@/lib/config";

type IndustrySlug =
  | "health-care"
  | "beauty-wellness"
  | "education"
  | "sports-academies"
  | "retail-services"
  | "food-leisure"
  | "events-venues"
  | "property-facilities"
  | "hotels-accommodation"
  | "home-services-trades"
  | "pet-services"
  | "public-sector"
  | "nonprofit-community"
  | "mobility-industry"
  | "vehicle-rental-chauffeur";

interface IndustryConfig {
  name: string;
  applicationCategory: string;
  description: string;
  featureList: string[];
  audience: string;
  keywords: string[];
}

interface FAQItem {
  question: string;
  answer: string;
}

interface IndustryJsonLdProps {
  industry: IndustrySlug;
  faqs?: FAQItem[];
  lang?: "en" | "ar";
}

const INDUSTRY_CONFIGS: Record<IndustrySlug, IndustryConfig> = {
  "health-care": {
    name: "Mawidi for Healthcare",
    applicationCategory: "HealthApplication",
    description:
      "AI-powered WhatsApp appointment booking and patient management system for clinics, hospitals, and healthcare providers in the GCC. Automate bookings, reduce no-shows, and improve patient communication.",
    featureList: [
      "WhatsApp Patient Booking",
      "Automated Appointment Reminders",
      "No-show Reduction",
      "Patient Data Management",
      "HIPAA-Compliant Security",
      "Multi-language Support (Arabic/English)",
      "EMR Integration",
      "Voice Agent Support",
    ],
    audience:
      "Healthcare providers, clinics, hospitals, medical centers, diagnostic labs",
    keywords: [
      "healthcare appointment booking",
      "patient management system",
      "WhatsApp healthcare",
      "clinic booking software",
      "medical appointment scheduler",
    ],
  },
  "beauty-wellness": {
    name: "Mawidi for Beauty & Wellness",
    applicationCategory: "BusinessApplication",
    description:
      "WhatsApp booking automation for beauty salons, spas, wellness centers, and aesthetic clinics. Manage appointments, reduce no-shows, and enhance customer experience.",
    featureList: [
      "Salon Appointment Booking",
      "Service Menu Management",
      "Staff Scheduling",
      "Customer Reminders",
      "Package & Membership Management",
      "Multi-location Support",
      "Arabic/English Interface",
      "Payment Integration",
    ],
    audience:
      "Beauty salons, spas, wellness centers, aesthetic clinics, barbershops",
    keywords: [
      "salon booking software",
      "spa appointment system",
      "beauty WhatsApp booking",
      "wellness center management",
      "aesthetic clinic software",
    ],
  },
  education: {
    name: "Mawidi for Education",
    applicationCategory: "EducationalApplication",
    description:
      "Smart scheduling solution for educational institutions, tutoring centers, and training academies. Automate class bookings, manage student attendance, and streamline parent communication.",
    featureList: [
      "Class Scheduling",
      "Student Enrollment Management",
      "Parent Communication",
      "Automated Attendance Tracking",
      "Tutor Availability Management",
      "Session Reminders",
      "Multi-course Support",
      "Bilingual Communication",
    ],
    audience:
      "Schools, tutoring centers, training institutes, educational academies",
    keywords: [
      "education scheduling software",
      "tutoring management system",
      "class booking platform",
      "student attendance tracking",
      "academic scheduling",
    ],
  },
  "sports-academies": {
    name: "Mawidi for Sports Academies",
    applicationCategory: "SportsApplication",
    description:
      "Training session booking and member management for sports academies, fitness centers, and athletic facilities. Streamline class schedules, manage memberships, and automate communications.",
    featureList: [
      "Training Session Booking",
      "Membership Management",
      "Coach Scheduling",
      "Attendance Tracking",
      "Automated Session Reminders",
      "Multi-sport Support",
      "Parent Communication",
      "Performance Analytics",
    ],
    audience:
      "Sports academies, fitness centers, gyms, athletic clubs, martial arts schools",
    keywords: [
      "sports academy software",
      "fitness booking system",
      "gym management platform",
      "training session scheduler",
      "athletic facility management",
    ],
  },
  "retail-services": {
    name: "Mawidi for Retail Services",
    applicationCategory: "BusinessApplication",
    description:
      "Appointment booking solution for retail service providers. Manage customer appointments, reduce wait times, and enhance the shopping experience with WhatsApp automation.",
    featureList: [
      "Service Appointment Booking",
      "Queue Management",
      "Customer Notifications",
      "Staff Scheduling",
      "Service Catalog Management",
      "Wait Time Updates",
      "Customer Feedback Collection",
      "Multi-branch Support",
    ],
    audience:
      "Retail stores, service centers, boutiques, personal shopping services",
    keywords: [
      "retail appointment booking",
      "service scheduling software",
      "customer queue management",
      "retail WhatsApp automation",
      "shopping appointment system",
    ],
  },
  "food-leisure": {
    name: "Mawidi for Food & Leisure",
    applicationCategory: "FoodEstablishmentReservation",
    description:
      "Table reservation and booking management for restaurants, cafes, and entertainment venues. Automate reservations, manage seating, and reduce no-shows with WhatsApp.",
    featureList: [
      "Table Reservation Management",
      "Seating Optimization",
      "Automated Booking Confirmations",
      "No-show Prevention",
      "Special Event Booking",
      "Menu Integration",
      "Waitlist Management",
      "Customer Preferences Tracking",
    ],
    audience:
      "Restaurants, cafes, lounges, entertainment venues, dining establishments",
    keywords: [
      "restaurant reservation system",
      "table booking software",
      "cafe appointment platform",
      "dining reservation management",
      "restaurant WhatsApp booking",
    ],
  },
  "events-venues": {
    name: "Mawidi for Events & Venues",
    applicationCategory: "EventApplication",
    description:
      "Event booking and venue management platform. Handle event reservations, manage capacities, coordinate schedules, and automate attendee communications via WhatsApp.",
    featureList: [
      "Event Booking Management",
      "Venue Capacity Planning",
      "Multi-event Scheduling",
      "Attendee Communication",
      "Automated Event Reminders",
      "Ticket Management",
      "Vendor Coordination",
      "Real-time Availability",
    ],
    audience:
      "Event venues, conference centers, wedding halls, exhibition spaces",
    keywords: [
      "event booking software",
      "venue management system",
      "event scheduling platform",
      "conference booking",
      "venue reservation software",
    ],
  },
  "property-facilities": {
    name: "Mawidi for Property & Facilities",
    applicationCategory: "RealEstateApplication",
    description:
      "Facility booking and property viewing scheduler for real estate, property management, and facility services. Automate tour bookings, manage amenity reservations, and streamline tenant communications.",
    featureList: [
      "Property Viewing Scheduling",
      "Amenity Booking Management",
      "Maintenance Request Handling",
      "Tenant Communication",
      "Facility Reservation System",
      "Tour Automation",
      "Multi-property Support",
      "Automated Reminders",
    ],
    audience:
      "Real estate agencies, property managers, facility management companies",
    keywords: [
      "property viewing scheduler",
      "facility booking software",
      "amenity reservation system",
      "real estate appointment booking",
      "property management platform",
    ],
  },
  "hotels-accommodation": {
    name: "Mawidi for Hotels & Accommodation",
    applicationCategory: "LodgingReservation",
    description:
      "Booking and guest service management for hotels, resorts, and accommodation providers. Automate reservations, manage guest requests, and enhance guest experience with WhatsApp.",
    featureList: [
      "Room Reservation Management",
      "Guest Service Requests",
      "Check-in/Check-out Automation",
      "Concierge Service Booking",
      "Spa & Dining Reservations",
      "Guest Communication",
      "Special Request Handling",
      "Multi-property Management",
    ],
    audience: "Hotels, resorts, vacation rentals, serviced apartments, hostels",
    keywords: [
      "hotel booking software",
      "accommodation reservation system",
      "guest service management",
      "hotel WhatsApp automation",
      "resort booking platform",
    ],
  },
  "home-services-trades": {
    name: "Mawidi for Home Services & Trades",
    applicationCategory: "HomeAndConstructionBusiness",
    description:
      "Appointment scheduling for home service providers and tradespeople. Manage service calls, coordinate technician schedules, and automate customer communications via WhatsApp.",
    featureList: [
      "Service Call Scheduling",
      "Technician Dispatch Management",
      "Job Tracking",
      "Customer Notifications",
      "Automated Appointment Reminders",
      "Service History Tracking",
      "Quote Management",
      "Emergency Service Booking",
    ],
    audience:
      "Plumbers, electricians, HVAC technicians, cleaning services, maintenance providers",
    keywords: [
      "home service scheduling",
      "tradesperson booking software",
      "service call management",
      "technician scheduling platform",
      "home repair appointment system",
    ],
  },
  "pet-services": {
    name: "Mawidi for Pet Services",
    applicationCategory: "PetStore",
    description:
      "Booking management for veterinary clinics, pet grooming salons, boarding facilities, and pet care services. Automate appointments, manage pet records, and communicate with pet owners via WhatsApp.",
    featureList: [
      "Veterinary Appointment Booking",
      "Grooming Session Scheduling",
      "Boarding Reservations",
      "Pet Record Management",
      "Owner Communication",
      "Vaccination Reminders",
      "Multi-pet Support",
      "Service Package Management",
    ],
    audience:
      "Veterinary clinics, pet grooming salons, boarding facilities, pet training centers",
    keywords: [
      "veterinary booking software",
      "pet grooming scheduler",
      "pet care management system",
      "vet appointment platform",
      "pet services booking",
    ],
  },
  "public-sector": {
    name: "Mawidi for Public Sector",
    applicationCategory: "GovernmentApplication",
    description:
      "Citizen appointment booking and service request management for government offices and public sector organizations. Streamline service delivery, reduce wait times, and improve citizen experience.",
    featureList: [
      "Citizen Appointment Scheduling",
      "Service Request Management",
      "Queue Management",
      "Multi-department Support",
      "Automated Notifications",
      "Accessibility Features",
      "Document Submission Tracking",
      "Bilingual Interface",
    ],
    audience:
      "Government offices, public service centers, municipal services, regulatory agencies",
    keywords: [
      "government appointment system",
      "public sector scheduling",
      "citizen service booking",
      "government service management",
      "public office scheduler",
    ],
  },
  "nonprofit-community": {
    name: "Mawidi for Nonprofit & Community",
    applicationCategory: "NonprofitType",
    description:
      "Event and service coordination for nonprofit organizations and community centers. Manage volunteer schedules, coordinate community services, and streamline member communications.",
    featureList: [
      "Volunteer Scheduling",
      "Community Event Management",
      "Service Appointment Booking",
      "Member Communication",
      "Donation Coordination",
      "Program Registration",
      "Automated Event Reminders",
      "Multi-language Support",
    ],
    audience:
      "Nonprofit organizations, community centers, charitable foundations, NGOs",
    keywords: [
      "nonprofit scheduling software",
      "volunteer management system",
      "community event booking",
      "nonprofit service coordination",
      "charitable organization platform",
    ],
  },
  "mobility-industry": {
    name: "Mawidi for Mobility Industry",
    applicationCategory: "AutomotiveBusiness",
    description:
      "Service appointment booking for automotive service centers, car washes, and vehicle maintenance providers. Automate service scheduling, manage bay availability, and communicate with customers via WhatsApp.",
    featureList: [
      "Service Appointment Booking",
      "Bay Management",
      "Service Package Selection",
      "Customer Vehicle History",
      "Automated Service Reminders",
      "Technician Scheduling",
      "Parts Availability Check",
      "Multi-location Support",
    ],
    audience:
      "Auto service centers, car washes, vehicle maintenance shops, tire centers",
    keywords: [
      "automotive service booking",
      "car service scheduler",
      "vehicle maintenance software",
      "auto shop management",
      "car wash booking system",
    ],
  },
  "vehicle-rental-chauffeur": {
    name: "Mawidi for Vehicle Rental & Chauffeur",
    applicationCategory: "RentalCarReservation",
    description:
      "Booking management for car rental companies and chauffeur services. Automate vehicle reservations, manage fleet availability, and coordinate driver schedules via WhatsApp.",
    featureList: [
      "Vehicle Reservation Management",
      "Fleet Availability Tracking",
      "Chauffeur Scheduling",
      "Automated Booking Confirmations",
      "Customer Communication",
      "Pick-up/Drop-off Coordination",
      "Service Package Management",
      "Multi-vehicle Support",
    ],
    audience:
      "Car rental companies, chauffeur services, limousine providers, transport services",
    keywords: [
      "car rental booking software",
      "chauffeur scheduling system",
      "vehicle reservation platform",
      "fleet management software",
      "limousine booking system",
    ],
  },
};

export default function IndustryJsonLd({
  industry,
  faqs = [],
  lang = "en",
}: IndustryJsonLdProps) {
  const config = INDUSTRY_CONFIGS[industry];
  const baseUrl = `https://${SITE.domain}`;

  // Build SoftwareApplication schema
  const softwareSchema = {
    "@context": "https://schema.org",
    "@type": "SoftwareApplication",
    name: config.name,
    applicationCategory: config.applicationCategory,
    operatingSystem: "Web, WhatsApp",
    description: config.description,
    url: `${baseUrl}/${lang}/industries/${industry}`,
    softwareVersion: "2.0",
    datePublished: "2024-01-01",
    dateModified: new Date().toISOString().split("T")[0],
    author: {
      "@type": "Organization",
      name: SITE.brand,
      url: baseUrl,
    },
    publisher: {
      "@type": "Organization",
      name: SITE.brand,
      url: baseUrl,
      logo: {
        "@type": "ImageObject",
        url: `${baseUrl}/images/logos/mawidi-logo.png`,
      },
    },
    offers: {
      "@type": "Offer",
      price: "149",
      priceCurrency: "USD",
      priceSpecification: {
        "@type": "UnitPriceSpecification",
        price: "149",
        priceCurrency: "USD",
        billingIncrement: 1,
        unitText: "MONTH",
      },
      availability: "https://schema.org/InStock",
      url: `${baseUrl}/${lang}/pricing`,
      seller: {
        "@type": "Organization",
        name: SITE.brand,
      },
      validFrom: "2024-01-01",
    },
    featureList: config.featureList.join(", "),
    screenshot: `${baseUrl}/images/screenshots/${industry}-dashboard.png`,
    applicationSubCategory: config.applicationCategory,
    audience: {
      "@type": "Audience",
      audienceType: config.audience,
    },
    areaServed: [
      { "@type": "Country", name: "Saudi Arabia", alternateName: "SA" },
      { "@type": "Country", name: "United Arab Emirates", alternateName: "AE" },
      { "@type": "Country", name: "Qatar", alternateName: "QA" },
      { "@type": "Country", name: "Kuwait", alternateName: "KW" },
      { "@type": "Country", name: "Bahrain", alternateName: "BH" },
      { "@type": "Country", name: "Oman", alternateName: "OM" },
    ],
    inLanguage: ["en", "ar"],
    availableLanguage: [
      { "@type": "Language", name: "English", alternateName: "en" },
      { "@type": "Language", name: "Arabic", alternateName: "ar" },
    ],
    keywords: config.keywords.join(", "),
    aggregateRating: {
      "@type": "AggregateRating",
      ratingValue: "4.8",
      ratingCount: "127",
      bestRating: "5",
      worstRating: "1",
    },
    review: [
      {
        "@type": "Review",
        reviewRating: {
          "@type": "Rating",
          ratingValue: "5",
          bestRating: "5",
        },
        author: {
          "@type": "Organization",
          name: "Industry Client",
        },
        reviewBody: `Excellent solution for ${config.audience.split(",")[0]} in the GCC region.`,
      },
    ],
  };

  // Build FAQPage schema if FAQs are provided
  let faqSchema = null;
  if (faqs.length > 0) {
    faqSchema = {
      "@context": "https://schema.org",
      "@type": "FAQPage",
      mainEntity: faqs.map((faq) => ({
        "@type": "Question",
        name: faq.question,
        acceptedAnswer: {
          "@type": "Answer",
          text: faq.answer,
        },
      })),
    };
  }

  return (
    <>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(softwareSchema) }}
      />
      {faqSchema && (
        <script
          type="application/ld+json"
          dangerouslySetInnerHTML={{ __html: JSON.stringify(faqSchema) }}
        />
      )}
    </>
  );
}
