@extends('labs.layout.app')

@section('content')



<!DOCTYPE html>
<html>

<head>
    <title></title>
    <style>
        body {
            font-family: Arial, sans-serif;
            font-size: 14px;
            margin: 0;
            padding: 0;
            background-color: #f8f9fa;
        }

        .container {
            width: 90%;
            margin: 0 auto;
            padding: 20px;
            background: white;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            border-radius: 5px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
            background: white;
            border-radius: 5px;
            overflow: hidden;
        }

        th,
        td {
            padding: 10px;
            text-align: left;

        }

        td {
            padding: 5px;
            /* Reduce unnecessary space */
            vertical-align: top;
            /* Align content to the top */
        }

        ul {
            margin-top: 0;
            /* Remove extra margin */
            padding-left: 20px;
            /* Keep bullet indentation */
        }

        th {
            background-color: #525659;
            color: white;
        }

        hr {
            border: 0;
            height: 1px;
            background: #ddd;
            margin: 20px 0;
        }

        .footers {
            background-color: #007BFF;
            color: white;
            padding: 15px;
            text-align: center;
            font-size: 12px;
            border-top: 3px solid #0056b3;
            margin-top: 20px;
        }

        @page {
            size: A4;
            margin: 10px;
            scale: 0.8;
            /* Reduce size */
        }

        .button-container {
            display: flex;
            justify-content: center;
            /* Center horizontally */
            margin-top: 20px;
            /* Add some space */
        }


        <style>.report-header {
            background-color: #f8f9fa;
            border-bottom: 3px solid #0d6efd;
            padding: 20px 0;
            margin-bottom: 30px;
        }

        .test-table {
            border-collapse: collapse;
            width: 100%;
            margin-bottom: 30px;
        }

        .test-table th {
            background-color: #0d6efd;
            color: white;
            padding: 12px;
            text-align: left;
        }

        .test-table td {
            padding: 12px;
            border-bottom: 1px solid #dee2e6;
            vertical-align: top;
        }

        .test-table tr:nth-child(even) {
            background-color: #f8f9fa;
        }

        .result-flag {
            font-size: 0.9em;
            padding: 3px 8px;
            border-radius: 4px;
            margin-left: 10px;
        }

        .normal-range {
            color: #6c757d;
            font-size: 0.9em;
        }

        @media print {
            .report-header {
                border: none;
            }

            .test-table {
                page-break-inside: avoid;
            }
        }
    </style>

    </style>
</head>

