@extends('layouts.app')

@section('title', 'My Profile')

@section('content')
<div class="max-w-4xl mx-auto px-4 py-8">
    <h1 class="text-2xl font-bold text-gray-800 mb-6">My Profile</h1>

    <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
        {{-- Sidebar --}}
        <div class="bg-white rounded-xl shadow-sm p-5">
            <div class="text-center mb-4">
                <div class="w-16 h-16 bg-red-100 rounded-full flex items-center justify-center text-2xl font-bold text-red-600 mx-auto">
                    {{ substr(auth()->user()->name, 0, 1) }}
                </div>
                <p class="font-bold mt-2">{{ auth()->user()->name }}</p>
                <p class="text-sm text-gray-500">{{ auth()->user()->email }}</p>
            </div>
            <nav class="space-y-1">
                <a href="{{ route('profile.index') }}" class="block px-3 py-2 rounded-lg bg-red-50 text-red-600 text-sm font-medium">Profile</a>
                <a href="{{ route('shop.orders.index') }}" class="block px-3 py-2 rounded-lg hover:bg-gray-50 text-sm text-gray-700">My Orders</a>
                <a href="{{ route('wishlist.index') }}" class="block px-3 py-2 rounded-lg hover:bg-gray-50 text-sm text-gray-700">Wishlist</a>
                <a href="{{ route('profile.addresses') }}" class="block px-3 py-2 rounded-lg hover:bg-gray-50 text-sm text-gray-700">Addresses</a>
            </nav>
        </div>

        {{-- Profile Form --}}
        <div class="md:col-span-2 bg-white rounded-xl shadow-sm p-6">
            <h2 class="font-bold text-gray-800 mb-4">Personal Information</h2>
            <form action="{{ route('profile.update') }}" method="POST">
                @csrf @method('PUT')
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Full Name</label>
                        <input type="text" name="name" value="{{ old('name', auth()->user()->name) }}" required class="w-full border border-gray-300 rounded-lg px-3 py-2">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Email</label>
                        <input type="email" name="email" value="{{ old('email', auth()->user()->email) }}" required class="w-full border border-gray-300 rounded-lg px-3 py-2">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Phone</label>
                        <input type="text" name="phone" value="{{ old('phone', auth()->user()->phone) }}" class="w-full border border-gray-300 rounded-lg px-3 py-2">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">New Password</label>
                        <input type="password" name="password" class="w-full border border-gray-300 rounded-lg px-3 py-2" placeholder="Leave blank to keep current">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">Confirm Password</label>
                        <input type="password" name="password_confirmation" class="w-full border border-gray-300 rounded-lg px-3 py-2">
                    </div>
                </div>
                <button type="submit" class="mt-4 bg-red-600 text-white px-6 py-2 rounded-lg hover:bg-red-700">Save Changes</button>
            </form>
        </div>
    </div>
</div>
@endsection
