@extends('patient.layouts.app')
@section('title','تفاصيل الزيارة')
@section('content')

<div class="p-card mb-3">
    <div class="d-flex align-items-center gap-3 mb-3">
        <div style="width:46px;height:46px;background:#eff6ff;border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:1.2rem">🏥</div>
        <div>
            <div class="fw-bold">د. {{ $record->doctor->user->name }}</div>
            <div style="font-size:.78rem;color:#64748b">{{ $record->visit_date->format('Y/m/d') }}</div>
        </div>
    </div>

    @if($record->chief_complaint)
    <div class="mb-3">
        <div style="font-size:.68rem;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:.06em;margin-bottom:4px">الشكوى</div>
        <div style="font-size:.88rem">{{ $record->chief_complaint }}</div>
    </div>
    @endif

    <div class="mb-3">
        <div style="font-size:.68rem;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:.06em;margin-bottom:4px">التشخيص</div>
        <div style="background:#eff6ff;border-right:3px solid #7c3aed;border-radius:0 8px 8px 0;padding:8px 12px;font-weight:700;color:#4c1d95">
            {{ $record->diagnosis }}
        </div>
    </div>
</div>

@if($record->prescriptions && count($record->prescriptions))
<div class="p-card mb-3">
    <div class="p-card-title">الوصفة الطبية</div>
    @foreach($record->prescriptions as $i => $med)
    @if(!empty($med['medicine']))
    <div class="d-flex align-items-start gap-2 py-2 border-bottom" style="border-color:#f3f4f6!important">
        <span style="width:22px;height:22px;background:#7c3aed;color:#fff;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:.65rem;font-weight:700;flex-shrink:0;margin-top:2px">{{ $i+1 }}</span>
        <div>
            <div class="fw-bold small">{{ $med['medicine'] }}</div>
            <div style="font-size:.75rem;color:#64748b">
                {{ $med['dose'] ?? '' }} {{ $med['times'] ? '· '.$med['times'] : '' }} {{ $med['duration'] ? '· '.$med['duration'] : '' }}
            </div>
            @if(!empty($med['instructions']))
            <div style="font-size:.72rem;color:#94a3b8;font-style:italic">{{ $med['instructions'] }}</div>
            @endif
        </div>
    </div>
    @endif
    @endforeach
</div>
@endif

@if($record->lab_tests && count($record->lab_tests))
<div class="p-card mb-3">
    <div class="p-card-title">التحاليل المطلوبة</div>
    <div class="d-flex flex-wrap gap-2">
        @foreach($record->lab_tests as $test)
        @if(!empty($test['test']))
        <span style="background:#fff5f5;border:1.5px solid #fecaca;border-radius:20px;padding:4px 12px;font-size:.8rem;font-weight:600;color:#991b1b">
            🔬 {{ $test['test'] }}
        </span>
        @endif
        @endforeach
    </div>
</div>
@endif

@if($record->instructions)
<div class="p-card mb-3">
    <div class="p-card-title">تعليمات</div>
    <div style="font-size:.88rem;color:#78350f;background:#fffbeb;border-radius:8px;padding:10px 12px">{{ $record->instructions }}</div>
</div>
@endif

@if($record->next_visit_date)
<div class="p-card">
    <div class="d-flex align-items-center gap-2">
        <span style="font-size:1.3rem">📅</span>
        <div>
            <div class="fw-semibold small">موعد المتابعة</div>
            <div style="font-size:.88rem;color:{{ $record->next_visit_date->isPast() ? '#dc2626' : '#065f46' }};font-weight:700">
                {{ $record->next_visit_date->format('Y/m/d') }}
            </div>
        </div>
    </div>
</div>
@endif
@endsection
