@extends('layouts.app')

@section('title', 'Business Standard - India\'s Leading Business Daily')
@section('meta_description', 'Get latest news on markets, economy, companies, politics, technology and more on Business Standard.')

@section('content')

    {{-- 1st section: SPOTLIGHT / HERO --}}
    @if($spotlightMain)
    <section class="border border-gray-300 mt-12">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6 py-6">
        <div class="flex flex-col md:flex-row justify-between gap-6">
          {{-- LEFT CONTENT --}}
          <div class="flex-1">
            <div class="mb-4">
              <h2 class="text-2xl md:text-3xl font-bold">
                <span class="text-red-700">{{ strtoupper($spotlightCategory->category_name_english ?? $spotlightCategory->category_name) }}</span>
                {{ strtoupper($spotlightCategory->category_name) }}
              </h2>
              <div class="w-16 h-[3px] bg-red-700 mt-2"></div>
            </div>
            <div class="grid md:grid-cols-2 gap-6 items-start">
              <a href="{{ $spotlightMain->canonical_url }}">
                <img src="{{ $spotlightMain->photo_url }}" class="w-full h-[220px] md:h-[250px] object-cover rounded" alt="{{ $spotlightMain->img_alt_english ?? $spotlightMain->news_title_english ?? $spotlightMain->news_title }}"/>
              </a>
              <div>
                <a href="{{ $spotlightMain->canonical_url }}">
                  <h3 class="text-xl md:text-3xl font-semibold leading-snug hover:text-red-700 transition">{{ $spotlightMain->news_title_english ?? $spotlightMain->news_title }}</h3>
                </a>
                <p class="text-gray-600 mt-3 leading-6">
                  {{ Str::limit(strip_tags($spotlightMain->news_content_short_english ?? $spotlightMain->news_content_short ?? ''), 160) }}
                </p>
              </div>
            </div>
          </div>
          {{-- RIGHT SIDE AD --}}
          <div class="w-full md:w-[260px] shrink-0">
            <p class="text-sm text-gray-600 mb-2 text-right md:text-left">Advertisement</p>
            <img src="{{ asset('images/ad.webp') }}" class="w-full h-[250px] object-cover border" alt="Advertisement"/>
          </div>
        </div>
        {{-- DIVIDER --}}
        <div class="border-t my-6"></div>
        {{-- BOTTOM NEWS --}}
        <div class="grid md:grid-cols-3 gap-4 text-sm md:text-base font-semibold">
          @foreach($spotlightLinks->take(3) as $link)
          <a href="{{ $link->canonical_url }}" class="md:border-r pr-4 hover:text-red-700 transition last:border-r-0">{{ $link->news_title_english ?? $link->news_title }}</a>
          @endforeach
        </div>
      </div>
    </section>
    @endif

    {{-- 2nd section: TOP NEWS --}}
    <section class="mt-8 border-t-4 pt-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="mb-4">
          <h2 class="text-xl md:text-xl font-bold">Top News</h2>
          <div class="w-16 h-[2px] bg-red-600 mt-2"></div>
        </div>
        <div class="grid md:grid-cols-3 gap-6">
          {{-- LEFT FEATURE --}}
          @if($topNewsHero)
          <div class="md:border-r md:pr-6">
            <a href="{{ $topNewsHero->canonical_url }}">
              <h3 class="text-lg md:text-2xl font-bold leading-snug mb-3 hover:text-red-700 transition">{{ $topNewsHero->news_title_english ?? $topNewsHero->news_title }}</h3>
              <img src="{{ $topNewsHero->photo_url }}" class="w-full h-[220px] md:h-[220px] object-cover rounded" alt="{{ $topNewsHero->img_alt_english ?? $topNewsHero->news_title }}"/>
            </a>
          </div>
          @endif
          {{-- MIDDLE LIST --}}
          <div class="space-y-1 md:border-r md:pr-6">
            @foreach($topNewsMiddle as $item)
            <a href="{{ $item->canonical_url }}" class="block pb-1 border-b hover:text-red-700 transition">
              <p class="font-bold text-sm">{{ $item->news_title_english ?? $item->news_title }}</p>
              <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
            </a>
            @endforeach
          </div>
          {{-- RIGHT SIDE --}}
          <div class="space-y-6">
            <div>
              <p class="text-sm text-gray-600 mb-2">Advertisement</p>
              <img src="{{ asset('images/ad.webp') }}" class="w-full h-[220px] object-cover border" alt="Advertisement"/>
            </div>
            @if($topNewsSubItems->first())
            <div class="border-t pt-4">
              <a href="{{ $topNewsSubItems->first()->canonical_url }}" class="hover:text-red-700 transition">
                <p class="font-bold">{{ $topNewsSubItems->first()->news_title_english ?? $topNewsSubItems->first()->news_title }}</p>
                <span class="text-xs text-gray-500">{{ $topNewsSubItems->first()->reading_time }} min read</span>
              </a>
            </div>
            @endif
          </div>
        </div>
      </div>
    </section>

    {{-- 3rd section: SPECIAL COVERAGE (For You - 4 categories) --}}
    @if($forYouItems->isNotEmpty())
    <section class="mt-10 border-t-4 pt-4">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="mb-6">
          <h2 class="text-xl font-bold">Special Coverage</h2>
          <div class="w-20 h-[2px] bg-red-600 mt-2"></div>
        </div>
        <div class="grid md:grid-cols-4 gap-6">
          @foreach($forYouItems as $item)
          <div class="border border-black">
            <div class="border-b text-center font-semibold py-2">{{ $item->category->category_name_english ?? $item->category->category_name ?? '' }}</div>
            <a href="{{ $item->canonical_url }}">
              <img src="{{ $item->photo_url }}" class="w-full h-[160px] object-cover" alt="{{ $item->img_alt_english ?? $item->news_title }}"/>
            </a>
            <div class="p-3 text-sm">
              <a href="{{ $item->canonical_url }}">
                <h3 class="font-bold mb-2 hover:text-red-700 transition">{{ $item->news_title_english ?? $item->news_title }}</h3>
              </a>
              <ul class="list-disc pl-4 space-y-1 font-normal text-xs">
                <li>{{ Str::limit(strip_tags($item->news_content_short_english ?? $item->news_content_short ?? ''), 80) }}</li>
              </ul>
              <a href="{{ route('category.show', $item->category->slug ?? '') }}" class="text-right block mt-2 text-gray-600 cursor-pointer hover:text-red-600">more →</a>
            </div>
          </div>
          @endforeach
        </div>
      </div>
    </section>
    @endif

    {{-- 4th section: LATEST NEWS --}}
    <section class="mt-10 border-t-4 pt-4">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="flex justify-between items-center mb-4">
          <div>
            <h2 class="text-xl font-bold">Latest News</h2>
            <div class="w-16 h-[2px] bg-red-600 mt-2"></div>
          </div>
        </div>
        <div class="grid md:grid-cols-3 gap-6">
          {{-- LEFT COLUMN --}}
          <div class="space-y-2 border-r md:pr-4">
            @foreach($latestSidebarFeed as $item)
            <a href="{{ $item->canonical_url }}" class="block pb-1 border-b hover:text-red-700 transition">
              <p class="font-semibold text-sm">{{ $item->news_title_english ?? $item->news_title }}</p>
              <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
            </a>
            @endforeach
          </div>
          {{-- MIDDLE COLUMN --}}
          <div class="space-y-4">
            @if($editorsPick)
            <div>
              <a href="{{ $editorsPick->canonical_url }}">
                <h3 class="text-lg font-bold mb-3 hover:text-red-700 transition">{{ $editorsPick->news_title_english ?? $editorsPick->news_title }}</h3>
                <img src="{{ $editorsPick->photo_url }}" class="w-full h-[220px] object-cover rounded" alt="{{ $editorsPick->img_alt_english ?? $editorsPick->news_title }}"/>
              </a>
            </div>
            @endif
            <div class="space-y-1">
              @foreach($editorsMiddle as $item)
              <a href="{{ $item->canonical_url }}" class="block border-b pb-1 hover:text-red-700 transition">
                <p class="font-semibold text-sm">{{ $item->news_title_english ?? $item->news_title }}</p>
                <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
              </a>
              @endforeach
            </div>
          </div>
          {{-- RIGHT COLUMN (ADVERTISEMENT) --}}
          <div class="hidden md:block">
            <p class="text-sm text-gray-600 mb-2">Advertisement</p>
            <img src="{{ asset('images/ad.webp') }}" class="w-full h-[600px] object-cover border rounded" alt="Advertisement"/>
          </div>
        </div>
      </div>
    </section>

    {{-- 5th section: SPOTLIGHT + POLL --}}
    <section class="mt-10 border-t-4 pt-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="grid md:grid-cols-4 gap-6">
          {{-- LEFT: SPOTLIGHT (Most Popular) --}}
          <div class="md:col-span-3">
            <div class="mb-4">
              <h2 class="text-xl font-bold">Spotlight</h2>
              <div class="w-16 h-[2px] bg-red-600 mt-2"></div>
            </div>
            <div class="grid md:grid-cols-3 gap-6">
              @foreach($mostPopular->take(3) as $item)
              <div class="border rounded p-3 bg-gray-50">
                <a href="{{ $item->canonical_url }}">
                  <h3 class="font-semibold mb-3 leading-snug hover:text-red-700 transition">{{ $item->news_title_english ?? $item->news_title }}</h3>
                  <img src="{{ $item->photo_url }}" class="w-full h-[150px] object-cover rounded" alt="{{ $item->img_alt_english ?? $item->news_title }}"/>
                </a>
                <p class="text-xs text-gray-500 mt-2">{{ $item->reading_time }} min read</p>
              </div>
              @endforeach
            </div>
          </div>
          {{-- RIGHT: POLL --}}
          <div class="bg-[#e6d2c2] p-5 rounded">
            <div class="mb-4">
              <h2 class="text-xl font-bold text-center">Poll</h2>
              <div class="w-16 h-[2px] bg-red-600 mt-2 mx-auto"></div>
            </div>
            <p class="font-semibold mb-4 text-sm leading-snug">Should the government increase focus on economic growth over fiscal consolidation?</p>
            <div class="space-y-3">
              <label class="flex items-center gap-3 bg-white p-3 rounded cursor-pointer">
                <input type="radio" name="poll" class="accent-red-600"> Yes
              </label>
              <label class="flex items-center gap-3 bg-white p-3 rounded cursor-pointer">
                <input type="radio" name="poll" class="accent-red-600"> No
              </label>
            </div>
            <div class="flex justify-between items-center mt-5">
              <span class="text-red-600 text-sm cursor-pointer">View All Polls</span>
              <button class="bg-red-600 text-white px-4 py-1 rounded text-sm">Submit</button>
            </div>
          </div>
        </div>
      </div>
    </section>

    {{-- 6th section: MARKETS (Section One) --}}
    @if($sectionOneMain)
    <section class="mt-10 border-t-4 pt-2">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="flex justify-between items-center mb-4">
          <div>
            <h2 class="text-xl font-bold">{{ $sectionOneCategory->category_name_english ?? $sectionOneCategory->category_name }}</h2>
            <div class="w-16 h-[2px] bg-red-600 mt-2"></div>
          </div>
          <a href="{{ route('category.show', $sectionOneCategory->slug) }}" class="text-sm text-gray-600 cursor-pointer hover:text-red-600">more →</a>
        </div>
        <div class="grid md:grid-cols-3 gap-6">
          {{-- LEFT COLUMN --}}
          <div class="space-y-2 md:border-r md:pr-4">
            @foreach($sectionOneLeft as $item)
            <a href="{{ $item->canonical_url }}" class="block border-b pb-1 hover:text-red-700 transition">
              <div class="flex gap-3">
                <img src="{{ $item->photo_url }}" class="w-20 h-16 object-cover rounded flex-shrink-0"/>
                <div>
                  <p class="font-semibold text-sm">{{ $item->news_title_english ?? $item->news_title }}</p>
                  <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
                </div>
              </div>
            </a>
            @endforeach
          </div>
          {{-- CENTER COLUMN --}}
          <div class="space-y-4">
            <a href="{{ $sectionOneMain->canonical_url }}">
              <h3 class="text-xl font-bold leading-snug mb-3 hover:text-red-700 transition">{{ $sectionOneMain->news_title_english ?? $sectionOneMain->news_title }}</h3>
              <img src="{{ $sectionOneMain->photo_url }}" class="w-full h-[220px] object-cover rounded" alt="{{ $sectionOneMain->img_alt_english ?? $sectionOneMain->news_title }}"/>
            </a>
            @foreach($sectionOneRight->take(2) as $item)
            <a href="{{ $item->canonical_url }}" class="flex gap-3 border-t pt-1 hover:text-red-700 transition">
              <img src="{{ $item->photo_url }}" class="w-20 h-16 object-cover rounded flex-shrink-0"/>
              <div>
                <p class="font-semibold text-sm">{{ $item->news_title_english ?? $item->news_title }}</p>
                <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
              </div>
            </a>
            @endforeach
          </div>
          {{-- RIGHT COLUMN --}}
          <div class="space-y-2 md:border-l md:pl-4">
            @foreach($citiesPanel as $item)
            <a href="{{ $item->canonical_url }}" class="flex gap-3 border-b pb-4 hover:text-red-700 transition">
              <img src="{{ $item->photo_url }}" class="w-20 h-16 object-cover rounded flex-shrink-0"/>
              <div>
                <p class="font-semibold text-sm">{{ $item->news_title_english ?? $item->news_title }}</p>
                <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
              </div>
            </a>
            @endforeach
          </div>
        </div>
      </div>
    </section>
    @endif

    {{-- 7th section: TOP GAINERS / LOSERS / (uses Section Two) --}}
    <section class="mt-10 border-t-4 pt-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="grid md:grid-cols-3 gap-6">
          {{-- TOP GAINERS (Most Popular) --}}
          <div>
            <div class="flex justify-between items-center mb-3">
              <div>
                <h2 class="text-xl font-bold">Top Stories</h2>
                <div class="w-20 h-[2px] bg-red-600 mt-2"></div>
              </div>
            </div>
            <div class="space-y-3 text-sm">
              @foreach($mostPopular->skip(3)->take(5) as $item)
              <a href="{{ $item->canonical_url }}" class="flex justify-between items-center border-b pb-2 hover:text-red-700 transition">
                <span class="font-semibold mr-2">{{ Str::limit($item->news_title_english ?? $item->news_title, 60) }}</span>
                <span class="text-xs text-gray-500 whitespace-nowrap">{{ $item->reading_time }}m</span>
              </a>
              @endforeach
            </div>
          </div>
          {{-- MOST READ (Section Two) --}}
          <div>
            <div class="flex justify-between items-center mb-3">
              <div>
                @if($sectionTwoCategory)
                <h2 class="text-xl font-bold">{{ $sectionTwoCategory->category_name_english ?? $sectionTwoCategory->category_name }}</h2>
                @else
                <h2 class="text-xl font-bold">Most Read</h2>
                @endif
                <div class="w-20 h-[2px] bg-red-600 mt-2"></div>
              </div>
              @if($sectionTwoCategory)
              <a href="{{ route('category.show', $sectionTwoCategory->slug) }}" class="text-sm text-gray-600 cursor-pointer hover:text-red-600">more →</a>
              @endif
            </div>
            <div class="space-y-3 text-sm">
              @foreach($sectionTwoItems as $item)
              <a href="{{ $item->canonical_url }}" class="flex justify-between items-center border-b pb-2 hover:text-red-700 transition">
                <span class="font-semibold mr-2">{{ Str::limit($item->news_title_english ?? $item->news_title, 60) }}</span>
                <span class="text-xs text-gray-500 whitespace-nowrap">{{ $item->reading_time }}m</span>
              </a>
              @endforeach
            </div>
          </div>
          {{-- IPO / Section Three --}}
          <div>
            <div class="flex justify-between items-center mb-3">
              <div>
                @if($sectionThreeCategory)
                <h2 class="text-xl font-bold">{{ $sectionThreeCategory->category_name_english ?? $sectionThreeCategory->category_name }}</h2>
                @else
                <h2 class="text-xl font-bold">Latest</h2>
                @endif
                <div class="w-40 h-[2px] bg-red-600 mt-2"></div>
              </div>
              @if($sectionThreeCategory)
              <a href="{{ route('category.show', $sectionThreeCategory->slug) }}" class="text-sm text-gray-600 cursor-pointer hover:text-red-600">more →</a>
              @endif
            </div>
            <div class="text-sm space-y-3 mt-3">
              @foreach($sectionThreeItems as $item)
              <a href="{{ $item->canonical_url }}" class="flex justify-between border-b pb-2 hover:text-red-700 transition">
                <span class="font-bold">{{ Str::limit($item->news_title_english ?? $item->news_title, 55) }}</span>
                <span class="font-bold text-gray-500 text-xs ml-2">{{ $item->published_at ? $item->published_at->format('d M') : '' }}</span>
              </a>
              @endforeach
            </div>
          </div>
        </div>
      </div>
    </section>

    {{-- 10th section: EXPLORE NEWS --}}
    @if(count($featuredSections) > 0)
    <section class="mt-10 bg-[#e6d2c2] py-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="mb-4">
          <h2 class="text-xl font-bold">Explore News</h2>
          <div class="w-20 h-[2px] bg-red-600 mt-2"></div>
        </div>
        {{-- TAG BOX - Categories --}}
        <div class="border border-gray-300 bg-[#f3e5d8] p-4 mb-6">
          <div class="flex flex-wrap gap-3">
            @foreach($allCategories as $cat)
            <a href="{{ route('category.show', $cat->slug) }}" class="px-4 py-2 bg-white border border-gray-200 rounded-full text-sm cursor-pointer hover:bg-red-600 hover:text-white transition duration-200">
              {{ $cat->category_name_english ?? $cat->category_name }} News
            </a>
            @endforeach
          </div>
        </div>
        {{-- CARDS GRID --}}
        <div class="grid md:grid-cols-4 gap-6">
          @foreach($featuredSections as $section)
          <div class="bg-white p-4 border rounded-md">
            <div class="flex justify-between items-center mb-2">
              <h3 class="font-bold text-xl">{{ $section['category']->category_name_english ?? $section['category']->category_name }}</h3>
              <a href="{{ route('category.show', $section['category']->slug) }}" class="text-sm text-gray-600 cursor-pointer hover:text-red-600">more →</a>
            </div>
            <div class="border-t pt-1 space-y-1 text-lg">
              @foreach($section['items']->take(2) as $item)
              <a href="{{ $item->canonical_url }}" class="block font-semibold hover:text-red-600 cursor-pointer {{ !$loop->first ? 'border-t pt-2' : '' }}">
                {{ Str::limit($item->news_title_english ?? $item->news_title, 75) }}
              </a>
              @endforeach
            </div>
          </div>
          @endforeach
        </div>
      </div>
    </section>
    @endif

    {{-- 11th section: COMPANIES + SIDEBAR --}}
    <section class="mt-10 border-t-4 pt-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="grid md:grid-cols-4 gap-6">
          {{-- LEFT MAIN --}}
          <div class="md:col-span-3">
            <div class="flex justify-between items-center mb-4">
              <div>
                <h2 class="text-xl font-bold">Popular Now</h2>
                <div class="w-16 h-[2px] bg-red-600 mt-2"></div>
              </div>
            </div>
            <div class="grid md:grid-cols-2 gap-6">
              @if($latestFeed->first())
              <div>
                <a href="{{ $latestFeed->first()->canonical_url }}">
                  <h3 class="text-xl font-bold leading-snug mb-3 hover:text-red-700 transition">{{ $latestFeed->first()->news_title_english ?? $latestFeed->first()->news_title }}</h3>
                  <img src="{{ $latestFeed->first()->photo_url }}" class="w-full h-[220px] object-cover rounded mb-2" alt="{{ $latestFeed->first()->img_alt_english ?? $latestFeed->first()->news_title }}"/>
                  <span class="text-xs text-gray-500">{{ $latestFeed->first()->reading_time }} min read</span>
                </a>
              </div>
              @endif
              <div class="space-y-4">
                @foreach($latestFeed->skip(1)->take(3) as $item)
                <a href="{{ $item->canonical_url }}" class="block border-b pb-3 hover:text-red-700 transition">
                  <p class="font-semibold leading-snug">{{ $item->news_title_english ?? $item->news_title }}</p>
                  <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
                </a>
                @endforeach
              </div>
            </div>
          </div>
          {{-- RIGHT SIDEBAR --}}
          <div class="bg-gray-100 p-4 rounded">
            <div class="flex justify-between items-center mb-4">
              <h3 class="font-bold text-lg">Top Writers</h3>
            </div>
            <div class="space-y-3 text-sm">
              @foreach($topWriters as $writer)
              <a href="{{ $writer->url }}" class="block border-b pb-2 cursor-pointer hover:text-red-600">{{ $writer->name }}</a>
              @endforeach
            </div>
          </div>
        </div>
      </div>
    </section>

    {{-- 12th section: DECODED / OPINION --}}
    <section class="mt-10 border-t-4 pt-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="flex justify-between items-center mb-4">
          <div>
            <h2 class="text-xl font-bold">Editor's Pick</h2>
            <div class="w-16 h-[2px] bg-red-600 mt-2"></div>
          </div>
        </div>
        <div class="grid md:grid-cols-4 gap-6 items-start">
          @if($editorsPick)
          <div class="md:col-span-3 bg-[#e6d2c2] p-5 rounded">
            <div class="grid md:grid-cols-2 gap-6 items-center">
              <div>
                <a href="{{ $editorsPick->canonical_url }}">
                  <h3 class="text-2xl font-bold leading-snug mb-3 hover:text-red-700 transition">{{ $editorsPick->news_title_english ?? $editorsPick->news_title }}</h3>
                </a>
                <p class="text-gray-800 leading-6 mb-3">{{ Str::limit(strip_tags($editorsPick->news_content_short_english ?? $editorsPick->news_content_short ?? ''), 180) }}</p>
                <span class="text-xs text-gray-700">{{ $editorsPick->reading_time }} min read</span>
              </div>
              <a href="{{ $editorsPick->canonical_url }}">
                <img src="{{ $editorsPick->photo_url }}" class="w-full h-[260px] object-cover rounded" alt="{{ $editorsPick->img_alt_english ?? $editorsPick->news_title }}"/>
              </a>
            </div>
          </div>
          @endif
          <div class="hidden md:block">
            <p class="text-sm text-gray-600 mb-2">Advertisement</p>
            <img src="{{ asset('images/ad.webp') }}" class="w-full h-[260px] object-cover border rounded" alt="Advertisement"/>
          </div>
        </div>
        <div class="grid md:grid-cols-4 gap-6 mt-6">
          @foreach($editorsMiddle as $item)
          <a href="{{ $item->canonical_url }}" class="hover:text-red-600 cursor-pointer">
            <p class="font-semibold leading-snug">{{ $item->news_title_english ?? $item->news_title }}</p>
            <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
          </a>
          @endforeach
          @foreach($statesPanel->take(2) as $item)
          <a href="{{ $item->canonical_url }}" class="hover:text-red-600 cursor-pointer">
            <p class="font-semibold leading-snug">{{ $item->news_title_english ?? $item->news_title }}</p>
            <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
          </a>
          @endforeach
        </div>
      </div>
    </section>

    {{-- 13th section: POPULAR NOW --}}
    <section class="mt-10 border-t-4 pt-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="mb-6">
          <h2 class="text-xl font-bold">Popular Now</h2>
          <div class="w-20 h-[2px] bg-red-600 mt-2"></div>
        </div>
        <div class="grid md:grid-cols-3 gap-6">
          @foreach($latestFeed->skip(4)->take(6)->chunk(2) as $chunk)
          <div class="space-y-6">
            @foreach($chunk as $item)
            <a href="{{ $item->canonical_url }}" class="block border-b pb-4 hover:text-red-700 transition">
              <p class="font-semibold leading-snug">{{ $item->news_title_english ?? $item->news_title }}</p>
              <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
            </a>
            @endforeach
          </div>
          @endforeach
        </div>
      </div>
    </section>

    {{-- 14th section: OPINION / Authors --}}
    <section class="mt-10 border-t-4 pt-6 bg-gray-100 py-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="flex justify-between items-center mb-6">
          <div>
            <h2 class="text-xl font-bold">Opinion</h2>
            <div class="w-16 h-[2px] bg-red-600 mt-2"></div>
          </div>
        </div>
        <div class="grid md:grid-cols-4 gap-6">
          @foreach($topWriters as $writer)
          @php $writerArticle = $writer->news()->published()->orderByDesc('news_id')->first(); @endphp
          @if($writerArticle)
          <a href="{{ $writerArticle->canonical_url }}" class="block bg-white p-4 rounded shadow-sm hover:shadow-md transition">
            <p class="font-semibold leading-snug mb-4">{{ $writerArticle->news_title_english ?? $writerArticle->news_title }}</p>
            <div class="flex items-center gap-3 mb-3">
              <img src="{{ $writer->photo_url }}" class="w-10 h-10 rounded-full object-cover" alt="{{ $writer->name }}"/>
              <span class="font-semibold text-blue-900">{{ $writer->name }}</span>
            </div>
            <span class="text-xs text-gray-500">{{ $writerArticle->reading_time }} min read</span>
          </a>
          @endif
          @endforeach
        </div>
      </div>
    </section>

    {{-- 15th section: CATEGORY TRIO --}}
    @if(count($featuredSections) >= 3)
    <section class="mt-10 border-t-4 pt-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="grid md:grid-cols-3 gap-6">
          @foreach(array_slice($featuredSections, 0, 3) as $section)
          <div>
            <div class="flex justify-between items-center mb-3">
              <div>
                <h2 class="text-xl font-bold">{{ $section['category']->category_name_english ?? $section['category']->category_name }}</h2>
                <div class="w-16 h-[2px] bg-red-600 mt-2"></div>
              </div>
              <a href="{{ route('category.show', $section['category']->slug) }}" class="text-sm text-gray-600 cursor-pointer hover:text-red-600">more →</a>
            </div>
            @if($section['items']->first())
            <a href="{{ $section['items']->first()->canonical_url }}">
              <h3 class="font-semibold text-lg leading-snug mb-3 hover:text-red-700 transition">{{ $section['items']->first()->news_title_english ?? $section['items']->first()->news_title }}</h3>
              <img src="{{ $section['items']->first()->photo_url }}" class="w-full h-[200px] object-cover rounded mb-2" alt="{{ $section['items']->first()->img_alt_english ?? $section['items']->first()->news_title }}"/>
              <span class="text-xs text-gray-500">{{ $section['items']->first()->reading_time }} min read</span>
            </a>
            @endif
            <div class="mt-2 space-y-3 text-sm">
              @foreach($section['items']->skip(1) as $item)
              <a href="{{ $item->canonical_url }}" class="block border-t pt-1 hover:text-red-700 transition">
                <p class="font-semibold text-lg">{{ Str::limit($item->news_title_english ?? $item->news_title, 80) }}</p>
                <span class="text-xs text-gray-500">{{ $item->reading_time }} min read</span>
              </a>
              @endforeach
            </div>
          </div>
          @endforeach
        </div>
      </div>
    </section>
    @endif

    {{-- 16th section: BS WEB REPORTS / Latest Feed --}}
    <section class="mt-10 bg-[#e6d2c2] py-6">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="flex justify-between items-center mb-6">
          <div>
            <h2 class="text-xl font-bold">BS Web Reports</h2>
            <div class="w-20 h-[2px] bg-red-600 mt-2"></div>
          </div>
        </div>
        <div class="grid md:grid-cols-3 gap-6">
          @php $bsItems = $latestFeed->skip(10)->take(7); @endphp
          @if($bsItems->first())
          <div>
            <a href="{{ $bsItems->first()->canonical_url }}">
              <h3 class="text-2xl font-semibold leading-snug mb-3 hover:text-red-700 transition">{{ $bsItems->first()->news_title_english ?? $bsItems->first()->news_title }}</h3>
              <img src="{{ $bsItems->first()->photo_url }}" class="w-full h-[220px] object-cover rounded mb-2" alt="{{ $bsItems->first()->img_alt_english ?? $bsItems->first()->news_title }}"/>
              <span class="text-xs text-gray-700">{{ $bsItems->first()->reading_time }} min read</span>
            </a>
          </div>
          @endif
          <div class="space-y-1 text-lg">
            @foreach($bsItems->skip(1)->take(4) as $item)
            <a href="{{ $item->canonical_url }}" class="block border-b border-gray-400 pb-1 hover:text-red-700 transition">
              <p class="font-semibold">{{ $item->news_title_english ?? $item->news_title }}</p>
              <span class="text-xs text-gray-700">{{ $item->reading_time }} min read</span>
            </a>
            @endforeach
          </div>
          <div class="space-y-1 text-lg">
            @foreach($bsItems->skip(4)->take(4) as $item)
            <a href="{{ $item->canonical_url }}" class="block border-b border-gray-400 pb-1 hover:text-red-700 transition">
              <p class="font-semibold">{{ $item->news_title_english ?? $item->news_title }}</p>
              <span class="text-xs text-gray-700">{{ $item->reading_time }} min read</span>
            </a>
            @endforeach
          </div>
        </div>
      </div>
    </section>

    {{-- 17th section: PEOPLE --}}
    <section class="mt-10 border-t-4 pt-4">
      <div class="max-w-[1200px] mx-auto px-4 md:px-6">
        <div class="flex justify-between items-center mb-6">
          <div>
            <h2 class="text-xl font-bold">People</h2>
            <div class="w-16 h-[2px] bg-red-600 mt-2"></div>
          </div>
        </div>
        <div class="grid md:grid-cols-3 gap-6">
          @foreach($topWriters->chunk(2) as $chunk)
          <div class="space-y-6">
            @foreach($chunk as $writer)
            @php $wArticle = $writer->news()->published()->orderByDesc('news_id')->first(); @endphp
            @if($wArticle)
            <a href="{{ $wArticle->canonical_url }}" class="flex justify-between gap-4 border-b pb-4 hover:text-red-700 transition">
              <div>
                <p class="font-semibold text-lg leading-snug">{{ $wArticle->news_title_english ?? $wArticle->news_title }}</p>
                <span class="text-xs text-gray-500">{{ $wArticle->reading_time }} min read | <span class="text-blue-700">{{ $writer->name }}</span></span>
              </div>
              <img src="{{ $writer->photo_url }}" class="w-20 h-20 object-cover rounded flex-shrink-0" alt="{{ $writer->name }}"/>
            </a>
            @endif
            @endforeach
          </div>
          @endforeach
        </div>
      </div>
    </section>

@endsection
