@extends('layouts.app')

@section('title', 'Surahs')

@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">Surahs (Chapters)</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">Surahs</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">
                        <div class="d-flex justify-content-between align-items-center">
                            <h5 class="card-title mb-0">
                                <i class="ri-book-open-line text-primary me-2"></i> All Surahs
                                <span class="badge bg-soft-primary text-primary ms-2">{{ $surahs->total() }}</span>
                            </h5>
                        </div>
                    </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>Arabic Name</th>
                                        <th>English Name</th>
                                        <th>Translation</th>
                                        <th>Revelation</th>
                                        <th>Ayats</th>
                                        <th style="width: 100px;">Actions</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @forelse($surahs as $surah)
                                    <tr class="table-row-hover">
                                        <td>
                                            <span class="badge bg-primary rounded-pill">{{ $surah->surah_no }}</span>
                                        </td>
                                        <td>
                                            <div class="d-flex align-items-center">
                                                <div class="flex-grow-1">
                                                    <h6 class="mb-1 fw-semibold" style="font-size: 20px; direction: rtl; text-align: right; font-family: 'Amiri', 'Traditional Arabic', serif;">
                                                        {{ $surah->surah_name_arabic }}
                                                    </h6>
                                                    @if($surah->surah_name_arabic_long)
                                                    <small class="text-muted d-block" style="font-size: 14px; direction: rtl; text-align: right;">
                                                        {{ $surah->surah_name_arabic_long }}
                                                    </small>
                                                    @endif
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <strong class="text-dark">{{ $surah->surah_name }}</strong>
                                        </td>
                                        <td>
                                            <span class="text-muted">{{ $surah->surah_name_translation }}</span>
                                        </td>
                                        <td>
                                            <span class="badge bg-{{ $surah->revelation_place == 'Mecca' ? 'primary' : 'success' }} rounded-pill">
                                                <i class="ri-map-pin-line me-1"></i>{{ $surah->revelation_place }}
                                            </span>
                                        </td>
                                        <td>
                                            <span class="badge bg-soft-info text-info">
                                                <i class="ri-file-text-line me-1"></i>{{ $surah->total_ayah }}
                                            </span>
                                        </td>
                                        <td>
                                            <a href="{{ route('quran.surah.show', $surah->surah_no) }}" class="btn btn-sm btn-primary rounded-pill">
                                                <i class="ri-eye-line"></i> View
                                            </a>
                                        </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 surahs 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">{{ $surahs->firstItem() ?? 0 }}</span> 
                                <span class="fw-semibold text-dark">to</span> 
                                <span class="fw-semibold text-primary">{{ $surahs->lastItem() ?? 0 }}</span> 
                                <span class="fw-semibold text-dark">of</span> 
                                <span class="fw-semibold text-primary">{{ $surahs->total() }}</span> 
                                <span class="fw-semibold text-dark">entries</span>
                            </div>
                            <div>
                                {{ $surahs->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

