<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Admission Letter — {{ $record?->admission_number }}</title>
    <style>
        @page { margin: 30mm 20mm 25mm 20mm; }

        body {
            font-family: DejaVu Sans, sans-serif;
            font-size: 10.5pt;
            line-height: 1.55;
            color: #1e293b;
        }

        .header { border-bottom: 2.5pt solid #0B6232; padding-bottom: 10pt; margin-bottom: 6pt; }
        .header table { width: 100%; border-collapse: collapse; }
        .header td { vertical-align: top; }
        .logo { height: 46pt; }

        .contact { font-size: 7.5pt; color: #64748b; text-align: right; line-height: 1.5; }
        .gold-rule { height: 3pt; background: #FFC66B; margin-bottom: 18pt; }

        h1 {
            font-size: 14pt;
            color: #0B6232;
            text-align: center;
            letter-spacing: 1.5pt;
            text-transform: uppercase;
            margin: 0 0 16pt;
        }

        .meta { width: 100%; border-collapse: collapse; margin-bottom: 16pt; font-size: 9.5pt; }
        .meta td { padding: 2pt 0; }
        .meta .label { color: #64748b; width: 32%; }
        .meta .value { font-weight: bold; }

        .panel {
            background: #f0f9f4;
            border-left: 3pt solid #0B6232;
            padding: 10pt 12pt;
            margin: 14pt 0;
        }
        .panel table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
        .panel td { padding: 3pt 0; vertical-align: top; }
        .panel .label { color: #475569; width: 34%; }
        .panel .value { font-weight: bold; color: #073F24; }

        p { margin: 0 0 9pt; text-align: justify; }

        .conditions { border: 0.75pt solid #cbd5e1; padding: 9pt 12pt; margin: 12pt 0; font-size: 9.5pt; }
        .conditions h2 { font-size: 10pt; color: #0B6232; margin: 0 0 6pt; }

        .signature { margin-top: 26pt; }
        .signature .line { border-top: 0.75pt solid #334155; width: 190pt; padding-top: 4pt; font-size: 9pt; }

        .footer {
            position: fixed;
            bottom: -16mm;
            left: 0; right: 0;
            border-top: 0.5pt solid #cbd5e1;
            padding-top: 5pt;
            font-size: 7pt;
            color: #94a3b8;
            text-align: center;
        }

        .verify { font-family: DejaVu Sans Mono, monospace; font-size: 8pt; }
    </style>
</head>
<body>

<div class="header">
    <table>
        <tr>
            <td style="width: 55%;">
                @if ($university['logo'])
                    <img src="{{ $university['logo'] }}" alt="{{ $university['name'] }}" class="logo">
                @else
                    <strong style="font-size: 15pt; color: #0B6232;">{{ $university['name'] }}</strong>
                @endif
            </td>
            <td class="contact">
                {{ $university['address'] }}<br>
                {{ $university['city'] }}, {{ $university['country'] }}<br>
                {{ $university['phone'] }}<br>
                {{ $university['email'] }}
            </td>
        </tr>
    </table>
</div>
<div class="gold-rule"></div>

<table class="meta">
    <tr>
        <td class="label">Date</td>
        <td class="value">{{ $record?->admitted_at?->format('j F Y') ?? now()->format('j F Y') }}</td>
    </tr>
    <tr>
        <td class="label">Admission Number</td>
        <td class="value">{{ $record?->admission_number }}</td>
    </tr>
    <tr>
        <td class="label">Application Number</td>
        <td class="value">{{ $application->application_number }}</td>
    </tr>
</table>

<h1>Offer of Admission</h1>

<p>
    <strong>{{ $applicant->fullName() }}</strong><br>
    @if ($applicant->address){{ $applicant->address }}<br>@endif
    @if ($applicant->district){{ $applicant->district }}, @endif{{ $applicant->country }}
</p>

<p>Dear {{ $applicant->first_name }},</p>

<p>
    Following consideration of your application, I am pleased to inform you that you have been offered
    a place at {{ $university['name'] }} for the programme detailed below. On behalf of the University,
    I congratulate you on this achievement and welcome you to our community.
</p>

<div class="panel">
    <table>
        <tr>
            <td class="label">Programme</td>
            <td class="value">{{ $programme?->name }}</td>
        </tr>
        <tr>
            <td class="label">Award</td>
            <td class="value">{{ $programme?->award }}</td>
        </tr>
        <tr>
            <td class="label">School</td>
            <td class="value">{{ $programme?->school?->name }}</td>
        </tr>
        <tr>
            <td class="label">Duration</td>
            <td class="value">{{ $programme?->durationLabel() }}</td>
        </tr>
        <tr>
            <td class="label">Intake</td>
            <td class="value">{{ $intake?->name }}</td>
        </tr>
        <tr>
            <td class="label">Study Mode</td>
            <td class="value">{{ ucfirst($record?->study_mode ?? 'Day') }}</td>
        </tr>
        <tr>
            <td class="label">Campus</td>
            <td class="value">{{ $record?->campus ?? 'Bunga Campus' }}</td>
        </tr>
        @if ($record?->reporting_date)
            <tr>
                <td class="label">Reporting Date</td>
                <td class="value">{{ $record->reporting_date->format('j F Y') }}</td>
            </tr>
        @endif
    </table>
</div>

<div class="conditions">
    <h2>Conditions of Admission</h2>
    @if ($record?->conditions)
        <p>{{ $record->conditions }}</p>
    @endif
    <p style="margin-bottom: 0;">
        This offer is made on the understanding that the information and documents submitted with your
        application are genuine and accurate. You will be required to present the originals of all
        academic and identity documents at registration. The University reserves the right to withdraw
        this offer if any information is found to be false or if the stated requirements are not met.
    </p>
</div>

@if ($record?->acceptance_deadline)
    <p>
        To accept this offer, please confirm your acceptance through the applicant portal and complete
        registration by <strong>{{ $record->acceptance_deadline->format('j F Y') }}</strong>. Places not
        confirmed by this date may be offered to other candidates.
    </p>
@endif

<p>
    Detailed joining instructions, including fees, registration requirements and accommodation
    information, accompany this letter and are available in your applicant portal.
</p>

<p>We look forward to welcoming you to {{ $university['name'] }}.</p>

<div class="signature">
    <p style="margin-bottom: 22pt;">Yours sincerely,</p>
    <div class="line">
        <strong>{{ $university['vice_chancellor'] }}</strong><br>
        Vice Chancellor<br>
        {{ $university['name'] }}
    </div>
</div>

<div class="footer">
    {{ $university['name'] }} &nbsp;&middot;&nbsp; {{ $university['motto'] }}
    &nbsp;&middot;&nbsp; This document may be verified with the Academic Registrar quoting reference
    <span class="verify">{{ $record?->verification_code }}</span>
</div>

</body>
</html>
