<?= $this->extend('layout/default') ?>

<?= $this->section('content') ?>
<div class="breadcrumb-area pt-50 pb-50 bg-gray">
    <div class="container">
        <div class="breadcrumb-content text-center">
            <ul>
                <li><a href="<?= base_url() ?>">Beranda</a></li>
                <li class="active">Jurusan</li>
            </ul>
            <h2><?= esc($jurusan['nama_jurusan']) ?></h2>
        </div>
    </div>
</div>

<div class="about-us-area pt-100 pb-100">
    <div class="container">
        <div class="row">
            <div class="col-lg-4 col-md-4">
                <div class="sidebar-widget bg-white p-4 rounded-4 shadow-sm border text-center">
                    <div class="jurusan-meta">
                        <div class="logo-jurusan-wrap mb-4">
                            <?php if ($jurusan['logo_jurusan']) : ?>
                                <img src="<?= base_url('assets/img/jurusan/' . $jurusan['logo_jurusan']) ?>" alt="Logo" class="img-fluid rounded-circle shadow-sm p-2 border border-2 border-success" style="width: 140px; height: 140px; object-fit: cover;">
                            <?php endif; ?>
                        </div>
                        <h4 class="fw-bold text-dark mb-1"><?= esc($jurusan['nama_jurusan']) ?></h4>
                        <p class="text-muted small">SMKN 1 Sukalarang</p>
                        
                        <div class="kaprodi-card mt-4 p-3 rounded-3 bg-light border text-center">
                            <p class="text-uppercase small fw-bold text-success mb-2" style="letter-spacing: 1px;">Ketua Program Keahlian</p>
                            <h6 class="fw-bold text-dark mb-0"><?= esc($jurusan['kaprog'] ?: 'Nama Kaprodi Belum Diisi') ?></h6>
                        </div>

                        <hr class="my-4 opacity-50">
<div class="text-start px-2">
    <p class="small mb-3 text-success fw-bold"><i class="fa fa-users me-2"></i> Guru Produktif :</p>
    <ul class="list-unstyled">
        <?php 
        if ($jurusan['guru_produktif']) :
            $daftar_guru = explode("\n", $jurusan['guru_produktif']);
            foreach ($daftar_guru as $guru) : 
                if (trim($guru) == "") continue;
        ?>
            <li class="small mb-2 text-secondary d-flex align-items-center">
                <i class="fa fa-check-circle text-success me-2" style="font-size: 10px;"></i>
                <?= esc(trim($guru)) ?>
            </li>
        <?php 
            endforeach; 
        else : 
        ?>
            <li class="small text-muted fst-italic">Data guru belum diisi</li>
        <?php endif; ?>
    </ul>
</div>
                    </div>
                </div>
            </div>

            <div class="col-lg-8 col-md-8">
                <div class="about-us-content px-lg-4">
                    
                    <div class="jurusan-profile-header mb-5">
                        <div class="profile-container shadow-lg rounded-4 overflow-hidden bg-dark">
                            <?php if ($jurusan['foto_kegiatan']) : ?>
                                <img src="<?= base_url('assets/img/kegiatan/' . $jurusan['foto_kegiatan']) ?>" 
                                     alt="Profil Utama" 
                                     class="img-fluid profile-main-img">
                                <div class="image-footer p-3 bg-success text-white text-center">
                                    <small class="fw-bold text-uppercase"><i class="fa fa-image me-2"></i> Profil Program Keahlian <?= esc($jurusan['nama_jurusan']) ?></small>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>
                    
                    <div class="row g-4 mb-5">
                        <div class="col-md-5">
    <div class="vision-box p-4 rounded-4 text-white shadow h-100" style="background: linear-gradient(135deg, #28a745, #1e7e34);">
        <h3 class="fw-bold mb-3 text-white" style="color: #ffffff !important;"><i class="fa fa-eye"></i> Visi</h3>
        
        <p class="fst-italic text-justify text-white" style="font-size: 15px; line-height: 1.6; color: #ffffff !important; opacity: 1 !important;">
            "<?= esc($jurusan['visi_jurusan'] ?: 'Visi belum diisi.') ?>"
        </p>
    </div>
