@extends('dashboard.user.layouts.app')
@section('content')
    <div class="page-container">

        <div class="page-title-head d-flex align-items-sm-center flex-sm-row flex-column gap-2">
            <div class="flex-grow-1">
                <h4 class="fs-18 fw-semibold mb-0">{{ $title }}</h4>
            </div>

            <div class="text-end">
                <x-dashboard.user.breadcrumbs :breadcrumbs="$breadcrumbs" />
            </div>
        </div>

        <div class="row">
            <div class="col-xl-12 col-lg-12">
                <div class="col-lg-10 mx-auto">
                    <div class="card border-0 shadow rounded-4 overflow-hidden">

                        {{-- ── CARD HEADER ── --}}
                        <div
                            class="card-header bg-light border-bottom px-4 px-md-5 py-3 d-flex justify-content-between align-items-center gap-2 flex-wrap">
                            <div>
                                <p class="text-uppercase text-muted fw-bold mb-0"
                                    style="font-size:.68rem;letter-spacing:.08em;">Deposit Reference</p>
                                <span class="fw-semibold"
                                    style="font-family:monospace;font-size:.85rem;">#{{ $deposit->reference_id }}</span>
                            </div>
                            <span class="{{ $deposit->status->badge() }} rounded-pill px-3 py-2"
                                style="font-size:.72rem;letter-spacing:.04em;">
                                {{ $deposit->status->label() }}
                            </span>
                        </div>

                        {{-- ── AMOUNT HERO ── --}}
                        <div class="text-center py-5 px-3 position-relative dps-hero">
                            <div class="dps-hero-glow"></div>
                            <div class="position-relative">
                                <p class="text-uppercase fw-bold mb-2 text-muted"
                                    style="font-size:.68rem;letter-spacing:.1em;">Deposit Amount</p>
                                <h2 class="display-5 fw-bold text-dark mb-1">
                                    {{ currency($deposit->user->currency) }}{{ formatAmount($deposit->amount) }}
                                </h2>
                                <span
                                    class="badge bg-white border text-muted fw-semibold px-3 py-2 rounded-pill d-inline-flex align-items-center gap-1"
                                    style="font-size:.72rem;">
                                    @if ($deposit->isBitcoinMethod())
                                        <i class="fa-brands fa-bitcoin"></i>
                                    @elseif ($deposit->isCreditCardMethod())
                                        <i class="fa-brands fa-cc-visa"></i>
                                    @elseif ($deposit->isPayPalMethod())
                                        <i class="fa-brands fa-paypal"></i>
                                    @elseif ($deposit->isBankTransferMethod())
                                        <i class="fa-solid fa-building-columns"></i>
                                    @endif
                                    {{ ucfirst($deposit->method) }} Deposit
                                </span>
                            </div>
                        </div>

                        <div class="card-body px-4 px-md-5 py-4">

                            {{-- ── DATE + QR CODE ROW ── --}}
                            <div class="row align-items-center mb-4 g-3">
                                <div class="col">
                                    <p class="text-uppercase text-muted fw-bold mb-1"
                                        style="font-size:.68rem;letter-spacing:.08em;">Deposit Date</p>
                                    <span class="fw-semibold">{{ formatDateTime($deposit->created_at) }}</span>
                                </div>
                                @if ($deposit->isBitcoinMethod())
                                    <div class="col-auto">
                                        <div class="border rounded-3 p-2 bg-light">
                                            @if ($wallet->qr_code_path)
                                                <img src="{{ asset($wallet->qr_code_path) }}" alt="Payment QR Code"
                                                    class="img-fluid rounded d-block" style="max-width:100px;">
                                            @else
                                                <img src="https://api.qrserver.com/v1/create-qr-code/?size=200x200&data={{ $wallet->address }}?amount={{ $deposit->amount }}"
                                                    alt="Payment QR Code" class="img-fluid rounded d-block"
                                                    style="max-width:100px;">
                                            @endif
                                        </div>
                                    </div>
                                @endif
                            </div>

                            {{-- ── PAYMENT DETAILS ── --}}
                            <p class="text-uppercase text-muted fw-bold mb-3 pb-2 border-bottom"
                                style="font-size:.68rem;letter-spacing:.1em;">
                                Payment Details
                            </p>

                            <div class="bg-light rounded-3 p-3 p-md-4 mb-4">
                                <div class="row g-0">

                                    @if ($deposit->isBitcoinMethod())

                                        <div class="col-12 py-3 border-bottom">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">Bitcoin
                                                Address</p>
                                            <strong class="d-block text-break"
                                                style="font-family:monospace;font-size:.85rem;">{{ $wallet->address ?? 'N/A' }}</strong>
                                        </div>
                                        <div class="col-12 py-3">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">Payment
                                                Proof</p>
                                            @if ($deposit->proof)
                                                <a href="{{ asset($deposit->proof) }}" target="_blank"
                                                    class="btn btn-sm btn-outline-primary rounded-3 d-inline-flex align-items-center gap-1">
                                                    <i class="bi bi-file-earmark-image"></i> View Proof
                                                </a>
                                            @else
                                                <strong class="text-muted">N/A</strong>
                                            @endif
                                        </div>
                                    @elseif ($deposit->isCreditCardMethod())
                                        <div class="col-12 col-sm-6 py-3 pe-sm-4 border-bottom">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">Card Number
                                            </p>
                                            <strong style="font-family:monospace;">**** **** ****
                                                {{ substr($deposit->card_number ?? '', -4) }}</strong>
                                        </div>
                                        <div class="col-12 col-sm-6 py-3 ps-sm-4 border-bottom dps-border-start-sm">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">Expiry Date
                                            </p>
                                            <strong>{{ $deposit->card_expiry_date ?? 'N/A' }}</strong>
                                        </div>
                                    @elseif ($deposit->isPayPalMethod())
                                        <div class="col-12 col-sm-6 py-3 pe-sm-4 border-bottom">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">PayPal
                                                Email</p>
                                            <strong>{{ $setting->paypal_email ?? 'N/A' }}</strong>
                                        </div>
                                        <div class="col-12 col-sm-6 py-3 ps-sm-4 border-bottom dps-border-start-sm">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">Payment
                                                Proof</p>
                                            @if ($deposit->proof)
                                                <a href="{{ asset($deposit->proof) }}" target="_blank"
                                                    class="btn btn-sm btn-outline-primary rounded-3 d-inline-flex align-items-center gap-1">
                                                    <i class="bi bi-file-earmark-image"></i> View Proof
                                                </a>
                                            @else
                                                <strong class="text-muted">N/A</strong>
                                            @endif
                                        </div>
                                    @elseif ($deposit->isBankTransferMethod())
                                        <div class="col-12 col-sm-6 py-3 pe-sm-4 border-bottom">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">Bank Name
                                            </p>
                                            <strong>{{ $setting->bank_name ?? 'N/A' }}</strong>
                                        </div>
                                        <div class="col-12 col-sm-6 py-3 ps-sm-4 border-bottom dps-border-start-sm">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">Account
                                                Name</p>
                                            <strong>{{ $setting->account_name ?? 'N/A' }}</strong>
                                        </div>
                                        <div class="col-12 col-sm-6 py-3 pe-sm-4 border-bottom">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">Account
                                                Number</p>
                                            <strong
                                                style="font-family:monospace;">{{ $setting->account_number ?? 'N/A' }}</strong>
                                        </div>

                                        @if ($setting->routing_number || $setting->bank_swift_code || $setting->bank_iban)
                                            <div class="col-12 col-sm-6 py-3 ps-sm-4 border-bottom dps-border-start-sm">
                                                @if ($setting->routing_number)
                                                    <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">
                                                        Routing Number</p>
                                                    <strong class="d-block mb-2"
                                                        style="font-family:monospace;">{{ $setting->routing_number }}</strong>
                                                @endif
                                                @if ($setting->bank_swift_code)
                                                    <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">
                                                        SWIFT Code</p>
                                                    <strong class="d-block mb-2"
                                                        style="font-family:monospace;">{{ $setting->bank_swift_code }}</strong>
                                                @endif
                                                @if ($setting->bank_iban)
                                                    <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">
                                                        IBAN</p>
                                                    <strong class="d-block"
                                                        style="font-family:monospace;">{{ $setting->bank_iban }}</strong>
                                                @endif
                                            </div>
                                        @endif

                                        <div class="col-12 py-3">
                                            <p class="text-muted mb-1" style="font-size:.75rem;font-weight:500;">Payment
                                                Proof</p>
                                            @if ($deposit->proof)
                                                <a href="{{ asset($deposit->proof) }}" target="_blank"
                                                    class="btn btn-sm btn-outline-primary rounded-3 d-inline-flex align-items-center gap-1">
                                                    <i class="bi bi-file-earmark-image"></i> View Proof
                                                </a>
                                            @else
                                                <strong class="text-muted">N/A</strong>
                                            @endif
                                        </div>

                                    @endif

                                </div>
                            </div>

                            {{-- ── PENDING NOTE ── --}}
                            @if ($deposit->isPending())
                                <div
                                    class="rounded-3 border border-warning-subtle bg-warning-subtle px-4 py-3 mb-4 d-flex align-items-start gap-3">
                                    <i class="bi bi-exclamation-triangle-fill text-warning mt-1 flex-shrink-0"></i>
                                    <p class="mb-0 small text-warning-emphasis">
                                        <strong class="text-uppercase"
                                            style="font-size:.68rem;letter-spacing:.06em;">Note:</strong>
                                        @if ($deposit->isBitcoinMethod())
                                            Please ensure the Bitcoin payment is sent to the provided wallet address.
                                            Verification may take up to 1–3 hours after the transaction is confirmed on the
                                            blockchain.
                                        @elseif ($deposit->isCreditCardMethod())
                                            The card payment is pending verification. Once confirmed, the deposit will be
                                            credited to your account within 1–2 business days.
                                        @elseif ($deposit->isPayPalMethod())
                                            The PayPal payment is pending verification. Once confirmed, the deposit will be
                                            credited to your account within 1–2 business days.
                                        @elseif ($deposit->isBankTransferMethod())
                                            The bank transfer is pending verification. Once confirmed, the deposit will be
                                            credited to your account within 1–2 business days.
                                        @endif
                                    </p>
                                </div>

                                <p class="text-muted small mb-4">
                                    <strong class="text-dark">Thank you for your deposit!</strong> We appreciate your trust
                                    in us and will process your request promptly.
                                </p>
                            @endif

                            {{-- ── ACTIONS ── --}}
                            <div class="d-flex pt-3 border-top">
                                <a href="{{ route('user.deposit.history') }}"
                                    class="btn btn-primary d-inline-flex align-items-center gap-2 rounded-3">
                                    <i class="bi bi-arrow-left"></i> Back
                                </a>
                            </div>

                        </div>{{-- /card-body --}}
                    </div>{{-- /card --}}
                </div>
            </div>

            <style>
                /* Hero */
                .dps-hero {
                    /* background-color: #f7f8fa; */
                }

                .dps-hero-glow {
                    position: absolute;
                    inset: 0;
                    pointer-events: none;
                    background: radial-gradient(ellipse 70% 70% at 50% 0%, rgba(13, 110, 253, .07) 0%, transparent 70%);
                }

                /* Responsive left border for paired columns */
                @media (min-width: 576px) {
                    .dps-border-start-sm {
                        border-left: 1px solid #dee2e6 !important;
                    }
                }
            </style>
        </div>
    </div>
@endsection
