@php
    $brandTxt = $brand ?? config('app.name', 'Brand');
    $subj     = $subject ?? '';
    $copy     = $copyright ?? ('© 2018 '.$brandTxt.'.');
    $bodyOut  = $body_html ?? nl2br(e($body_text ?? $body ?? ''));

    $snsList = [];
    if (!empty($sns) && is_array($sns)) {
        if (isset($sns[0]) && is_array($sns[0])) $snsList = $sns;
        else foreach ($sns as $k=>$u) if ($u) $snsList[] = ['label'=>ucfirst((string)$k), 'url'=>$u];
    }
@endphp

<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#f3f4f6; padding:22px 0;">
    <tr>
        <td align="center">
            <table role="presentation" width="620" cellpadding="0" cellspacing="0"
                   style="width:620px; max-width:94%; background:#ffffff; border-radius:16px; overflow:hidden; border:1px solid #e5e7eb;">
                <tr>
                    <td style="padding:16px 18px; border-bottom:1px solid #e5e7eb; background:#ffffff;">
                        <div style="font-weight:900; color:#111827; font-size:14px;">
                            @if(!empty($logoUrl))
                                <img src="{{ $logoUrl }}" alt="{{ $brandTxt }}" style="height:18px; vertical-align:middle;">
                            @else
                                {{ $brandTxt }}
                            @endif
                        </div>
                    </td>
                </tr>

                <tr>
                    <td style="padding:18px;">
                        <div style="font-weight:900; font-size:16px; color:#111827;">
                            {{ $subj }}
                        </div>
                        <div style="height:10px;"></div>

                        <div style="background:#0f172a; border-radius:14px; padding:14px; border:1px solid #111827;">
                            <div style="font-size:13px; color:#e5e7eb; line-height:1.8;  height:300px">
                                {!! $bodyOut !!}
                            </div>
                        </div>

                        {{-- Highlight tip --}}
                        <div style="border-left:4px solid #6b7280; padding:10px 12px; background:#f3f4f6; border-radius:12px; margin-top:20px ">
                            <div style="font-size:12px; color:#111827; font-weight:800; margin-bottom:4px;">안내</div>
                            <div style="font-size:12px; color:#374151; line-height:1.6;">
                                이 메일은 발신 전용입니다. 문의가 필요하면 관리자 채널을 통해 연락해 주세요.
                            </div>
                        </div>

                        <div style="margin-top:16px; font-size:12px; color:#6b7280; line-height:1.6;">
                            <div style="border-top:1px solid #eef2f7; padding-top:12px;">
                                <div style="margin-bottom:10px;">{{ $copy }}</div>

                                @if(!empty($snsList))
                                    <div>
                                        @foreach($snsList as $s)
                                            @php $u=$s['url']??''; $l=$s['label']??''; @endphp
                                            @if($u && $l)
                                                <a href="{{ $u }}" style="color:#2563eb; text-decoration:none; margin-right:12px;">
                                                    {{ $l }}
                                                </a>
                                            @endif
                                        @endforeach
                                    </div>
                                @endif
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
