<style>
    /* Shared report table — keep ALL columns visible in Dompdf */
    <?php
    if (!function_exists('app_font_pdf')) {
        $CI =& get_instance();
        $CI->load->helper('settings');
    }
    $pdf_font = app_font_pdf();
    ?>
    body {
        font-family: '<?php echo htmlspecialchars($pdf_font); ?>', DejaVu Sans, sans-serif;
    }
    .table {
        border-collapse: collapse;
        border-spacing: 0;
        width: 100%;
        table-layout: fixed;
        float: none;
        margin: 0;
        font-size: 10.5px;
        line-height: 1.35;
        text-align: left;
        font-family: '<?php echo htmlspecialchars($pdf_font); ?>', DejaVu Sans, sans-serif;
    }

    .table th,
    .table td {
        padding: 4px 4px;
        border: 1px solid #333;
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
        vertical-align: top;
        white-space: normal;
    }

    .table th {
        text-align: center;
        font-weight: bold;
        background: #f0f0f0;
        font-size: 10px;
    }

    .table td {
        text-align: left;
    }

    .header-table {
        width: 100%;
        border-collapse: collapse;
        border: none;
        margin: 0;
        padding: 0;
        table-layout: fixed;
    }

    .header-table td {
        border: none;
        vertical-align: middle;
        padding: 0;
    }

    .logo-left {
        width: 20%;
        text-align: left;
    }

    .logo-middle {
        width: 60%;
        text-align: center;
    }

    .logo-right {
        width: 20%;
        text-align: right;
    }

    .krc-logo,
    .dlrl-logo {
        width: 90px;
        height: auto;
    }

    .header-title {
        font-size: 16px;
        line-height: 20px;
        margin: 0;
        padding: 0;
        font-weight: bold;
    }

    .header-subtitle {
        font-size: 14px;
        line-height: 18px;
        margin: 3px 0 0 0;
        padding: 0;
        font-weight: bold;
    }

    .header-location {
        font-size: 12px;
        line-height: 16px;
        margin: 3px 0 0 0;
        padding: 0;
        font-weight: bold;
    }

    #footer {
        position: fixed;
        left: 0px;
        bottom: -50px;
        right: 0px;
        height: 42px;
        border-top: 1px solid #000;
    }

    #footer .page:after {
        content: counter(page, decimal);
    }
</style>
<?php
$this->load->helper('report');

$logo1 = '';
$logo2 = '';
if ($this->session->userdata('loggedin')) {
    $logo1 = $this->session->userdata('logo1');
    $logo2 = $this->session->userdata('logo2');
}

// Dompdf cannot reliably fetch http(s) logo URLs — embed as data-URI from local files
$logo1_src = '';
$logo2_src = '';
$logo1_file = report_export_logo_file($logo1, 'uploads/univlogo/KRC_logo.png');
$logo2_file = report_export_logo_file($logo2, 'uploads/univlogo/DLRL_logo.png');
if ($logo1_file) {
    $logo1_src = 'data:' . $logo1_file['mime'] . ';base64,' . base64_encode($logo1_file['data']);
}
if ($logo2_file) {
    $logo2_src = 'data:' . $logo2_file['mime'] . ';base64,' . base64_encode($logo2_file['data']);
}
?>
<?php
$show_title = !isset($show_title) ? true : (bool) $show_title;
if ($show_title) {
?>
<table class="header-table">
    <tr>
        <td class="logo-left">
            <?php if ($logo1_src) { ?>
            <img src="<?php echo htmlspecialchars($logo1_src); ?>" alt="KRC Logo" class="krc-logo" width="90" height="90" style="width:90px;height:auto;">
            <?php } ?>
        </td>
        <td class="logo-middle">
            <p class="header-title">Knowledge Resource Centre (KRC)</p>
            <p class="header-subtitle">DLRL</p>
            <p class="header-location">Hyderabad</p>
        </td>
        <td class="logo-right">
            <?php if ($logo2_src) { ?>
            <img src="<?php echo htmlspecialchars($logo2_src); ?>" alt="DLRL Logo" class="dlrl-logo" width="90" height="90" style="width:90px;height:auto;">
            <?php } ?>
        </td>
    </tr>
</table>
<br>
<?php } ?>
