@extends('layouts.app')

@section('content')
    <div class="row justify-content-center">
        <div class="col-lg-6">
            <div class="card shadow-sm">
                <div class="card-header fw-bold">Edit Country</div>
                <div class="card-body">
                    <form method="POST" action="{{ route('countries.update', $country) }}" class="row g-2">
                        @csrf
                        @method('PUT')
                        <div class="col-12">
                            <label class="form-label">Continent</label>
                            <select name="continent_id" class="form-select" required>
                                @foreach($continents as $c)
                                    <option value="{{ $c->id }}" {{ (string) old('continent_id', $selectedContinentId) === (string) $c->id ? 'selected' : '' }}>{{ $c->name }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="col-12">
                            <label class="form-label">Name</label>
                            <input name="name" class="form-control" required maxlength="255" value="{{ old('name', $country->name) }}">
                        </div>
                        <div class="col-12">
                            <label class="form-label">Status</label>
                            <select name="status" class="form-select">
                                <option value="1" {{ old('status', $country->status) ? 'selected' : '' }}>Active</option>
                                <option value="0" {{ !old('status', $country->status) ? 'selected' : '' }}>Inactive</option>
                            </select>
                        </div>
                        <div class="col-12 d-flex gap-2">
                            <button class="btn btn-primary">Update</button>
                            <a href="{{ route('countries.index') }}" class="btn btn-outline-secondary">Back</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection
