import { blogs } from "@/utils/data";
import Link from "next/link";

const BlogSection = ({ hideHeader = false }: { hideHeader?: boolean }) => (
    <section className="blog-section-one section-space">
        <div className="small-container">
            {!hideHeader && (
                <div className="title-box mb-40 wow fadeInLeft" data-wow-delay=".5s">
                    <span className="section-sub-title">LATEST blog</span>
                    <h3 className="section-title mt-10">Latest Blog Insights</h3>
                </div>
            )}
            <div className="row g-4">
                {blogs.slice(0, 3).map((blog, index) => (
                    <div key={blog.id} className="col-xxl-4 col-xl-4 col-lg-6">
                        <div className="blog-style-one relative overflow-hidden">
                            <Link className="blog-image w-img block relative" href={`/blog/${blog.slug}`}>
                                <img src={blog.image} alt={blog.title} />
                                <span className="blog-category-tag">{blog.category}</span>
                            </Link>
                            <div className="blog-content">
                                <div className="post-meta">
                                    <span className="p-relative">
                                        <i className="fa-solid fa-user"></i> By Admin
                                    </span>
                                    <span className="p-relative">
                                        <i className="fa-solid fa-calendar-days"></i> {blog.date}
                                    </span>
                                </div>
                                <hr />
                                <h5 className="blog-title mb-30">
                                    <Link href={`/blog/${blog.slug}`}>{blog.title}</Link>
                                </h5>
                                <div className="blog-link">
                                    <Link className="primary-btn-5 btn-hover" href={`/blog/${blog.slug}`}>
                                        Read MORE &nbsp; | <i className="fa-solid fa-arrow-right"></i>
                                        <span className="btn-hover-span"></span>
                                    </Link>
                                </div>
                            </div>
                        </div>
                    </div>
                ))}
            </div>
        </div>

        <style jsx>{`
            .relative { position: relative; }
            .blog-image { position: relative; display: block; overflow: hidden; border-radius: 20px 20px 0 0; }
            .blog-image img { width: 100%; border-radius: 20px 20px 0 0; }
            .blog-category-tag {
                position: absolute;
                bottom: 0px;
                right: 0px;
                background: #3779b9;
                color: #fff;
                padding: 10px 20px;
                font-size: 13px;
                font-weight: 700;
                text-transform: uppercase;
                z-index: 2;
                border-radius: 12px 0 0 0;
                letter-spacing: 0.5px;
            }
            .blog-style-one {
                border-left: 1px solid #e2e8f0;
                border-right: 1px solid #e2e8f0;
                border-bottom: 1px solid #e2e8f0;
                border-radius: 20px 20px 15px 15px;
                background: #fff;
                transition: all 0.3s ease;
            }
            .blog-style-one:hover {
                border-color: #3779b9;
                box-shadow: 0 10px 30px rgba(55, 121, 185, 0.1);
            }
            .blog-content {
                padding: 30px 25px;
            }
            .blog-title {
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
                overflow: hidden;
                line-height: 1.5;
                height: 3em;
            }
            .post-meta span {
                display: inline-flex;
                align-items: center;
                gap: 8px;
                margin-right: 15px;
                font-size: 14px;
                color: #64748b;
            }
            .post-meta i {
                color: #3779b9;
            }
        `}</style>
    </section>
);

export default BlogSection;
