<?php
$content = <<<'HTML'
<!-- ================================================================= -->
            <!-- 7. GIFT & QRIS                                                    -->
            <!-- ================================================================= -->
            <?php 
                $hasOldGift = isset($sectionMap['gift']);
                $hasNewGift = !empty($gift_settings['is_enabled']) || !empty($gift_accounts);
                
                if ($hasOldGift || $hasNewGift): 
                
                $giftConfig = $sectionMap['gift'] ?? [];
                
                $oldBankName = $giftConfig['bank_name'] ?? '';
                $oldAccNum = $giftConfig['account_number'] ?? '';
                $oldAccName = $giftConfig['account_name'] ?? '';
                $qrisPath = $giftConfig['qris_image'] ?? null;
                
                if (!empty($gift_accounts)) {
                    $firstAcc = $gift_accounts[0];
                    $oldBankName = $firstAcc['bank_name'] ?? $oldBankName;
                    $oldAccNum = $firstAcc['account_number'] ?? $oldAccNum;
                    $oldAccName = $firstAcc['account_name'] ?? $oldAccName;
                }
                
                $qrisUrl = $qrisPath ? url('/i/media/serve') . '?path=' . urlencode($qrisPath) : '';
            ?>
                <section class="py-16 md:py-20 lg:py-24 px-6 md:px-12 space-y-8 border-b <?= $style['borderColor'] ?>">
                    <?php
                    $headerEmoji = '🎁';
                    $headerTitle = 'Wedding Gift & Angpau';
                    require __DIR__ . '/../partials/section_header.php';
                    ?>
                    <div class="text-center mt-2">
                        <p class="text-xs text-slate-400 leading-relaxed max-w-xs mx-auto">
                            For friends and family who wish to send wedding tokens or digital gifts, details are provided below:
                        </p>
                    </div>

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6 max-w-2xl mx-auto items-stretch text-left">
                        
                        <!-- Bank Transfer Card -->
                        <?php if (!empty($oldBankName) || !empty($oldAccNum)): ?>
                            <div class="<?= $style['cardBg'] ?> border <?= $style['borderColor'] ?> rounded-3xl p-6 flex flex-col justify-between space-y-4 shadow-sm hover:border-amber-400/60 transition">
                                <div class="space-y-3">
                                    <div class="flex items-center justify-between border-b border-slate-100 pb-3">
                                        <div class="flex items-center gap-2">
                                            <span class="text-xl">💳</span>
                                            <span class="text-sm font-bold <?= $style['textColor'] ?>"><?= escape_html($oldBankName) ?></span>
                                        </div>
                                        <span class="text-[10px] font-bold uppercase tracking-wider text-slate-400">Bank Transfer</span>
                                    </div>

                                    <?php if (!empty($oldAccNum)): ?>
                                        <div>
                                            <p class="text-xxs uppercase tracking-wider text-slate-400 font-bold">Account Number</p>
                                            <div class="flex items-center justify-between mt-1 bg-slate-50 border border-slate-200/80 rounded-xl px-3 py-2">
                                                <span class="text-base font-bold text-amber-700 font-mono"><?= escape_html($oldAccNum) ?></span>
                                                <button type="button" onclick="copyToClipboard('<?= escape_html($oldAccNum) ?>', 'Account number copied!')" class="inline-flex items-center gap-1 text-xs font-semibold <?= $style['accent'] ?> hover:text-amber-700 <?= $style['cardBg'] ?> border border-amber-200 px-2.5 py-1 rounded-lg shadow-2xs hover:<?= $style['accentBg'] ?> transition">
                                                    <span>📋</span> Copy
                                                </button>
                                            </div>
                                        </div>
                                    <?php endif; ?>

                                    <?php if (!empty($oldAccName)): ?>
                                        <div class="pt-1">
                                            <p class="text-xxs uppercase tracking-wider text-slate-400 font-bold">Account Holder</p>
                                            <p class="text-xs font-bold <?= $style['textColor'] ?> mt-0.5"><?= escape_html($oldAccName) ?></p>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                        <?php endif; ?>

                        <!-- QRIS Digital Payment Card -->
                        <?php if ($qrisUrl !== ''): ?>
                            <div class="<?= $style['cardBg'] ?> border <?= $style['borderColor'] ?> rounded-3xl p-6 flex flex-col justify-between space-y-4 shadow-sm hover:border-amber-400/60 transition cursor-pointer" onclick="openQrisModal('<?= escape_html($qrisUrl) ?>')">
                                <div class="space-y-3 text-center">
                                    <div class="flex items-center justify-between border-b border-slate-100 pb-3">
                                        <div class="flex items-center gap-2">
                                            <span class="text-xl">📲</span>
                                            <span class="text-sm font-bold <?= $style['textColor'] ?>">QRIS Payment</span>
                                        </div>
                                        <span class="text-[10px] font-bold uppercase tracking-wider text-amber-700 <?= $style['accentBg'] ?> px-2 py-0.5 rounded-full border border-amber-200/60">Instant</span>
                                    </div>

                                    <div class="bg-slate-50 border border-slate-100 rounded-2xl p-3 inline-block mx-auto">
                                        <img src="<?= escape_html($qrisUrl) ?>" alt="QRIS Code" class="w-32 h-32 object-contain mx-auto rounded-xl">
                                    </div>
                                    <p class="text-xs <?= $style['subText'] ?> font-medium">Tap to enlarge &amp; scan QRIS</p>
                                </div>
                            </div>
                        <?php endif; ?>

                    </div>
                </section>
            <?php endif; ?>
HTML;

file_put_contents('app/views/public/identity/sections/gift.php', $content);
echo "Fixed gift.php fully\n";
