@php
    $valuationCustomerOnlyTier = $valuation_customer_only_tier ?? null;
    $valuationHighlightTier = $valuation_highlight_tier ?? null;
    $valuationConditionLabel = $valuation_condition_label ?? null;
    $showRetail = $valuationCustomerOnlyTier === null && $valuation_email_price_to_show === 'all';
    $showClean = $valuationCustomerOnlyTier === 'clean_price'
        || ($valuationCustomerOnlyTier === null && in_array($valuation_email_price_to_show, ['all', 'clean_price']));
    $showAverage = $valuationCustomerOnlyTier === 'average_price'
        || ($valuationCustomerOnlyTier === null && in_array($valuation_email_price_to_show, ['all', 'average_price']));
    $showBelow = $valuationCustomerOnlyTier === 'below_price'
        || ($valuationCustomerOnlyTier === null && in_array($valuation_email_price_to_show, ['all', 'below_price']));
@endphp
@if(!empty($enquiry->reason))
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Registration</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            {{ strtoupper($enquiry->reason?->registration) }}
        </td>
    </tr>
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Vehicle Make/Model</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            {{ $enquiry->reason?->make }}
            {{ $enquiry->reason?->model }}
        </td>
    </tr>
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Derivative</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            {{ $enquiry->reason?->derivative }}
        </td>
    </tr>
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Mileage</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            {{ $enquiry->reason?->mileage }}
        </td>
    </tr>
    @if(!empty($enquiry->reason?->body_type))
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Body type</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            {{ $enquiry->reason?->body_type }}
        </td>
    </tr>
    @endif
    @if(!empty($enquiry->reason?->colour))
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Colour</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            {{ $enquiry->reason?->colour }}
        </td>
    </tr>
    @endif
    @if(!empty($valuationConditionLabel))
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Condition</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            {{ ucwords(str_replace('_', ' ', $valuationConditionLabel)) }}
        </td>
    </tr>
    @endif
    <tr>
        <td colspan="2" style="padding: 10px;">
            <p style="font-size: 0.85em; color: #333; margin: 0;">
                Retail is the dealer forecourt price. The three condition-based figures are part-exchange
                offers — what a dealer would pay for the vehicle based on its condition.
            </p>
        </td>
    </tr>
    @if($showRetail)
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Retail value</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            {{ $enquiry->reason?->adjusted_retail_price ?? $enquiry->reason?->retail_price }}
            <p style="font-size: 0.8em; color: #333; margin-bottom: 0;">The suggested market retail valuation for the vehicle.</p>
        </td>
    </tr>
    @endif
    @if(!empty($enquiry->reason?->clean_price) && $showClean)
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Clean value</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            @if($valuationHighlightTier === 'clean_price')<strong>@endif
            {{ $enquiry->reason?->adjusted_clean_price ?? $enquiry->reason?->clean_price }}
            @if($valuationHighlightTier === 'clean_price')</strong>@endif
            <p style="font-size: 0.8em; color: #333; margin-bottom: 0;">Showroom condition — no reconditioning needed, unmarked paint and trim, complete service history, both keys present.</p>
        </td>
    </tr>
    @endif
    @if(!empty($enquiry->reason?->average_price) && $showAverage)
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Average value</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            @if($valuationHighlightTier === 'average_price')<strong>@endif
            {{ $enquiry->reason?->adjusted_average_price ?? $enquiry->reason?->average_price }}
            @if($valuationHighlightTier === 'average_price')</strong>@endif
            <p style="font-size: 0.8em; color: #333; margin-bottom: 0;">Average condition — may need some light mechanical or paintwork reconditioning, documented service history.</p>
        </td>
    </tr>
    @endif
    @if(!empty($enquiry->reason?->below_price) && $showBelow)
    <tr>
        <td width="32%" valign="top" style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            <strong>Below value</strong>
        </td>
        <td width="58%" valign="middle"
            style="border-bottom:1px solid {{ $layerAccentColour }};padding: 10px;">
            @if($valuationHighlightTier === 'below_price')<strong>@endif
            {{ $enquiry->reason?->adjusted_below_price ?? $enquiry->reason?->below_price }}
            @if($valuationHighlightTier === 'below_price')</strong>@endif
            <p style="font-size: 0.8em; color: #333; margin-bottom: 0;">Below average condition — requires mechanical or bodywork repairs, service history may be limited.</p>
        </td>
    </tr>
    @endif
@endif
