@extends('web.layouts.auth')

@section('title', '회원가입 Debug | PIN FOR YOU')

@section('auth_content')
    <div class="auth-card">
        <h2 class="auth-title">회원가입 Debug</h2>

        <div style="margin:12px 0;">
            <div style="font-weight:800;margin-bottom:6px;">Payload(session)</div>
            <pre style="white-space:pre-wrap; font-size:12px; background:rgba(0,0,0,.25); padding:12px; border-radius:12px;">
{{ json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT) }}
        </pre>
        </div>

        <div style="display:flex; gap:8px; flex-wrap:wrap; margin: 14px 0;">
            <form method="POST" action="{{ route('web.auth.register.profile.debug.run') }}">
                @csrf
                <input type="hidden" name="step" value="mem_info">
                <button class="auth-btn auth-btn--primary" type="submit">DRYRUN: mem_info</button>
            </form>

            <form method="POST" action="{{ route('web.auth.register.profile.debug.run') }}">
                @csrf
                <input type="hidden" name="step" value="mem_st_ring">
                <button class="auth-btn auth-btn--primary" type="submit">DRYRUN: mem_st_ring</button>
            </form>

            <form method="POST" action="{{ route('web.auth.register.profile.debug.run') }}">
                @csrf
                <input type="hidden" name="step" value="mem_auth">
                <button class="auth-btn auth-btn--primary" type="submit">DRYRUN: mem_auth</button>
            </form>

            <form method="POST" action="{{ route('web.auth.register.profile.debug.run') }}">
                @csrf
                <input type="hidden" name="step" value="mem_auth_log">
                <button class="auth-btn auth-btn--primary" type="submit">DRYRUN: mem_auth_log</button>
            </form>
        </div>

        @if(!empty($last))
            <hr style="opacity:.2;margin:16px 0;">

            <div style="font-weight:900;">마지막 실행 결과</div>
            <div style="margin:8px 0; opacity:.85;">
                step: <b>{{ $last['step'] ?? '-' }}</b> /
                mode: <b>{{ !empty($last['commit']) ? 'COMMIT' : 'DRY RUN(ROLLBACK)' }}</b> /
                ok: <b>{{ !empty($last['ok']) ? 'true' : 'false' }}</b>
            </div>
            <div style="white-space:pre-line; opacity:.85;">{{ $last['message'] ?? '' }}</div>

            <div style="margin-top:12px;">
                <div style="font-weight:800;margin-bottom:6px;">Captured Queries</div>
                <pre style="white-space:pre-wrap; font-size:12px; background:rgba(0,0,0,.25); padding:12px; border-radius:12px;">
{{ json_encode($last['queries'] ?? [], JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT) }}
            </pre>
            </div>
        @endif
    </div>
@endsection
