<!DOCTYPE html>
<html>
<head>
    <title>Formulario Orientasaun Trabalho Final Do Curso</title>
    <style>
        body { font-family: 'Times New Roman', Times, serif; font-size: 13px; color: #000; background: #fff; margin: 0; padding: 20px; }
        .sheet { width: 100%; max-width: 800px; margin: 0 auto; box-sizing: border-box; }
        .header-table { width: 100%; border-collapse: collapse; margin-bottom: 5px; }
        .header-table td { border: none !important; padding: 0; vertical-align: middle; }
        .logo-left, .logo-right { width: 75px; height: 75px; object-fit: contain; }
        .header-center { text-align: center; }
        .inst-title { font-size: 15px; font-weight: bold; margin: 0; text-transform: uppercase; }
        .dept-title { font-size: 13px; font-weight: bold; margin: 2px 0; text-transform: uppercase; }
        .address { font-size: 11px; margin: 1px 0; }
        .garis-pembatas { border-top: 2.5px solid #000; margin-top: 6px; margin-bottom: 12px; width: 100%; }
        
        .form-title-box { text-align: center; font-weight: bold; font-size: 13px; text-decoration: underline; margin-bottom: 15px; text-transform: uppercase; letter-spacing: 0.5px; }
        
        .identity-table { width: 100%; border-collapse: collapse; margin-bottom: 15px; font-size: 13px; }
        .identity-table td { border: none !important; padding: 3px 2px; vertical-align: top; }
        .label-col { width: 220px; font-weight: bold; text-transform: uppercase; }
        .separator-col { width: 15px; text-align: center; font-weight: bold; }
        
        /* Perapian Tabel Konsultasi */
        .konsultasi-table { width: 100%; border-collapse: collapse !important; margin-top: 10px; page-break-inside: auto; }
        .konsultasi-table th, .konsultasi-table td { border: 1px solid #000 !important; padding: 5px 6px; text-align: center; vertical-align: middle; font-size: 12px; }
        .konsultasi-table th { background-color: #f2f2f2 !important; -webkit-print-color-adjust: exact; font-weight: bold; text-transform: uppercase; }
        .konsultasi-table tr { page-break-inside: avoid; page-break-after: auto; }
        
        .col-nu { width: 40px; }
        .col-loron { width: 120px; }
        .col-materia { text-align: left !important; height: 28px; } 
        .col-assinatura { width: 140px; }

        .signature-section { margin-top: 20px; width: 100%; page-break-inside: avoid; }
        .signature-table { width: 100%; border-collapse: collapse; }
        .signature-table td { border: none !important; vertical-align: top; text-align: center; font-size: 13px; }

        @media print { 
            .no-print { display: none !important; }
            body { padding: 0; }
            .konsultasi-table th { background-color: #f2f2f2 !important; -webkit-print-color-adjust: exact; }
        }

        /* --- PENGATURAN UKURAN LOGO --- */
        .logo-left { 
            width: 75px; 
            height: auto; 
            object-fit: contain; 
        }
        .logo-right { 
            width: 110px; 
            height: auto; 
            object-fit: contain; 
        }
    </style>
</head>
<body>

<div class="sheet">
    <!-- Tombol Navigasi (Otomatis tersembunyi saat dicetak) -->
    <div class="no-print" style="margin-bottom: 20px;">
        <button onclick="window.print()" style="padding: 6px 15px; background: #28a745; color: #fff; border: none; cursor: pointer; border-radius: 4px;">Print PDF</button>
        <a href="<?= base_url('trabalhofinal'); ?>" style="padding: 6px 15px; background: #6c757d; color: #fff; text-decoration: none; border-radius: 4px; margin-left: 10px;">Fila Fali</a>
    </div>

    <!-- Header Surat -->
    <table class="header-table">
        <tr>
            <td style="width: 90px; text-align: left;">
                <img src="<?= base_url('template/img/Logo IPDC.png') ?>" class="logo-left" alt="Logo IPDC">
            </td>
            <td class="header-center">
                <div class="inst-title">INSTITUTO PROFISSIONAL DE CANOSSA</div>
                <div class="dept-title">DEPARTAMENTU TÉCNICAS DE COMPUTAÇÃO E INFORMÁTICA</div>
                <div class="address">Ave. Aldeia Has Laran Delta Comoro Dili</div>
                <div class="address">Telp: 33122803, Email: institutoprofissionaldecanossa@gmail.com</div>
            </td>
            <td style="width: 110px; text-align: right;">
                <img src="<?= base_url('template/img/tci.png') ?>" class="logo-right" alt="Logo TCI">
            </td>
        </tr>
    </table>

    <div class="garis-pembatas"></div>

    <div class="form-title-box">
        FORMULARIO ORIENTASAUN TRABALHO FINAL DO CURSO
    </div>

    <?php if(isset($row)): ?>
    <table class="identity-table">
        <tr>
            <td class="label-col">NARAN ESTUDANTE</td>
            <td class="separator-col">:</td>
            <td><strong><?= $row->naran_estudante; ?></strong></td>
        </tr>
        <tr>
            <td class="label-col">NRE</td>
            <td class="separator-col">:</td>
            <td><strong><?= $row->nre; ?></strong></td>
        </tr>
        <tr>
            <td class="label-col">DEPARTAMENTO</td>
            <td class="separator-col">:</td>
            <td><?= $row->departamentu; ?></td>
        </tr>
        <tr>
            <td class="label-col">TITULU TRABALHO FINAL DO CURSO</td>
            <td class="separator-col">:</td>
            <td><?= $row->titulu; ?></td>
        </tr>
        <tr>
            <td class="label-col">DOSENTE ORIENTADOR I</td>
            <td class="separator-col">:</td>
            <td><?= $row->orientador_1; ?></td>
        </tr>
        <tr>
            <td class="label-col">DOSENTE ORIENTADOR II</td>
            <td class="separator-col">:</td>
            <td><?= $row->orientador_2; ?></td>
        </tr>
    </table>

    <table class="konsultasi-table">
        <thead>
            <tr>
                <th class="col-nu">Nú.</th>
                <th class="col-loron">Loron/ Data</th>
                <th>Materia</th>
                <th class="col-assinatura">Assinatura</th>
            </tr>
        </thead>
        <tbody>
            <?php for($i = 1; $i <= 12; $i++): ?>
            <tr>
                <td class="col-nu"><?= $i; ?></td>
                <td class="col-loron"></td>
                <td class="col-materia"></td>
                <td class="col-assinatura"></td>
            </tr>
            <?php endfor; ?>
        </tbody>
    </table>

    <div class="signature-section">
        <table class="signature-table">
            <tr>
                <td style="width: 50%;"></td>
                <td style="width: 50%; text-align: center;">
                    <?php
                    $bulan = [
                        1 => 'Janeiru', 'Fevereiru', 'Marsu', 'Abril', 'Maiu', 'Junho',
                        'Julho', 'Agustu', 'Setembru', 'Outubru', 'Novembru', 'Dezembru'
                    ];
                    $tgl_sumber = (!empty($row->data)) ? strtotime($row->data) : time();
                    $hari_ini = date('j', $tgl_sumber);
                    $bulan_ini = $bulan[(int)date('n', $tgl_sumber)];
                    $tahun_ini = date('Y', $tgl_sumber);
                    ?>
                    Dili, <?= $hari_ini . ' ' . $bulan_ini . ' ' . $tahun_ini; ?><br><br>
                    <strong>Koodenador/a Departamentu <?= $row->departamentu; ?></strong>
                    <br><br><br><br>
                    <strong>( ........................................................ )</strong>
                </td>
            </tr>
        </table>
    </div>
    <?php endif; ?>

</div>

<!-- Script agar jendela print langsung muncul otomatis -->
<script type="text/javascript">
    window.onload = function() {
        window.print();
    }
</script>

</body>
</html>