<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style type="text/css">
        /* Reset margins for full control */
        @page {
            margin: 0;
            size: a4 portrait;
        }
        * {
            box-sizing: border-box;
        }
        body {
            margin: 0;
            padding: 0;
            font-family: 'Times New Roman', serif;
            background-color: #ffffff;
        }

        /* The Master Table ensures everything stays on ONE page */
        .master-table {
            width: 100%;
            height: 100%; /* Spans exactly one A4 page */
            border-collapse: collapse;
        }

        .page-padding {
            padding: 40px; /* Outer white space */
            vertical-align: middle;
        }

        /* The Double Border logic using nested containers */
        .outer-border {
            border: 1px solid #000;
            padding: 4px; /* Space for the double line effect */
            height: 1000px; /* Fixed height to prevent page spill */
            width: 100%;
        }

        .inner-border {
            border: 2px solid #000;
            height: 100%;
            width: 100%;
            padding: 50px 30px;
            text-align: center;
            position: relative; /* Essential for absolute footer */
        }

        /* Content Styles */
        h1 {
            font-size: 30pt;
            text-decoration: underline;
            margin: 0 0 20px 0;
            font-weight: bold;
        }
        h2 {
            font-size: 20pt;
            margin: 0 0 10px 0;
            font-weight: bold;
        }
        .category {
            font-size: 16pt;
            font-weight: bold;
            text-decoration: underline;
            margin-bottom: 30px;
        }
        .logo-box {
            margin: 20px auto 40px auto;
        }
        .logo-box img {
            width: 180px;
            height: auto;
        }
        .project-title {
            font-size: 16pt;
            font-weight: bold;
            line-height: 1.4;
            text-transform: uppercase;
            margin: 0 auto 40px auto;
            max-width: 90%;
        }
        .cost-section {
            font-size: 18pt;
            font-weight: bold;
            text-decoration: underline;
            margin-bottom: 50px;
        }

        /* Bottom Anchored Logic */
        .footer-container {
            position: absolute;
            bottom: 60px;
            left: 0;
            right: 0;
            text-align: center;
        }
        .footer-info {
            font-size: 12pt;
            line-height: 1.5;
            text-transform: uppercase;
            font-weight: bold;
        }
        .page-number {
            position: absolute;
            bottom: 20px;
            right: 20px;
            font-size: 10pt;
            color: #333;
        }
    </style>
</head>
<body class="cover-pdf">
    <table class="master-table">
        <tr>
            <td class="page-padding">
                <div class="outer-border">
                    <div class="inner-border">
                        
                        <h1>{{ $mainTitle }}</h1>
                        <h2>{{ $departmentName }}</h2>
                        <div class="category">{{ $schemeTypeYear }}</div>

                        <div class="logo-box">
                            <img src="{{ $logoDataUri }}" alt="Logo">
                        </div>

                        <div class="project-title">
                            {!! $schemeNameHtml !!}
                        </div>

                        <div class="cost-section">
                            {{ $costLine }}
                        </div>

                        <div class="footer-container">
                            <div class="footer-info">
                                THE PC-I / ESTIMATE HAS BEEN PREPARED IN THE OFFICE OF<br>
                                {{ $preparerDesignation }}, {{ $preparerDepartment }}, KMC.
                            </div>
                        </div>

                        <div class="page-number">{{ $pageNumberLine }}</div>

                    </div>
                </div>
            </td>
        </tr>
    </table>
</body>
</html>