@extends('layouts.app')

@section('title', 'Juz ' . $juz->juz_number)

@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">Juz {{ $juz->juz_number }}</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"><a href="{{ route('quran.juzs') }}">Juzs</a></li>
                            <li class="breadcrumb-item active">{{ $juz->juz_number }}</li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <!-- Juz Header -->
        <div class="row mb-4">
            <div class="col-lg-12">
                <div class="card border-0 shadow-sm overflow-hidden" style="background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);">
                    <div class="card-body text-white p-4">
                        <div class="row align-items-center">
                            <div class="col-md-8">
                                <h3 class="mb-2">
                                    <i class="ri-bookmark-line me-2"></i> Juz {{ $juz->juz_number }}
                                </h3>
                                @if($juz->ayahs_data && isset($juz->ayahs_data['ayahs']))
                                <p class="mb-0 opacity-75">
                                    <i class="ri-file-text-line me-1"></i> {{ count($juz->ayahs_data['ayahs']) }} Ayats
                                </p>
                                @endif
                            </div>
                            <div class="col-md-4 text-end">
                                <a href="{{ route('quran.juzs') }}" class="btn btn-light btn-sm">
                                    <i class="ri-arrow-left-line"></i> Back to Juzs
                                </a>
                            </div>
                        </div>
                    </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-file-list-3-line text-primary me-2"></i> Ayats in this Juz
                        </h5>
                    </div>
                    <div class="card-body">
                        @if($juz->ayahs_data && isset($juz->ayahs_data['ayahs']))
                        <div class="table-responsive">
                            <table class="table table-hover align-middle mb-0">
                                <thead class="table-light">
                                    <tr>
                                        <th style="width: 100px;">Ayah #</th>
                                        <th>Surah</th>
                                        <th style="width: 120px;">In Surah</th>
                                        <th>Arabic Text</th>
                                        <th style="width: 80px;">Page</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach($juz->ayahs_data['ayahs'] as $ayah)
                                    <tr class="table-row-hover">
                                        <td>
                                            <span class="badge bg-primary rounded-pill">{{ $ayah['number'] ?? 'N/A' }}</span>
                                        </td>
                                        <td>
                                            <strong class="text-dark">{{ $ayah['surah']['englishName'] ?? 'N/A' }}</strong>
                                            <br>
                                            <small class="text-muted" style="direction: rtl;">{{ $ayah['surah']['name'] ?? '' }}</small>
                                        </td>
                                        <td>
                                            <span class="badge bg-soft-info text-info">{{ $ayah['numberInSurah'] ?? 'N/A' }}</span>
                                        </td>
                                        <td style="direction: rtl; text-align: right; font-size: 18px; font-family: 'Amiri', 'Traditional Arabic', serif;">
                                            {{ $ayah['text'] ?? 'N/A' }}
                                        </td>
                                        <td>
                                            <span class="badge bg-secondary rounded-pill">{{ $ayah['page'] ?? 'N/A' }}</span>
                                        </td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                        @else
                        <div class="alert alert-info border-0 shadow-sm">
                            <i class="ri-information-line me-2"></i> No ayahs data available for this Juz.
                        </div>
                        @endif
                    </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

