@extends('layouts.front')
@section('content')
<div class="container">
    <div class="row">
        <div class="col-sm-12">
            <div class="mobilesecitoninner">
                @if (Session::has('sucmessage'))
                    <div class="alert alert-success alert-dismissible show fade">
                        <div class="alert-body">
                            <button class="close" data-dismiss="alert">
                                <span>&times;</span>
                            </button>
                            {{ Session::get('sucmessage') }}
                        </div>
                    </div>
                @endif

                @if (Session::has('message'))
                    <div class="alert alert-danger alert-dismissible show fade">
                        <div class="alert-body">
                            <button class="close" data-dismiss="alert">
                                <span>&times;</span>
                            </button>
                            {{ Session::get('message') }}
                        </div>
                    </div>
                @endif
                <div id="homepageseciton">
                    <div class="megacontentbiscion">
                        @if ($useranswerdetails)
                            <h2>Subject Wise Result:</h2>
                            <div class="megacontentdata">
                                <table class="table table-condensed">
                                    <thead>
                                        <tr>
                                            <th>Subjectes</th>
                                            <th>Marks</th>
                                            <th>Percentage</th>
                                            <th>Result</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($resultPage['subject_rows'] as $subjectRow)
                                            <tr>
                                                <th>{{ $subjectRow['label'] }}</th>
                                                <td>{{ $subjectRow['marks'] }}</td>
                                                <td>{{ $subjectRow['percentage'] }} %</td>
                                                <td>{{ $subjectRow['percentage'] >= 40 ? 'Pass' : 'Fail' }}</td>
                                            </tr>
                                        @endforeach
                                    </tbody>
                                </table>
                            </div>

                            <h2 style="color:#208fcc">Overall Result:</h2>
                            <div class="megacontentdata">
                                <table class="table table-condensed">
                                    <thead>
                                        <tr><th>Your Marks</th><td>{{ $useranswerdetails->totalmarks }}</td></tr>
                                        <tr><th>Your Percentage</th><td>{{ $useranswerdetails->totalpercentage }} %</td></tr>
                                        <tr>
                                            <th>Your Result</th>
                                            <td>
                                                @if ((int) $useranswerdetails->status === 1)
                                                    <span style="color:#1a9501; font-size:14px; font-weight:bold">Pass</span>
                                                @else
                                                    <span style="color:#d33902; font-size:14px; font-weight:bold">Fail</span>
                                                @endif
                                            </td>
                                        </tr>
                                    </thead>
                                </table>
                            </div>
                        @else
                            <h2>Exam Result</h2>
                            <div class="megacontentdata">
                                <p class="text-muted">Your result is not available yet.</p>
                            </div>
                        @endif

                        <h2 style="color:#208fcc">Scholarship Rank:</h2>
                        <div class="megacontentdata">
                            <div class="scholershipboard">
                                <ul>
                                    <li class="headlinesecionthow"><span>Name</span><span>Mobile</span><span>Rank</span></li>
                                    @forelse ($leadreboard as $leadreboarddata)
                                        <li>
                                            <span>{{ $leadreboarddata->user?->name ?? 'Student' }}</span>
                                            <span>{{ $leadreboarddata->masked_mobile }}</span>
                                            <span>{{ $leadreboarddata->display_rank }}</span>
                                        </li>
                                    @empty
                                        <li style="font-size:16px; color:#0674cd; font-weight:bold;">No qualified students found yet.</li>
                                    @endforelse
                                </ul>
                            </div>
                            {{ $leadreboard->links() }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
$( document ).ready(function() {
    $( "#showedetails" ).on( "click", function() {
        $('#password').attr('type', 'text');
        $('#showedetails').hide();
        $('#hideedetails').show();
    });

    $( "#hideedetails" ).on( "click", function() {
        $('#password').attr('type', 'password');
        $('#hideedetails').hide();
        $('#showedetails').show();
    });
});
</script>
@endsection
