@extends('layouts.modcp')

@section('page-title', "Dashboard - " . config('app.name') )

@section('modcp-content')
    <div class="modcp-page-title">
        Dashboard
    </div>
    <div class="modcp-stats">
        <a href="{{ route('queue.index') }}" class="modcp-stat-card modcp-stat-card--orange">
            <div class="modcp-stat-icon"><i data-lucide="clipboard-list" size="22"></i></div>
            <div class="modcp-stat-info">
                <span class="modcp-stat-value">{{ $stats['pending'] }}</span>
                <span class="modcp-stat-label">In queue</span>
            </div>
        </a>
        <a href="{{ route('modcp.locked') }}" class="modcp-stat-card">
            <div class="modcp-stat-icon"><i data-lucide="lock" size="22"></i></div>
            <div class="modcp-stat-info">
                <span class="modcp-stat-value">{{ $stats['locked'] }}</span>
                <span class="modcp-stat-label">Locked</span>
            </div>
        </a>
        @can('is-admin')
            <a href="{{ route('modcp.draft') }}" class="modcp-stat-card">
                <div class="modcp-stat-icon"><i data-lucide="scissors" size="22"></i></div>
                <div class="modcp-stat-info">
                    <span class="modcp-stat-value">{{ $stats['draft'] }}</span>
                    <span class="modcp-stat-label">Draft</span>
                </div>
            </a>
            <a href="{{ route('modcp.hidden') }}" class="modcp-stat-card">
                <div class="modcp-stat-icon"><i data-lucide="eye-off" size="22"></i></div>
                <div class="modcp-stat-info">
                    <span class="modcp-stat-value">{{ $stats['hidden'] }}</span>
                    <span class="modcp-stat-label">Hidden</span>
                </div>
            </a>
            <a href="{{ route('modcp.deleted') }}" class="modcp-stat-card modcp-stat-card--danger">
                <div class="modcp-stat-icon"><i data-lucide="trash-2" size="22"></i></div>
                <div class="modcp-stat-info">
                    <span class="modcp-stat-value">{{ $stats['deleted'] }}</span>
                    <span class="modcp-stat-label">Deleted</span>
                </div>
            </a>
        @endcan
        <div class="modcp-stat-card modcp-stat-card--muted">
            <div class="modcp-stat-icon"><i data-lucide="database" size="22"></i></div>
            <div class="modcp-stat-info">
                <span class="modcp-stat-value">{{ $stats['total'] }}</span>
                <span class="modcp-stat-label">Total entries</span>
            </div>
        </div>
    </div>

    @if($recentDeleted->isNotEmpty())
        <div class="modcp-section-title" style="margin-top: 25px;">Recently deleted</div>
        <div class="modcp-list">
            @foreach($recentDeleted as $entry)
                <div class="modcp-list-item">
                    <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>
                Deleted {{ $entry->deleted_at->diffForHumans() }}
            </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"
                              onsubmit="return confirm('Permanently delete?')">
                            @csrf @method('DELETE')
                            <button type="submit" class="btn danger">
                                <i data-lucide="trash-2" size="13"></i> Purge
                            </button>
                        </form>
                    </div>
                </div>
            @endforeach
            <a href="{{ route('modcp.deleted') }}" class="modcp-list-see-all">
                See all deleted entries →
            </a>
        </div>
    @endif

@endsection
