<?php 
// 1. Cek Keamanan Login
require_once $_SERVER['DOCUMENT_ROOT'] . '/auth/cek_login.php'; 

// 2. Hubungkan ke database
include $_SERVER['DOCUMENT_ROOT'] . '/assets/db/db.php'; 
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SINKARKES - Panel Input Sertifikat</title>
    
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap" rel="stylesheet">

    <style>
        body { background-color: #f0f2f5; font-family: 'Open Sans', sans-serif; color: #444; }
        .header-top { background: #ffffff; padding: 12px 0; border-bottom: 3px solid #40ada6; margin-bottom: 30px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
        .header-logo { height: 45px; }
        
        .user-info { font-size: 0.85rem; border-right: 1px solid #ddd; padding-right: 15px; margin-right: 15px; }
        .btn-logout { border-radius: 20px; font-weight: 700; font-size: 0.75rem; text-transform: uppercase; padding: 5px 15px; transition: 0.3s; }
        .btn-profil { border-radius: 20px; font-weight: 700; font-size: 0.75rem; text-transform: uppercase; padding: 5px 15px; margin-right: 5px; transition: 0.3s; }

        .card-entry { border: none; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); overflow: hidden; background: #fff; }
        .card-header-custom { background: #40ada6; color: #fff; padding: 20px; border: none; }
        .card-header-custom h5 { margin: 0; font-weight: 700; }
        .section-title { font-size: 0.85rem; font-weight: 700; color: #40ada6; text-transform: uppercase; border-left: 4px solid #40ada6; padding-left: 10px; margin: 25px 0 15px 0; }
        .form-control { border-radius: 8px; border: 1px solid #ced4da; padding: 12px; font-size: 0.9rem; }
        .form-control:focus { border-color: #40ada6; box-shadow: 0 0 0 0.2rem rgba(64, 173, 166, 0.25); }
        label { font-weight: 600; font-size: 0.8rem; color: #666; margin-bottom: 5px; }
        
        .btn-save { background: #40ada6; border: none; border-radius: 8px; padding: 15px; font-weight: 700; text-transform: uppercase; transition: 0.3s; color: white; }
        .btn-save:hover { background: #358e88; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(64, 173, 166, 0.4); color: white; text-decoration: none; }
        .btn-list { background: rgba(255,255,255,0.2); border: 1px solid #fff; color: #fff; border-radius: 6px; font-weight: 600; }
        .btn-list:hover { background: white; color: #40ada6; }
        .vaksin-box { background: #f8f9fa; padding: 20px; border-radius: 10px; border: 1px solid #e9ecef; height: 100%; }
    </style>
</head>
<body>

<div class="header-top">
    <div class="container d-flex justify-content-between align-items-center">
        <a href="admin.php">
            <img src="../assets/img/SINKARKES.png" alt="Logo SINKARKES" class="header-logo">
        </a>
        <div class="d-flex align-items-center">
            <div class="user-info d-none d-md-block text-right">
                <span class="text-muted small">Login sebagai:</span><br>
                <strong class="text-dark"><?php echo $_SESSION['nama_admin']; ?></strong>
            </div>

            <a href="../auth/profil.php" class="btn btn-outline-info btn-profil" title="Ganti Password">
                <i class="fas fa-user-cog"></i> Profil
            </a>

            <a href="../auth/logout.php" class="btn btn-outline-danger btn-logout" onclick="return confirm('Apakah Anda yakin ingin keluar dari sistem?')">
                <i class="fas fa-sign-out-alt mr-1"></i> Logout
            </a>
        </div>
    </div>
</div>

<div class="container mb-5">
    <div class="row justify-content-center">
        <div class="col-xl-10">
            <div class="card card-entry">
                <div class="card-header-custom d-flex justify-content-between align-items-center">
                    <h5><i class="fas fa-file-medical-alt mr-2"></i> ENTRY DATA SERTIFIKAT BARU</h5>
                    <a href="../CRUD/list_sertifikat.php" class="btn btn-list btn-sm">
                        <i class="fas fa-list mr-1"></i> Lihat Database
                    </a>
                </div>
                <div class="card-body p-4 p-md-5">
                    <form action="../CRUD/proses_simpan.php" method="POST">
                        
                        <div class="section-title">Informasi Pasien</div>
                        <div class="row">
                            <div class="col-md-6 form-group">
                                <label>Nama Lengkap (Sesuai Paspor)</label>
                                <input type="text" name="nama_lengkap" class="form-control" placeholder="CONTOH: UMAYAH OTONG" required>
                            </div>
                            <div class="col-md-3 form-group">
                                <label>NIK (KTP)</label>
                                <input type="text" name="nik" class="form-control" placeholder="16 DIGIT NIK" required maxlength="16">
                            </div>
                            <div class="col-md-3 form-group">
                                <label>Jenis Kelamin</label>
                                <select name="jenis_kelamin" class="form-control" required>
                                    <option value="">-- Pilih --</option>
                                    <option value="Male">Male</option>
                                    <option value="Female">Female</option>
                                </select>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-3 form-group">
                                <label>Nomor Paspor</label>
                                <input type="text" name="no_paspor" class="form-control" placeholder="X7708993" required>
                            </div>
                            <div class="col-md-3 form-group">
                                <label>Tanggal Lahir</label>
                                <input type="date" name="tgl_lahir" class="form-control" required>
                            </div>
                            <div class="col-md-6 form-group">
                                <label>Nomor Kode ICV (eICV / Barcode)</label>
                                <input type="text" name="no_icv" id="no_icv" class="form-control" 
                                       placeholder="E25-00001XXXX" 
                                       pattern="E25-[0-9]{9}" 
                                       title="Format penulisan harus: E25-00001XXXX (Contoh: E25-000013213)" 
                                       required>
                                <small class="text-danger font-italic">
                                    * Format penulisan wajib: <strong>E25-00001XXXX</strong>
                                </small>
                            </div>
                        </div>

                        <div class="row mt-3">
                            <div class="col-md-6 mb-4">
                                <div class="vaksin-box">
                                    <div class="section-title mt-0">Vaksinasi 1 (Utama)</div>
                                    <div class="form-group">
                                        <label>Nama Vaksin</label>
                                        <input type="text" name="vaksin_1_nama" class="form-control" value="MENINGITIS MENINGOCOCCUS">
                                    </div>
                                    <div class="form-group">
                                        <label>Batch Number 1</label>
                                        <select name="vaksin_1_batch" class="form-control" required>
                                            <option value="">-- Pilih Batch --</option>
                                            <option value="BIOFARMA B20241126-1">BIOFARMA B20241126-1</option>
                                            <option value="BIOFARMA B20241201-2">BIOFARMA B20241201-2</option>
                                            <option value="BIOFARMA B20241017-2">BIOFARMA B20241017-2</option>
                                        </select>
                                    </div>
                                    <div class="row">
                                        <div class="col-6"><label>Tgl Vaksin</label><input type="date" name="vaksin_1_tgl_admin" class="form-control"></div>
                                        <div class="col-6"><label>Valid Sampai</label><input type="date" name="vaksin_1_valid_sampai" class="form-control"></div>
                                    </div>
                                    <div class="form-group mt-3">
                                        <label>Faskes / Dokter</label>
                                        <select name="vaksin_1_faskes" class="form-control" required>
                                            <option value="">-- Pilih Faskes (Opsional) --</option>
                                            <option value="Klinik Pratama Abdul Karim Medika Center - dr. MEGA ROBBIATY UTOMO">Klinik Pratama Abdul Karim Medika Center / dr. Mega Robbiaty Utomo</option>
                                            <option value="Klinik Pratama Citra Medika - dr. TIARA WINDASARI AGUSTIN">Klinik Pratama Citra Medika / dr. Tiara Windasari Agustin</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            
                            <div class="col-md-6 mb-4">
                                <div class="vaksin-box">
                                    <div class="section-title mt-0">Vaksinasi 2 (Tambahan)</div>
                                    <div class="form-group">
                                        <label>Nama Vaksin</label>
                                        <input type="text" name="vaksin_2_nama" class="form-control" placeholder="POLIO">
                                    </div>
                                    <div class="form-group">
                                        <label>Batch Number 2</label>
                                        <select name="vaksin_2_batch" class="form-control">
                                            <option value="">-- Pilih Batch (Opsional) --</option>
                                            <option value="BIOFARMA 21000125">BIOFARMA 21000125</option>
                                            <option value="BIOFARMA 21000525">BIOFARMA 21000525</option>
                                        </select>
                                    </div>
                                    <div class="row">
                                        <div class="col-6"><label>Tgl Vaksin</label><input type="date" name="vaksin_2_tgl_admin" class="form-control"></div>
                                        <div class="col-6"><label>Valid Sampai</label><input type="date" name="vaksin_2_valid_sampai" class="form-control"></div>
                                    </div>
                                    <div class="form-group mt-3">
                                        <label>Faskes / Dokter</label>
                                        <select name="vaksin_2_faskes" class="form-control">
                                            <option value="">-- Pilih Faskes (Opsional) --</option>
                                            <option value="Klinik Pratama Abdul Karim Medika Center - dr. MEGA ROBBIATY UTOMO">Klinik Pratama Abdul Karim Medika Center / dr. Mega Robbiaty Utomo</option>
                                            <option value="Klinik Pratama Citra Medika - dr. TIARA WINDASARI AGUSTIN">Klinik Pratama Citra Medika / dr. Tiara Windasari Agustin</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <button type="submit" class="btn btn-save btn-block btn-lg mt-2 shadow-sm">
                            <i class="fas fa-save mr-2"></i> Simpan & Simulasikan Sertifikat
                        </button>
                    </form>
                </div>
            </div>
            <p class="text-center mt-4 text-muted small">&copy; 2026 Balai Kekarantinaan Kesehatan - Kemenkes RI</p>
        </div>
    </div>
</div>

<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>