<?= $this->extend('layouts/app') ?>

<?= $this->section('content') ?>

<style>
    /* ===== MODERN SAAS DESIGN SYSTEM TOKENS ===== */
    :root {
        --bg-body: #f8fafc;
        --bg-card: #ffffff;
        --bg-accent: #f1f5f9;
        --bg-input: #ffffff;
        --border-color: #e2e8f0;
        --border-hover: #cbd5e1;
        --text-main: #0f172a;
        --text-sub: #64748b;
        --primary: #4f46e5;
        --primary-hover: #4338ca;
        --primary-light: rgba(79, 70, 229, 0.08);
        --success: #10b981;
        --warning: #f59e0b;
        --danger: #ef4444;
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
        --radius-lg: 16px;
        --radius-md: 12px;
        --radius-sm: 8px;
        --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @media (prefers-color-scheme: dark) {
        :root {
            --bg-body: #0b0f19;
            --bg-card: #151e2e;
            --bg-accent: #1e293b;
            --bg-input: #0f172a;
            --border-color: #243044;
            --border-hover: #334155;
            --text-main: #f8fafc;
            --text-sub: #94a3b8;
            --primary-light: rgba(79, 70, 229, 0.18);
            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
            --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
        }
    }

    [data-bs-theme="dark"] {
        --bg-body: #0b0f19;
        --bg-card: #151e2e;
        --bg-accent: #1e293b;
        --bg-input: #0f172a;
        --border-color: #243044;
        --border-hover: #334155;
        --text-main: #f8fafc;
        --text-sub: #94a3b8;
        --primary-light: rgba(79, 70, 229, 0.18);
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    }

    body, .content-wrapper, .main-content, .content, .page-content, main, .reset-password-workspace {
        background-color: var(--bg-body) !important;
        color: var(--text-main) !important;
        transition: var(--transition);
    }

    /* Form Container Layout */
    .reset-card-container {
        max-width: 540px;
        margin: 2rem auto;
    }

    /* Card Premium Styling */
    .card-modern {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        padding: 2rem;
        box-shadow: var(--shadow-md);
        transition: var(--transition);
    }

    /* Avatar Circle */
    .avatar-circle-lg {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary-light);
        color: var(--primary);
        font-weight: 700;
        font-size: 1.35rem;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    /* User Profile Card Box */
    .user-profile-box {
        background: var(--bg-accent);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 1.25rem;
    }

    /* Code Pill */
    .code-pill {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        color: var(--text-main);
        font-family: var(--bs-font-monospace);
        font-size: 0.85rem;
        font-weight: 600;
        padding: 0.25rem 0.6rem;
        border-radius: var(--radius-sm);
    }

    /* Warning Alert Callout */
    .warning-callout {
        background: rgba(245, 158, 11, 0.1);
        border: 1px solid rgba(245, 158, 11, 0.25);
        color: var(--text-main);
        border-radius: var(--radius-md);
        padding: 1rem 1.25rem;
    }
</style>

<div class="container-fluid py-4 reset-password-workspace">
    
    <div class="reset-card-container">
        
        <!-- BREADCRUMB / BACK LINK -->
        <div class="mb-3">
            <a href="<?= base_url('superadmin/user') ?>" class="text-sub text-decoration-none small fw-semibold d-inline-flex align-items-center gap-1 hover-underline">
                <i class="bi bi-arrow-left"></i> Kembali ke Manajemen User
            </a>
        </div>

        <!-- MAIN CONFIRMATION CARD -->
        <div class="card-modern">
            
            <!-- HEADER -->
            <div class="text-center mb-4">
                <div class="d-inline-flex align-items-center justify-content-center bg-warning-subtle text-warning p-3 rounded-circle mb-3">
                    <i class="bi bi-shield-lock-fill fs-2"></i>
                </div>
                <h4 class="fw-bold text-main mb-1">Konfirmasi Reset Password</h4>
                <p class="text-sub small mb-0">Tindakan ini akan menyetel ulang kata sandi pengguna ke nilai default sistem.</p>
            </div>

            <?php
                $username = $user['username'] ?? 'User';
                $namaLengkap = $user['nama_lengkap'] ?? $user['username'] ?? 'User';
                $email = $user['email'] ?? '-';
                $initial = strtoupper(substr(trim($namaLengkap), 0, 1));
            ?>

            <!-- TARGET USER INFO CARD -->
            <div class="user-profile-box mb-4">
                <div class="d-flex align-items-center gap-3">
                    <div class="avatar-circle-lg"><?= $initial ?></div>
                    <div class="overflow-hidden">
                        <div class="fw-bold text-main text-truncate" style="font-size: 1rem;"><?= esc($namaLengkap) ?></div>
                        <div class="d-flex align-items-center gap-2 mt-1">
                            <span class="code-pill text-primary">
                                <i class="bi bi-at"></i><?= esc($username) ?>
                            </span>
                            <span class="text-sub small font-monospace text-truncate"><?= esc($email) ?></span>
                        </div>
                    </div>
                </div>
            </div>

            <!-- WARNING CALLOUT BOX -->
            <div class="warning-callout mb-4">
                <div class="d-flex gap-2.5">
                    <i class="bi bi-exclamation-triangle-fill text-warning fs-5 flex-shrink-0 mt-0.5"></i>
                    <div class="small">
                        <strong class="d-block mb-1 text-main">Perhatian!</strong>
                        Password untuk akun ini akan diganti menjadi <code class="bg-card px-1.5 py-0.5 rounded border border-color text-danger fw-bold font-monospace">12345678</code>. Pengguna disarankan untuk segera memperbarui password setelah berhasil login.
                    </div>
                </div>
            </div>

            <!-- FORM ACTION -->
            <form method="post" action="<?= base_url('superadmin/user/reset-password/' . $user['id_user']) ?>">
                <?= csrf_field() ?>

                <div class="d-flex flex-column flex-sm-row gap-2 pt-2">
                    <a href="<?= base_url('superadmin/user') ?>" class="btn btn-outline-secondary rounded-3 py-2.5 px-4 fw-semibold flex-grow-1 d-inline-flex align-items-center justify-content-center gap-2">
                        <i class="bi bi-x-circle"></i> Batal
                    </a>
                    <button type="submit" class="btn btn-dark rounded-3 py-2.5 px-4 fw-semibold flex-grow-1 d-inline-flex align-items-center justify-content-center gap-2 shadow-sm">
                        <i class="bi bi-key-fill text-warning"></i> Ya, Reset Password
                    </button>
                </div>
            </form>

        </div>

    </div>

</div>

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