@extends('admin.layouts.app')

@section('title', 'Edit Blog Article')

@push('styles')
<script src="https://cdn.tiny.cloud/1/{{ config('services.tinymce.api_key', 'no-api-key') }}/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>
@endpush

@section('content')
<div class="mb-6">
    <h2 class="text-xl font-bold text-gray-800">Edit Blog Article</h2>
    <p class="text-sm text-gray-500 mt-1">Review, approve, reject, or fine-tune article metadata before publishing.</p>
</div>

<div class="mb-6 bg-white rounded-xl border border-gray-100 p-4 flex flex-wrap gap-3">
    <a href="{{ route('admin.blog-articles.preview', $blogArticle) }}" target="_blank" class="px-4 py-2.5 rounded-lg bg-gray-900 text-white text-sm font-semibold">Live Preview</a>
    @if($blogArticle->status !== 'approved')
        <form method="POST" action="{{ route('admin.blog-articles.approve', $blogArticle) }}">
            @csrf
            @method('PATCH')
            <button type="submit" class="px-4 py-2.5 rounded-lg bg-green-600 text-white text-sm font-semibold">Approve & Publish</button>
        </form>
    @endif
    @if($blogArticle->status !== 'rejected')
        <button type="button" data-reject-action="{{ route('admin.blog-articles.reject', $blogArticle) }}" class="px-4 py-2.5 rounded-lg bg-yellow-100 text-yellow-800 text-sm font-semibold">Reject With Feedback</button>
    @endif
</div>

@include('admin.blog-articles._form', [
    'action' => route('admin.blog-articles.update', $blogArticle),
    'method' => 'PUT',
    'blogArticle' => $blogArticle,
    'categories' => $categories,
])

@include('admin.blog-articles._reject_modal')
@endsection

@push('scripts')
@include('admin.blog-articles._tinymce')
@endpush
