<?php $__env->startSection('title', 'Kelola User'); ?>
<?php $__env->startSection('page_title', 'Manajemen User'); ?>

<?php $__env->startPush('styles'); ?>
    <style>
        .user-choice-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 20px;
            margin-top: 18px;
        }

        .user-choice-card {
            background: #fff;
            border: 1px solid #e2e8f0;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
            display: flex;
            flex-direction: column;
            gap: 18px;
            min-height: 220px;
            padding: 24px;
            text-decoration: none;
            transition: all 0.2s ease;
        }

        .user-choice-card:hover {
            border-color: #93c5fd;
            box-shadow: 0 16px 38px rgba(37, 99, 235, 0.1);
            transform: translateY(-2px);
        }

        .choice-icon {
            align-items: center;
            border-radius: 14px;
            display: inline-flex;
            height: 48px;
            justify-content: center;
            width: 48px;
        }

        .choice-icon.guru {
            background: #dbeafe;
            color: #1d4ed8;
        }

        .choice-icon.siswa {
            background: #dcfce7;
            color: #15803d;
        }

        .choice-title {
            color: #1e293b;
            display: block;
            font-size: 20px;
            font-weight: 800;
            margin-bottom: 6px;
        }

        .choice-desc {
            color: #64748b;
            line-height: 1.55;
            margin: 0;
        }

        .choice-footer {
            align-items: center;
            color: #2563eb;
            display: flex;
            font-weight: 700;
            gap: 8px;
            justify-content: space-between;
            margin-top: auto;
        }

        .choice-count {
            color: #475569;
            font-size: 14px;
            font-weight: 700;
        }

        .filter-actions {
            align-items: center;
            display: flex;
            gap: 12px;
            min-width: 0;
        }

        .header-actions {
            align-items: center;
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: flex-end;
        }

        .btn-secondary-action {
            align-items: center;
            background: #eff6ff;
            border: 1px solid #bfdbfe;
            border-radius: 10px;
            color: #1d4ed8;
            display: inline-flex;
            font-size: 15px;
            font-weight: 700;
            gap: 8px;
            padding: 12px 18px;
            text-decoration: none;
            transition: all 0.2s ease;
        }

        .btn-secondary-action:hover {
            background: #dbeafe;
            color: #1e40af;
            transform: translateY(-1px);
        }

        .btn-success-action {
            align-items: center;
            background: #dcfce7;
            border: 1px solid #bbf7d0;
            border-radius: 10px;
            color: #15803d;
            display: inline-flex;
            font-size: 15px;
            font-weight: 700;
            gap: 8px;
            padding: 12px 18px;
            text-decoration: none;
            transition: all 0.2s ease;
        }

        .btn-success-action:hover {
            background: #bbf7d0;
            color: #166534;
            transform: translateY(-1px);
        }

        .import-help {
            background: #eff6ff;
            border-left: 4px solid #2563eb;
            border-radius: 8px;
            color: #334155;
            line-height: 1.6;
            margin-bottom: 20px;
            padding: 14px 16px;
        }

        .import-help code {
            background: #dbeafe;
            border-radius: 6px;
            color: #1e3a8a;
            display: block;
            font-size: 13px;
            font-weight: 700;
            margin-top: 8px;
            padding: 8px;
            white-space: normal;
        }

        .import-error-list {
            background: #fef2f2;
            border: 1px solid #fecaca;
            border-radius: 8px;
            color: #991b1b;
            margin-bottom: 18px;
            max-height: 220px;
            overflow-y: auto;
            padding: 12px 16px;
        }

        .import-error-list ul {
            margin: 0;
            padding-left: 18px;
        }

        .filter-actions .search-box {
            min-width: min(420px, 100%);
        }

        .filter-select {
            min-width: 210px;
        }

        .filter-select select {
            width: 100%;
            min-height: 46px;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            background: #fff;
            color: #334155;
            font: inherit;
            font-size: 14px;
            outline: none;
            padding: 12px 14px;
            transition: border-color 0.3s, box-shadow 0.3s;
        }

        .filter-select select:focus {
            border-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }

        .field-error {
            color: #dc2626;
            font-size: 12px;
            margin-top: 6px;
        }

        .empty-state {
            color: #64748b;
            padding: 32px;
            text-align: center;
        }

        .profile-fields {
            display: none;
        }

        .profile-fields.show {
            display: block;
        }

        .btn-link-reset,
        .btn-back-link {
            color: #64748b;
            font-size: 14px;
            text-decoration: none;
        }

        .btn-link-reset:hover,
        .btn-back-link:hover {
            color: #1e293b;
        }

        .delete-form {
            display: inline-flex;
        }

        .action-btns {
            flex-wrap: wrap;
        }

        .profile-meta {
            color: #334155;
            font-weight: 600;
            line-height: 1.5;
        }

        .profile-meta span {
            color: #64748b;
            display: block;
            font-size: 12px;
            font-weight: 500;
            margin-top: 2px;
        }

        .pagination nav {
            align-items: center;
            display: flex;
            gap: 10px;
        }

        @media (max-width: 820px) {
            .user-choice-grid {
                grid-template-columns: 1fr;
            }

            .content-header,
            .filter-actions,
            .header-actions {
                align-items: stretch;
                flex-direction: column;
            }

            .filter-actions .search-box,
            .filter-actions .filter-select,
            .filter-actions .btn-save,
            .header-actions .btn-add,
            .header-actions .btn-secondary-action,
            .header-actions .btn-success-action {
                width: 100%;
                justify-content: center;
            }
        }
    </style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
    <?php if(($pageMode ?? 'landing') === 'landing'): ?>
        <section class="admin-page-header">
            <div>
                <h3>Kelola User</h3>
                <p>Pilih data yang ingin dikelola agar akun guru dan siswa tidak bercampur.</p>
            </div>
        </section>

        <div class="user-choice-grid">
            <a href="<?php echo e(route('admin.users.guru')); ?>" class="user-choice-card">
                <span class="choice-icon guru"><i class="fa-solid fa-chalkboard-user"></i></span>
                <div>
                    <span class="choice-title">Data Guru</span>
                    <p class="choice-desc">Kelola akun guru, email login, NIP, nomor HP, dan profil pengajar.</p>
                </div>
                <div class="choice-footer">
                    <span class="choice-count"><?php echo e($guruCount ?? 0); ?> guru</span>
                    <span>Masuk <i class="fa-solid fa-arrow-right"></i></span>
                </div>
            </a>

            <a href="<?php echo e(route('admin.users.siswa')); ?>" class="user-choice-card">
                <span class="choice-icon siswa"><i class="fa-solid fa-user-graduate"></i></span>
                <div>
                    <span class="choice-title">Data Siswa</span>
                    <p class="choice-desc">Kelola akun siswa, email login, NIS, kelas, dan profil peserta didik.</p>
                </div>
                <div class="choice-footer">
                    <span class="choice-count"><?php echo e($siswaCount ?? 0); ?> siswa</span>
                    <span>Masuk <i class="fa-solid fa-arrow-right"></i></span>
                </div>
            </a>
        </div>
    <?php else: ?>
        <?php
            $isEdit = ($formMode ?? 'create') === 'edit' && $selectedUser;
            $modalRole = old('role', $selectedUser?->role ?? ($defaultRole ?? $selectedRole ?? 'guru'));
            $guruProfile = $selectedUser?->guruProfile;
            $siswaProfile = $selectedUser?->siswaProfile;
            $isGuruPage = ($selectedRole ?? 'guru') === 'guru';
            $roleLabel = $isGuruPage ? 'Guru' : 'Siswa';
            $sectionRoute = $isGuruPage ? route('admin.users.guru') : route('admin.users.siswa');
            $createRoute = $isGuruPage ? route('admin.users.guru.create') : route('admin.users.siswa.create');
            $selectedKelas = $selectedKelas ?? '';
            $importErrors = $errors->getBag('import');
        ?>

        <section class="admin-page-header">
            <div>
                <a class="btn-back-link" href="<?php echo e(route('admin.users.index')); ?>">
                    <i class="fa-solid fa-arrow-left"></i> Kembali ke pilihan Kelola User
                </a>
                <h3 style="margin-top: 8px;">Data <?php echo e($roleLabel); ?></h3>
                <p>Menampilkan akun <?php echo e(strtolower($roleLabel)); ?> saja. Akun admin tidak ditampilkan di halaman ini.</p>
            </div>

            <div class="header-actions">
                <?php if (! ($isGuruPage)): ?>
                    <a href="<?php echo e(route('admin.users.siswa.naik-kelas')); ?>" class="btn-secondary-action">
                        <i class="fa-solid fa-people-arrows"></i> Naik Kelas Massal
                    </a>

                    <a href="#importSiswaModal" class="btn-success-action">
                        <i class="fa-solid fa-file-excel"></i> Import Excel
                    </a>

                    <a href="<?php echo e(route('admin.users.siswa.template')); ?>" class="btn-secondary-action">
                        <i class="fa-solid fa-download"></i> Download Template
                    </a>
                <?php endif; ?>

                <a href="<?php echo e($createRoute); ?>" class="btn-add" style="text-decoration: none;">
                    <i class="fa-solid fa-plus"></i> Tambah <?php echo e($roleLabel); ?>

                </a>
            </div>
        </section>

        <section class="content-header">
            <form class="filter-actions" action="<?php echo e($sectionRoute); ?>" method="GET">
                <div class="search-box">
                    <span><i class="fa-solid fa-magnifying-glass"></i></span>
                    <input type="text" name="search" value="<?php echo e($search); ?>" placeholder="Cari nama atau email <?php echo e(strtolower($roleLabel)); ?>...">
                </div>

                <?php if (! ($isGuruPage)): ?>
                    <div class="filter-select">
                        <select name="kelas" aria-label="Filter kelas siswa">
                            <option value="">Semua Kelas</option>
                            <?php $__currentLoopData = ($kelasOptions ?? collect()); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $kelasOption): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($kelasOption); ?>" <?php if($selectedKelas === $kelasOption): echo 'selected'; endif; ?>>
                                    <?php echo e($kelasOption); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                <?php endif; ?>

                <button type="submit" class="btn-save">
                    <i class="fa-solid fa-filter"></i> Cari
                </button>

                <?php if($search || $selectedKelas): ?>
                    <a href="<?php echo e($sectionRoute); ?>" class="btn-link-reset">Reset</a>
                <?php endif; ?>
            </form>
        </section>

        <div class="table-card">
            <table>
                <thead>
                    <tr>
                        <th>Pengguna</th>
                        <?php if($isGuruPage): ?>
                            <th>NIP</th>
                            <th>No HP</th>
                        <?php else: ?>
                            <th>NIS</th>
                            <th>Kelas</th>
                        <?php endif; ?>
                        <th>Role</th>
                        <th>Dibuat</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td>
                                <div class="user-info">
                                    <img src="https://ui-avatars.com/api/?name=<?php echo e(urlencode($user->name)); ?>&background=random" alt="User">
                                    <div class="user-details">
                                        <span class="user-name"><?php echo e($user->name); ?></span>
                                        <span class="user-email"><?php echo e($user->email); ?></span>
                                    </div>
                                </div>
                            </td>
                            <?php if($isGuruPage): ?>
                                <td class="profile-meta"><?php echo e($user->guruProfile?->nip ?? '-'); ?></td>
                                <td class="profile-meta"><?php echo e($user->guruProfile?->no_hp ?? '-'); ?></td>
                            <?php else: ?>
                                <td class="profile-meta"><?php echo e($user->siswaProfile?->nis ?? '-'); ?></td>
                                <td class="profile-meta"><?php echo e($user->siswaProfile?->kelas ?? '-'); ?></td>
                            <?php endif; ?>
                            <td><span class="badge <?php echo e($user->role); ?>"><?php echo e(ucfirst($user->role)); ?></span></td>
                            <td><?php echo e($user->created_at?->format('d M Y')); ?></td>
                            <td>
                                <div class="action-btns">
                                    <a class="btn-action btn-edit" title="Edit" href="<?php echo e(route('admin.users.edit', $user)); ?>">
                                        <i class="fa-solid fa-pen"></i>
                                    </a>
                                    <form class="delete-form" action="<?php echo e(route('admin.users.destroy', $user)); ?>" method="POST" onsubmit="return confirm('Hapus user ini?')">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('DELETE'); ?>
                                        <button class="btn-action btn-delete" title="Hapus" type="submit">
                                            <i class="fa-solid fa-trash"></i>
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="6" class="empty-state">Belum ada data <?php echo e(strtolower($roleLabel)); ?> yang sesuai.</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>

            <div class="pagination">
                <span class="page-info">
                    Menampilkan <?php echo e($users->firstItem() ?? 0); ?>-<?php echo e($users->lastItem() ?? 0); ?> dari <?php echo e($users->total()); ?> <?php echo e(strtolower($roleLabel)); ?>

                </span>
                <div class="page-numbers">
                    <?php echo e($users->links('vendor.pagination.custom')); ?>

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

        <?php if (! ($isGuruPage)): ?>
            <div class="modal-overlay <?php echo e(session('showImportModal') || $importErrors->any() ? 'show' : ''); ?>" id="importSiswaModal">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3>Import Data Siswa</h3>
                        <a class="close-btn" href="<?php echo e($sectionRoute); ?>"><i class="fa-solid fa-xmark"></i></a>
                    </div>

                    <div class="import-help">
                        <strong>Format kolom Excel</strong>
                        <p style="margin: 6px 0 0;">Gunakan file .xlsx, .xls, atau .csv dengan header pada baris pertama. Password boleh kosong dan akan otomatis memakai default <strong>password</strong>.</p>
                        <code>Nama | Email | Password | NIS | Kelas</code>
                    </div>

                    <?php if($importErrors->any()): ?>
                        <div class="import-error-list">
                            <strong>Import dibatalkan. Periksa error berikut:</strong>
                            <ul>
                                <?php $__currentLoopData = $importErrors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php $__currentLoopData = (array) $error; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $message): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <li><?php echo e($message); ?></li>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                    <?php endif; ?>

                    <form action="<?php echo e(route('admin.users.siswa.import')); ?>" method="POST" enctype="multipart/form-data">
                        <?php echo csrf_field(); ?>

                        <div class="form-group">
                            <label for="file_excel">File Excel</label>
                            <input id="file_excel" type="file" name="file_excel" accept=".xlsx,.xls,.csv" required>
                            <?php $__errorArgs = ['file_excel', 'import'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="modal-footer">
                            <a href="<?php echo e($sectionRoute); ?>" class="btn-cancel" style="text-decoration: none;">Batal</a>
                            <a href="<?php echo e(route('admin.users.siswa.template')); ?>" class="btn-cancel" style="text-decoration: none;">
                                <i class="fa-solid fa-download"></i> Template
                            </a>
                            <button type="submit" class="btn-save">
                                <i class="fa-solid fa-eye"></i> Upload dan Preview
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        <?php endif; ?>

        <div class="modal-overlay <?php echo e(($showModal ?? false) || $errors->any() ? 'show' : ''); ?>" id="userModal">
            <div class="modal-content">
                <div class="modal-header">
                    <h3><?php echo e($isEdit ? 'Edit User' : 'Tambah ' . $roleLabel); ?></h3>
                    <a class="close-btn" href="<?php echo e($sectionRoute); ?>"><i class="fa-solid fa-xmark"></i></a>
                </div>

                <form action="<?php echo e($isEdit ? route('admin.users.update', $selectedUser) : route('admin.users.store')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <?php if($isEdit): ?>
                        <?php echo method_field('PUT'); ?>
                    <?php endif; ?>

                    <div class="form-group">
                        <label for="name">Nama Lengkap</label>
                        <input id="name" type="text" name="name" value="<?php echo e(old('name', $selectedUser?->name)); ?>" placeholder="Masukkan nama lengkap" required>
                        <?php $__errorArgs = ['name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="form-group">
                        <label for="email">Email</label>
                        <input id="email" type="email" name="email" value="<?php echo e(old('email', $selectedUser?->email)); ?>" placeholder="Masukkan alamat email" required>
                        <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="form-group">
                        <label for="role">Peran (Role)</label>
                        <select id="role" name="role" required>
                            <option value="guru" <?php if($modalRole === 'guru'): echo 'selected'; endif; ?>>Guru</option>
                            <option value="siswa" <?php if($modalRole === 'siswa'): echo 'selected'; endif; ?>>Siswa</option>
                        </select>
                        <?php $__errorArgs = ['role'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="form-group">
                        <label for="password"><?php echo e($isEdit ? 'Password Baru' : 'Password'); ?></label>
                        <input id="password" type="password" name="password" placeholder="<?php echo e($isEdit ? 'Kosongkan jika tidak ingin mengubah password' : 'Minimal 8 karakter'); ?>" <?php echo e($isEdit ? '' : 'required'); ?>>
                        <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="form-group">
                        <label for="jenis_kelamin">Jenis Kelamin</label>
                        <select id="jenis_kelamin" name="jenis_kelamin">
                            <option value="">-- Pilih Jenis Kelamin --</option>
                            <option value="L" <?php if(old('jenis_kelamin', $guruProfile?->jenis_kelamin ?? $siswaProfile?->jenis_kelamin) === 'L'): echo 'selected'; endif; ?>>Laki-laki</option>
                            <option value="P" <?php if(old('jenis_kelamin', $guruProfile?->jenis_kelamin ?? $siswaProfile?->jenis_kelamin) === 'P'): echo 'selected'; endif; ?>>Perempuan</option>
                        </select>
                        <?php $__errorArgs = ['jenis_kelamin'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="profile-fields <?php echo e($modalRole === 'guru' ? 'show' : ''); ?>" id="guruFields">
                        <div class="form-group">
                            <label for="nip">NIP</label>
                            <input id="nip" type="text" name="nip" value="<?php echo e(old('nip', $guruProfile?->nip)); ?>" placeholder="Masukkan NIP guru">
                            <?php $__errorArgs = ['nip'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="form-group">
                            <label for="no_hp">No HP</label>
                            <input id="no_hp" type="text" name="no_hp" value="<?php echo e(old('no_hp', $guruProfile?->no_hp)); ?>" placeholder="Masukkan nomor HP">
                            <?php $__errorArgs = ['no_hp'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                    </div>

                    <div class="profile-fields <?php echo e($modalRole === 'siswa' ? 'show' : ''); ?>" id="siswaFields">
                        <div class="form-group">
                            <label for="nis">NIS</label>
                            <input id="nis" type="text" name="nis" value="<?php echo e(old('nis', $siswaProfile?->nis)); ?>" placeholder="Masukkan NIS siswa">
                            <?php $__errorArgs = ['nis'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="form-group">
                            <label for="kelas">Kelas</label>
                            <input id="kelas" type="text" name="kelas" value="<?php echo e(old('kelas', $siswaProfile?->kelas)); ?>" placeholder="Contoh: 5A">
                            <?php $__errorArgs = ['kelas'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="alamat">Alamat</label>
                        <input id="alamat" type="text" name="alamat" value="<?php echo e(old('alamat', $guruProfile?->alamat ?? $siswaProfile?->alamat)); ?>" placeholder="Masukkan alamat">
                        <?php $__errorArgs = ['alamat'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <div class="field-error"><?php echo e($message); ?></div> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>

                    <div class="modal-footer">
                        <a href="<?php echo e($sectionRoute); ?>" class="btn-cancel" style="text-decoration: none;">Batal</a>
                        <button type="submit" class="btn-save"><i class="fa-solid fa-check"></i> Simpan Data</button>
                    </div>
                </form>
            </div>
        </div>
    <?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script>
        const roleSelect = document.getElementById('role');
        const guruFields = document.getElementById('guruFields');
        const siswaFields = document.getElementById('siswaFields');

        function toggleProfileFields() {
            if (!roleSelect || !guruFields || !siswaFields) {
                return;
            }

            guruFields.classList.toggle('show', roleSelect.value === 'guru');
            siswaFields.classList.toggle('show', roleSelect.value === 'siswa');
        }

        if (roleSelect) {
            roleSelect.addEventListener('change', toggleProfileFields);
            toggleProfileFields();
        }
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\elearningsd-allFitur-main\resources\views/admin/kelola-user.blade.php ENDPATH**/ ?>