@extends('layouts.landing')
@section('title', 'Solicitudes de Amistad')

@section('content')
<div class="container" style="max-width:680px">
    <div class="card shadow-sm">
        <div class="card-header bg-white font-weight-bold">
            <i class="fas fa-user-friends mr-2 text-primary"></i> Solicitudes de amistad
        </div>
        <div class="card-body p-0">
            @forelse($requests as $friendship)
                <div class="d-flex align-items-center p-3 border-bottom">
                    <a href="{{ route('social.profile', $friendship->sender) }}">
                        <img src="{{ $friendship->sender->profile_photo_url }}"
                             class="rounded-circle mr-3" width="50" height="50" style="object-fit:cover">
                    </a>
                    <div class="flex-grow-1">
                        <a href="{{ route('social.profile', $friendship->sender) }}" class="font-weight-bold text-dark">
                            {{ $friendship->sender->name }} {{ $friendship->sender->apellidoPaterno }}
                        </a>
                        <div class="text-muted small">{{ $friendship->created_at->diffForHumans() }}</div>
                    </div>
                    <div class="d-flex">
                        <form action="{{ route('friendships.accept', $friendship) }}" method="POST" class="mr-2">
                            @csrf
                            <button class="btn btn-primary btn-sm">
                                <i class="fas fa-check mr-1"></i> Aceptar
                            </button>
                        </form>
                        <form action="{{ route('friendships.destroy', $friendship) }}" method="POST">
                            @csrf @method('DELETE')
                            <button class="btn btn-outline-secondary btn-sm">
                                <i class="fas fa-times mr-1"></i> Rechazar
                            </button>
                        </form>
                    </div>
                </div>
            @empty
                <div class="text-center text-muted py-5">
                    <i class="fas fa-user-check fa-3x mb-3 d-block text-success"></i>
                    No tienes solicitudes pendientes.
                </div>
            @endforelse
        </div>
    </div>
</div>
@endsection
