@extends('layouts.app')

@section('title', 'Ayats')

@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">Ayats (Verses)</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">Ayats</li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>

        <!-- Filter -->
        <div class="row mb-4">
            <div class="col-lg-12">
                <div class="card border-0 shadow-sm">
                    <div class="card-body">
                        <form method="GET" action="{{ route('quran.ayats') }}" class="row g-3">
                            <div class="col-md-6">
                                <label class="form-label fw-semibold">
                                    <i class="ri-filter-line me-1"></i> Filter by Surah
                                </label>
                                <select name="surah_id" class="form-select form-select-lg">
                                    <option value="">All Surahs</option>
                                    @foreach($surahs as $s)
                                    <option value="{{ $s->id }}" {{ request('surah_id') == $s->id ? 'selected' : '' }}>
                                        {{ $s->surah_no }}. {{ $s->surah_name }}
                                    </option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-6 d-flex align-items-end">
                                <button type="submit" class="btn btn-primary me-2">
                                    <i class="ri-search-line"></i> Filter
                                </button>
                                <a href="{{ route('quran.ayats') }}" class="btn btn-secondary">
                                    <i class="ri-refresh-line"></i> Reset
                                </a>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <!-- Ayats List -->
        <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-text-line text-primary me-2"></i> All Ayats
                            <span class="badge bg-soft-primary text-primary ms-2">{{ $ayats->total() }}</span>
                        </h5>
                    </div>
                    <div class="card-body">
                        @foreach($ayats as $ayat)
                        <div class="card border-0 shadow-sm mb-3 ayat-card" style="background: linear-gradient(to right, #f8f9fa 0%, #ffffff 100%);">
                            <div class="card-body p-4">
                                <div class="d-flex justify-content-between align-items-start mb-3">
                                    <div>
                                        <span class="badge bg-primary rounded-pill">
                                            {{ $ayat->surah->surah_name }} - Ayah {{ $ayat->ayah_no }}
                                        </span>
                                        @if($ayat->juz)
                                        <span class="badge bg-info rounded-pill ms-1">Juz {{ $ayat->juz }}</span>
                                        @endif
                                    </div>
                                </div>
                                
                                <!-- Arabic Text -->
                                <div class="mb-3 p-3 rounded" style="background-color: #f8f9fa; border-right: 4px solid #667eea;">
                                    <div style="font-size: 20px; direction: rtl; text-align: right; font-family: 'Amiri', 'Traditional Arabic', serif; line-height: 2;">
                                        {{ $ayat->arabic_text }}
                                    </div>
                                </div>
                                
                                <!-- Transliteration -->
                                @if($ayat->transliteration)
                                <div class="mb-3 p-3 rounded bg-soft-warning">
                                    <div class="d-flex align-items-start">
                                        <i class="ri-translate-2-line text-warning me-2 mt-1"></i>
                                        <div>
                                            <small class="text-muted d-block mb-1">Transliteration</small>
                                            <div class="text-dark fst-italic">{{ $ayat->transliteration }}</div>
                                        </div>
                                    </div>
                                </div>
                                @endif
                                
                                <!-- Translation -->
                                <div class="p-3 rounded" style="background-color: #e7f3ff;">
                                    <div class="d-flex align-items-start">
                                        <i class="ri-translate-line text-primary me-2 mt-1"></i>
                                        <div>
                                            <small class="text-muted d-block mb-1">English Translation</small>
                                            <div class="text-dark">{{ $ayat->english_translation }}</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        @endforeach

                        <!-- 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">{{ $ayats->firstItem() ?? 0 }}</span> 
                                <span class="fw-semibold text-dark">to</span> 
                                <span class="fw-semibold text-primary">{{ $ayats->lastItem() ?? 0 }}</span> 
                                <span class="fw-semibold text-dark">of</span> 
                                <span class="fw-semibold text-primary">{{ $ayats->total() }}</span> 
                                <span class="fw-semibold text-dark">entries</span>
                            </div>
                            <div>
                                {{ $ayats->links() }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

@push('styles')
<style>
    .ayat-card {
        transition: all 0.3s ease;
    }
    .ayat-card:hover {
        transform: translateX(5px);
        box-shadow: 0 5px 15px rgba(0,0,0,0.1) !important;
    }
    .bg-soft-warning {
        background-color: rgba(245, 158, 11, 0.1);
    }
</style>
@endpush
    </div>
</div>
@endsection

