import { Metadata } from 'next'
import { prisma } from '@/lib/prisma'
import Link from 'next/link'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { ArrowRight, Star, Award, ShieldCheck, Wheat } from 'lucide-react'
import ProductCard from '@/components/ProductCard'
import { MultipleStructuredData } from '@/components/StructuredData'
import { generateProductListJsonLd, generateBreadcrumbJsonLd, generateFAQJsonLd } from '@/lib/structured-data'

export const metadata: Metadata = {
  title: 'Kashmina Rice - Premium Basmati Rice | Kashmina Steam & Sella | Padmaaja Rasooi',
  description: 'Discover authentic Kashmina Rice - Premium basmati with extraordinary length, exquisite aroma and royal taste. Available in Kashmina Steam Grade-1, Kashmina Sella, Kashmina Dubar & Kashmina Tibar varieties. Export quality, lab tested, FSSAI approved.',
  keywords: [
    'kashmina rice',
    'kashmina basmati rice',
    'kashmina steam rice',
    'kashmina sella rice',
    'kashmina steam grade 1',
    'kashmina sella tibar',
    'kashmina dubar',
    'premium kashmina rice',
    'authentic kashmina basmati',
    'kashmina rice online',
    'kashmina rice price',
    'padmaaja kashmina rice',
    'buy kashmina rice',
    'kashmina rice india',
    'export quality kashmina rice'
  ],
  openGraph: {
    title: 'Kashmina Rice - Premium Basmati | Padmaaja Rasooi',
    description: 'Authentic Kashmina Rice with extraordinary length, exquisite aroma and royal taste. Premium basmati varieties - Steam, Sella, Dubar & Tibar.',
    type: 'website',
    images: ['/images/kashmina-rice.jpg'],
  },
  alternates: {
    canonical: '/kashmina-rice',
  },
}

async function getKashminaProducts() {
  try {
    const products = await prisma.product.findMany({
      where: {
        isActive: true,
        OR: [
          { name: { contains: 'Kashmina', mode: 'insensitive' } },
          { brand: { contains: 'Kashmina', mode: 'insensitive' } },
          { description: { contains: 'Kashmina', mode: 'insensitive' } }
        ]
      },
      include: {
        category: true
      },
      orderBy: [
        { stock: 'desc' },
        { createdAt: 'desc' }
      ]
    })
    return products
  } catch (error) {
    console.error('Failed to fetch Kashmina products:', error)
    return []
  }
}

