@extends('emails.partials.layout')

@php
    $withdrawalUrl = app()->getLocale() === 'de' ? url('/de/widerrufsbelehrung') : url('/en/withdrawal');
    $subject = $forRecipient
        ? __('emails.gift_voucher.recipient.subject', ['amount' => $amount, 'currency' => $currency])
        : __('emails.gift_voucher.purchaser.subject', ['amount' => $amount, 'currency' => $currency]);
    $greeting = $forRecipient
        ? __('emails.gift_voucher.recipient.greeting')
        : __('emails.gift_voucher.purchaser.greeting');
    $subtitle = $forRecipient
        ? __('emails.gift_voucher.recipient.subtitle')
        : __('emails.gift_voucher.purchaser.subtitle');
    $body = $forRecipient
        ? __('emails.gift_voucher.recipient.body', [
            'amount' => $amount,
            'currency' => $currency,
            'purchaser' => $voucher->purchaser_email,
        ])
        : __('emails.gift_voucher.purchaser.body', [
            'amount' => $amount,
            'currency' => $currency,
            'recipient' => $voucher->recipient_email ?: __('emails.gift_voucher.purchaser.recipient_fallback'),
        ]);
@endphp

@section('title', $subject)
@section('preheader', $subtitle)
@section('hero_title', $greeting)
@section('hero_subtitle', $subtitle)

@section('content')
    <p style="margin:0 0 12px; font-size:15px; color:#1f2937;">
        {!! $body !!}
    </p>
    @if ($voucher->message)
        <div style="margin: 18px 0; padding: 14px 16px; background: #f3f4f6; border-left: 4px solid #2563eb; border-radius: 8px;">
            <strong>{{ __('emails.gift_voucher.message_title') }}</strong>
            <p style="margin: 8px 0 0; white-space: pre-line;">{{ $voucher->message }}</p>
        </div>
    @endif
    <div style="margin: 18px 0; padding: 16px; border: 1px dashed #d1d5db; border-radius: 10px; background: #f9fafb;">
        <p style="margin: 0 0 6px; font-size: 13px; text-transform:uppercase; letter-spacing:0.08em; color: #6b7280;">
            {{ __('emails.gift_voucher.code_label') }}
        </p>
        <div style="display: inline-block; padding: 10px 14px; background: #111827; color: #ffffff; border-radius: 8px; font-weight: bold; letter-spacing: 1px;">
            {{ $voucher->code }}
        </div>
        <p style="margin: 10px 0 0; font-size: 14px; color: #4b5563;">
            {{ __('emails.gift_voucher.redeem_hint') }}
        </p>
        @isset($printUrl)
            <p style="margin: 8px 0 0; font-size: 14px;">
                <a href="{{ $printUrl }}" style="color:#1d4ed8; text-decoration:none;">{{ __('emails.gift_voucher.printable') }}</a>
            </p>
        @endisset
    </div>
    <p style="font-size: 14px; color: #4b5563; margin: 12px 0;">
        {{ __('emails.gift_voucher.expiry', ['date' => optional($voucher->expires_at)->toFormattedDateString()]) }}
    </p>
    <p style="font-size: 14px; color: #4b5563; margin: 12px 0;">
        {!! __('emails.gift_voucher.withdrawal', ['url' => $withdrawalUrl]) !!}
    </p>
@endsection

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