<body>
    <div class="container">
        <div class="row">
            <div class="col-md-6">
                <table>
                    <tr>
                        <td colspan="2">
                            <img src="https://bluhealth.bluai.ai/admin/assets/images/logo/BluHealth_Logo.png" alt="BluHealth Logo" width="150">
                        </td>
                        <td colspan="2" style="text-align: center;">
                            <h3>Clinical Information</h3>
                        </td>
                    </tr>
                </table>
                <hr>

                <!-- Patient & Doctor Information -->
                <table>
                    <tr>
                        <th colspan="2">Patient Information</th>
                        <th colspan="2">Doctor Information</th>
                    </tr>
                    <tr>
                        <td><strong>Name:</strong></td>
                        <td>{{ $patient ? $patient->first_name .' ' .$patient->last_name : 'N/A' }}</td>
                        <td><strong>Dr.:</strong></td>
                        <td>{{ $hcp ? $hcp->first_name .' ' .$hcp->last_name : 'N/A' }}</td>
                    </tr>
                    <tr>
                        <td><strong>Email:</strong></td>
                        <td>{{ $patient ? $patient->email : 'N/A' }}</td>
                        <td><strong>Email:</strong></td>
                        <td>{{ $hcp ? $hcp->email : 'N/A' }}</td>
                    </tr>
                    <tr>
                        <td colspan="2"></td>
                        <td><strong>Address:</strong></td>
                        <td>{{ $hcp ? $hcp->address : 'N/A' }}</td>
                    </tr>
                    <tr>
                        <td colspan="2"></td>
                        <td><strong>Phone:</strong></td>
                        <td>{{ $hcp ? $hcp->contact_phone_personal : 'N/A' }}</td>
                    </tr>
                </table>

                <!-- Reason for Blood Work & Specialty Tests -->
                <table>
                    <tr>
                        <th>Reason for Blood Work</th>
                        <th>Specialty Tests</th>
                    </tr>
                    <tr>
                        <td>

                            <ul class="list-unstyled mb-0">
                                @foreach($reason_for_blood_work ?? [] as $reason)
                                <li class="d-flex align-items-center mb-1">
                                    <i class="fas fa-check-circle text-success me-2" style="font-size: 1rem;"></i>
                                    <span class="fw-medium">{{ ucfirst(str_replace('_', ' ', $reason)) }}</span>
                                </li>
                                @if('otherReason' == $reason)
                                <div class=" text-muted small">
                                    <i class="fas fa-angle-right ms-5 me-1"></i>{{ strtoupper($other_reason) }}
                                </div>
                                @endif
                                @endforeach
                            </ul>

                        </td>
                        <td>
                            <ul class="list-unstyled mb-0">
                                @foreach($specialty_tests ?? [] as $specialty)
                                <li class="d-flex align-items-center mb-1">
                                    <i class="fas fa-check-circle text-success me-2" style="font-size: 1rem;"></i>
                                    <span class="fw-medium">{{ ucfirst(str_replace('_', ' ', $specialty)) }}</span>
                                </li>
                                @if('cardiacMarkers' == $specialty)
                                <div class="d-flex flex-column text-muted small">
                                    @foreach($cardiac_tests ?? [] as $cardiac)
                                    <div class="d-flex align-items-center">
                                        <i class="fas fa-angle-right ms-5 me-2"></i> <span>{{ strtoupper($cardiac) }}</span>
                                    </div>
                                    @endforeach
                                </div>
                                @endif
                                @if('inflammatoryMarkers' == $specialty)
                                <div class="d-flex flex-column text-muted small">
                                    @foreach($inflammatory_tests ?? [] as $inflammatory)
                                    <div class="d-flex align-items-center">
                                        <i class="fas fa-angle-right ms-5 me-2"></i> <span>{{ strtoupper($inflammatory) }}</span>
                                    </div>
                                    @endforeach
                                </div>
                                @endif
                                @if('hormonalStudies' == $specialty)
                                <div class="d-flex flex-column text-muted small">
                                    @foreach($hormone_tests ?? [] as $hormone)
                                    <div class="d-flex align-items-center">
                                        <i class="fas fa-angle-right ms-5 me-2"></i> <span>{{ strtoupper($hormone) }}</span>
                                    </div>
                                    @endforeach
                                </div>
                                @endif
                                @endforeach
                            </ul>
                        </td>
                    </tr>
                </table>

                <!-- Basic Panel -->
                <table>
                    <tr>
                        <th>Basic Panel</th>
                    </tr>
                    <tr>
                        <td>
                            <ul class="list-unstyled mb-0">
                                @foreach($basic_panel ?? [] as $panel)
                                <li class="d-flex align-items-center mb-1">
                                    <i class="fas fa-check-circle text-success me-2" style="font-size: 1rem;"></i>
                                    <span class="fw-medium">{{ ucfirst(str_replace('_', ' ', $panel)) }}</span>
                                </li>

                                @if($panel == 'cbc')
                                <ul class="text-muted small ms-4">
                                    <li class="d-flex align-items-center">
                                        <i class="fas fa-angle-right me-2"></i>
                                        <span>{{ strtoupper($basic_panel_options[0] ?? 'No options available') }}</span>
                                    </li>
                                </ul>
                                @endif

                                @if($panel == 'thyroidFunctionTests')
                                <ul class="text-muted small ms-4">
                                    @foreach($thyroid_tests ?? [] as $test)
                                    <li class="d-flex align-items-center">
                                        <i class="fas fa-angle-right me-2"></i>
                                        <span>{{ strtoupper($test) }}</span>
                                    </li>
                                    @endforeach
                                </ul>
                                @endif
                                @endforeach
                            </ul>
                        </td>
                    </tr>
                </table>
                <hr>

                <!-- Footer -->
                <div class="footers">
                    &copy; 2025 BluHealth. All rights reserved.
                </div>
            </div>
            <div class="col-md-6">
    @if ($reportUrl)
        @if (Str::endsWith($reportUrl, ['.pdf'])) 
    
            <iframe src="{{ asset($reportUrl) }}" width="100%" height="1000px"></iframe>
        @else
            <img src="{{ asset($reportUrl) }}" alt="Lab Report" width="600">
        @endif
        <br>
        <div class="mt-2 ">
            <a href="{{ asset($reportUrl) }}" class="btn btn-primary" download>Download Report</a>
            <a href="javascript:void(0)" onclick="printLabresultPage({{ $lab_id }})" class="btn btn-primary">Print</a>
        </div>
    @else
        <p>No Report Available</p>
    @endif
