@extends('layouts.app')

@section('title', 'Sajdahs')

@section('content')
<div class="page-content">
    <div class="container-fluid">
        <!-- Page Title -->
        <div class="row">
            <div class="col-12">
                <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                    <h4 class="mb-sm-0">Sajdahs (Prostrations)</h4>
                    <div class="page-title-right">
                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
                            <li class="breadcrumb-item"><a href="{{ route('quran.index') }}">Quran</a></li>
                            <li class="breadcrumb-item active">Sajdahs</li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="card border-0 shadow-sm">
                    <div class="card-header bg-transparent border-bottom">
                        <h5 class="card-title mb-0">
                            <i class="ri-hand-heart-line text-warning me-2"></i> All Sajdahs (Prostrations)
                            <span class="badge bg-soft-warning text-warning ms-2">{{ $sajdahs->total() }}</span>
                        </h5>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-hover align-middle mb-0">
                                <thead class="table-light">
                                    <tr>
                                        <th style="width: 60px;">#</th>
                                        <th>Surah</th>
                                        <th style="width: 150px;">Ayah Number</th>
                                        <th>Arabic Text</th>
                                        <th style="width: 120px;">Type</th>
                                        <th style="width: 80px;">Page</th>
                                        <th style="width: 80px;">Juz</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @forelse($sajdahs as $sajdah)
                                    <tr class="table-row-hover">
                                        <td>
                                            <span class="badge bg-warning rounded-pill">{{ $sajdah->id }}</span>
                                        </td>
                                        <td>
                                            <strong class="text-dark">{{ $sajdah->surah->surah_name }}</strong>
                                            <br>
                                            <small class="text-muted" style="direction: rtl; font-family: 'Amiri', 'Traditional Arabic', serif;">
                                                {{ $sajdah->surah->surah_name_arabic }}
                                            </small>
                                        </td>
                                        <td>
                                            <span class="badge bg-primary rounded-pill">Ayah {{ $sajdah->number_in_surah }}</span>
                                            <br>
                                            <small class="text-muted">#{{ $sajdah->ayah_number }}</small>
                                        </td>
                                        <td style="direction: rtl; text-align: right; font-size: 18px; font-family: 'Amiri', 'Traditional Arabic', serif;">
                                            {{ $sajdah->arabic_text }}
                                        </td>
                                        <td>
                                            @if($sajdah->obligatory)
                                            <span class="badge bg-danger rounded-pill">
                                                <i class="ri-alert-line me-1"></i>Obligatory
                                            </span>
                                            @elseif($sajdah->recommended)
                                            <span class="badge bg-warning rounded-pill">
                                                <i class="ri-star-line me-1"></i>Recommended
                                            </span>
                                            @else
                                            <span class="badge bg-secondary rounded-pill">N/A</span>
                                            @endif
                                        </td>
                                        <td>
                                            <span class="badge bg-secondary rounded-pill">{{ $sajdah->page ?? 'N/A' }}</span>
                                        </td>
                                        <td>
                                            <span class="badge bg-info rounded-pill">{{ $sajdah->juz ?? 'N/A' }}</span>
                                        </td>
                                    </tr>
                                    @empty
                                    <tr>
                                        <td colspan="7" class="text-center py-5">
                                            <div class="text-muted">
                                                <i class="ri-inbox-line fs-1 d-block mb-2"></i>
                                                No sajdahs found
                                            </div>
                                        </td>
                                    </tr>
                                    @endforelse
                                </tbody>
                            </table>
                        </div>
                        
                        <!-- Pagination -->
                        <div class="d-flex justify-content-between align-items-center mt-4 pt-3 border-top">
                            <div class="text-muted">
                                <span class="fw-semibold text-dark">Showing</span> 
                                <span class="fw-semibold text-primary">{{ $sajdahs->firstItem() ?? 0 }}</span> 
                                <span class="fw-semibold text-dark">to</span> 
                                <span class="fw-semibold text-primary">{{ $sajdahs->lastItem() ?? 0 }}</span> 
                                <span class="fw-semibold text-dark">of</span> 
                                <span class="fw-semibold text-primary">{{ $sajdahs->total() }}</span> 
                                <span class="fw-semibold text-dark">entries</span>
                            </div>
                            <div>
                                {{ $sajdahs->links() }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

@push('styles')
<style>
    .table-row-hover:hover {
        background-color: #f8f9fa;
        transition: background-color 0.2s ease;
    }
</style>
@endpush
    </div>
</div>
@endsection

