@php
    $newsfirst = \App\Models\NewEventContain::latest('released_at')->first();
    // Use regex to extract the first <p>...</p> from the HTML description
    $paragraphs = preg_split('/\r\n|\r|\n/', $newsfirst->description);
@endphp

<div class="news-section">

        <div class="news-card">
            <div class="news-image">
                <img src="{{ asset('storage/' . $newsfirst->image) }}" alt="News Image">
            </div>
            <div class="news-content">
                <h2 class="title">{{ $newsfirst->title }}</h2>
                @if(isset($paragraphs[0]) && trim($paragraphs[0]) !== '')
                    <p class="description">{!! $paragraphs[0] !!}</p>
                @endif

                <div class="news-meta">
                    <div class="meta-info">
                        <span class="published">Published date : </span>
                        <span class="date">{{ $newsfirst->released_at->format('d M Y') }}</span>
                    </div>
                    <div class="meta-info">
                        <span class="published">Published by : </span>
                        <span class="author">{{ $newsfirst->author }}</span>
                    </div>
                </div>
                <div class="read-more-wrapper">
                    <a href="{{ route('individualNews', $newsfirst->id) }}" class="read-more-btn">READ MORE</a>
                    <a href="{{ route('individualNews', $newsfirst->id) }}" class="read-more-arrow" aria-label="Read more">
                        <!-- SVG Arrow Icon -->
                        <svg width="24" height="24" viewBox="0 0 24 24" fill="none">
                            <circle cx="12" cy="12" r="12" fill="#0a4375"/>
                            <path d="M10 8l4 4-4 4" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
                        </svg>
                    </a>
                </div>
            </div>
    </div>
</div>