</div>




        </div>


        <br>

        <div class="row">
           
                @if (!empty($test_results['complete_blood_count']) && is_array($test_results['complete_blood_count']))
                <div class="col-md-6">
                <div class="container">

                <div class="report-header p-4">
                        <!-- Logo and Customer Care Info -->
                        <div class="d-flex justify-content-between align-items-center mb-3">
                            <img src="https://bluhealth.bluai.ai/admin/assets/images/logo/BluHealth_Logo.png"
                                alt="Lab Logo"
                                style="height: 40px; width: auto;">
                            
                            <div class="text-center">

                            <img src="{{ Storage::url('uploads/labs/' . $labDetails->photo) }}"
                                alt="Lab Logo"
                                style="height: 40px; width: auto;">
                                <h5 class="mb-1 text-primary">Customer Care</h5>
                                <p class="mb-0"><strong>7625896635</strong></p>
                                <p class="mb-0"><strong>7625896635</strong></p>
                            </div>
                        </div>

                        <hr class="my-3 border-primary">

                        <!-- Patient and Doctor Details -->
                        <div class="row">
                            <!-- Patient Information (Left) -->
                            <div class="col-md-6">
                                <div class="p-3">
                                    <p class="mb-1"><strong>Patient Name:</strong> {{ $patient ? $patient->first_name .' ' .$patient->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Age/Sex:</strong> {{ $patient ? \Carbon\Carbon::parse($patient->date_of_birth)->age . ' years / ' . $patient->sex : 'N/A' }}</p>

                                    <p class="mb-1"><strong>Refered By:</strong>{{ $hcp ? $hcp->first_name .' ' .$hcp->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Panel Address:</strong> {{ $patient ? $patient->address : 'N/A' }}</p> 
                                </div>
                            </div>

                            <!-- Doctor Information (Right) -->
                            <div class="col-md-6">
                                <div class="p-3">
                                   <p class="mb-1"><strong>Lab Name:</strong> {{ $labDetails ? $labDetails->first_name .' ' .$labDetails->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Lab No:</strong> {{ $labDetails ? $labDetails->cin : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Reg Date:</strong>  {{ $labDetails ? \Carbon\Carbon::parse($labDetails->created_at)->format('d/M/Y h:i A') : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Report Date:</strong>  {{ $test_results ? \Carbon\Carbon::parse($test_results->created_at)->format('d/M/Y h:i A') : 'N/A' }}</p>

                                </div>
                            </div>
                        </div>

                        <hr>
                    </div>
 
                    <table class="test-table">
                        <thead>
                            <tr>
                                <th>Test Name</th>
                                <th>Result</th>
                                <th>Normal Range</th>
                                <th>Units</th>
                                <th>Remarks</th>
                            </tr>
                        </thead>

                        <tbody>

                            @if (!empty($test_results['complete_blood_count']) && is_array($test_results['complete_blood_count']))

                            <!-- Heading Row for Complete Blood Count -->
                            <tr>
                                <td colspan="5" class="text-center font-weight-bold">Complete Blood Count</td>
                            </tr>

                            @foreach($test_results['complete_blood_count'] as $testResult)
                            <tr>
                                <td>
                                    {{ isset($testResult['test_name']) ? ucfirst(str_replace(['_', '-'], ' ', $testResult['test_name'])) : 'N/A' }}
                                </td>
                                <td>
                                    <strong>{{ $testResult['result'] ?? 'No Result' }}</strong>
                                </td>
                                <td class="normal-range">
                                    {{ $testResult['normal_range'] ?? 'Reference range not specified' }}
                                </td>
                                <td>
                                    {{ $testResult['units'] ?? '-' }}
                                </td>
                                <td class="text-muted">
                                    <em>{{ $testResult['remarks'] ?? 'No remarks' }}</em>
                                </td>
                            </tr>
                            @endforeach
                            @else
                            <tr>
                                <td colspan="5" class="text-center text-muted">No test results available</td>
                            </tr>
                            @endif

                        </tbody>
                    </table>



                  

                    <div class="footer-notes text-muted p-3">
                    <div class="d-flex justify-content-between">
                        <!-- Left Side -->
                        <div class="footer-notes text-muted">
                            <p><small><strong>Note:</strong> Reference ranges vary by age, sex, and method.</small></p>
                            <p><small><strong>Reviewed by:</strong> Dr. Jane Smith, Lab Director.</small></p>
                            <p><small><strong>Next Screening:</strong> 20-Mar-2025.</small></p>
                        </div>


                        <!-- Right Side -->
                        <div class="text-end">
                        <p><small>Dr. {{ $hcp ? $hcp->first_name .' ' .$hcp->last_name : 'N/A' }}</small></p>
                        <img src="{{ Storage::url('uploads/labs/' . $labDetails->signature) }}" 
                            alt="Dr. Rahul Signature" 
                            style="height: 50px; width: auto;">
                    </div>

                    </div>
                </div>
                </div>
                </div>
                @endif
        


      


                @if (!empty($test_results['lipid_profile']) && is_array($test_results['lipid_profile']))
                <br>
                <div class="col-md-6">
                <div class="container">

                <div class="report-header p-4">
                        <!-- Logo and Customer Care Info -->
                        <div class="d-flex justify-content-between align-items-center mb-3">
                            <img src="https://bluhealth.bluai.ai/admin/assets/images/logo/BluHealth_Logo.png"
                                alt="Lab Logo"
                                style="height: 40px; width: auto;">
                            
                            <div class="text-center">

                            <img src="{{ Storage::url('uploads/labs/' . $labDetails->photo) }}"
                                alt="Lab Logo"
                                style="height: 40px; width: auto;">
                                <h5 class="mb-1 text-primary">Customer Care</h5>
                                <p class="mb-0"><strong>7625896635</strong></p>
                                <p class="mb-0"><strong>7625896635</strong></p>
                            </div>
                        </div>

                        <hr class="my-3 border-primary">

                        <!-- Patient and Doctor Details -->
                        <div class="row">
                            <!-- Patient Information (Left) -->
                            <div class="col-md-6">
                                <div class="p-3">
                                    <p class="mb-1"><strong>Patient Name:</strong> {{ $patient ? $patient->first_name .' ' .$patient->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Age/Sex:</strong> {{ $patient ? \Carbon\Carbon::parse($patient->date_of_birth)->age . ' years / ' . $patient->sex : 'N/A' }}</p>

                                    <p class="mb-1"><strong>Refered By:</strong>{{ $hcp ? $hcp->first_name .' ' .$hcp->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Panel Address:</strong> {{ $patient ? $patient->address : 'N/A' }}</p> 
                                </div>
                            </div>

                            <!-- Doctor Information (Right) -->
                            <div class="col-md-6">
                                <div class="p-3">
                                   <p class="mb-1"><strong>Lab Name:</strong> {{ $labDetails ? $labDetails->first_name .' ' .$labDetails->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Lab No:</strong> {{ $labDetails ? $labDetails->cin : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Reg Date:</strong>  {{ $labDetails ? \Carbon\Carbon::parse($labDetails->created_at)->format('d/M/Y h:i A') : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Report Date:</strong>  {{ $test_results ? \Carbon\Carbon::parse($test_results->created_at)->format('d/M/Y h:i A') : 'N/A' }}</p>

                                </div>
                            </div>
                        </div>

                        <hr>
                    </div>

                    <table class="test-table">
                        <thead>
                            <tr>
                                <th>Test Name</th>
                                <th>Result</th>
                                <th>Normal Range</th>
                                <th>Units</th>
                                <th>Remarks</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (!empty($test_results['lipid_profile']) && is_array($test_results['lipid_profile']))
                            <tr>
                                <td colspan="5" class="text-center font-weight-bold">Lipid Profile (Lipid Panel)</td>
                            </tr>

                            @foreach($test_results['lipid_profile'] as $testResult)
                            <tr>
                                <td>
                                    {{ isset($testResult['test_name']) ? ucfirst(str_replace(['_', '-'], ' ', $testResult['test_name'])) : 'N/A' }}
                                </td>
                                <td>
                                    <strong>{{ $testResult['result'] ?? 'No Result' }}</strong>
                                </td>
                                <td class="normal-range">
                                    {{ $testResult['normal_range'] ?? 'Reference range not specified' }}
                                </td>
                                <td>
                                    {{ $testResult['units'] ?? '-' }}
                                </td>
                                <td class="text-muted">
                                    <em>{{ $testResult['remarks'] ?? 'No remarks' }}</em>
                                </td>
                            </tr>
                            @endforeach
                            @else
                            <tr>
                                <td colspan="5" class="text-center text-muted">No test results available</td>
                            </tr>
                            @endif


                        </tbody>
                    </table>


                   

                    <div class="footer-notes text-muted p-3">
                    <div class="d-flex justify-content-between">
                        <!-- Left Side -->
                        <div class="footer-notes text-muted">
                            <p><small><strong>Note:</strong> Reference ranges vary by age, sex, and method.</small></p>
                            <p><small><strong>Reviewed by:</strong> Dr. Jane Smith, Lab Director.</small></p>
                            <p><small><strong>Next Screening:</strong> 20-Mar-2025.</small></p>
                        </div>


                        <!-- Right Side -->
                        <div class="text-end">
                        <p><small>Dr. {{ $hcp ? $hcp->first_name .' ' .$hcp->last_name : 'N/A' }}</small></p>
                        <img src="{{ Storage::url('uploads/labs/' . $labDetails->signature) }}" 
                            alt="Dr. Rahul Signature" 
                            style="height: 50px; width: auto;">
                    </div>

                    </div>
                </div>
                </div>
                </div>
                @endif
        
     
 

          

                @if (!empty($test_results['preoperative']) && is_array($test_results['preoperative']))
                <br>
                <div class="col-md-6">
                <div class="container">

                <div class="report-header p-4">
                        <!-- Logo and Customer Care Info -->
                        <div class="d-flex justify-content-between align-items-center mb-3">
                            <img src="https://bluhealth.bluai.ai/admin/assets/images/logo/BluHealth_Logo.png"
                                alt="Lab Logo"
                                style="height: 40px; width: auto;">
                            
                            <div class="text-center">

                            <img src="{{ Storage::url('uploads/labs/' . $labDetails->photo) }}"
                                alt="Lab Logo"
                                style="height: 40px; width: auto;">
                                <h5 class="mb-1 text-primary">Customer Care</h5>
                                <p class="mb-0"><strong>7625896635</strong></p>
                                <p class="mb-0"><strong>7625896635</strong></p>
                            </div>
                        </div>

                        <hr class="my-3 border-primary">

                        <!-- Patient and Doctor Details -->
                        <div class="row">
                            <!-- Patient Information (Left) -->
                            <div class="col-md-6">
                                <div class="p-3">
                                    <p class="mb-1"><strong>Patient Name:</strong> {{ $patient ? $patient->first_name .' ' .$patient->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Age/Sex:</strong> {{ $patient ? \Carbon\Carbon::parse($patient->date_of_birth)->age . ' years / ' . $patient->sex : 'N/A' }}</p>

                                    <p class="mb-1"><strong>Refered By:</strong>{{ $hcp ? $hcp->first_name .' ' .$hcp->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Panel Address:</strong> {{ $patient ? $patient->address : 'N/A' }}</p> 
                                </div>
                            </div>

                            <!-- Doctor Information (Right) -->
                            <div class="col-md-6">
                                <div class="p-3">
                                   <p class="mb-1"><strong>Lab Name:</strong> {{ $labDetails ? $labDetails->first_name .' ' .$labDetails->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Lab No:</strong> {{ $labDetails ? $labDetails->cin : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Reg Date:</strong>  {{ $labDetails ? \Carbon\Carbon::parse($labDetails->created_at)->format('d/M/Y h:i A') : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Report Date:</strong>  {{ $test_results ? \Carbon\Carbon::parse($test_results->created_at)->format('d/M/Y h:i A') : 'N/A' }}</p>

                                </div>
                            </div>
                        </div>

                        <hr>
                    </div>



                    <table class="test-table">
                        <thead>
                            <tr>
                                <th>Test Name</th>
                                <th>Result</th>
                                <th>Normal Range</th>
                                <th>Units</th>
                                <th>Remarks</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (!empty($test_results['preoperative']) && is_array($test_results['preoperative']))
                            <tr>
                                <td colspan="5" class="text-center font-weight-bold"> Preoperative (Pre-op)</td>
                            </tr>
                            @foreach($test_results['preoperative'] as $testResult)
                            <tr>
                                <td>
                                    {{ isset($testResult['test_name']) ? ucfirst(str_replace(['_', '-'], ' ', $testResult['test_name'])) : 'N/A' }}
                                </td>
                                <td>
                                    <strong>{{ $testResult['result'] ?? 'No Result' }}</strong>
                                </td>
                                <td class="normal-range">
                                    {{ $testResult['normal_range'] ?? 'Reference range not specified' }}
                                </td>
                                <td>
                                    {{ $testResult['units'] ?? '-' }}
                                </td>
                                <td class="text-muted">
                                    <em>{{ $testResult['remarks'] ?? 'No remarks' }}</em>
                                </td>
                            </tr>
                            @endforeach
                            @else
                            <tr>
                                <td colspan="5" class="text-center text-muted">No test results available</td>
                            </tr>
                            @endif


                            <br>


                        </tbody>
                    </table>


                 

                    <div class="footer-notes text-muted p-3">
                    <div class="d-flex justify-content-between">
                        <!-- Left Side -->
                        <div class="footer-notes text-muted">
                            <p><small><strong>Note:</strong> Reference ranges vary by age, sex, and method.</small></p>
                            <p><small><strong>Reviewed by:</strong> Dr. Jane Smith, Lab Director.</small></p>
                            <p><small><strong>Next Screening:</strong> 20-Mar-2025.</small></p>
                        </div>


                        <!-- Right Side -->
                        <div class="text-end">
                        <p><small>Dr. {{ $hcp ? $hcp->first_name .' ' .$hcp->last_name : 'N/A' }}</small></p>
                        <img src="{{ Storage::url('uploads/labs/' . $labDetails->signature) }}" 
                            alt="Dr. Rahul Signature" 
                            style="height: 50px; width: auto;">
                    </div>

                    </div>
                </div>
                </div>
                </div>

                @endif

           




                <br>
                @if (!empty($test_results['acute_illness']) && is_array($test_results['acute_illness']))
             
                <div class="col-md-6">
                <div class="container">

                <div class="report-header p-4">
                        <!-- Logo and Customer Care Info -->
                        <div class="d-flex justify-content-between align-items-center mb-3">
                            <img src="https://bluhealth.bluai.ai/admin/assets/images/logo/BluHealth_Logo.png"
                                alt="Lab Logo"
                                style="height: 40px; width: auto;">
                            
                            <div class="text-center">

                            <img src="{{ Storage::url('uploads/labs/' . $labDetails->photo) }}"
                                alt="Lab Logo"
                                style="height: 40px; width: auto;">
                                <h5 class="mb-1 text-primary">Customer Care</h5>
                                <p class="mb-0"><strong>7625896635</strong></p>
                                <p class="mb-0"><strong>7625896635</strong></p>
                            </div>
                        </div>

                        <hr class="my-3 border-primary">

                        <!-- Patient and Doctor Details -->
                        <div class="row">
                            <!-- Patient Information (Left) -->
                            <div class="col-md-6">
                                <div class="p-3">
                                    <p class="mb-1"><strong>Patient Name:</strong> {{ $patient ? $patient->first_name .' ' .$patient->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Age/Sex:</strong> {{ $patient ? \Carbon\Carbon::parse($patient->date_of_birth)->age . ' years / ' . $patient->sex : 'N/A' }}</p>

                                    <p class="mb-1"><strong>Refered By:</strong>{{ $hcp ? $hcp->first_name .' ' .$hcp->last_name : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Panel Address:</strong> {{ $patient ? $patient->address : 'N/A' }}</p> 
                                </div>
                            </div>

                            <!-- Doctor Information (Right) -->
                            <div class="col-md-6">
                                <div class="p-3">
                                   <p class="mb-1"><strong>Lab Name:</strong> {{ $labDetails ? $labDetails->lab_name  : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Lab No:</strong> {{ $labDetails ? $labDetails->cin : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Reg Date:</strong>  {{ $labDetails ? \Carbon\Carbon::parse($labDetails->created_at)->format('d/M/Y h:i A') : 'N/A' }}</p>
                                    <p class="mb-1"><strong>Report Date:</strong>  {{ $test_results ? \Carbon\Carbon::parse($test_results->created_at)->format('d/M/Y h:i A') : 'N/A' }}</p>

                                </div>
                            </div>
                        </div>

                        <hr>
                    </div>


                    <table class="test-table">
                        <thead>
                            <tr>
                                <th>Test Name</th>
                                <th>Result</th>
                                <th>Normal Range</th>
                                <th>Units</th>
                                <th>Remarks</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (!empty($test_results['acute_illness']) && is_array($test_results['acute_illness']))
                            <tr>
                                <td colspan="5" class="text-center font-weight-bold"> Acute Illness</td>
                            </tr>
                            @foreach($test_results['acute_illness'] as $testResult)
                            <tr>
                                <td>
                                    {{ isset($testResult['test_name']) ? ucfirst(str_replace(['_', '-'], ' ', $testResult['test_name'])) : 'N/A' }}
                                </td>
                                <td>
                                    <strong>{{ $testResult['result'] ?? 'No Result' }}</strong>
                                </td>
                                <td class="normal-range">
                                    {{ $testResult['normal_range'] ?? 'Reference range not specified' }}
                                </td>
                                <td>
                                    {{ $testResult['units'] ?? '-' }}
                                </td>
                                <td class="text-muted">
                                    <em>{{ $testResult['remarks'] ?? 'No remarks' }}</em>
                                </td>
                            </tr>
                            @endforeach
                            @else
                            <tr>
                                <td colspan="5" class="text-center text-muted">No test results available</td>
                            </tr>
                            @endif

                        </tbody>
                    </table>


                    <div class="footer-notes text-muted p-3">
                    <div class="d-flex justify-content-between">
                        <!-- Left Side -->
                        <div class="footer-notes text-muted">
                            <p><small><strong>Note:</strong> Reference ranges vary by age, sex, and method.</small></p>
                            <p><small><strong>Reviewed by:</strong> Dr. Jane Smith, Lab Director.</small></p>
                            <p><small><strong>Next Screening:</strong> 20-Mar-2025.</small></p>
                        </div>


                        <!-- Right Side -->
                        <div class="text-end">
                        <p><small>Dr. {{ $hcp ? $hcp->first_name .' ' .$hcp->last_name : 'N/A' }}</small></p>
                        <img src="{{ Storage::url('uploads/labs/' . $labDetails->signature) }}" 
                            alt="Dr. Rahul Signature" 
                            style="height: 50px; width: auto;">
                    </div>

                    </div>
                </div>

                </div>
                </div>
                @endif
           
        </div>

</body>

</html>

<div class="text-center mt-3">
    <a href="{{ route('labs.labtest') }}" class="btn btn-sm btn-secondary">Back to Lab List</a>
</div>



@endsection;