import React from 'react';
import { Link } from '@inertiajs/react';
import { Calendar, Clock, ArrowRight } from 'lucide-react';
import { formatCustomDate } from '@/lib/utils';

interface BlogProps {
    post: {
        id: number;
        title: string;
        slug: string;
        excerpt?: string;
        published_at?: string;
        reading_time?: number;
        category?: { name: string; slug: string };
    };
}

export const BlogCard: React.FC<BlogProps> = ({ post }) => {
    return (
        <div className="glass-card glass-card-hover rounded-2xl overflow-hidden flex flex-col justify-between group">
            <div className="p-6">
                <div className="flex items-center justify-between gap-2 mb-3">
                    <span className="text-[11px] font-semibold uppercase tracking-wider px-2.5 py-0.5 rounded-full bg-[#00F2FE]/10 text-[#00F2FE] border border-[#00F2FE]/20">
                        {post.category?.name || 'Article'}
                    </span>
                    <div className="flex items-center gap-1 text-[11px] text-slate-400">
                        <Clock className="w-3 h-3 text-slate-400" />
                        <span>{post.reading_time || 5} min read</span>
                    </div>
                </div>

                <h3 className="text-lg font-bold text-white group-hover:text-[#00F2FE] transition-colors mb-2 line-clamp-2">
                    <Link href={`/blog/${post.slug}`}>{post.title}</Link>
                </h3>
                <p className="text-xs text-slate-400 leading-relaxed line-clamp-3 mb-6">
                    {post.excerpt}
                </p>
            </div>

            <div className="px-6 py-4 bg-[#060B18]/40 border-t border-slate-800 flex items-center justify-between">
                <span className="text-xs text-slate-400 flex items-center gap-1">
                    <Calendar className="w-3 h-3 text-slate-400" />
                    {post.published_at ? formatCustomDate(post.published_at) : 'Recent'}
                </span>
                <Link
                    href={`/blog/${post.slug}`}
                    className="text-xs font-semibold text-[#00F2FE] hover:text-white flex items-center gap-1 transition-colors"
                >
                    Read Article
                    <ArrowRight className="w-3.5 h-3.5 group-hover:translate-x-1 transition-transform" />
                </Link>
            </div>
        </div>
    );
};
