<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>@yield('title', 'ApiEco - Pontos Turísticos')</title>
    <script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 min-h-screen">
    <nav class="bg-emerald-600 text-white shadow-lg">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between h-16">
                <div class="flex items-center">
                    <a href="{{ route('home') }}" class="text-xl font-bold">ApiEco</a>
                    <div class="hidden md:flex ml-10 space-x-4">
                        <a href="{{ route('pontos-turisticos.index') }}" class="hover:bg-emerald-700 px-3 py-2 rounded-md">Pontos Turísticos</a>
                        @auth
                            <a href="{{ route('dashboard') }}" class="hover:bg-emerald-700 px-3 py-2 rounded-md">Dashboard</a>
                            @if(auth()->user()->role === 'admin' || auth()->user()->role === 'parceiro')
                                <a href="{{ route('admin.dashboard') }}" class="hover:bg-emerald-700 px-3 py-2 rounded-md">Admin</a>
                                <a href="{{ route('admin.pontos-turisticos.index') }}" class="hover:bg-emerald-700 px-3 py-2 rounded-md">Gerenciar Pontos</a>
                            @endif
                        @endauth
                    </div>
                </div>
                <div class="flex items-center">
                    @guest
                        <a href="{{ route('login') }}" class="hover:bg-emerald-700 px-3 py-2 rounded-md">Entrar</a>
                        <a href="{{ route('register') }}" class="bg-white text-emerald-600 hover:bg-gray-100 px-4 py-2 rounded-md ml-2">Cadastrar</a>
                    @else
                        <span class="mr-4">{{ auth()->user()->name }}</span>
                        <form action="{{ route('logout') }}" method="POST" class="inline">
                            @csrf
                            <button type="submit" class="bg-emerald-800 hover:bg-emerald-900 px-3 py-2 rounded-md">Sair</button>
                        </form>
                    @endguest
                </div>
            </div>
        </div>
    </nav>

    @if(session('success'))
        <div class="max-w-7xl mx-auto px-4 mt-4">
            <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
                {{ session('success') }}
            </div>
        </div>
    @endif

    @if(session('error'))
        <div class="max-w-7xl mx-auto px-4 mt-4">
            <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded">
                {{ session('error') }}
            </div>
        </div>
    @endif

    <main class="max-w-7xl mx-auto px-4 py-8">
        @yield('content')
    </main>

    <footer class="bg-gray-800 text-white py-8 mt-16">
        <div class="max-w-7xl mx-auto px-4 text-center">
            <p>&copy; {{ date('Y') }} ApiEco - Sistema de Pontos Turísticos</p>
        </div>
    </footer>
</body>
</html>
