@extends('layouts.app')

@section('title', 'Admin - ApiEco')

@section('content')
<div class="mb-8 flex justify-between items-center">
    <div>
        <h1 class="text-3xl font-bold text-gray-800">Painel Administrativo</h1>
        <p class="text-gray-600">Gerencie os pontos turísticos do sistema.</p>
    </div>
    <a href="{{ route('admin.pontos-turisticos.create') }}" class="bg-emerald-600 text-white px-4 py-2 rounded-md hover:bg-emerald-700">
        + Novo Ponto Turístico
    </a>
</div>

<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
    <div class="bg-white rounded-lg shadow p-6">
        <h3 class="text-xl font-semibold text-gray-800">{{ $stats['total_pontos'] }}</h3>
        <p class="text-gray-600">Total de Pontos</p>
    </div>
    <div class="bg-green-100 rounded-lg shadow p-6">
        <h3 class="text-xl font-semibold text-green-800">{{ $stats['pontos_ativos'] }}</h3>
        <p class="text-green-600">Pontos Ativos</p>
    </div>
    <div class="bg-red-100 rounded-lg shadow p-6">
        <h3 class="text-xl font-semibold text-red-800">{{ $stats['pontos_inativos'] }}</h3>
        <p class="text-red-600">Pontos Inativos</p>
    </div>
    <div class="bg-blue-100 rounded-lg shadow p-6">
        <a href="{{ route('admin.pontos-turisticos.index') }}" class="block">
            <h3 class="text-xl font-semibold text-blue-800">Gerenciar →</h3>
            <p class="text-blue-600">Ver Todos</p>
        </a>
    </div>
</div>

<div class="bg-white rounded-lg shadow">
    <div class="p-4 border-b border-gray-200">
        <h2 class="text-xl font-semibold text-gray-800">Últimos Pontos Cadastrados</h2>
    </div>
    
    @if($recentPontos->isEmpty())
        <div class="p-8 text-center text-gray-500">
            Nenhum ponto turístico cadastrado.
        </div>
    @else
        <table class="w-full">
            <thead class="bg-gray-50">
                <tr>
                    <th class="px-4 py-3 text-left text-sm font-semibold text-gray-600">Nome</th>
                    <th class="px-4 py-3 text-left text-sm font-semibold text-gray-600">Cidade</th>
                    <th class="px-4 py-3 text-left text-sm font-semibold text-gray-600">Status</th>
                    <th class="px-4 py-3 text-left text-sm font-semibold text-gray-600">Ações</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-gray-200">
                @foreach($recentPontos as $ponto)
                    <tr class="hover:bg-gray-50">
                        <td class="px-4 py-3">
                            <a href="{{ route('admin.pontos-turisticos.show', $ponto) }}" class="text-emerald-600 hover:underline">
                                {{ $ponto->nome }}
                            </a>
                        </td>
                        <td class="px-4 py-3 text-gray-600">{{ $ponto->cidade }}/{{ $ponto->estado }}</td>
                        <td class="px-4 py-3">
                            <span class="px-2 py-1 rounded text-sm {{ $ponto->status === 'ativo' ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700' }}">
                                {{ ucfirst($ponto->status) }}
                            </span>
                        </td>
                        <td class="px-4 py-3">
                            <a href="{{ route('admin.pontos-turisticos.edit', $ponto) }}" class="text-blue-600 hover:underline mr-2">Editar</a>
                            <form action="{{ route('admin.pontos-turisticos.destroy', $ponto) }}" method="POST" class="inline">
                                @csrf
                                @method('DELETE')
                                <button type="submit" onclick="return confirm('Tem certeza que deseja excluir?')" class="text-red-600 hover:underline">
                                    Excluir
                                </button>
                            </form>
                        </td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    @endif
</div>
@endsection