<style>
    .news-section {
        padding: 40px 5%;
        background-color: #f8f8f8;
    }
    .news-card {
        display: flex;
        gap: 30px;
        padding: 20px;
        margin-bottom: 30px;
        max-width: 1200px;
        margin: 0 auto 30px;
    }

    .news-image {
        flex: 0 0 400px;
    }

    .news-image img {
        width: 100%;
        height: 250px;
        border-radius: 40px;
        object-fit: cover;
    }

    .news-content {
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .title {
        color: #004675;
        font-size: 1.8rem;
        font-weight: 600;
        margin: 0 0 15px 0;
    }

    .description {
        color: #666;
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 20px;
    }

    .news-meta {
        margin-top: auto;
        margin-bottom: 15px;
    }

    .meta-info {
        margin-bottom: 5px;
    }

    .published {
        color: #ff6b00;
        font-size: 14px;
    }

    .date, .author {
        color: #f3881b;
        font-size: 14px;
    }

    .read-more-wrapper {
        display: flex;
        align-items: center;
        gap: 16px;
        justify-content: flex-end;
    }

    .read-more-btn {
        background: #0a4375;
        color: #fff;
        padding: 10px 28px;
        border-radius: 8px;
        font-weight: 600;
        letter-spacing: 1px;
        text-decoration: none;
        font-size: 1rem;
        border: none;
        transition: background 0.2s;
        display: inline-block;
    }

    .read-more-btn:hover {
        background: #08325a;
    }

    .read-more-arrow {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: none;
        text-decoration: none;
        transition: box-shadow 0.2s;
    }

    .read-more-arrow svg {
        display: block;
    }

    .read-more-arrow:hover {
        box-shadow: 0 2px 8px rgba(10,67,117,0.15);
    }
/* Enhanced responsive styles */
@media (max-width: 1200px) {
        .news-section {
            padding: 35px 4%;
        }
        .news-card {
            margin: 0 20px 30px;
            gap: 25px;
            padding: 18px;
        }
        .news-image {
            flex: 0 0 350px;
        }
        .news-image img {
            height: 230px;
            border-radius: 35px;
        }
        .title {
            font-size: 1.7rem;
            margin-bottom: 13px;
        }
        .description {
            font-size: 13.5px;
            margin-bottom: 18px;
        }
        .read-more-wrapper {
            gap: 14px;
        }
        .read-more-btn {
            padding: 9px 25px;
            font-size: 0.95rem;
        }
        .read-more-arrow {
            width: 40px;
            height: 40px;
        }
    }

    @media (max-width: 992px) {
        .news-section {
            padding: 30px 3%;
        }
        .news-card {
            gap: 20px;
            padding: 16px;
            margin: 0 15px 25px;
        }
        .news-image {
            flex: 0 0 300px;
        }
        .news-image img {
            height: 220px;
            border-radius: 30px;
        }
        .title {
            font-size: 1.6rem;
            margin-bottom: 12px;
        }
        .description {
            font-size: 13px;
            margin-bottom: 16px;
        }
        .news-meta {
            margin-bottom: 13px;
        }
        .read-more-wrapper {
            gap: 12px;
        }
        .read-more-btn {
            padding: 8px 22px;
            font-size: 0.9rem;
        }
        .read-more-arrow {
            width: 36px;
            height: 36px;
        }
    }

    @media (max-width: 768px) {
        .news-section {
            padding: 25px 2%;
        }
        .news-card {
            flex-direction: column;
            gap: 20px;
            margin: 0 15px 25px;
            padding: 14px;
        }
        .news-image {
            flex: none;
            width: 100%;
        }
        .news-image img {
            height: 200px;
            border-radius: 25px;
        }
        .title {
            font-size: 1.4rem;
            margin-bottom: 10px;
        }
        .description {
            font-size: 12.5px;
            margin-bottom: 14px;
        }
        .news-content {
            padding: 0;
        }
        .news-meta {
            margin-bottom: 12px;
        }
        .read-more-wrapper {
            gap: 10px;
        }
        .read-more-btn {
            padding: 7px 20px;
            font-size: 0.85rem;
        }
        .read-more-arrow {
            width: 32px;
            height: 32px;
        }
    }

    @media (max-width: 600px) {
        .news-section {
            padding: 20px 1%;
        }
        .news-card {
            gap: 15px;
            margin: 0 10px 20px;
            padding: 12px;
        }
        .news-image img {
            height: 180px;
            border-radius: 20px;
        }
        .title {
            font-size: 1.3rem;
            margin-bottom: 8px;
        }
        .description {
            font-size: 12px;
            margin-bottom: 12px;
        }
        .news-meta {
            margin-bottom: 10px;
        }
        .meta-info {
            margin-bottom: 4px;
        }
        .published, .date, .author {
            font-size: 13px;
        }
        .read-more-wrapper {
            gap: 8px;
        }
        .read-more-btn {
            padding: 6px 18px;
            font-size: 0.8rem;
        }
        .read-more-arrow {
            width: 28px;
            height: 28px;
        }
    }

    @media (max-width: 576px) {
        .news-section {
            padding: 15px 1%;
        }
        .news-card {
            padding: 15px;
            margin: 0 10px 20px;
            gap: 12px;
        }
        .news-image img {
            height: 180px;
            border-radius: 15px;
        }
        .title {
            font-size: 1.2rem;
            margin-bottom: 10px;
        }
        .description {
            font-size: 12px;
            margin-bottom: 15px;
        }
        .meta-info {
            margin-bottom: 3px;
        }
        .published, .date, .author {
            font-size: 12px;
        }
        .read-more-btn {
            font-size: 12px;
            padding: 5px 16px;
        }
        .read-more-arrow {
            width: 24px;
            height: 24px;
        }
    }

    @media (max-width: 480px) {
        .news-section {
            padding: 12px 1%;
        }
        .news-card {
            padding: 12px;
            margin: 0 8px 15px;
            gap: 10px;
        }
        .news-image img {
            height: 160px;
            border-radius: 12px;
        }
        .title {
            font-size: 1.1rem;
            margin-bottom: 8px;
        }
        .description {
            font-size: 11px;
            margin-bottom: 12px;
        }
        .news-meta {
            margin-bottom: 8px;
        }
        .meta-info {
            margin-bottom: 2px;
        }
        .published, .date, .author {
            font-size: 11px;
        }
        .read-more-wrapper {
            gap: 6px;
        }
        .read-more-btn {
            font-size: 11px;
            padding: 4px 14px;
        }
        .read-more-arrow {
            width: 20px;
            height: 20px;
        }
    }

    @media (max-width: 400px) {
        .news-section {
            padding: 10px 1%;
        }
        .news-card {
            padding: 10px;
            margin: 0 5px 12px;
            gap: 8px;
        }
        .news-image img {
            height: 140px;
            border-radius: 10px;
        }
        .title {
            font-size: 1rem;
            margin-bottom: 6px;
        }
        .description {
            font-size: 10px;
            margin-bottom: 10px;
        }
        .news-meta {
            margin-bottom: 6px;
        }
        .published, .date, .author {
            font-size: 10px;
        }
        .read-more-wrapper {
            gap: 5px;
        }
        .read-more-btn {
            font-size: 10px;
            padding: 3px 12px;
        }
        .read-more-arrow {
            width: 18px;
            height: 18px;
        }
    }

    @media (max-width: 360px) {
        .news-section {
            padding: 8px 1%;
        }
        .news-card {
            padding: 8px;
            margin: 0 3px 10px;
            gap: 6px;
        }
        .news-image img {
            height: 120px;
            border-radius: 8px;
        }
        .title {
            font-size: 0.9rem;
            margin-bottom: 5px;
        }
        .description {
            font-size: 9px;
            margin-bottom: 8px;
        }
        .news-meta {
            margin-bottom: 5px;
        }
        .published, .date, .author {
            font-size: 9px;
        }
        .read-more-wrapper {
            gap: 4px;
        }
        .read-more-btn {
            font-size: 9px;
            padding: 2px 10px;
        }
        .read-more-arrow {
            width: 16px;
            height: 16px;
        }
    }
</style>
