@extends('emails.partials.layout')

@php
    /** @var \App\Models\EventPackageAddon $addon */
    $event = $addon->event;
    $tenant = $event?->tenant;
    $label = $addon->metadata['label'] ?? $addon->addon_key;
    $amount = $addon->amount ? number_format((float) $addon->amount, 2).' '.($addon->currency ?? 'EUR') : __('emails.addons.receipt.unknown_amount');
    $summary = [];
    if ($addon->extra_photos > 0) {
        $summary[] = __('emails.addons.receipt.summary.photos', ['count' => number_format($addon->extra_photos)]);
    }
    if ($addon->extra_guests > 0) {
        $summary[] = __('emails.addons.receipt.summary.guests', ['count' => number_format($addon->extra_guests)]);
    }
    if ($addon->extra_gallery_days > 0) {
        $summary[] = __('emails.addons.receipt.summary.gallery', ['count' => $addon->extra_gallery_days]);
    }
    $eventName = $event?->name['de'] ?? $event?->name['en'] ?? $event?->name ?? __('emails.package_limits.event_fallback');
    $ctaUrl = url('/tenant/events/'.($event?->slug ?? ''));
@endphp

@section('title', __('emails.addons.receipt.subject', ['addon' => $label]))
@section('preheader', __('emails.addons.receipt.subtitle', ['addon' => $label]))
@section('hero_title', __('emails.addons.receipt.greeting', ['name' => $tenant?->name ?? __('emails.package_limits.team_fallback')]))
@section('hero_subtitle', __('emails.addons.receipt.subtitle', ['addon' => $label]))

@section('content')
    <p style="margin:0 0 12px; font-size:15px; color:#1f2937;">
        {{ __('emails.addons.receipt.body', [
            'addon' => $label,
            'event' => $eventName,
            'amount' => $amount,
        ]) }}
    </p>
    @if (! empty($summary))
        <div style="background-color:#f8fafc; border:1px solid #e2e8f0; border-radius:12px; padding:16px; margin-bottom:12px;">
            <p style="margin:0 0 8px; font-size:13px; text-transform:uppercase; letter-spacing:0.08em; color:#64748b;">
                {{ __('emails.addons.receipt.summary_title') }}
            </p>
            <table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
                @foreach ($summary as $line)
                    <tr>
                        <td style="padding:6px 0; font-size:14px; color:#0f172a;">{{ $line }}</td>
                    </tr>
                @endforeach
            </table>
        </div>
    @endif
@endsection

@section('cta')
    <a href="{{ $ctaUrl }}" style="display:inline-block; background-color:#111827; color:#ffffff; text-decoration:none; padding:12px 20px; border-radius:999px; font-weight:600; font-size:14px;">
        {{ __('emails.addons.receipt.action') }}
    </a>
@endsection

@section('footer')
    {!! __('emails.brand.footer') !!}
@endsection
