@php
  use App\Helpers\TextFormatter;
@endphp
@extends('layouts.app')
@section('content')
<div class="max-w-md mx-auto p-6 bg-white shadow rounded">

  {{-- cover --}}
  @if($link->campaign->cover_image)
    <img src="{{ asset('storage/'.$link->campaign->cover_image) }}"
         alt="Bannière" class="w-full mb-4" style="height:auto;">
  @endif

  <h2 class="text-xl mb-4">{{ $link->campaign->name }}</h2>
  <p class="mb-4">{!! TextFormatter::convertWhatsappToHtml($link->campaign->message) !!}</p>

  @if(session('error'))
    <div class="p-3 bg-red-100 text-red-800 rounded mb-4">
      {{ session('error') }}
    </div>
  @endif

  <form action="{{ route('don.pay',[$link->campaign->slug,$link->token]) }}"
        method="POST">
    @csrf
    <label class="block mb-1">Montant (XOF)</label>
    <input name="amount" type="number" step="1" min="200" required
           class="w-full border p-2 rounded mb-4"
           value="{{ old('amount') }}">

    <button type="submit"
            class="w-full bg-green-600 text-white p-2 rounded hover:bg-green-700">
      Payer
    </button>
  </form>

</div>
@endsection
