@extends('layouts.admin')

@section('title', 'Profil Saya')
@section('page-title', 'Pengaturan Akun')

@section('content')
    <div class="card">
        <div class="card-body">
            @if (session('success'))
                <div class="alert alert-success">{{ session('success') }}</div>
            @endif

            <form action="{{ route('petani.profile.update') }}" method="POST" enctype="multipart/form-data">
                @csrf
                @method('PUT')

                <div class="row">
                    <div class="col-md-4 text-center">
                        <img src="{{ $user->foto ? asset('storage/' . $user->foto) : asset('template/admin/static/images/faces/2.jpg') }}"
                            alt="Avatar" class="rounded-circle img-thumbnail mb-3"
                            style="width: 150px; height: 150px; object-fit: cover;">

                        <div class="mb-3">
                            <label class="form-label btn btn-sm btn-outline-primary">
                                Ganti Foto <input type="file" name="foto" hidden accept="image/*">
                            </label>
                        </div>
                    </div>

                    <div class="col-md-8">
                        <div class="mb-3">
                            <label class="form-label">Nama Lengkap / Nama Toko</label>
                            <input type="text" name="nama_lengkap" class="form-control" value="{{ $user->nama_lengkap }}"
                                required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">Email</label>
                            <input type="email" name="email" class="form-control" value="{{ $user->email }}" required>
                        </div>

                        <hr class="my-4">
                        <h6 class="text-muted mb-3">Ganti Password (Opsional)</h6>

                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Password Baru</label>
                                <input type="password" name="password" class="form-control"
                                    placeholder="Kosongkan jika tidak diganti">
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Konfirmasi Password</label>
                                <input type="password" name="password_confirmation" class="form-control"
                                    placeholder="Ulangi password baru">
                            </div>
                        </div>

                        <button type="submit" class="btn btn-primary">Simpan Perubahan</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
@endsection
