@php
    $brandTxt = $brand ?? config('app.name', 'Brand');
    $subTxt   = $subtitle ?? '공지/이벤트/안내 메일';
    $subj     = $subject ?? '';
    $copy     = $copyright ?? ('© 2018 '.$brandTxt.'.');
    $bodyOut  = $body_html ?? nl2br(e($body_text ?? $body ?? ''));

    // sns: (1) [['label'=>'','url'=>''], ...] 또는 (2) ['instagram'=>'url', 'youtube'=>'url']
    $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:#0b1220; padding:28px 0;">
    <tr>
        <td align="center">

            <table role="presentation" width="720" cellpadding="0" cellspacing="0"
                   style="width:720px; max-width:94%; border-radius:22px; overflow:hidden; background:#0b1220;">

                {{-- outer glow frame --}}
                <tr>
                    <td style="padding:1px; background:linear-gradient(135deg, rgba(37,99,235,.95), rgba(124,58,237,.95), rgba(34,197,94,.75)); border-radius:22px;">
                        <table role="presentation" width="100%" cellpadding="0" cellspacing="0"
                               style="background:#ffffff; border-radius:21px; overflow:hidden;">

                            {{-- Header --}}
                            <tr>
                                <td style="padding:18px 22px; background:linear-gradient(90deg,#2563eb,#7c3aed); color:#fff;">
                                    <div style="font-weight:900; font-size:16px; letter-spacing:.2px;">
                                        @if(!empty($logoUrl))
                                            <img src="{{ $logoUrl }}" alt="{{ $brandTxt }}" style="height:22px; vertical-align:middle;">
                                        @else
                                            {{ $brandTxt }}
                                        @endif
                                    </div>
                                </td>
                            </tr>

                            {{-- Hero Image --}}
                            @if(!empty($heroUrl))
                                <tr>
                                    <td>
                                        <img src="{{ $heroUrl }}" alt="" style="width:100%; display:block;">
                                    </td>
                                </tr>
                            @endif

                            {{-- Content --}}
                            <tr>
                                <td style="padding:26px 22px;">
                                    <div style="font-weight:900; font-size:22px; line-height:1.25; color:#0f172a; margin-bottom:12px;">
                                        {{ $subj }}
                                    </div>

                                    <div style="height:10px;"></div>

                                    <div style="background:linear-gradient(180deg,#f8fafc,#ffffff); border:1px solid #eef2f7; border-radius:16px; padding:16px 16px;">
                                        <div style="font-size:14px; line-height:1.85; color:#111;  height:300px">
                                            {!! $bodyOut !!}
                                        </div>
                                    </div>

                                    <div style="height:16px;"></div>

                                    {{-- Highlight tip --}}
                                    <div style="border-left:4px solid #6b7280; padding:10px 12px; background:#f3f4f6; border-radius:12px;">
                                        <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>

                                    {{-- Footer --}}
                                    <div style="margin-top:22px; font-size:12px; color:#64748b; line-height:1.7;">
                                        <div style="border-top:1px solid #eef2f7; padding-top:14px;">
                                            <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>

        </td>
    </tr>
</table>
