@extends('layouts.admin')

@section('content')
<section class="py-4">
    <div class="container-fluid px-lg-4">

        {{-- =========================
        JUDUL HALAMAN
        ========================= --}}
        <h4 class="fw-bold mb-3">Profil Akun Admin</h4>

        {{-- =========================
        ALERT SUKSES
        ========================= --}}
        @if (session('success'))
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                {{ session('success') }}
                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
            </div>
        @endif

        {{-- =========================
        CARD FORM
        ========================= --}}
        <div class="card shadow-sm border-0">
            <div class="card-body">

                <form action="{{ route('admin.akun.update') }}" method="POST">
                    @csrf

                    {{-- =========================
                    INFORMASI AKUN
                    ========================= --}}
                    <h6 class="fw-bold mb-3">
                        <i class="bi bi-person-circle me-1"></i> Informasi Akun
                    </h6>

                    <div class="row g-3 mb-4">
                        {{-- Nama Admin --}}
                        <div class="col-12 col-md-6">
                            <label class="form-label fw-semibold">Nama Admin</label>
                            <input type="text"
                                name="name"
                                value="{{ old('name', $user->name) }}"
                                class="form-control @error('name') is-invalid @enderror"
                                placeholder="Nama lengkap admin"
                                required>
                            @error('name')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>

                        {{-- Email Admin --}}
                        <div class="col-12 col-md-6">
                            <label class="form-label fw-semibold">Email Admin</label>
                            <input type="email"
                                name="email"
                                value="{{ old('email', $user->email) }}"
                                class="form-control @error('email') is-invalid @enderror"
                                placeholder="email@domain.com"
                                required>
                            @error('email')
                                <div class="invalid-feedback">{{ $message }}</div>
                            @enderror
                        </div>
                    </div>

                    {{-- =========================
                    GANTI PASSWORD (OPSIONAL)
                    ========================= --}}
                    <div class="accordion mb-4" id="passwordAccordion">
                        <div class="accordion-item">
                            <h2 class="accordion-header">
                                <button class="accordion-button collapsed fw-semibold"
                                    type="button"
                                    data-bs-toggle="collapse"
                                    data-bs-target="#passwordCollapse">
                                    <i class="bi bi-lock me-2"></i> Ganti Password (Opsional)
                                </button>
                            </h2>

                            <div id="passwordCollapse" class="accordion-collapse collapse">
                                <div class="accordion-body">

                                    <div class="mb-3">
                                        <label class="form-label">Password Baru</label>
                                        <input type="password"
                                            name="password"
                                            class="form-control @error('password') is-invalid @enderror"
                                            placeholder="Minimal 8 karakter">
                                        @error('password')
                                            <div class="invalid-feedback">{{ $message }}</div>
                                        @enderror
                                    </div>

                                    <div class="mb-2">
                                        <label class="form-label">Konfirmasi Password</label>
                                        <input type="password"
                                            name="password_confirmation"
                                            class="form-control"
                                            placeholder="Ulangi password baru">
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>

                    {{-- =========================
                    TOMBOL SIMPAN
                    ========================= --}}
                    <div class="d-grid d-md-flex justify-content-md-end">
                        <button class="btn btn-primary px-4 py-2">
                            <i class="bi bi-save me-1"></i> Simpan Perubahan
                        </button>
                    </div>

                </form>

            </div>
        </div>

    </div>
</section>
@endsection
