@extends('admin.layouts.app')

@section('title', 'Edit — ' . $country->name)
@section('page-title', 'Edit Country')

@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')

{{-- Breadcrumb --}}
<nav class="flex items-center gap-2 text-sm text-gray-500 mb-6">
    <a href="{{ route('admin.countries.index') }}" class="hover:text-blue-600">Countries</a>
    <span>/</span>
    <span class="text-gray-800 font-medium">{{ $country->name }}</span>
</nav>

@include('admin.countries._form', [
    'country' => $country,
    'action'  => route('admin.countries.update', $country),
    'method'  => 'PUT',
])

@endsection

@push('scripts')
@include('admin.countries._tinymce')
<script>
function previewImage(input, imgId, wrapId) {
    const wrap = document.getElementById(wrapId);
    const img  = document.getElementById(imgId);
    if (input.files && input.files[0]) {
        const reader = new FileReader();
        reader.onload = e => { img.src = e.target.result; if(wrap) wrap.classList.remove('hidden'); };
        reader.readAsDataURL(input.files[0]);
    }
}
</script>
@endpush
