@extends('layouts.app')

@section('title', 'Novo Ponto Turístico - ApiEco')

@section('content')
<div class="max-w-3xl mx-auto">
    <div class="mb-8">
        <h1 class="text-3xl font-bold text-gray-800">Cadastrar Novo Ponto Turístico</h1>
        <p class="text-gray-600">Preencha os dados do ponto turístico</p>
    </div>

    <form action="{{ route('admin.pontos-turisticos.store') }}" method="POST" class="bg-white rounded-lg shadow p-6">
        @csrf

        <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
            <div class="md:col-span-2">
                <label for="nome" class="block text-gray-700 text-sm font-bold mb-2">Nome *</label>
                <input type="text" id="nome" name="nome" value="{{ old('nome') }}"
                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-emerald-500 @error('nome') border-red-500 @enderror"
                    required>
                @error('nome')
                    <p class="text-red-500 text-sm mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div class="md:col-span-2">
                <label for="descricao" class="block text-gray-700 text-sm font-bold mb-2">Descrição *</label>
                <textarea id="descricao" name="descricao" rows="4"
                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-emerald-500 @error('descricao') border-red-500 @enderror"
                    required>{{ old('descricao') }}</textarea>
                @error('descricao')
                    <p class="text-red-500 text-sm mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div>
                <label for="tipo_id" class="block text-gray-700 text-sm font-bold mb-2">Tipo *</label>
                <select id="tipo_id" name="tipo_id"
                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-emerald-500 @error('tipo_id') border-red-500 @enderror"
                    required>
                    <option value="">Selecione...</option>
                    @foreach($tipos as $tipo)
                        <option value="{{ $tipo->id }}" {{ old('tipo_id') == $tipo->id ? 'selected' : '' }}>
                            {{ $tipo->icone }} {{ $tipo->nome }}
                        </option>
                    @endforeach
                </select>
                @error('tipo_id')
                    <p class="text-red-500 text-sm mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div>
                <label for="status" class="block text-gray-700 text-sm font-bold mb-2">Status *</label>
                <select id="status" name="status"
                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-emerald-500 @error('status') border-red-500 @enderror"
                    required>
                    <option value="ativo" {{ old('status', 'ativo') === 'ativo' ? 'selected' : '' }}>Ativo</option>
                    <option value="inativo" {{ old('status') === 'inativo' ? 'selected' : '' }}>Inativo</option>
                    <option value="temporariamente_fechado" {{ old('status') === 'temporariamente_fechado' ? 'selected' : '' }}>Temporariamente Fechado</option>
                </select>
                @error('status')
                    <p class="text-red-500 text-sm mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div class="md:col-span-2">
                <label for="endereco" class="block text-gray-700 text-sm font-bold mb-2">Endereço *</label>
                <input type="text" id="endereco" name="endereco" value="{{ old('endereco') }}"
                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-emerald-500 @error('endereco') border-red-500 @enderror"
                    required>
                @error('endereco')
                    <p class="text-red-500 text-sm mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div>
                <label for="cidade" class="block text-gray-700 text-sm font-bold mb-2">Cidade *</label>
                <input type="text" id="cidade" name="cidade" value="{{ old('cidade', 'Salvador') }}"
                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-emerald-500 @error('cidade') border-red-500 @enderror"
                    required>
                @error('cidade')
                    <p class="text-red-500 text-sm mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div>
                <label for="estado" class="block text-gray-700 text-sm font-bold mb-2">Estado *</label>
                <select id="estado" name="estado"
                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-emerald-500 @error('estado') border-red-500 @enderror"
                    required>
                    <option value="">Selecione...</option>
                    <option value="AC">Acre</option>
                    <option value="AL">Alagoas</option>
                    <option value="AP">Amapá</option>
                    <option value="AM">Amazonas</option>
                    <option value="BA" {{ old('estado', 'BA') === 'BA' ? 'selected' : '' }}>Bahia</option>
                    <option value="CE">Ceará</option>
                    <option value="DF">Distrito Federal</option>
                    <option value="ES">Espírito Santo</option>
                    <option value="GO">Goiás</option>
                    <option value="MA">Maranhão</option>
                    <option value="MT">Mato Grosso</option>
                    <option value="MS">Mato Grosso do Sul</option>
                    <option value="MG">Minas Gerais</option>
                    <option value="PA">Pará</option>
                    <option value="PB">Paraíba</option>
                    <option value="PR">Paraná</option>
                    <option value="PE">Pernambuco</option>
                    <option value="PI">Piauí</option>
                    <option value="RJ">Rio de Janeiro</option>
                    <option value="RN">Rio Grande do Norte</option>
                    <option value="RS">Rio Grande do Sul</option>
                    <option value="RO">Rondônia</option>
                    <option value="RR">Roraima</option>
                    <option value="SC">Santa Catarina</option>
                    <option value="SP">São Paulo</option>
                    <option value="SE">Sergipe</option>
                    <option value="TO">Tocantins</option>
                </select>
                @error('estado')
                    <p class="text-red-500 text-sm mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div>
                <label for="latitude" class="block text-gray-700 text-sm font-bold mb-2">Latitude *</label>
                <input type="number" step="0.000001" id="latitude" name="latitude" value="{{ old('latitude') }}"
                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-emerald-500 @error('latitude') border-red-500 @enderror"
                    required>
                @error('latitude')
                    <p class="text-red-500 text-sm mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div>
                <label for="longitude" class="block text-gray-700 text-sm font-bold mb-2">Longitude *</label>
                <input type="number" step="0.000001" id="longitude" name="longitude" value="{{ old('longitude') }}"
                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-emerald-500 @error('longitude') border-red-500 @enderror"
                    required>
                @error('longitude')
                    <p class="text-red-500 text-sm mt-1">{{ $message }}</p>
                @enderror
            </div>
        </div>

        <div class="flex gap-4">
            <button type="submit" class="bg-emerald-600 text-white px-6 py-2 rounded-md hover:bg-emerald-700">
                Salvar
            </button>
            <a href="{{ route('admin.pontos-turisticos.index') }}" class="bg-gray-200 text-gray-700 px-6 py-2 rounded-md hover:bg-gray-300">
                Cancelar
            </a>
        </div>
    </form>
</div>
@endsection
