"use client";

import Link from "next/link";
import { Check } from "lucide-react";

const SEO_CHECKS = [
  "Meta titles optimized",
  "Schema markup active",
  "Bangla keywords tracked",
  "Sitemap submitted",
];

export default function SEOHealthCard({ score = 92 }: { score?: number }) {
  const color = score >= 80 ? "text-green-600" : score >= 60 ? "text-yellow-500" : "text-red-500";
  const ring = score >= 80 ? "stroke-green-500" : score >= 60 ? "stroke-yellow-500" : "stroke-red-500";
  const circumference = 2 * Math.PI * 28;
  const dash = (score / 100) * circumference;

  return (
    <div className="bg-white border border-slate-100 rounded-xl overflow-hidden">
      <div className="px-4 py-3 border-b border-slate-100">
        <h2 className="text-sm font-bold text-slate-900">SEO Health</h2>
      </div>
      <div className="p-4">
        {/* Score ring */}
        <div className="flex items-center gap-4 mb-4">
          <div className="relative w-16 h-16 flex-shrink-0">
            <svg className="w-16 h-16 -rotate-90" viewBox="0 0 64 64">
              <circle cx="32" cy="32" r="28" fill="none" stroke="#f1f5f9" strokeWidth="7" />
              <circle
                cx="32"
                cy="32"
                r="28"
                fill="none"
                className={ring}
                strokeWidth="7"
                strokeLinecap="round"
                strokeDasharray={`${dash} ${circumference}`}
                style={{ transition: "stroke-dasharray 1s ease" }}
              />
            </svg>
            <div className="absolute inset-0 flex items-center justify-center">
              <span className={`text-lg font-bold ${color}`}>{score}</span>
            </div>
          </div>
          <div>
            <p className={`text-2xl font-bold ${color}`}>{score}<span className="text-sm font-normal text-slate-400">/100</span></p>
            <p className="text-xs text-slate-500">SEO Score</p>
          </div>
        </div>

        <ul className="space-y-1.5 mb-4">
          {SEO_CHECKS.map((check) => (
            <li key={check} className="flex items-center gap-2 text-xs text-slate-600">
              <div className="w-4 h-4 bg-green-100 rounded-full flex items-center justify-center flex-shrink-0">
                <Check className="w-2.5 h-2.5 text-green-600" />
              </div>
              {check}
            </li>
          ))}
        </ul>

        <Link
          href="/admin/seo"
          className="block w-full bg-purple-600 hover:bg-purple-700 text-white text-xs font-semibold py-2 rounded-lg text-center transition-colors"
        >
          Open SEO Center
        </Link>
      </div>
    </div>
  );
}
