

<?php $__env->startSection('title', 'Profil Sekolah'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <!-- Page Header with School Badge -->
    <div class="row mb-4">
        <div class="col-12">
            <div class="card border-0 shadow-sm" style="background: linear-gradient(135deg, #28a745 0%, #20c997 100%);">
                <div class="card-body p-4">
                    <div class="row align-items-center">
                        <div class="col-md-8">
                            <div class="d-flex align-items-center text-white" style="text-shadow: 0 2px 4px rgba(0,0,0,0.3);">
                                <div class="flex-shrink-0">
                                    <div class="rounded-circle bg-white p-3 shadow">
                                        <i class="bi bi-building-fill fs-1 text-success"></i>
                                    </div>
                                </div>
                                <div class="flex-grow-1 ms-4">
                                    <h2 class="mb-1 fw-bold text-white" style="text-shadow: 0 2px 4px rgba(0,0,0,0.3);"><?php echo e($school->name); ?></h2>
                                    <p class="mb-1 text-white" style="text-shadow: 0 1px 3px rgba(0,0,0,0.3);">
                                        <i class="bi bi-geo-alt-fill me-1"></i>
                                        <?php echo e($school->kabKota->name ?? 'Lokasi tidak tersedia'); ?>

                                    </p>
                                    <div class="d-flex gap-3 mt-2">
                                        <span class="badge bg-white text-success fw-bold">
                                            <i class="bi bi-mortarboard-fill me-1"></i>
                                            <?php echo e(strtoupper($school->level)); ?>

                                        </span>
                                        <span class="badge bg-white text-success fw-bold">
                                            <i class="bi bi-patch-check-fill me-1"></i>
                                            <?php echo e($school->status); ?>

                                        </span>
                                        <?php if($school->accreditation): ?>
                                        <span class="badge bg-warning text-dark fw-bold">
                                            <i class="bi bi-award-fill me-1"></i>
                                            Akreditasi <?php echo e($school->accreditation); ?>

                                        </span>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4 text-md-end mt-3 mt-md-0">
                            <div class="text-white" style="text-shadow: 0 2px 4px rgba(0,0,0,0.3);">
                                <div class="mb-2">
                                    <small class="text-white">NPSN</small>
                                    <h4 class="mb-0 fw-bold text-white"><?php echo e($school->npsn); ?></h4>
                                </div>
                                <div>
                                    <span class="badge <?php echo e($school->is_active ? 'bg-white text-success' : 'bg-secondary'); ?> px-3 py-2 fw-bold">
                                        <i class="bi <?php echo e($school->is_active ? 'bi-check-circle-fill' : 'bi-x-circle-fill'); ?> me-1"></i>
                                        <?php echo e($school->is_active ? 'Aktif' : 'Nonaktif'); ?>

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

    <?php if(session('success')): ?>
    <div class="alert alert-success alert-dismissible fade show" role="alert">
        <i class="bi bi-check-circle me-2"></i><?php echo e(session('success')); ?>

        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    </div>
    <?php endif; ?>

    <?php if(session('error')): ?>
    <div class="alert alert-danger alert-dismissible fade show" role="alert">
        <i class="bi bi-exclamation-circle me-2"></i><?php echo e(session('error')); ?>

        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    </div>
    <?php endif; ?>

    <?php if($school->profile_locked): ?>
    <div class="alert alert-warning alert-dismissible fade show" role="alert">
        <div class="d-flex align-items-center">
            <i class="bi bi-lock-fill fs-4 me-3"></i>
            <div>
                <strong>Profil Terkunci</strong>
                <p class="mb-0">Data profil sekolah sudah terkunci sejak <?php echo e($school->profile_updated_at ? $school->profile_updated_at->format('d M Y H:i') : '-'); ?>. Untuk melakukan perubahan data, silakan hubungi Admin Dinas untuk membuka kunci.</p>
            </div>
        </div>
        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    </div>
    <?php endif; ?>

    <!-- Quick Stats -->
    <div class="row mb-4">
        <div class="col-md-4">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div class="flex-shrink-0">
                            <div class="rounded-circle bg-primary bg-opacity-10 p-3">
                                <i class="bi bi-person-video3 fs-3 text-primary"></i>
                            </div>
                        </div>
                        <div class="flex-grow-1 ms-3">
                            <h6 class="text-muted mb-1">Total Guru</h6>
                            <h2 class="mb-0 fw-bold"><?php echo e($totalGuru); ?></h2>
                            <small class="text-success">
                                <i class="bi bi-arrow-up"></i> Aktif
                            </small>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div class="flex-shrink-0">
                            <div class="rounded-circle bg-info bg-opacity-10 p-3">
                                <i class="bi bi-person-workspace fs-3 text-info"></i>
                            </div>
                        </div>
                        <div class="flex-grow-1 ms-3">
                            <h6 class="text-muted mb-1">Tenaga Kependidikan</h6>
                            <h2 class="mb-0 fw-bold"><?php echo e($totalTendik); ?></h2>
                            <small class="text-success">
                                <i class="bi bi-arrow-up"></i> Aktif
                            </small>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card border-0 shadow-sm h-100">
                <div class="card-body">
                    <div class="d-flex align-items-center">
                        <div class="flex-shrink-0">
                            <div class="rounded-circle bg-success bg-opacity-10 p-3">
                                <i class="bi bi-people-fill fs-3 text-success"></i>
                            </div>
                        </div>
                        <div class="flex-grow-1 ms-3">
                            <h6 class="text-muted mb-1">Total GTK</h6>
                            <h2 class="mb-0 fw-bold"><?php echo e($totalGuru + $totalTendik); ?></h2>
                            <small class="text-muted">
                                Guru & Tendik
                            </small>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <!-- School Information Card -->
        <div class="col-lg-8">
            <div class="card border-0 shadow-sm mb-4">
                <div class="card-header bg-primary text-white py-3">
                    <h5 class="mb-0">
                        <i class="bi bi-info-circle me-2"></i>
                        Informasi Sekolah
                    </h5>
                </div>
                <div class="card-body p-4">
                    <form action="<?php echo e(route('admin-sekolah.profil.update')); ?>" method="POST" id="profilForm">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('PUT'); ?>
                        
                        <h6 class="text-primary mb-3 pb-2 border-bottom">
                            <i class="bi bi-card-text me-2"></i>Data Identitas
                        </h6>
                        
                        <div class="row mb-4">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-hash text-muted me-1"></i>NPSN
                                </label>
                                <input type="text" class="form-control bg-light" value="<?php echo e($school->npsn); ?>" readonly>
                                <small class="text-muted">Nomor Pokok Sekolah Nasional</small>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-building text-muted me-1"></i>Nama Sekolah
                                </label>
                                <input type="text" class="form-control bg-light" value="<?php echo e($school->name); ?>" readonly>
                            </div>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-mortarboard text-muted me-1"></i>Jenjang
                                </label>
                                <input type="text" class="form-control bg-light" value="<?php echo e(strtoupper($school->level)); ?>" readonly>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-patch-check text-muted me-1"></i>Status
                                </label>
                                <input type="text" class="form-control bg-light" value="<?php echo e($school->status); ?>" readonly>
                            </div>
                        </div>

                        <h6 class="text-primary mb-3 pb-2 border-bottom mt-4">
                            <i class="bi bi-geo-alt me-2"></i>Lokasi & Wilayah
                        </h6>

                        <div class="mb-4">
                            <label class="form-label fw-bold">
                                <i class="bi bi-map text-muted me-1"></i>Alamat Lengkap <span class="text-danger">*</span>
                            </label>
                            <textarea name="address" class="form-control <?php $__errorArgs = ['address'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" rows="3" placeholder="Masukkan alamat lengkap sekolah" <?php echo e($school->profile_locked ? 'disabled' : ''); ?>><?php echo e(old('address', $school->address)); ?></textarea>
                            <?php $__errorArgs = ['address'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                            <div class="invalid-feedback"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-pin-map text-muted me-1"></i>Kabupaten/Kota
                                </label>
                                <input type="text" class="form-control bg-light" value="<?php echo e($school->kabKota->name ?? '-'); ?>" readonly>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-diagram-3 text-muted me-1"></i>KCD
                                </label>
                                <input type="text" class="form-control bg-light" value="<?php echo e($school->kcd->name ?? ($school->kabKota->kcd->name ?? '-')); ?>" readonly>
                            </div>
                        </div>

                        <h6 class="text-primary mb-3 pb-2 border-bottom mt-4">
                            <i class="bi bi-telephone me-2"></i>Kontak & Informasi
                        </h6>

                        <div class="row mb-4">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-telephone-fill text-muted me-1"></i>Nomor Telepon
                                </label>
                                <input type="text" name="phone" class="form-control <?php $__errorArgs = ['phone'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('phone', $school->phone)); ?>" placeholder="Contoh: 0274-1234567" <?php echo e($school->profile_locked ? 'disabled' : ''); ?>>
                                <?php $__errorArgs = ['phone'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-envelope-fill text-muted me-1"></i>Email
                                </label>
                                <input type="email" name="email" class="form-control <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('email', $school->email)); ?>" placeholder="email@sekolah.sch.id" <?php echo e($school->profile_locked ? 'disabled' : ''); ?>>
                                <?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="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <h6 class="text-primary mb-3 pb-2 border-bottom mt-4">
                            <i class="bi bi-person-badge me-2"></i>Data Kepala Sekolah
                        </h6>

                        <div class="row mb-4">
                            <div class="col-md-12">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-person-fill text-muted me-1"></i>Nama Kepala Sekolah
                                </label>
                                <input type="text" name="principal_name" class="form-control <?php $__errorArgs = ['principal_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('principal_name', $school->principal_name)); ?>" placeholder="Nama lengkap kepala sekolah" <?php echo e($school->profile_locked ? 'disabled' : ''); ?>>
                                <?php $__errorArgs = ['principal_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <div class="row mb-4">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-card-text text-muted me-1"></i>NIP Kepala Sekolah
                                </label>
                                <input type="text" name="principal_nip" class="form-control <?php $__errorArgs = ['principal_nip'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('principal_nip', $school->principal_nip)); ?>" placeholder="18 digit NIP" <?php echo e($school->profile_locked ? 'disabled' : ''); ?>>
                                <?php $__errorArgs = ['principal_nip'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-phone-fill text-muted me-1"></i>HP Kepala Sekolah
                                </label>
                                <input type="text" name="principal_phone" class="form-control <?php $__errorArgs = ['principal_phone'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('principal_phone', $school->principal_phone)); ?>" placeholder="08xxxxxxxxxx" <?php echo e($school->profile_locked ? 'disabled' : ''); ?>>
                                <?php $__errorArgs = ['principal_phone'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <h6 class="text-primary mb-3 pb-2 border-bottom mt-4">
                            <i class="bi bi-universal-access me-2"></i>Unit Layanan Disabilitas (ULD)
                        </h6>

                        <div class="mb-3">
                            <div class="form-check form-switch">
                                <input class="form-check-input" type="checkbox" id="has_uld" name="has_uld" value="1" <?php echo e(old('has_uld', $school->has_uld) ? 'checked' : ''); ?> <?php echo e($school->profile_locked ? 'disabled' : ''); ?>>
                                <label class="form-check-label fw-bold" for="has_uld">
                                    <i class="bi bi-check-circle text-muted me-1"></i>
                                    Sekolah memiliki Unit Layanan Disabilitas (ULD)
                                </label>
                            </div>
                        </div>

                        <div class="row mb-4" id="uld_count_wrapper" style="display: none;">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-123 text-muted me-1"></i>Jumlah ULD Aktif
                                </label>
                                <input type="number" name="uld_count" id="uld_count" class="form-control <?php $__errorArgs = ['uld_count'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('uld_count', $school->uld_count)); ?>" min="0" placeholder="Masukkan jumlah ULD" <?php echo e($school->profile_locked ? 'disabled' : ''); ?>>
                                <?php $__errorArgs = ['uld_count'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                <small class="text-muted">Jumlah Unit Layanan Disabilitas yang aktif</small>
                            </div>
                        </div>

                        <!-- ULD Locations Dynamic Form -->
                        <div id="uld_locations_wrapper" style="display: none;">
                            <h6 class="text-primary mb-3 pb-2 border-bottom mt-4">
                                <i class="bi bi-geo-fill me-2"></i>Data Lokasi ULD
                            </h6>
                            <div id="uld_locations_container">
                                <!-- ULD location forms will be inserted here dynamically -->
                            </div>
                        </div>

                        <h6 class="text-primary mb-3 pb-2 border-bottom mt-4">
                            <i class="bi bi-award me-2"></i>Informasi Tambahan
                        </h6>

                        <div class="row mb-4">
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-globe text-muted me-1"></i>Website
                                </label>
                                <input type="url" name="website" class="form-control <?php $__errorArgs = ['website'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('website', $school->website)); ?>" placeholder="https://www.sekolah.sch.id" <?php echo e($school->profile_locked ? 'disabled' : ''); ?>>
                                <?php $__errorArgs = ['website'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                            <div class="col-md-6">
                                <label class="form-label fw-bold">
                                    <i class="bi bi-award-fill text-muted me-1"></i>Akreditasi
                                </label>
                                <select name="accreditation" class="form-select <?php $__errorArgs = ['accreditation'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" <?php echo e($school->profile_locked ? 'disabled' : ''); ?>>
                                    <option value="">Pilih Akreditasi</option>
                                    <option value="A" <?php echo e(old('accreditation', $school->accreditation) == 'A' ? 'selected' : ''); ?>>A (Sangat Baik)</option>
                                    <option value="B" <?php echo e(old('accreditation', $school->accreditation) == 'B' ? 'selected' : ''); ?>>B (Baik)</option>
                                    <option value="C" <?php echo e(old('accreditation', $school->accreditation) == 'C' ? 'selected' : ''); ?>>C (Cukup)</option>
                                    <option value="Belum Terakreditasi" <?php echo e(old('accreditation', $school->accreditation) == 'Belum Terakreditasi' ? 'selected' : ''); ?>>Belum Terakreditasi</option>
                                </select>
                                <?php $__errorArgs = ['accreditation'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                        </div>

                        <div class="d-flex justify-content-end gap-2 mt-4 pt-3 border-top">
                            <?php if($school->profile_locked): ?>
                                <div class="alert alert-info mb-0 w-100">
                                    <i class="bi bi-info-circle me-2"></i>
                                    Data profil terkunci. Hubungi Admin Dinas untuk membuka kunci.
                                </div>
                            <?php else: ?>
                                <button type="reset" class="btn btn-secondary">
                                    <i class="bi bi-x-circle me-1"></i>
                                    Reset
                                </button>
                                <button type="submit" class="btn btn-primary">
                                    <i class="bi bi-save me-1"></i>
                                    Simpan Perubahan
                                </button>
                            <?php endif; ?>
                        </div>
                    </form>
                </div>
            </div>
        </div>

        <!-- Sidebar -->
        <div class="col-lg-4">
            <!-- Kepala Sekolah -->
            <div class="card border-0 shadow-sm mb-4">
                <div class="card-header bg-gradient text-white border-bottom py-3" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
                    <h6 class="mb-0 fw-bold">
                        <i class="bi bi-person-badge-fill me-2"></i>
                        Kepala Sekolah
                    </h6>
                </div>
                <div class="card-body">
                    <?php if($school->principal_name): ?>
                    <div class="text-center mb-3">
                        <div class="rounded-circle bg-primary bg-opacity-10 d-inline-flex align-items-center justify-content-center mb-2" style="width: 100px; height: 100px;">
                            <i class="bi bi-person-fill text-primary" style="font-size: 3rem;"></i>
                        </div>
                        <h6 class="fw-bold mb-0"><?php echo e($school->principal_name); ?></h6>
                        <?php if($school->principal_nip): ?>
                        <small class="text-muted">NIP: <?php echo e($school->principal_nip); ?></small>
                        <?php endif; ?>
                    </div>
                    
                    <?php if($school->principal_phone || $school->email): ?>
                    <div class="border-top pt-3">
                        <?php if($school->email): ?>
                        <div class="mb-2 pb-2 border-bottom">
                            <div class="d-flex align-items-start">
                                <i class="bi bi-envelope-fill text-muted me-2 mt-1"></i>
                                <div>
                                    <small class="text-muted d-block">Email Sekolah</small>
                                    <small class="fw-medium text-break"><?php echo e($school->email); ?></small>
                                </div>
                            </div>
                        </div>
                        <?php endif; ?>
                        
                        <?php if($school->principal_phone): ?>
                        <div class="mb-2">
                            <div class="d-flex align-items-start">
                                <i class="bi bi-phone-fill text-muted me-2 mt-1"></i>
                                <div>
                                    <small class="text-muted d-block">HP Kepala Sekolah</small>
                                    <small class="fw-medium"><?php echo e($school->principal_phone); ?></small>
                                </div>
                            </div>
                        </div>
                        <?php endif; ?>
                    </div>
                    <?php endif; ?>
                    <?php else: ?>
                    <div class="text-center text-muted py-4">
                        <i class="bi bi-person-x-fill mb-2 opacity-50" style="font-size: 3rem;"></i>
                        <p class="mb-0 small">Data kepala sekolah<br>belum tersedia</p>
                        <small class="text-muted">Silakan lengkapi data di bawah</small>
                    </div>
                    <?php endif; ?>
                </div>
            </div>

            <!-- Contact Info -->
            <div class="card border-0 shadow-sm mb-4">
                <div class="card-header bg-white border-bottom py-3">
                    <h6 class="mb-0 fw-bold">
                        <i class="bi bi-telephone-fill text-primary me-2"></i>
                        Kontak Sekolah
                    </h6>
                </div>
                <div class="card-body">
                    <?php if($school->phone || $school->email || $school->website): ?>
                        <?php if($school->phone): ?>
                        <div class="mb-3 pb-3 border-bottom">
                            <div class="d-flex align-items-start">
                                <div class="flex-shrink-0">
                                    <div class="rounded-circle bg-primary bg-opacity-10 p-2">
                                        <i class="bi bi-telephone-fill text-primary"></i>
                                    </div>
                                </div>
                                <div class="flex-grow-1 ms-3">
                                    <small class="text-muted d-block">Telepon</small>
                                    <a href="tel:<?php echo e($school->phone); ?>" class="text-dark text-decoration-none fw-bold">
                                        <?php echo e($school->phone); ?>

                                    </a>
                                </div>
                            </div>
                        </div>
                        <?php endif; ?>
                        
                        <?php if($school->email): ?>
                        <div class="mb-3 pb-3 border-bottom">
                            <div class="d-flex align-items-start">
                                <div class="flex-shrink-0">
                                    <div class="rounded-circle bg-info bg-opacity-10 p-2">
                                        <i class="bi bi-envelope-fill text-info"></i>
                                    </div>
                                </div>
                                <div class="flex-grow-1 ms-3">
                                    <small class="text-muted d-block">Email</small>
                                    <a href="mailto:<?php echo e($school->email); ?>" class="text-dark text-decoration-none fw-bold text-break">
                                        <?php echo e($school->email); ?>

                                    </a>
                                </div>
                            </div>
                        </div>
                        <?php endif; ?>
                        
                        <?php if($school->website): ?>
                        <div>
                            <div class="d-flex align-items-start">
                                <div class="flex-shrink-0">
                                    <div class="rounded-circle bg-success bg-opacity-10 p-2">
                                        <i class="bi bi-globe text-success"></i>
                                    </div>
                                </div>
                                <div class="flex-grow-1 ms-3">
                                    <small class="text-muted d-block">Website</small>
                                    <a href="<?php echo e($school->website); ?>" target="_blank" class="text-primary fw-bold text-break">
                                        <?php echo e(str_replace(['http://', 'https://'], '', $school->website)); ?>

                                        <i class="bi bi-box-arrow-up-right ms-1"></i>
                                    </a>
                                </div>
                            </div>
                        </div>
                        <?php endif; ?>
                    <?php else: ?>
                    <div class="text-center py-4">
                        <i class="bi bi-info-circle fs-1 text-muted d-block mb-2"></i>
                        <p class="text-muted mb-0">Belum ada informasi kontak</p>
                        <small class="text-muted">Lengkapi data kontak sekolah</small>
                    </div>
                    <?php endif; ?>
                </div>
            </div>

            <!-- School Address -->
            <div class="card border-0 shadow-sm mb-4">
                <div class="card-header bg-white border-bottom py-3">
                    <h6 class="mb-0 fw-bold">
                        <i class="bi bi-geo-alt-fill text-danger me-2"></i>
                        Alamat Lengkap
                    </h6>
                </div>
                <div class="card-body">
                    <?php if($school->address): ?>
                    <p class="mb-0"><?php echo e($school->address); ?></p>
                    <hr>
                    <small class="text-muted">
                        <i class="bi bi-pin-map me-1"></i>
                        <?php echo e($school->kabKota->name ?? 'Kab/Kota'); ?>

                    </small>
                    <?php else: ?>
                    <div class="text-center py-3">
                        <i class="bi bi-map fs-1 text-muted d-block mb-2"></i>
                        <p class="text-muted mb-0 small">Alamat belum diisi</p>
                    </div>
                    <?php endif; ?>
                </div>
            </div>

            <!-- Info Card -->
            <div class="card border-0 shadow-sm bg-light">
                <div class="card-body">
                    <h6 class="mb-3">
                        <i class="bi bi-lightbulb-fill text-warning me-2"></i>
                        Tips
                    </h6>
                    <ul class="small text-muted mb-0 ps-3">
                        <li class="mb-2">Lengkapi semua informasi kontak agar mudah dihubungi</li>
                        <li class="mb-2">Update data secara berkala untuk akurasi informasi</li>
                        <li class="mb-2">Pastikan email dan website dapat diakses dengan baik</li>
                        <li>Isi data ULD jika sekolah memiliki unit layanan disabilitas</li>
                    </ul>
                </div>
            </div>

            <!-- ULD Locations Display -->
            <?php if($school->has_uld && $uldLocations->count() > 0): ?>
            <div class="card border-0 shadow-sm mt-4">
                <div class="card-header bg-gradient text-white border-bottom py-3" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
                    <h6 class="mb-0 fw-bold">
                        <i class="bi bi-geo-alt-fill me-2"></i>
                        Lokasi ULD (<?php echo e($uldLocations->count()); ?>)
                    </h6>
                </div>
                <div class="card-body">
                    <?php $__currentLoopData = $uldLocations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $location): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <div class="mb-3 <?php echo e(!$loop->last ? 'pb-3 border-bottom' : ''); ?>">
                        <div class="d-flex align-items-start mb-2">
                            <div class="flex-shrink-0">
                                <div class="rounded-circle bg-primary bg-opacity-10 d-flex align-items-center justify-content-center" style="width: 35px; height: 35px;">
                                    <span class="fw-bold text-primary"><?php echo e($index + 1); ?></span>
                                </div>
                            </div>
                            <div class="flex-grow-1 ms-3">
                                <h6 class="mb-1 fw-bold"><?php echo e($location->name); ?></h6>
                                <p class="mb-1 small text-muted">
                                    <i class="bi bi-geo-alt me-1"></i><?php echo e($location->address); ?>

                                </p>
                                <p class="mb-0 small">
                                    <i class="bi bi-signpost me-1"></i>
                                    <span class="badge bg-info"><?php echo e($location->kecamatan); ?></span>
                                </p>
                            </div>
                        </div>
                    </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
            <?php endif; ?>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
    // ULD checkbox toggle
    const hasUldCheckbox = document.getElementById('has_uld');
    const uldCountWrapper = document.getElementById('uld_count_wrapper');
    const uldCountInput = document.getElementById('uld_count');
    const uldLocationsWrapper = document.getElementById('uld_locations_wrapper');
    const uldLocationsContainer = document.getElementById('uld_locations_container');
    const isProfileLocked = <?php echo e($school->profile_locked ? 'true' : 'false'); ?>;
    
    // Store existing ULD locations data
    const existingLocations = <?php echo json_encode($uldLocations ?? [], 15, 512) ?>;
    
    if (hasUldCheckbox && uldCountWrapper) {
        function toggleUldCount() {
            if (hasUldCheckbox.checked) {
                uldCountWrapper.style.display = 'block';
                uldCountInput.required = true;
            } else {
                uldCountWrapper.style.display = 'none';
                uldCountInput.required = false;
                uldCountInput.value = '';
                uldLocationsWrapper.style.display = 'none';
                uldLocationsContainer.innerHTML = '';
            }
        }
        
        hasUldCheckbox.addEventListener('change', toggleUldCount);
        
        // Initial state
        toggleUldCount();
    }
    
    // ULD Count change handler - Generate dynamic forms
    if (uldCountInput) {
        uldCountInput.addEventListener('input', function() {
            const count = parseInt(this.value) || 0;
            
            if (count > 0) {
                uldLocationsWrapper.style.display = 'block';
                generateUldLocationForms(count);
            } else {
                uldLocationsWrapper.style.display = 'none';
                uldLocationsContainer.innerHTML = '';
            }
        });
        
        // Trigger on page load if value exists
        if (uldCountInput.value > 0) {
            uldLocationsWrapper.style.display = 'block';
            generateUldLocationForms(parseInt(uldCountInput.value));
        }
    }
    
    function generateUldLocationForms(count) {
        uldLocationsContainer.innerHTML = '';
        
        for (let i = 0; i < count; i++) {
            const existingData = existingLocations[i] || {};
            const formHtml = `
                <div class="card mb-3 border-start border-primary border-3">
                    <div class="card-header bg-light">
                        <h6 class="mb-0">
                            <i class="bi bi-pin-map-fill text-primary me-2"></i>
                            ULD ${i + 1}
                        </h6>
                    </div>
                    <div class="card-body">
                        <div class="mb-3">
                            <label class="form-label fw-bold">
                                <i class="bi bi-building text-muted me-1"></i>Nama ULD <span class="text-danger">*</span>
                            </label>
                            <input type="text" 
                                name="uld_locations[${i}][name]" 
                                class="form-control" 
                                placeholder="Contoh: ULD Gedung A" 
                                value="${existingData.name || ''}"
                                ${isProfileLocked ? 'disabled' : 'required'}>
                        </div>
                        <div class="mb-3">
                            <label class="form-label fw-bold">
                                <i class="bi bi-geo-alt text-muted me-1"></i>Alamat ULD <span class="text-danger">*</span>
                            </label>
                            <textarea 
                                name="uld_locations[${i}][address]" 
                                class="form-control" 
                                rows="2" 
                                placeholder="Alamat lengkap lokasi ULD"
                                ${isProfileLocked ? 'disabled' : 'required'}>${existingData.address || ''}</textarea>
                        </div>
                        <div class="mb-0">
                            <label class="form-label fw-bold">
                                <i class="bi bi-signpost text-muted me-1"></i>Kecamatan <span class="text-danger">*</span>
                            </label>
                            <input type="text" 
                                name="uld_locations[${i}][kecamatan]" 
                                class="form-control" 
                                placeholder="Nama kecamatan" 
                                value="${existingData.kecamatan || ''}"
                                ${isProfileLocked ? 'disabled' : 'required'}>
                        </div>
                    </div>
                </div>
            `;
            
            uldLocationsContainer.insertAdjacentHTML('beforeend', formHtml);
        }
    }
});
</script>
<?php $__env->stopPush(); ?>

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