<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Vehicle Delivery Undertaking</title>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Gujarati&display=swap" rel="stylesheet">
    <style>
        @page {
            size: A4;
            margin: 2cm;
        }

        html, body {
            margin: 0;
            padding: 0;
            font-family: 'Noto Sans Gujarati', 'Calibri', sans-serif;
            background: #f5f5f5;
            transform: none !important;
        }

        .container {
            width: 21cm;
            min-height: 29.7cm;
            background: #fff;
            margin: 0 auto;
            padding: 2cm;
            padding-bottom: 80px;
            box-shadow: 0 0 5px rgba(0,0,0,0.1);
            font-size: 18px;
            line-height: 1.7;
        }

        .section {
            margin-bottom: 20px;
        }

        .signature {
            margin-top: 60px;
        }

        ol {
            padding-left: 20px;
        }

        .print-button {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            padding: 10px 20px;
            font-size: 16px;
            background-color: #6f7b91;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            z-index: 9999;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
            transition: background-color 0.3s ease;
        }

        .print-button:hover {
            background-color: #0056b3;
        }

        @media print {
            .print-button {
                display: none !important;
            }
        }

        .page-break {
            page-break-before: always;
            break-before: page;
        }
    </style>
</head>
<body>

    <div class="container">
        @php
            function isGujarati($text) {
                return preg_match('/[\x{0A80}-\x{0AFF}]/u', $text);
            }

            function gujaratiDate($date) {
                $gujDigits = ['૦', '૧', '૨', '૩', '૪', '૫', '૬', '૭', '૮', '૯'];
                return str_replace(range(0, 9), $gujDigits, $date);
            }

            function showGujarati($text) {
                $gujDigits = ['૦', '૧', '૨', '૩', '૪', '૫', '૬', '૭', '૮', '૯'];
                $text = str_replace(range(0, 9), $gujDigits, $text ?? '');
                return $text ?: '___________________';
            }

            $isGujarati = isset($data->customer_name) && isGujarati($data->customer_name);
            $todayDate = \Carbon\Carbon::now()->format('d-m-Y');
        @endphp

        <div class="section" style="text-align: center;">
            <strong><u style="font-size: 24px;">બાંયેધરી પત્ર</u></strong>
        </div>

        <div class="section">
            તારીખ : {{ gujaratiDate($todayDate) }}<br />
            પ્રતિ શ્રી મેનેજર,<br />
            પરમ ઓટોમોબાઇલ્સ પ્રા.લી,<br />
            ગાંધીનગર.
        </div>

        <div class="section">
            હું, {{ showGujarati($data->customer_name ?? '') }} આજ રોજ નીચે મુજબ ની ગાડી ખરીદી રહ્યો છું જેની વિગતો નીચે પ્રમાણે છે.
            <ol style="margin-left: 40px;">
                <li>મોડેલ : {{ showGujarati($data->car_model_name ?? '') }}</li>
                <li>કલર : {{ showGujarati($data->exteriorcolor_name ?? '') }}</li>
                <li>ચેસ્સીસ નંબર : {{ showGujarati($data->chassis_number ?? '') }}</li>
                <li>એન્જિન નંબર : {{ showGujarati($data->engine_number ?? '') }}</li>
                <li>ઉત્પાદન નું વર્ષ : {{ showGujarati($data->manufacturing_year ?? '') }}</li>
            </ol>
        </div>

        <div class="section">
            આર ટી ઓ અને કમિશનર ઓફ ટ્રાન્સપોર્ટ, ગુજરાત ના આદેશ મુજબ મને જાણ કરવામાં આવી છે કે નવી ગાડી ની ડિલિવરી નંબર પ્લેટ વિના થશે નહિ...
        </div>

        <div class="section">
            વધુમાં, હું એ પણ સમજું છું અને સ્વીકારું છું કે કારને લગતી તમામ વોરંટી આ પત્રની તારીખથી માન્ય છે...
        </div>

        <div class="section">
            આપનો વિશ્વાસુ,<br />
            <div class="signature">
                નામ : {{ showGujarati($data->customer_name ?? '') }}<br />
                કોન્ટેક્ટ નંબર : {{ showGujarati($data->contact_number ?? '') }}<br />
                તારીખ : {{ gujaratiDate($todayDate) }}
            </div>
        </div>
    </div>

    <div class="page-break"></div>

    <div class="container">
        <div class="section" style="text-align: center;">
            <strong><u style="font-size: 24px;">Undertaking</u></strong>
        </div>

        <div class="section">
            TO,<br />
            The Manager,<br />
            Param Automobiles Pvt. Ltd
        </div>

        <div class="section">
            I, Mr./Mrs/Ms. {{ $data->customer_name ?? '___________________' }}<br />
            Acknowledge following details of my new vehicle delivery.
            <ol style="margin-left: 40px;">
                <li>Model: {{ $data->car_model_name ?? '___________________' }}</li>
                <li>Color: {{ $data->exteriorcolor_name ?? '___________________' }}</li>
                <li>Chassis No: {{ $data->chassis_number ?? '___________________' }}</li>
                <li>Engine No: {{ $data->engine_number ?? '___________________' }}</li>
                <li>Manufactured in: {{ $data->manufacturing_year ?? '___________________' }}</li>
            </ol>
        </div>

        <div class="section">
            Wherein, I am informed that as per the order of RTO and Commissioner of Transport, Gujarat, the delivery of a new vehicle will not be done without a number plate...
        </div>

        <div class="section">
            I understand that after the RTO tax process is completed, I will not make any changes to the variant or color of the new vehicle model and will not cancel the delivery of the vehicle...
        </div>

        <div class="section">
            Additionally, I also understand and acknowledge that all the warranties related to the car are valid from the date of this letter and not from the date which I choose for the delivery of the car.
        </div>

        <div class="section">
            I also agree that the dealership will not be responsible for the choice number.
        </div>

        <div class="section">
            Herewith I provide my undertaking that all documents pertaining to KYC/RTO registration are genuine and valid.
        </div>

        <div class="section">
            Acknowledging acceptance and agreement of the foregoing, I affix my signature here too.
        </div>

        Customer Signature<br />
        <div class="signature">
            Customer Name: {{ $data->customer_name ?? '___________________' }}<br />
            Date of Acknowledgement: {{ \Carbon\Carbon::now()->format('d-m-Y') }}<br />
            Contact Number: {{ $data->contact_number ?? '___________________' }}
        </div>
    </div>

    <button class="print-button" onclick="window.print()">Print</button>

</body>
</html>
