<?php

namespace App\Mail;

use App\Models\Investment;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class AdminInvestmentPendingMail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(public Investment $investment) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Inversión pendiente de aprobación',
        );
    }

    public function content(): Content
    {
        $investor = $this->investment->user;

        return new Content(
            markdown: 'mail.admin.investment-pending',
            with: [
                'investorName' => $investor?->name ?? '—',
                'investorEmail' => $investor?->email ?? '—',
                'amount' => number_format((float) $this->investment->amount, 2, '.', ''),
                'durationMonths' => (int) $this->investment->duration_months,
                'txid' => $this->investment->txid ?: '—',
                'actionUrl' => route('admin.investments.index', ['tab' => 'pending'], absolute: true),
            ],
        );
    }
}
