@php
  $titre = ($donor->sexe === 'F') ? 'Chère' : 'Cher';
  use App\Helpers\TextFormatter;
@endphp
<!DOCTYPE html>
<html lang="fr">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    body {
      font-family: Arial, sans-serif;
      color: #333;
      margin: 0;
      padding: 0;
    }

    .header {
      color: #fff;
      padding: 20px;
      text-align: center;
    }

    .header .contact {
      font-size: 0.9em;
      margin-top: 5px;
    }

    .header .contact a {
      color: #ffffff;
      text-decoration: underline;
    }

    .content {
      display: flex;
      flex-direction: column;
      padding: 20px;
    }

    .image {
      width: 200px;
      max-width: 100%;
      margin: 0 auto 20px auto;
    }

    .image img {
      width: 100%;
      height: auto;
      border-radius: 4px;
      display: block;
    }

    .text {
      text-align: left;
    }

    .btn {
      display: inline-block;
      padding: 12px 24px;
      color: #fff !important;
      text-decoration: none;
      border-radius: 4px;
      font-weight: bold;
      font-size: 16px;
      margin-top: 10px;
    }

    .footer {
      padding: 20px;
      text-align: center;
    }

    .signature {
      background-color: #f0f4f8;
      padding: 15px;
      border-radius: 4px;
      display: inline-block;
      margin-top: 20px;
      font-weight: bold;
    }

    @media (min-width: 768px) {
      .content {
        flex-direction: row;
        align-items: flex-start;
        gap: 20px;
      }

      .image {
        flex-shrink: 0;
        width: 400px;
        margin: 50px;
      }

      .text {
        flex: 1;
      }
    }
  </style>
  <title>Invitation à faire un don</title>
</head>
<body>

  <div class="header" style="background-color: {{ $link->campaign->color ?? 'rgb(0, 128, 21)' }};">
    <h3>{{ $link->campaign->name }}</h3>
    <p class="contact"><a href="{{$link->campaign->contact_email}}">{{ $link->campaign->contact_email }}</a> | {{$link->campaign->contact_phone }}</p>
  </div>

  <div class="content">
    {{-- Colonne image (si définie) --}}
    <div class="image">
      @if($link->campaign->cover_image)
        <img src="{{ asset('storage/'.$link->campaign->cover_image) }}" alt="Couverture">
      @endif
    </div>

    {{-- Colonne texte --}}
    <div class="text">
      <p>{{ $titre }} {{ $donor->prenom }} {{ $donor->nom }}, {{ $donor->fonction }}</p>
      <p>{!! TextFormatter::convertWhatsappToHtml($campaignMessage) !!}</p>
      <a href="{{ $url }}" class="btn" style="background-color: {{ $link->campaign->color ?? 'rgb(0, 128, 21)'}};">Accéder à la page de don</a>
      <p style="margin-top:20px;">Merci pour votre implication et votre soutien à notre institution.</p>
    </div>
  </div>

  <div class="footer">
    <div class="signature" style="color: {{ $link->campaign->color ?? 'rgb(0, 128, 21)' }};">
      @if($link->campaign->initiator_name)
      <strong>{{ $link->campaign->initiator_name }}</strong><br>
        @if($link->campaign->initiator_position)
        {{ $link->campaign->initiator_position }}
        @endif
      @endif
    </div>
  </div>

</body>
</html>
