@if (InlineMode)
{
    @* Inline rendering without MudDialog wrapper *@
    <div class="auth-dialog-content">
        <MudStack Spacing="3" AlignItems="AlignItems.Center" Class="mb-4">
            <MudAvatar Size="Size.Large" Color="Color.Primary" Variant="Variant.Filled">
                <MudIcon Icon="@(_currentStep == AuthStep.Phone ? Icons.Material.Outlined.PhoneAndroid : Icons.Material.Outlined.LockOpen)" Size="Size.Large" />
            </MudAvatar>
            <MudText Typo="Typo.h5">@GetDialogTitle()</MudText>
        </MudStack>
        <PhoneVerifyForm @ref="_phoneVerifyForm"
                         CurrentStep="_currentStep"
                         PhoneRequest="_phoneRequest"
                         VerifyRequest="_verifyRequest"
                         CaptchaCode="@_captchaCode"
                         CaptchaInput="@_captchaInput"
                         CaptchaInputChanged="@(v => _captchaInput = v)"
                         OnRefreshCaptcha="GenerateCaptcha"
                         IsBusy="_isBusy"
                         ErrorMessage="@_errorMessage"
                         InfoMessage="@_infoMessage"
                         PhoneNumber="@_phoneNumber"
                         ResendRemaining="_resendRemaining"
                         OnChangePhone="ChangePhoneAsync"
                         OnResendOtp="ResendOtpAsync"
                         ReferralCode="@_referralCode"
                         ReferralCodeChanged="OnReferralCodeChanged" />
    </div>
}
else
{
    <MudDialog Class="auth-dialog-wrapper">
        <DialogContent>
            <div class="auth-dialog-content">
                <MudStack Spacing="2" AlignItems="AlignItems.Center" Class="mb-4 pt-2">
                    <MudAvatar Size="Size.Large" Color="Color.Primary" Variant="Variant.Filled">
                        <MudIcon Icon="@(_currentStep == AuthStep.Phone ? Icons.Material.Outlined.PhoneAndroid : Icons.Material.Outlined.LockOpen)" Size="Size.Large" />
                    </MudAvatar>
                    <MudText Typo="Typo.h5" Align="Align.Center">@GetDialogTitle()</MudText>
                </MudStack>

                <PhoneVerifyForm @ref="_phoneVerifyForm"
                                 CurrentStep="_currentStep"
                                 PhoneRequest="_phoneRequest"
                                 VerifyRequest="_verifyRequest"
                                 CaptchaCode="@_captchaCode"
                                 CaptchaInput="@_captchaInput"
                                 CaptchaInputChanged="@(v => _captchaInput = v)"
                                 OnRefreshCaptcha="GenerateCaptcha"
                                 IsBusy="_isBusy"
                                 ErrorMessage="@_errorMessage"
                                 InfoMessage="@_infoMessage"
                                 PhoneNumber="@_phoneNumber"
                                 ResendRemaining="_resendRemaining"
                                 OnChangePhone="ChangePhoneAsync"
                                 OnResendOtp="ResendOtpAsync"
                                 ReferralCode="@_referralCode"
                                 ReferralCodeChanged="OnReferralCodeChanged" />

                <MudStack Class="mt-4" Spacing="2">
                    @if (_currentStep == AuthStep.Phone)
                    {
                        <MudButton Variant="Variant.Filled"
                                   Color="Color.Primary"
                                   OnClick="SendOtpAsync"
                                   Disabled="_isBusy"
                                   Class="rounded-lg"
                                   FullWidth="true"
                                   Size="Size.Large">
                            @if (_isBusy)
                            {
                                <MudProgressCircular Size="Size.Small" Indeterminate="true" Class="me-2" />
                            }
                            ارسال رمز پویا
                        </MudButton>
                    }
                    else if (_currentStep == AuthStep.Verify)
                    {
                        <MudButton Variant="Variant.Filled"
                                   Color="Color.Primary"
                                   OnClick="VerifyOtpAsync"
                                   Disabled="_isBusy || IsVerificationLocked"
                                   Class="rounded-lg"
                                   FullWidth="true"
                                   Size="Size.Large">
                            @if (_isBusy)
                            {
                                <MudProgressCircular Size="Size.Small" Indeterminate="true" Class="me-2" />
                            }
                            تأیید و ورود
                        </MudButton>
                    }
                    @if (!HideCancelButton)
                    {
                        <MudButton Variant="Variant.Text"
                                   OnClick="Cancel"
                                   Disabled="_isBusy"
                                   FullWidth="true">لغو
                        </MudButton>
                    }
                </MudStack>
            </div>
        </DialogContent>
    </MudDialog>
}
