@extends('emails.email-template')

@php
    $isProcessed = $deposit->status == 'Processed';
@endphp

@section('title', 'Deposit notification')
@section('subtitle', $deposit->status == 'Processed' ? 'Your deposit has been processed' : 'Your deposit is being processed')
@section('company_name', $settings->site_name ?? config('app.name'))

@section('greeting', 'Hello ' . ($foramin ? 'Admin' : ($user->name ?? 'Customer')))

@section('content')
@if ($foramin)
    <p style="margin-top:0;">You have a new deposit notification for <strong>{{ $user->name ?? 'Customer' }}</strong>. Amount: <strong>{{ $settings->currency }}{{ number_format((float) $deposit->amount, 2) }}</strong>. {{ $isProcessed ? 'Status: processed.' : 'Action may be required in the admin panel.' }}</p>
@else
    @if ($isProcessed)
        <p style="margin-top:0;">Your deposit of <strong>{{ $settings->currency }}{{ number_format((float) $deposit->amount, 2) }}</strong> has been received and <strong>confirmed</strong>. Your available balance has been updated.</p>
    @else
        <p style="margin-top:0;">Your deposit has been recorded and is <strong>pending confirmation</strong>. You will receive another email when it is fully processed.</p>
    @endif
@endif

<div style="text-align:center; margin: 18px 0;">
    <span style="display:inline-block; padding: 8px 18px; border-radius: 999px; font-weight: 700; font-size: 12px; letter-spacing: 0.06em; background: #eff6ff; color: #1d4ed8; border: 1px solid #93c5fd;">DEPOSIT</span>
</div>
@endsection

@section('additional_content')
@include('emails.partials.transaction-account-summary', ['user' => $user, 'settings' => $settings, 'foramin' => $foramin])

@php
    $depositRows = [
        ['label' => 'Reference / TXN ID', 'value' => $deposit->txn_id ? (string) $deposit->txn_id : '—'],
        ['label' => 'Amount', 'value' => $settings->currency . number_format((float) $deposit->amount, 2)],
        ['label' => 'Payment method', 'value' => $deposit->payment_mode ? (string) $deposit->payment_mode : '—'],
        ['label' => 'Status', 'value' => $isProcessed ? 'Processed / Credited' : 'Pending confirmation'],
        ['label' => 'Date', 'value' => \Carbon\Carbon::parse($deposit->created_at)->toDayDateTimeString()],
    ];
@endphp
@include('emails.partials.transaction-detail-rows', ['rows' => $depositRows, 'panelTitle' => 'Deposit details'])

@if (!$foramin && !$isProcessed)
<div class="info-box">
    <p style="margin:0;"><strong>Note:</strong> If this was a blockchain or manual transfer, confirmation times can vary. No action is needed unless support contacts you.</p>
</div>
@endif

@if (!$foramin && $isProcessed)
<div class="success-box">
    <p style="margin:0;"><strong>Success.</strong> Funds are available according to your product rules. Review your transaction history for the full audit trail.</p>
</div>
@endif

@include('emails.partials.transaction-history-cta', ['foramin' => $foramin])
@endsection

@section('help_text')
<p style="margin:0;">If you did not initiate this deposit, contact us immediately at <a href="mailto:{{ $settings->contact_email ?? '#' }}" style="color:#4F46E5; font-weight:600;">{{ $settings->contact_email ?? 'support' }}</a>.</p>
@endsection
