<MudDialog>
    <DialogContent>
        <MudStack Spacing="3">
            <MudPaper Class="pa-3" Elevation="0" Outlined="true">
                <MudText Typo="Typo.subtitle1" Color="Color.Primary" Class="mb-2">اطلاعات کاربر</MudText>
                <MudSimpleTable Dense="true">
                    <tbody>
                        <tr>
                            <td><strong>نام کاربر:</strong></td>
                            <td>@Request.UserName</td>
                        </tr>
                        <tr>
                            <td><strong>شناسه کاربر:</strong></td>
                            <td>@Request.UserId</td>
                        </tr>
                    </tbody>
                </MudSimpleTable>
            </MudPaper>

            <MudPaper Class="pa-3" Elevation="0" Outlined="true">
                <MudText Typo="Typo.subtitle1" Color="Color.Primary" Class="mb-2">اطلاعات درخواست</MudText>
                <MudSimpleTable Dense="true">
                    <tbody>
                        <tr>
                            <td><strong>شناسه درخواست:</strong></td>
                            <td>@Request.Id</td>
                        </tr>
                        <tr>
                            <td><strong>مبلغ:</strong></td>
                            <td><MudText Color="Color.Primary"><strong>@Request.Amount.ToString("N0") تومان</strong></MudText></td>
                        </tr>
                        <tr>
                            <td><strong>روش برداشت:</strong></td>
                            <td>
                                <MudChip T="string" Size="Size.Small" Color="Color.Info">@MethodText</MudChip>
                            </td>
                        </tr>
                        <tr>
                            <td><strong>وضعیت:</strong></td>
                            <td>
                                <MudChip T="string" Size="Size.Small" Color="@GetStatusColor()">@StatusText</MudChip>
                            </td>
                        </tr>
                        <tr>
                            <td><strong>تاریخ درخواست:</strong></td>
                            <td>@Request.RequestedAt.ToDateTime().ToLocalTime().MiladiToJalaliWithTime()</td>
                        </tr>
                        @if (Request.ProcessedDate.HasValue)
                        {
                            <tr>
                                <td><strong>تاریخ پردازش:</strong></td>
                                <td>@Request.ProcessedDate.Value.MiladiToJalaliWithTime()</td>
                            </tr>
                        }
                    </tbody>
                </MudSimpleTable>
            </MudPaper>

            <MudPaper Class="pa-3" Elevation="0" Outlined="true">
                <MudText Typo="Typo.subtitle1" Color="Color.Primary" Class="mb-2">اطلاعات بانکی</MudText>
                <MudSimpleTable Dense="true">
                    <tbody>
                        @if (!string.IsNullOrWhiteSpace(Request.IbanNumber))
                        {
                            <tr>
                                <td><strong>شماره شبا:</strong></td>
                                <td>@Request.IbanNumber</td>
                            </tr>
                        }
                        @if (!string.IsNullOrWhiteSpace(Request.BankReferenceId))
                        {
                            <tr>
                                <td><strong>شماره مرجع بانک:</strong></td>
                                <td>@Request.BankReferenceId</td>
                            </tr>
                        }
                        @if (!string.IsNullOrWhiteSpace(Request.BankTrackingCode))
                        {
                            <tr>
                                <td><strong>کد پیگیری بانکی:</strong></td>
                                <td>@Request.BankTrackingCode</td>
                            </tr>
                        }
                        @if (!string.IsNullOrWhiteSpace(Request.PaymentFailureReason))
                        {
                            <tr>
                                <td><strong>دلیل خطای پرداخت:</strong></td>
                                <td><MudText Color="Color.Error">@Request.PaymentFailureReason</MudText></td>
                            </tr>
                        }
                        @if (!string.IsNullOrWhiteSpace(Request.AdminNote))
                        {
                            <tr>
                                <td><strong>یادداشت مدیر:</strong></td>
                                <td>@Request.AdminNote</td>
                            </tr>
                        }
                    </tbody>
                </MudSimpleTable>
            </MudPaper>
        </MudStack>
    </DialogContent>
    <DialogActions>
        <MudButton OnClick="Cancel">بستن</MudButton>
    </DialogActions>
</MudDialog>

@code {
    [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
    [Parameter] public WithdrawalRequestModel Request { get; set; } = null!;
    [Parameter] public string StatusText { get; set; } = "";
    [Parameter] public string MethodText { get; set; } = "";

    private Color GetStatusColor()
    {
        return Request.Status switch
        {
            0 => Color.Warning,
            1 => Color.Info,
            2 => Color.Warning,
            3 => Color.Success,
            4 => Color.Error,
            5 => Color.Default,
            _ => Color.Default
        };
    }

    private void Cancel() => MudDialog.Cancel();
}
