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

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

        .header { border-bottom: 2.5pt solid #0B6232; padding-bottom: 10pt; }
        .header table { width: 100%; border-collapse: collapse; }
        .header td { vertical-align: top; }
        .logo { height: 42pt; }
        .contact { font-size: 7.5pt; color: #64748b; text-align: right; line-height: 1.5; }
        .gold-rule { height: 3pt; background: #FFC66B; margin-bottom: 16pt; }

        h1 {
            font-size: 13pt;
            color: #0B6232;
            text-align: center;
            letter-spacing: 1.2pt;
            text-transform: uppercase;
            margin: 0 0 4pt;
        }
        .subtitle { text-align: center; font-size: 9pt; color: #64748b; margin-bottom: 16pt; }

        h2 {
            font-size: 10.5pt;
            color: #0B6232;
            margin: 16pt 0 6pt;
            padding-bottom: 3pt;
            border-bottom: 0.75pt solid #FFC66B;
        }

        p { margin: 0 0 8pt; text-align: justify; }
        ul { margin: 0 0 8pt; padding-left: 14pt; }
        li { margin-bottom: 3.5pt; }

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

        table.fees { width: 100%; border-collapse: collapse; font-size: 9.5pt; margin-bottom: 10pt; }
        table.fees th, table.fees td { border: 0.5pt solid #cbd5e1; padding: 5pt 7pt; text-align: left; }
        table.fees th { background: #f1f5f9; color: #334155; }
        table.fees td.amount { text-align: right; font-weight: bold; }

        .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;
        }
    </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: 14pt; 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>

<h1>Joining Instructions</h1>
<p class="subtitle">{{ $intake?->name }} &nbsp;&middot;&nbsp; {{ $programme?->name }}</p>

<div class="panel">
    <table>
        <tr>
            <td class="label">Name</td>
            <td class="value">{{ $applicant->fullName() }}</td>
        </tr>
        <tr>
            <td class="label">Admission Number</td>
            <td class="value">{{ $record?->admission_number }}</td>
        </tr>
        <tr>
            <td class="label">Programme</td>
            <td class="value">{{ $programme?->name }}</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('l, j F Y') }}</td>
            </tr>
        @endif
    </table>
</div>

<h2>1. Accepting Your Offer</h2>
<p>
    Confirm your acceptance through the applicant portal
    @if ($record?->acceptance_deadline)
        by <strong>{{ $record->acceptance_deadline->format('j F Y') }}</strong>
    @endif.
    Places that are not confirmed may be offered to other candidates.
</p>

<h2>2. Reporting &amp; Registration</h2>
<p>Report to the Academic Registrar's office at the {{ $record?->campus ?? 'Bunga' }} campus with:</p>
<ul>
    <li>This letter and your admission letter</li>
    <li>Original academic certificates and transcripts (with two photocopies of each)</li>
    <li>Original National ID or passport (with two photocopies)</li>
    <li>Four recent passport-size photographs</li>
    <li>Proof of payment of the fees below</li>
    <li>A medical report from a recognised health facility</li>
</ul>

<h2>3. Fees</h2>
<table class="fees">
    <tr>
        <th>Item</th>
        <th style="text-align: right; width: 32%;">Amount ({{ $programme?->currency ?? 'UGX' }})</th>
    </tr>
    <tr>
        <td>Tuition (per academic year)</td>
        <td class="amount">
            {{ $programme?->tuition_amount ? number_format((float) $programme->tuition_amount) : 'See Finance Office' }}
        </td>
    </tr>
    <tr>
        <td>Registration and functional fees</td>
        <td class="amount">See Finance Office</td>
    </tr>
</table>
<p>
    Fees are payable to the University bank account before registration. Always quote your admission
    number, <strong>{{ $record?->admission_number }}</strong>, on every payment. Confirm the current
    fee structure with the Finance Office before paying.
</p>

<h2>4. Academic Calendar</h2>
<p>
    @if ($intake?->start_date)
        Teaching for {{ $intake->name }} begins on <strong>{{ $intake->start_date->format('j F Y') }}</strong>.
    @else
        The academic calendar for your intake will be published in the applicant portal.
    @endif
    Orientation week runs immediately before teaching begins and attendance is compulsory.
</p>

<h2>5. Accommodation</h2>
<p>
    The University does not operate halls of residence at all campuses. The Dean of Students' office
    maintains a list of approved hostels near each campus and can advise on options and current rates.
</p>

<h2>6. Contact</h2>
<p>
    Admissions: {{ $university['email'] }} &nbsp;&middot;&nbsp; {{ $university['phone'] }}<br>
    {{ $university['address'] }}, {{ $university['city'] }}, {{ $university['country'] }}
</p>

<div class="footer">
    {{ $university['name'] }} &nbsp;&middot;&nbsp; {{ $university['motto'] }}
    &nbsp;&middot;&nbsp; Reference {{ $record?->verification_code }}
</div>

</body>
</html>
