<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>

<div class="row justify-content-center">
    <div class="col-12 col-md-8 col-lg-6">
        
        <!-- Info Banner if forced -->
        <?php if (session()->getFlashdata('info')): ?>
        <div class="alert alert-warning border-0 shadow-sm mb-4" style="border-radius: 12px;">
            <div class="d-flex align-items-center gap-2">
                <i class="bi bi-exclamation-triangle-fill fs-4 text-warning"></i>
                <div>
                    <h6 class="fw-bold mb-0">Ubah Password Bawaan Anda</h6>
                    <small><?= session()->getFlashdata('info') ?></small>
                </div>
            </div>
        </div>
        <?php endif; ?>

        <div class="card border-0 shadow-sm" style="border-radius: 12px;">
            <div class="card-header bg-transparent border-0 pt-4 px-4 pb-0">
                <h5 class="fw-bold text-dark mb-0">Pengaturan Sandi Akun</h5>
                <small class="text-muted">Masukkan kata sandi baru minimal 6 karakter.</small>
            </div>

            <div class="card-body p-4">
                <?php if (session()->get('errors')): ?>
                    <div class="alert alert-danger py-2 small border-0">
                        <ul class="mb-0 ps-3">
                            <?php foreach (session()->get('errors') as $err): ?>
                                <li><?= esc($err) ?></li>
                            <?php endforeach; ?>
                        </ul>
                    </div>
                <?php endif; ?>

                <form action="/siswa/change-password" method="post">
                    <?= csrf_field() ?>

                    <div class="mb-3">
                        <label class="form-label text-dark fw-semibold">Kata Sandi Baru</label>
                        <input type="password" name="new_password" class="form-control border-primary" 
                            placeholder="Minimal 6 karakter" required minlength="6">
                    </div>

                    <div class="mb-4">
                        <label class="form-label text-dark fw-semibold">Konfirmasi Kata Sandi Baru</label>
                        <input type="password" name="confirm_password" class="form-control border-primary" 
                            placeholder="Ulangi kata sandi baru" required minlength="6">
                    </div>

                    <button type="submit" class="btn btn-primary w-100 rounded-pill py-2">
                        <i class="bi bi-shield-check me-2"></i>Perbarui Password Saya
                    </button>
                </form>
            </div>
        </div>

    </div>
</div>

<?= $this->endSection() ?>