</div>

                        <div class="col-md-7">
                            <div class="mission-box p-4 rounded-4 bg-light border shadow-sm h-100">
                                <h3 class="fw-bold mb-3 text-success"><i class="fa fa-bullseye"></i> Misi</h3>
                                <ul class="list-unstyled mb-0">
                                    <?php 
                                    $misi_items = explode("\n", $jurusan['misi_jurusan']);
                                    foreach ($misi_items as $item) : 
                                        if (trim($item) == "") continue;
                                    ?>
                                        <li class="mb-2 d-flex align-items-start">
                                            <span class="badge bg-success-light text-success me-3 rounded-circle p-2">
                                                <i class="fa fa-arrow-right" style="font-size: 10px;"></i>
                                            </span>
                                            <span class="text-secondary small text-justify"><?= esc(trim($item)) ?></span>
                                        </li>
                                    <?php endforeach; ?>
                                </ul>
                            </div>
                        </div>
                    </div>

                    <h2 class="fw-bold mb-4 border-bottom pb-3"><i class="fa fa-list-ul text-success"></i> Kompetensi Inti</h2>
                    <div class="row g-3 mb-5">
                        <?php 
                        $poin_kompetensi = explode("\n", $jurusan['deskripsi']);
                        foreach ($poin_kompetensi as $poin) : 
                            if (trim($poin) == "") continue;
                        ?>
                            <div class="col-md-6">
                                <div class="competency-card p-3 rounded-3 shadow-sm bg-white border-start border-4 border-success h-100">
                                    <div class="d-flex align-items-start">
                                        <div class="icon-point me-3">
                                            <i class="fa fa-check text-success"></i>
                                        </div>
                                        <p class="mb-0 fw-medium text-dark small text-justify" style="line-height: 1.4;"><?= esc(trim($poin)) ?></p>
                                    </div>
                                </div>
                            </div>
                        <?php endforeach; ?>
                    </div>

                    <h2 class="fw-bold mb-4 border-bottom pb-3"><i class="fa fa-camera text-success"></i> Galeri Kegiatan</h2>
                    <div class="row g-3">
                        <?php 
                        $db = \Config\Database::connect();
                        $galeri_foto = $db->table('jurusan_galeri')
                                    ->where('id_jurusan', $jurusan['id_jurusan'])
                                    ->get()->getResultArray();

                        if (!empty($galeri_foto)) :
                            foreach ($galeri_foto as $gf) : 
                        ?>
                            <div class="col-md-4 col-6">
                                <div class="gallery-item rounded-3 overflow-hidden shadow-sm position-relative">
                                    <img src="<?= base_url('assets/img/kegiatan/' . $gf['foto']) ?>" 
                                         alt="Kegiatan" class="img-fluid w-100" style="height: 200px; object-fit: cover;">
                                    <div class="gallery-overlay d-flex align-items-center justify-content-center text-white text-center p-2">
                                        <small class="fw-bold">Dokumentasi</small>
                                    </div>
                                </div>
                            </div>
                        <?php endforeach; else: ?>
                            <div class="col-12 text-center py-4">
                                <p class="text-muted fst-italic small">Belum ada foto galeri.</p>
                            </div>
                        <?php endif; ?>
                    </div>

                    <div class="mt-5 p-4 rounded-3 border-start border-4 border-warning bg-light shadow-sm text-justify">
                        <h4 class="fw-bold mb-2 text-dark">Lulusan Kompeten & Siap Kerja</h4>
                        <p class="mb-0 text-muted small">Membekali siswa dengan keterampilan teknis dan karakter Pancawaluya untuk bersaing di dunia industri.</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    .text-justify { text-align: justify; text-justify: inter-word; }
    .bg-gray { background-color: #f8f9f9; }
    .bg-success-light { background-color: rgba(40, 167, 69, 0.1); }
    .profile-container { width: 100%; background-color: #1a1a1a; }
    .profile-main-img { width: 100%; height: auto; max-height: 600px; object-fit: contain; display: block; margin: 0 auto; }
    .gallery-item:hover img { transform: scale(1.1); transition: 0.3s; }
    .gallery-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(40, 167, 69, 0.7); opacity: 0; transition: 0.3s; }
    .gallery-item:hover .gallery-overlay { opacity: 1; }
    .competency-card { transition: all 0.3s ease; }
    .competency-card:hover { transform: translateY(-5px); background-color: #fafff9 !important; }
    .icon-point { background: #e6f7eb; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0; }
    .sidebar-widget { position: sticky; top: 30px; }
    .kaprodi-card { border-top: 3px solid #28a745 !important; }
</style>
<?= $this->endSection() ?>