<?php $__env->startSection('content'); ?>

<style>
    /* --- Global Dark Mode & Modern Overrides --- */
    .modern-card {
        background-color: var(--bg-card, #1e293b);
        border: 1px solid var(--border-color, #334155);
        border-radius: 20px;
    }
    
    [data-theme="dark"] .card,
    [data-theme="dark"] .modal-content {
        background-color: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-main); border-radius: 24px;
    }
    [data-theme="dark"] .card-header, [data-theme="dark"] .modal-header, [data-theme="dark"] .modal-footer { border-color: var(--border-color); }
    [data-theme="dark"] .modal-header { border-top-left-radius: 24px; border-top-right-radius: 24px; }
    
    [data-theme="dark"] .form-control, [data-theme="dark"] .form-select {
        background-color: var(--hover-bg); border-color: var(--border-color); color: var(--text-main); border-radius: 12px;
    }
    [data-theme="dark"] .form-control:focus, [data-theme="dark"] .form-select:focus {
        border-color: var(--primary-color); box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
    }
    [data-theme="dark"] .text-muted { color: #cbd5e1 !important; }
    [data-theme="dark"] h2, [data-theme="dark"] h5, [data-theme="dark"] label { color: var(--text-main); }
    
    [data-theme="dark"] .table { color: var(--text-main); border-color: var(--border-color); }
    [data-theme="dark"] .table-light th { background-color: rgba(255,255,255,0.03) !important; color: var(--text-main); border-color: var(--border-color) !important; }
    [data-theme="dark"] .table-hover tbody tr:hover { background-color: rgba(255, 255, 255, 0.05); color: var(--text-main); }
    [data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

    .btn-pill { border-radius: 50rem !important; }
    .form-control, .form-select { border-radius: 12px; }
</style>

<div class="container py-4">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div>
            <h2 class="fw-bold text-white"><i class="bi bi-journal-bookmark me-2 text-primary"></i>Master Mata Pelajaran</h2>
            <p class="text-muted mb-0">Kelola daftar mata pelajaran sekolah.</p>
        </div>
        <button class="btn btn-primary btn-pill px-4 fw-bold shadow-sm" data-bs-toggle="modal" data-bs-target="#modalTambah">
            <i class="bi bi-plus-lg me-1"></i> Tambah Mapel
        </button>
    </div>

    <?php if(session('success')): ?>
        <div class="alert alert-success alert-dismissible fade show rounded-4 bg-success bg-opacity-25 border-0 border-start border-success border-4 text-white shadow-sm">
            <i class="bi bi-check-circle-fill me-2"></i> <?php echo e(session('success')); ?>

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

    <div class="card modern-card shadow-sm border-secondary overflow-hidden">
        <div class="card-body p-0">
            <div class="table-responsive">
                <table class="table table-hover align-middle mb-0 text-white">
                    <thead class="table-light">
                        <tr>
                            <th width="5%" class="px-4 py-3 text-center">No</th>
                            <th width="15%" class="py-3 text-center">Kode Mapel</th>
                            <th class="py-3">Nama Mata Pelajaran</th>
                            <th width="15%" class="py-3 text-center px-4">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $subjects; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td class="px-4 text-center text-muted border-secondary"><?php echo e($index + 1); ?></td>
                            <td class="text-center border-secondary">
                                <span class="badge bg-info bg-opacity-25 text-info border border-info rounded-pill px-3 py-2"><?php echo e($item->code); ?></span>
                            </td>
                            <td class="fw-bold border-secondary"><?php echo e($item->name); ?></td>
                            <td class="text-center px-4 border-secondary">
                                <div class="d-flex justify-content-center gap-2">
                                    <button class="btn btn-sm btn-outline-warning rounded-circle" style="width:35px; height:35px;" 
                                        data-bs-toggle="modal" 
                                        data-bs-target="#modalEdit<?php echo e($item->id); ?>" title="Edit Mapel">
                                        <i class="bi bi-pencil"></i>
                                    </button>
                                    
                                    <form action="<?php echo e(route('mapel.destroy', $item->id)); ?>" method="POST" class="d-inline" onsubmit="return confirm('Hapus mapel ini?')">
                                        <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                        <button class="btn btn-sm btn-outline-danger rounded-circle" style="width:35px; height:35px;" title="Hapus Mapel"><i class="bi bi-trash"></i></button>
                                    </form>
                                </div>
                            </td>
                        </tr>

                        
                        <div class="modal fade" id="modalEdit<?php echo e($item->id); ?>" tabindex="-1">
                            <div class="modal-dialog modal-dialog-centered">
                                <div class="modal-content shadow-lg border-secondary rounded-4">
                                    <div class="modal-header bg-warning border-0 text-dark rounded-top-4 py-3">
                                        <h5 class="modal-title fw-bold"><i class="bi bi-pencil-square me-2"></i> Edit Mata Pelajaran</h5>
                                        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                                    </div>
                                    <form action="<?php echo e(route('mapel.update', $item->id)); ?>" method="POST">
                                        <?php echo csrf_field(); ?> <?php echo method_field('PUT'); ?>
                                        <div class="modal-body p-4">
                                            <div class="mb-4">
                                                <label class="form-label fw-bold small text-muted text-uppercase">Kode Mapel</label>
                                                <input type="text" name="code" class="form-control rounded-pill py-2" value="<?php echo e($item->code); ?>" required>
                                            </div>
                                            <div class="mb-2">
                                                <label class="form-label fw-bold small text-muted text-uppercase">Nama Mata Pelajaran</label>
                                                <input type="text" name="name" class="form-control rounded-pill py-2" value="<?php echo e($item->name); ?>" required>
                                            </div>
                                        </div>
                                        <div class="modal-footer border-0" style="background-color: rgba(255,255,255,0.02);">
                                            <button type="button" class="btn btn-outline-light btn-pill px-4" data-bs-dismiss="modal">Batal</button>
                                            <button type="submit" class="btn btn-warning text-dark btn-pill px-4 fw-bold"><i class="bi bi-check-circle me-1"></i> Simpan Perubahan</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="4" class="text-center py-5 border-0">
                                <div class="text-muted opacity-50 mb-3"><i class="bi bi-journal-x" style="font-size: 4rem;"></i></div>
                                <h5 class="text-white fw-bold">Belum ada data mata pelajaran.</h5>
                            </td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="modalTambah" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content shadow-lg border-secondary rounded-4">
            <div class="modal-header bg-primary border-0 text-white rounded-top-4 py-3">
                <h5 class="modal-title fw-bold"><i class="bi bi-plus-circle me-2"></i> Tambah Mata Pelajaran</h5>
                <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
            </div>
            <form action="<?php echo e(route('mapel.store')); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <div class="modal-body p-4">
                    <div class="mb-4">
                        <label class="form-label fw-bold small text-muted text-uppercase">Kode Mapel</label>
                        <input type="text" name="code" class="form-control rounded-pill py-2" placeholder="Cth: MTK, IND, IPA" required>
                        <small class="text-primary mt-2 d-block"><i class="bi bi-info-circle me-1"></i> Gunakan singkatan unik (Maks 5 karakter disarankan).</small>
                    </div>
                    <div class="mb-2">
                        <label class="form-label fw-bold small text-muted text-uppercase">Nama Mata Pelajaran</label>
                        <input type="text" name="name" class="form-control rounded-pill py-2" placeholder="Cth: Matematika Wajib" required>
                    </div>
                </div>
                <div class="modal-footer border-0" style="background-color: rgba(255,255,255,0.02);">
                    <button type="button" class="btn btn-outline-light btn-pill px-4" data-bs-dismiss="modal">Batal</button>
                    <button type="submit" class="btn btn-primary btn-pill px-5 fw-bold"><i class="bi bi-save me-1"></i> Simpan</button>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/vol15_7/infinityfree.com/if0_40829333/sislajar-skansa.gt.tc/htdocs/resources/views/pages/referensi/mapel/index.blade.php ENDPATH**/ ?>