<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{{ config('app.name', 'Toko Adenium') }} - @yield('title', 'Home')</title>

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.bunny.net">
    <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

    <!-- Scripts -->
    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="antialiased">
    <nav class="bg-green-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">
                        🪴 Toko Adenium
                    </a>
                </div>

                <div class="flex items-center space-x-4">
                    <a href="{{ route('products.index') }}" class="hover:text-green-200">Produk</a>
                    <a href="{{ route('orders.index') }}" class="hover:text-green-200">Pesanan</a>

                    @auth
                        <!-- User sudah login -->
                        <div class="flex items-center space-x-4">
                            @if(Auth::user()->role === 'admin')
                                <!-- Navbar untuk Admin -->
                                <a href="{{ route('admin.dashboard') }}" class="hover:text-green-200">Admin Dashboard</a>
                                <span class="text-sm">{{ Auth::user()->name }} (Admin)</span>
                                <form method="POST" action="{{ route('admin.logout') }}" class="inline">
                                    @csrf
                                    <button type="submit" class="hover:text-green-200 text-sm">Logout</button>
                                </form>
                            @else
                                <!-- Navbar untuk Customer -->
                                <a href="{{ route('user.dashboard') }}" class="hover:text-green-200">Dashboard</a>
                                <a href="{{ route('orders.create') }}" class="hover:text-green-200">Checkout</a>
                                <span class="text-sm">{{ Auth::user()->name }}</span>
                                <form method="POST" action="{{ route('customer.logout') }}" class="inline">
                                    @csrf
                                    <button type="submit" class="hover:text-green-200 text-sm">Logout</button>
                                </form>
                            @endif
                        </div>
                    @else
                        <!-- User belum login -->
                        <div class="flex items-center space-x-4">
                            <a href="{{ route('customer.login') }}" class="bg-white text-green-600 px-3 py-1 rounded-md font-semibold hover:bg-green-50 border border-green-200">
                                Masuk
                            </a>
                            <a href="{{ route('customer.register') }}" class="hover:text-green-200 bg-green-700 px-3 py-1 rounded">Daftar</a>
                        </div>
                    @endauth
                </div>
            </div>
        </div>
    </nav>

    <main class="min-h-screen bg-gray-50">
        @yield('content')
    </main>

    <footer class="bg-gray-800 text-white py-8">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
            <p>&copy; 2026 Toko Adenium. All rights reserved.</p>
        </div>
    </footer>
</body>
</html>