@php
    $events = \App\Models\NewEventContain::where('individual_zone_id', $individualZone->id)
        ->where('new_event', 'events')
        ->orderByDesc('released_at')
        ->take(3)
        ->get();
    $latestEvent = \App\Models\NewEventContain::where('individual_zone_id', $individualZone->id)
        ->where('new_event', 'events')
        ->orderByDesc('released_at')
        ->first();
@endphp

<div class="events-section">
    <div class="events-content">
        <div class="events-list">
            <h2 class="events-title">Upcoming Club Events</h2>
            @foreach($events as $event)
                <div class="event-bar" onclick="window.location.href='{{ route('individualNews', $event->id) }}'">
                    {{ $event->title }}
                </div>
            @endforeach
        </div>
        <div class="events-image">
            @if($latestEvent && $latestEvent->image)
                <img src="{{ asset('storage/' . $latestEvent->image) }}" alt="Latest Event Image" />
            @else
                <img src="{{ asset('images/club-events.jpg') }}" alt="Club Events" />
            @endif
        </div>
    </div>
</div>

<style>
.events-section {
    margin: 5rem 0;
    padding: 48px;
}
.events-content {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
}
.events-list {
    width: 50%;
}
.events-title {

    font-family: Poppins;
    font-weight: 500;
    font-size: 40px;
    line-height: 100%;
    letter-spacing: 0%;
    color: #314C7D;
    margin-bottom: 5%;
}
.event-bar {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 1.5px 4px rgba(0,0,0,0.10);
    /* Optional: for better appearance */
    border-radius: 8px;
    background: #F8F8F8;
    transition: box-shadow 0.2s;
    padding: 15px;
    margin-bottom: 5%;
    color: #666666;
    position: relative;
    overflow: hidden;
    font-family: Poppins;
    font-weight: 600;
    font-size: 24px;
    line-height: 28px;
    letter-spacing: 0.6px;
    vertical-align: middle;
}
.event-bar:hover {
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 3px 8px rgba(0,0,0,0.15);
}
/* .event-bar::after {
    content: "";
    display: block;
    position: absolute;
    right: 0;
    top: 0;
    width: 30px;
    height: 100%;
    background: #34507B;
    border-radius: 0 4px 4px 0;
} */
 .events-image {
    width: 50%;
    margin-left: -8%;
 }
.events-image img {
    width: 100%;
    aspect-ratio: 1/0.5;
    object-fit: cover;
    border-radius: 6px;
}
/* Enhanced responsive styles */
@media (max-width: 1200px) {
    .events-section {
        margin: 4.5rem 0;
        padding: 40px;
    }
    .events-content {
        gap: 1.8rem;
    }
    .events-title {
        font-size: 36px;
        margin-bottom: 4.5%;
    }
    .event-bar {
        padding: 14px;
        margin-bottom: 4.5%;
        font-size: 22px;
        line-height: 26px;
    }
    .events-image {
        margin-left: -7%;
    }
}

@media (max-width: 992px) {
    .events-section {
        margin: 4rem 0;
        padding: 35px;
    }
    .events-content {
        gap: 1.5rem;
    }
    .events-title {
        font-size: 32px;
        margin-bottom: 4%;
    }
    .event-bar {
        padding: 13px;
        margin-bottom: 4%;
        font-size: 20px;
        line-height: 24px;
    }
    .events-image {
        margin-left: -6%;
    }
}

@media (max-width: 768px) {
    .events-section {
        margin: 3.5rem 0;
        padding: 30px;
    }
    .events-content {
        gap: 1.2rem;
    }
    .events-title {
        font-size: 28px;
        margin-bottom: 3.5%;
    }
    .event-bar {
        padding: 12px;
        margin-bottom: 3.5%;
        font-size: 18px;
        line-height: 22px;
    }
    .events-image {
        margin-left: -5%;
    }
}

@media (max-width: 700px) {
    .events-section {
        margin: 3rem 0;
        padding: 25px;
    }
    .events-content {
        flex-direction: column;
        gap: 1rem;
    }
    .events-list {
        width: 100%;
    }
    .events-title {
        font-size: 26px;
        margin-bottom: 3%;
        text-align: center;
    }
    .event-bar {
        padding: 11px;
        margin-bottom: 3%;
        font-size: 16px;
        line-height: 20px;
    }
    .events-image {
        width: 100%;
        margin-left: 0;
    }
    .events-image img {
        width: 100%;
        height: auto;
    }
}

@media (max-width: 600px) {
    .events-section {
        margin: 2.5rem 0;
        padding: 20px;
    }
    .events-content {
        gap: 0.8rem;
    }
    .events-title {
        font-size: 24px;
        margin-bottom: 2.5%;
    }
    .event-bar {
        padding: 10px;
        margin-bottom: 2.5%;
        font-size: 15px;
        line-height: 18px;
    }
}

@media (max-width: 480px) {
    .events-section {
        margin: 2rem 0;
        padding: 15px;
    }
    .events-content {
        gap: 0.6rem;
    }
    .events-title {
        font-size: 22px;
        margin-bottom: 2%;
    }
    .event-bar {
        padding: 9px;
        margin-bottom: 2%;
        font-size: 14px;
        line-height: 16px;
    }
}

@media (max-width: 400px) {
    .events-section {
        margin: 1.5rem 0;
        padding: 12px;
    }
    .events-content {
        gap: 0.5rem;
    }
    .events-title {
        font-size: 20px;
        margin-bottom: 1.5%;
    }
    .event-bar {
        padding: 8px;
        margin-bottom: 1.5%;
        font-size: 13px;
        line-height: 15px;
    }
}

@media (max-width: 360px) {
    .events-section {
        margin: 1.2rem 0;
        padding: 10px;
    }
    .events-content {
        gap: 0.4rem;
    }
    .events-title {
        font-size: 18px;
        margin-bottom: 1.2%;
    }
    .event-bar {
        padding: 7px;
        margin-bottom: 1.2%;
        font-size: 12px;
        line-height: 14px;
    }
}
</style>
