@extends('layouts.modcp')

@section('page-title', 'Deleted entries - ' . config('app.name') )

@section('modcp-content')

    <div class="modcp-page-title">
        <i data-lucide="trash-2" size="20"></i>
        Deleted entries
        <span class="modcp-count">{{ $entries->total() }}</span>
    </div>

    @if($entries->isEmpty())
        <div class="modcp-empty">
            <i data-lucide="check-circle" size="36"></i>
            <p>No deleted entries.</p>
        </div>
    @else
        <div class="modcp-list">
            @foreach($entries as $entry)
                <div class="modcp-list-item modcp-list-item--deleted">
                    <div class="modcp-list-item-cover">
                        @if($entry->main_image)
                            <img src="{{ Storage::url($entry->main_image) }}" alt="">
                        @else
                            <i data-lucide="image" size="20"></i>
                        @endif
                    </div>
                    <div class="modcp-list-item-info">
                        <span class="modcp-list-item-title">{{ $entry->complete_title ?? $entry->title }}</span>
                        <span class="modcp-list-item-meta">
                    <span class="badge {{ $entry->type }}">{{ $entry->type }}</span>
                    @php $daysLeft = max(0, 7 - (int) now()->diffInDays($entry->deleted_at)) @endphp
                    <span style="color: var(--error)">
                        Deleted {{ $entry->deleted_at->diffForHumans() }}
                        @if($daysLeft > 0) · purged in {{ $daysLeft }}d @endif
                    </span>
                </span>
                    </div>
                    <div class="modcp-list-item-actions">
                        <form action="{{ route('modcp.restore', $entry->id) }}" method="POST" style="display:inline">
                            @csrf @method('PATCH')
                            <button type="submit" class="btn success">
                                <i data-lucide="rotate-ccw" size="13"></i> Restore
                            </button>
                        </form>
                        <form action="{{ route('modcp.destroy', $entry->id) }}" method="POST" style="display:inline"
                              @submit="if (!confirm('Permanently delete this entry?')) $event.preventDefault()">
                            @csrf @method('DELETE')
                            <button type="submit" class="btn danger">
                                <i data-lucide="trash-2" size="13"></i> Purge
                            </button>
                        </form>
                    </div>
                </div>
            @endforeach
        </div>
        {{ $entries->links() }}
    @endif

@endsection
