@extends('admin.layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 offset-md-2">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h1>Destination Details</h1>
                <div class="btn-group">
                    <a href="{{ route('admin.destinations.edit', $destination) }}" class="btn btn-primary">
                        <i class="fas fa-edit"></i> Edit
                    </a>
                    <a href="{{ route('admin.destinations.index') }}" class="btn btn-secondary">
                        <i class="fas fa-arrow-left"></i> Back to List
                    </a>
                </div>
            </div>

            <div class="card">
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-8">
                            <div class="mb-4">
                                <h2 class="d-flex align-items-center">
                                    <span style="font-size: 2rem; margin-right: 10px;">{{ $destination->flag }}</span>
                                    {{ $destination->name }}
                                    @if($destination->is_active)
                                        <span class="badge bg-success ms-2">Active</span>
                                    @else
                                        <span class="badge bg-secondary ms-2">Inactive</span>
                                    @endif
                                </h2>
                                @if($destination->country_code)
                                    <p class="text-muted mb-0">Country Code: {{ $destination->country_code }}</p>
                                @endif
                            </div>

                            <div class="mb-4">
                                <h5>Description</h5>
                                <p class="text-muted">{{ $destination->description }}</p>
                            </div>

                            <div class="row mb-4">
                                <div class="col-md-6">
                                    <h6>Universities Count</h6>
                                    <p class="mb-0">
                                        <span class="badge bg-info fs-6">{{ $destination->universities_count }} Universities</span>
                                    </p>
                                </div>
                                <div class="col-md-6">
                                    <h6>Sort Order</h6>
                                    <p class="mb-0">{{ $destination->sort_order }}</p>
                                </div>
                            </div>

                            <div class="mb-4">
                                <h6>Created</h6>
                                <p class="mb-0">{{ $destination->created_at->format('M d, Y \\a\\t h:i A') }}</p>
                                @if($destination->updated_at != $destination->created_at)
                                    <h6 class="mt-2">Last Updated</h6>
                                    <p class="mb-0">{{ $destination->updated_at->format('M d, Y \\a\\t h:i A') }}</p>
                                @endif
                            </div>

                            @if($destination->additional_info)
                                <div class="mb-4">
                                    <h6>Additional Information</h6>
                                    <pre class="bg-light p-3 rounded">{{ json_encode($destination->additional_info, JSON_PRETTY_PRINT) }}</pre>
                                </div>
                            @endif
                        </div>

                        <div class="col-md-4">
                            @if($destination->image)
                                <div class="mb-4">
                                    <h6>Destination Image</h6>
                                    <img src="{{ Storage::url($destination->image) }}" 
                                         alt="{{ $destination->name }}" 
                                         class="img-fluid rounded shadow-sm">
                                </div>
                            @else
                                <div class="mb-4">
                                    <h6>Destination Image</h6>
                                    <div class="bg-light rounded d-flex align-items-center justify-content-center" 
                                         style="height: 200px;">
                                        <div class="text-center text-muted">
                                            <i class="fas fa-image fa-3x mb-2"></i>
                                            <p>No image uploaded</p>
                                        </div>
                                    </div>
                                </div>
                            @endif

                            <div class="d-grid gap-2">
                                <a href="{{ route('admin.destinations.edit', $destination) }}" 
                                   class="btn btn-outline-primary">
                                    <i class="fas fa-edit"></i> Edit Destination
                                </a>
                                
                                <form action="{{ route('admin.destinations.destroy', $destination) }}" 
                                      method="POST" 
                                      onsubmit="return confirm('Are you sure you want to delete this destination? This action cannot be undone.')">
                                    @csrf
                                    @method('DELETE')
                                    <button type="submit" class="btn btn-outline-danger w-100">
                                        <i class="fas fa-trash"></i> Delete Destination
                                    </button>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@push('styles')
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
@endpush