<?php

namespace App\Notifications;

use App\Models\Booking;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class BookingReminder extends Notification
{
    use Queueable;

    public function __construct(public Booking $booking) {}

    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        $b = $this->booking;
        $when = $b->scheduled_at?->isoFormat('dddd D [de] MMMM, HH:mm');

        return (new MailMessage)
            ->subject("Recordatorio: tu cita es {$when}")
            ->greeting("Hola {$b->customer->first_name}")
            ->line("Te recordamos tu cita en {$b->company->name}.")
            ->line("**Servicio:** {$b->service->name}")
            ->line("**Fecha:** {$when}")
            ->line("Si no puedes asistir, por favor cancela o reprograma con anticipación.")
            ->salutation("Te esperamos · {$b->company->name}");
    }
}
