import type { Metadata } from "next";
import type { Lang } from "@/lib/config";
import JsonLd from "@/components/JsonLd";
import { buildPageMetadata } from "@/lib/seo";
import CalculatorClient from "./CalculatorClient";

export function generateMetadata({
  params,
}: {
  params: { lang: Lang };
}): Metadata {
  const isAr = params.lang === "ar";
  return buildPageMetadata({
    lang: params.lang,
    title: isAr
      ? "حاسبة العائد على الاستثمار | موعدي"
      : "ROI Calculator - Calculate Your Savings | Mawidi",
    description: isAr
      ? "احسب كم تخسر عيادتك سنوياً بسبب عدم حضور المرضى. حاسبة مجانية لتكلفة عدم الحضور والتوفير مع موعدي"
      : "Calculate how much your clinic loses annually to patient no-shows. Free no-show cost calculator and savings estimator with Mawidi AI receptionist.",
    path: "/tools/roi-calculator",
    keywords: isAr
      ? [
          "حاسبة عدم الحضور",
          "تكلفة عدم حضور المرضى",
          "حاسبة العائد على الاستثمار",
          "موعدي",
        ]
      : [
          "clinic no show calculator",
          "appointment loss calculator GCC",
          "receptionist cost Saudi Arabia",
          "ROI calculator healthcare",
        ],
  });
}

export default function ROICalculatorPage({
  params,
}: {
  params: { lang: Lang };
}) {
  const { lang } = params;
  const isAr = lang === "ar";

  const faqData = {
    mainEntity: [
      {
        "@type": "Question" as const,
        name: isAr
          ? "كم تخسر العيادات بسبب عدم الحضور؟"
          : "How much do clinics lose to no-shows?",
        acceptedAnswer: {
          "@type": "Answer" as const,
          text: isAr
            ? "تخسر العيادات في الخليج ما بين 15-35% من إيراداتها بسبب عدم حضور المرضى. بالنسبة لعيادة متوسطة تستقبل 300 موعد شهرياً بقيمة 350 ريال للموعد، هذا يعني خسارة تصل إلى 441,000 ريال سنوياً."
            : "GCC clinics lose 15-35% of their revenue to patient no-shows. For a mid-size clinic with 300 monthly appointments at SAR 350 each, this translates to up to SAR 441,000 lost annually.",
        },
      },
      {
        "@type": "Question" as const,
        name: isAr
          ? "هل يمكن للذكاء الاصطناعي تقليل عدم الحضور؟"
          : "Can AI reduce no-show rates?",
        acceptedAnswer: {
          "@type": "Answer" as const,
          text: isAr
            ? "نعم، تظهر الدراسات أن التذكيرات الآلية عبر واتساب والتأكيدات الذكية تقلل عدم الحضور بنسبة 60-70%. يستخدم موعدي الذكاء الاصطناعي للتذكير وإعادة الجدولة وتحصيل العربون لتقليل الخسائر."
            : "Yes, studies show automated WhatsApp reminders and smart confirmations reduce no-shows by 60-70%. Mawidi uses AI for reminders, rescheduling, and deposit collection to minimize losses.",
        },
      },
      {
        "@type": "Question" as const,
        name: isAr
          ? "كيف يعمل حاسبة العائد على الاستثمار؟"
          : "How does the ROI calculator work?",
        acceptedAnswer: {
          "@type": "Answer" as const,
          text: isAr
            ? "أدخل عدد مواعيدك الشهرية، متوسط قيمة الموعد، ونسبة عدم الحضور الحالية. تحسب الحاسبة خسائرك السنوية وتقارنها بتكلفة موعدي لتظهر لك التوفير الصافي والعائد على الاستثمار."
            : "Enter your monthly appointments, average appointment value, and current no-show rate. The calculator computes your annual losses and compares them with Mawidi's cost to show net savings and ROI.",
        },
      },
      {
        "@type": "Question" as const,
        name: isAr
          ? "ما هو متوسط العائد على الاستثمار مع موعدي؟"
          : "What is the average ROI with Mawidi?",
        acceptedAnswer: {
          "@type": "Answer" as const,
          text: isAr
            ? "يحقق عملاء موعدي عائداً على الاستثمار يتراوح بين 500-1200% في السنة الأولى. معظم العيادات تسترد تكلفة الاشتراك خلال 15-30 يوماً فقط."
            : "Mawidi customers achieve 500-1200% ROI in their first year. Most clinics recover their subscription cost within just 15-30 days.",
        },
      },
      {
        "@type": "Question" as const,
        name: isAr
          ? "هل الحاسبة مناسبة لجميع أنواع الأعمال؟"
          : "Is the calculator suitable for all business types?",
        acceptedAnswer: {
          "@type": "Answer" as const,
          text: isAr
            ? "نعم، الحاسبة مصممة للعيادات الطبية وصالونات التجميل والمطاعم وأي عمل يعتمد على المواعيد في دول الخليج. يمكنك تعديل جميع المدخلات لتناسب مجال عملك."
            : "Yes, the calculator works for healthcare clinics, beauty salons, restaurants, and any appointment-based business in the GCC. All inputs are customizable for your industry.",
        },
      },
    ],
  };

  return (
    <div className="min-h-screen bg-white dark:bg-slate-950">
      <CalculatorClient lang={lang} />

      <JsonLd type="FAQPage" data={faqData} />

      <JsonLd
        type="SoftwareApplication"
        data={{
          name: isAr
            ? "حاسبة العائد على الاستثمار من موعدي"
            : "Mawidi ROI Calculator",
          applicationCategory: "BusinessApplication",
          operatingSystem: "Web",
          offers: {
            "@type": "Offer",
            price: "0",
            priceCurrency: "USD",
            availability: "https://schema.org/InStock",
          },
          description: isAr
            ? "حاسبة مجانية لحساب تكلفة عدم حضور المرضى والتوفير المتوقع مع موعدي"
            : "Free calculator to estimate patient no-show costs and projected savings with Mawidi AI receptionist",
          featureList: isAr
            ? "حساب تكلفة عدم الحضور، تقدير التوفير، حساب العائد على الاستثمار، دعم عملات الخليج"
            : "No-show cost calculation, Savings estimation, ROI calculation, GCC currency support",
        }}
      />
    </div>
  );
}
