<?php

declare(strict_types=1);

namespace App\Mail;

use App\Models\Tenant;
use App\Services\Billing\PreflightResult;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

/**
 * Письмо клиенту: приём лидов возобновлён (Billing v2 Spec C §3.7).
 *
 * Триггер: BalancePreflightSweepJob при переходе frozen → active (пополнение/снижение лимита).
 */
final class BalanceUnfrozenMail extends Mailable
{
    use Queueable;
    use SerializesModels;

    public function __construct(
        public readonly Tenant $tenant,
        public readonly PreflightResult $result,
    ) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Приём лидов возобновлён',
            to: [$this->tenant->contact_email],
        );
    }

    public function content(): Content
    {
        return new Content(view: 'emails.balance_unfrozen');
    }
}
