@extends('layouts.app')
@php $active_page = 'news'; @endphp


@section('content')
<!-- Hero Section -->
<section class="relative bg-slate-50 pt-32 pb-20 lg:pt-48 lg:pb-32 overflow-hidden border-b border-slate-100">
    <div class="absolute inset-0 max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
        <div class="absolute right-0 top-0 w-1/2 h-full bg-brand-primary/5 blur-3xl rounded-full transform translate-x-1/3 -translate-y-1/4"></div>
        <div class="absolute left-0 bottom-0 w-1/3 h-2/3 bg-brand-light/20 blur-3xl rounded-full transform -translate-x-1/2 translate-y-1/3"></div>
    </div>
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10 text-center">
        <span class="inline-block py-1 px-3 rounded-full bg-brand-primary/10 text-brand-primary text-sm font-semibold tracking-wider mb-6 border border-brand-primary/20 backdrop-blur-sm">INSIGHTS</span>
        <h1 class="text-4xl md:text-5xl lg:text-7xl font-extrabold text-slate-900 tracking-tight mb-8">
            News & <span class="text-transparent bg-clip-text bg-gradient-to-r from-brand-primary to-brand-secondary">Articles</span>
        </h1>
        <p class="text-lg md:text-xl text-slate-600 max-w-2xl mx-auto leading-relaxed">
            Stay updated with the latest news, industry insights, and updates from ECS.
        </p>
    </div>
</section>

<!-- Blog Grid -->
<section class="py-20 lg:py-32 bg-slate-50 relative">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 relative z-10">
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
            @forelse($posts as $post)
            <div class="bg-white rounded-3xl overflow-hidden shadow-lg shadow-slate-200/50 hover:shadow-xl hover:-translate-y-2 transition-all duration-300 group flex flex-col h-full border border-slate-100">
                <div class="relative h-64 overflow-hidden">
                    @if($post->image_path)
                        <img src="{{ asset($post->image_path) }}" alt="{{ $post->title }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-700">
                    @else
                        <div class="w-full h-full bg-slate-200 flex items-center justify-center">
                            <svg class="w-12 h-12 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"></path></svg>
                        </div>
                    @endif
                    <div class="absolute inset-0 bg-gradient-to-t from-slate-900/80 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div>
                </div>
                
                <div class="p-8 flex flex-col flex-grow">
                    <div class="flex items-center gap-4 mb-4">
                        <span class="text-sm font-bold text-brand-primary bg-brand-primary/10 px-3 py-1 rounded-full">{{ $post->published_at->format('M d, Y') }}</span>
                    </div>
                    
                    <h3 class="text-xl font-bold text-slate-900 mb-4 line-clamp-2 group-hover:text-brand-primary transition-colors">
                        <a href="{{ route('news.show', $post->slug) }}" class="focus:outline-none">
                            <span class="absolute inset-0" aria-hidden="true"></span>
                            {{ $post->title }}
                        </a>
                    </h3>
                    
                    <p class="text-slate-600 mb-6 line-clamp-3">
                        {{ Str::limit(strip_tags($post->content), 120) }}
                    </p>
                    
                    <div class="mt-auto border-t border-slate-100 pt-6 flex items-center justify-between">
                        <span class="text-brand-primary font-bold text-sm flex items-center gap-2 group-hover:translate-x-1 transition-transform">
                            Read Article
                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"></path></svg>
                        </span>
                    </div>
                </div>
            </div>
            @empty
            <div class="col-span-full text-center py-20">
                <div class="inline-flex items-center justify-center w-20 h-20 rounded-full bg-slate-100 mb-6">
                    <svg class="w-10 h-10 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"></path></svg>
                </div>
                <h3 class="text-2xl font-bold text-slate-900 mb-2">Check Back Later</h3>
                <p class="text-slate-500 max-w-md mx-auto">We're currently preparing some insightful articles for you. Our news section will be updated soon.</p>
            </div>
            @endforelse
        </div>
        
        @if($posts->hasPages())
        <div class="mt-16 flex justify-center">
            {{ $posts->links() }}
        </div>
        @endif
    </div>
</section>
@endsection
