'use client';

import { useRouter } from 'next/navigation';
import { motion } from 'framer-motion';

export default function CheckoutCancelPage() {
  const router = useRouter();

  // Note: Removed auto-redirect to allow offset order state restoration to work
  // User can manually click "Try Again" to return to calculator

  return (
    <div className="min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-cyan-50 flex items-center justify-center p-6">
      <motion.div
        initial={{ opacity: 0, y: 20 }}
        animate={{ opacity: 1, y: 0 }}
        transition={{ duration: 0.5 }}
        className="max-w-2xl w-full"
      >
        {/* Cancel Header */}
        <motion.div
          initial={{ scale: 0 }}
          animate={{ scale: 1 }}
          transition={{ delay: 0.2, type: 'spring', stiffness: 200 }}
          className="text-center mb-8"
        >
          <div className="text-yellow-500 text-7xl mb-4">⚠️</div>
          <h1 className="text-4xl md:text-5xl font-bold text-slate-800 mb-2">
            Checkout Cancelled
          </h1>
          <p className="text-xl text-slate-600">
            Your payment was not processed
          </p>
        </motion.div>

        {/* Information Card */}
        <motion.div
          initial={{ opacity: 0, y: 20 }}
          animate={{ opacity: 1, y: 0 }}
          transition={{ delay: 0.3 }}
          className="bg-white rounded-2xl shadow-luxury p-8 mb-6"
        >
          <h2 className="text-2xl font-bold text-slate-800 mb-4">What happened?</h2>
          <p className="text-slate-600 mb-6 leading-relaxed">
            You cancelled the checkout process before completing your payment.
            No charges have been made to your card.
          </p>

          <div className="bg-blue-50 border-l-4 border-blue-500 p-4 rounded">
            <p className="text-blue-800 font-medium">
              💡 Your climate impact matters
            </p>
            <p className="text-blue-700 text-sm mt-1">
              Every ton of CO₂ offset helps combat climate change. Consider completing
              your purchase to make a positive impact on our planet.
            </p>
          </div>
        </motion.div>

        {/* Why Offset Section */}
        <motion.div
          initial={{ opacity: 0, y: 20 }}
          animate={{ opacity: 1, y: 0 }}
          transition={{ delay: 0.4 }}
          className="bg-gradient-to-r from-cyan-500 to-blue-500 rounded-2xl shadow-luxury p-6 text-white mb-6"
        >
          <h3 className="text-2xl font-bold mb-4">🌊 Why Carbon Offsetting Matters</h3>
          <div className="space-y-3">
            <div className="flex items-start gap-3">
              <span className="text-cyan-200 text-xl flex-shrink-0">✓</span>
              <p className="text-cyan-50">
                <strong>Protect Marine Ecosystems:</strong> Reduce ocean acidification
                and protect marine life.
              </p>
            </div>
            <div className="flex items-start gap-3">
              <span className="text-cyan-200 text-xl flex-shrink-0">✓</span>
              <p className="text-cyan-50">
                <strong>Support Verified Projects:</strong> All projects are certified
                and verified for real climate impact.
              </p>
            </div>
            <div className="flex items-start gap-3">
              <span className="text-cyan-200 text-xl flex-shrink-0">✓</span>
              <p className="text-cyan-50">
                <strong>Transparent Impact:</strong> Track exactly where your contribution
                goes and the impact it creates.
              </p>
            </div>
          </div>
        </motion.div>

        {/* Action Buttons */}
        <motion.div
          initial={{ opacity: 0 }}
          animate={{ opacity: 1 }}
          transition={{ delay: 0.5 }}
          className="flex flex-col sm:flex-row gap-4 justify-center"
        >
          <button
            onClick={() => router.push('/calculator')}
            className="px-8 py-3 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition-all hover:shadow-lg font-semibold text-center"
          >
            Try Again
          </button>
          <button
            onClick={() => router.push('/')}
            className="px-8 py-3 bg-white text-slate-700 rounded-lg hover:bg-slate-50 transition-all hover:shadow-lg font-semibold border border-slate-200 text-center"
          >
            Return to Home
          </button>
        </motion.div>

        {/* Help Section */}
        <motion.div
          initial={{ opacity: 0 }}
          animate={{ opacity: 1 }}
          transition={{ delay: 0.6 }}
          className="mt-8 text-center"
        >
          <p className="text-slate-500 text-sm mb-2">Need help with your order?</p>
          <a
            href="mailto:support@puffinoffset.com"
            className="text-blue-500 hover:text-blue-600 font-medium text-sm"
          >
            Contact Support
          </a>
        </motion.div>
      </motion.div>
    </div>
  );
}
