{{-- records/index.blade.php --}}
@extends('patient.layouts.app')
@section('title','سجلاتي الطبية')
@section('content')

@forelse($records as $record)
<a href="{{ route('patient.records.show',$record->id) }}" style="text-decoration:none;color:inherit">
<div class="p-card mb-2">
    <div class="d-flex align-items-start gap-3">
        <div style="width:44px;height:44px;background:#eff6ff;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:1.1rem;flex-shrink:0">🏥</div>
        <div class="flex-grow-1">
            <div class="fw-semibold">{{ $record->diagnosis }}</div>
            <div style="font-size:.78rem;color:#64748b">
                د. {{ $record->doctor->user->name }} · {{ $record->visit_date->format('Y/m/d') }}
            </div>
            @if($record->prescriptions && count($record->prescriptions))
            <div style="font-size:.72rem;color:#94a3b8;margin-top:2px">
                💊 {{ collect($record->prescriptions)->pluck('medicine')->filter()->take(2)->join(', ') }}
            </div>
            @endif
        </div>
        <i class="bi bi-chevron-left text-muted"></i>
    </div>
</div>
</a>
@empty
<div class="p-card text-center py-5 text-muted">
    <i class="bi bi-file-earmark-x fs-2 d-block mb-2"></i>
    لا توجد سجلات طبية بعد
</div>
@endforelse

@if($records->hasPages())
<div class="d-flex justify-content-center mt-2">{{ $records->links('pagination::bootstrap-5') }}</div>
@endif
@endsection