export default async function KashminaRicePage() {
  const products = await getKashminaProducts()
  const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'https://padmaajarasooi.com'

  // Generate JSON-LD for SEO
  const productListJsonLd = generateProductListJsonLd(products, baseUrl)
  
  const breadcrumbJsonLd = generateBreadcrumbJsonLd([
    { name: 'Home', url: '/' },
    { name: 'Kashmina Rice', url: '/kashmina-rice' }
  ], baseUrl)

  const faqJsonLd = generateFAQJsonLd([
    {
      question: 'What is Kashmina Rice?',
      answer: 'Kashmina Rice is a premium basmati rice variety known for its extraordinary grain length, exquisite aroma, and royal taste. It is aged basmati rice that undergoes strict quality control and is available in various grades including Steam and Sella processing.'
    },
    {
      question: 'What are the different types of Kashmina Rice available?',
      answer: 'Kashmina Rice is available in multiple varieties: Kashmina Steam Grade-1, Kashmina Steam Dubar, Kashmina Steam Tibar, Kashmina Sella Grade-1, Kashmina Sella Tibar, and Kashmina Sella Dubar. Each variety offers unique cooking properties and taste profiles.'
    },
    {
      question: 'Is Kashmina Rice export quality?',
      answer: 'Yes, Kashmina Rice meets international quality standards and is export-grade basmati rice. It is lab-tested, FSSAI approved, and certified for quality and purity.'
    },
    {
      question: 'What is the difference between Kashmina Steam and Kashmina Sella?',
      answer: 'Kashmina Steam rice is processed with steam for enhanced aroma and taste, resulting in softer grains. Kashmina Sella undergoes parboiling before milling, making it firmer with better texture, ideal for biryani and special occasions.'
    },
    {
      question: 'Where can I buy Kashmina Rice?',
      answer: 'You can buy authentic Kashmina Rice from Padmaaja Rasooi online. We offer various pack sizes with home delivery across India.'
    }
  ])

  return (
    <>
      {/* SEO: Structured Data */}
      <MultipleStructuredData 
        dataArray={[productListJsonLd, breadcrumbJsonLd, faqJsonLd]}
        idPrefix="kashmina"
      />

      <div className="min-h-screen bg-gradient-to-br from-amber-50 via-yellow-50 to-orange-50">
        {/* Hero Section */}
        <section className="relative py-20 overflow-hidden">
          <div className="absolute inset-0 bg-[radial-gradient(circle_at_30%_20%,rgba(245,158,11,0.1),transparent_50%)]"></div>
          <div className="absolute inset-0 bg-[radial-gradient(circle_at_70%_80%,rgba(251,191,36,0.1),transparent_50%)]"></div>
          
          <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10">
            {/* Breadcrumb */}
            <nav className="mb-8 text-sm">
              <ol className="flex items-center space-x-2 text-gray-600">
                <li><Link href="/" className="hover:text-amber-600">Home</Link></li>
                <li>/</li>
                <li className="text-amber-600 font-semibold">Kashmina Rice</li>
              </ol>
            </nav>

            <div className="text-center max-w-4xl mx-auto">
              <Badge className="mb-6 bg-gradient-to-r from-amber-500 to-orange-500 text-white px-6 py-2">
                Premium Basmati Rice
              </Badge>
              
              <h1 className="text-5xl md:text-6xl lg:text-7xl font-bold text-gray-900 mb-6">
                <span className="text-transparent bg-gradient-to-r from-amber-600 via-yellow-600 to-orange-600 bg-clip-text">
                  Kashmina Rice
                </span>
              </h1>
              
              <p className="text-xl md:text-2xl text-gray-700 mb-8 leading-relaxed">
                Authentic aged Basmati rice with <span className="font-bold text-amber-600">extraordinary length</span>, 
                <span className="font-bold text-amber-600"> exquisite aroma</span>, and 
                <span className="font-bold text-amber-600"> royal taste</span>
              </p>

              {/* Key Features */}
              <div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-12">
                <div className="bg-white/80 backdrop-blur-sm rounded-xl p-6 shadow-lg">
                  <Wheat className="h-8 w-8 text-emerald-600 mx-auto mb-2" />
                  <p className="font-semibold text-gray-900">Authentic Grains</p>
                </div>
                <div className="bg-white/80 backdrop-blur-sm rounded-xl p-6 shadow-lg">
                  <Award className="h-8 w-8 text-blue-600 mx-auto mb-2" />
                  <p className="font-semibold text-gray-900">Export Quality</p>
                </div>
                <div className="bg-white/80 backdrop-blur-sm rounded-xl p-6 shadow-lg">
                  <ShieldCheck className="h-8 w-8 text-purple-600 mx-auto mb-2" />
                  <p className="font-semibold text-gray-900">Lab Tested</p>
                </div>
                <div className="bg-white/80 backdrop-blur-sm rounded-xl p-6 shadow-lg">
                  <Star className="h-8 w-8 text-amber-600 mx-auto mb-2" />
                  <p className="font-semibold text-gray-900">Premium Grade</p>
                </div>
              </div>
            </div>
          </div>
        </section>

        {/* Products Section */}
        <section className="py-16 bg-white">
          <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div className="text-center mb-12">
              <h2 className="text-3xl md:text-4xl font-bold text-gray-900 mb-4">
                Kashmina Rice Varieties
              </h2>
              <p className="text-lg text-gray-600 max-w-3xl mx-auto">
                Choose from our premium collection of Kashmina Steam and Sella rice in various grades
              </p>
            </div>

            {products.length > 0 ? (
              <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
                {products.map((product, index) => (
                  <ProductCard key={product.id} product={product} index={index} />
                ))}
              </div>
            ) : (
              <div className="text-center py-12">
                <p className="text-gray-600 text-lg mb-6">
                  Kashmina Rice products are currently being updated. Please check back soon!
                </p>
                <Link href="/products">
                  <Button size="lg">
                    View All Products
                    <ArrowRight className="ml-2 h-4 w-4" />
                  </Button>
                </Link>
              </div>
            )}
          </div>
        </section>

        {/* About Kashmina Section */}
        <section className="py-16 bg-gradient-to-br from-amber-50 to-orange-50">
          <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div className="max-w-4xl mx-auto">
              <h2 className="text-3xl md:text-4xl font-bold text-gray-900 mb-8 text-center">
                Why Choose Kashmina Rice?
              </h2>
              
              <div className="space-y-6 bg-white/80 backdrop-blur-sm rounded-2xl p-8 shadow-lg">
                <div>
                  <h3 className="text-xl font-bold text-gray-900 mb-3">Premium Quality</h3>
                  <p className="text-gray-700 leading-relaxed">
                    Kashmina Rice is a treasured grain variety known for its distinct aroma and great nutty taste. 
                    Each grain is carefully selected and aged to perfection, ensuring the highest quality standards.
                  </p>
                </div>

                <div>
                  <h3 className="text-xl font-bold text-gray-900 mb-3">Export Grade Standards</h3>
                  <p className="text-gray-700 leading-relaxed">
                    Our Kashmina Rice meets international quality standards, making it suitable for global markets. 
                    It undergoes rigorous quality checks and lab testing to ensure purity and excellence.
                  </p>
                </div>

                <div>
                  <h3 className="text-xl font-bold text-gray-900 mb-3">Multiple Varieties</h3>
                  <p className="text-gray-700 leading-relaxed">
                    Available in both Steam and Sella processing, with various grades including Grade-1, Dubar, and Tibar. 
                    Whether you need rice for daily cooking or special occasions, we have the perfect variety for you.
                  </p>
                </div>

                <div>
                  <h3 className="text-xl font-bold text-gray-900 mb-3">Certified & Safe</h3>
                  <p className="text-gray-700 leading-relaxed">
                    FSSAI approved and certified for quality. Our Kashmina Rice is free from harmful chemicals, 
                    pesticide-free, and processed in hygienic conditions to ensure your family's health and safety.
                  </p>
                </div>
              </div>
            </div>
          </div>
        </section>

        {/* CTA Section */}
        <section className="py-16 bg-gradient-to-r from-amber-600 to-orange-600">
          <div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
            <h2 className="text-3xl md:text-4xl font-bold text-white mb-6">
              Experience the Royal Taste of Kashmina Rice
            </h2>
            <p className="text-xl text-white/90 mb-8">
              Order now and enjoy premium quality basmati rice delivered to your doorstep
            </p>
            <div className="flex flex-wrap justify-center gap-4">
              <Link href="/products">
                <Button size="lg" variant="secondary">
                  Shop All Products
                  <ArrowRight className="ml-2 h-4 w-4" />
                </Button>
              </Link>
              <Link href="/contact">
                <Button size="lg" variant="outline" className="bg-white/10 text-white border-white hover:bg-white hover:text-amber-600">
                  Contact Us
                </Button>
              </Link>
            </div>
          </div>
        </section>
      </div>
    </>
  )
}
