<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Laser Marking Stopped Consolidated Report</title>
</head>

<body style="margin:0; padding:0; background-color:#eef2f7; font-family:Arial, Helvetica, sans-serif;">

<table width="100%" cellpadding="0" cellspacing="0" border="0"
       style="background-color:#eef2f7; padding:35px 10px;">

    <tr>
        <td align="center">

            <!-- MAIN CONTAINER -->
            <table width="760" cellpadding="0" cellspacing="0" border="0"
                   style="max-width:760px; width:100%; background:#ffffff; border-radius:14px; overflow:hidden;">

                <tr>
                    <td style="background:#111827; padding:28px 32px;">

                        <table width="100%" cellpadding="0" cellspacing="0" border="0">

                            <tr>

                                <td valign="middle">

                                    <!-- Company -->
                                    <div style="
                                        font-size:12px;
                                        color:#94a3b8;
                                        text-transform:uppercase;
                                        letter-spacing:1.5px;
                                        font-weight:bold;
                                    ">
                                        CRI Digital Manufacturing
                                    </div>

                                    <!-- Title -->
                                    <div style="
                                        font-size:28px;
                                        color:#ffffff;
                                        font-weight:bold;
                                        margin-top:7px;
                                        line-height:34px;
                                    ">
                                        Laser Marking Stoppage Report
                                    </div>

                                    <!-- Subtitle -->
                                    <div style="
                                        font-size:13px;
                                        color:#cbd5e1;
                                        margin-top:7px;
                                    ">
                                        Consolidated report of machine stoppage records
                                    </div>

                                </td>


                                <!-- Report Icon -->
                                <td align="right" valign="middle">

                                    <table cellpadding="0" cellspacing="0" border="0">
                                        <tr>
                                            <td align="center"
                                                style="
                                                    width:54px;
                                                    height:54px;
                                                    background:#1e293b;
                                                    border:1px solid #475569;
                                                    border-radius:12px;
                                                    color:#ffffff;
                                                    font-size:23px;
                                                    font-weight:bold;
                                                ">
                                                LMSR
                                            </td>
                                        </tr>
                                    </table>

                                </td>

                            </tr>

                        </table>

                    </td>
                </tr>

                <tr>
                    <td style="height:4px; background:#2563eb; font-size:0; line-height:0;">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td style="padding:28px 32px 12px 32px;">

                        <table width="100%" cellpadding="0" cellspacing="0" border="0">

                            <tr>

                                <!-- LEFT -->
                                <td width="50%" valign="top">

                                    <div style="
                                        font-size:11px;
                                        color:#94a3b8;
                                        text-transform:uppercase;
                                        letter-spacing:1px;
                                        font-weight:bold;
                                    ">
                                        Report Type
                                    </div>

                                    <div style="
                                        font-size:15px;
                                        color:#1e293b;
                                        font-weight:bold;
                                        margin-top:5px;
                                    ">
                                        Consolidated Report
                                    </div>

                                </td>


                                <!-- RIGHT -->
                                <td width="50%" valign="top" align="right">

                                    <div style="
                                        font-size:11px;
                                        color:#94a3b8;
                                        text-transform:uppercase;
                                        letter-spacing:1px;
                                        font-weight:bold;
                                    ">
                                        Generated On
                                    </div>

                                    <div style="
                                        font-size:15px;
                                        color:#1e293b;
                                        font-weight:bold;
                                        margin-top:5px;
                                    ">
                                        {{ now()->format('d M Y, h:i A') }}
                                    </div>

                                </td>

                            </tr>

                        </table>

                    </td>
                </tr>

                @php
                    $reportStart = now()->subDay()->setTime(8, 0, 0);
                    $reportEnd = now()->setTime(8, 0, 0);
                @endphp

                <tr>
                    <td style="padding:15px 32px 20px 32px;">

                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                               style="
                                   background:#f8fafc;
                                   border:1px solid #e2e8f0;
                                   border-radius:10px;
                               ">

                            <tr>

                                <td style="padding:17px 18px;">

                                    <div style="
                                        font-size:14px;
                                        color:#1e293b;
                                        font-weight:bold;
                                    ">
                                        Laser Marking Stoppage Summary
                                    </div>

                                    <div style="
                                        font-size:12px;
                                        color:#64748b;
                                        line-height:19px;
                                        margin-top:5px;
                                    ">
                                        The following laser marking machine stoppage records were identified
                                        during the reporting period from
                                        <strong>
                                            {{ $reportStart->format('d M Y, h:i A') }}
                                        </strong>
                                        to
                                        <strong>
                                            {{ $reportEnd->format('d M Y, h:i A') }}
                                        </strong>.
                                        Please review the details and take the necessary action.
                                    </div>

                                </td>

                            </tr>

                        </table>

                    </td>
                </tr>

                <tr>
                    <td style="padding:5px 32px 15px 32px;">

                        <table width="100%" cellpadding="0" cellspacing="0" border="0">

                            <tr>

                                <td>

                                    <div style="
                                        font-size:19px;
                                        font-weight:bold;
                                        color:#111827;
                                    ">
                                        Stoppage Details
                                    </div>

                                    <div style="
                                        font-size:12px;
                                        color:#94a3b8;
                                        margin-top:4px;
                                    ">
                                        {{ $records->count() }} record(s) found
                                    </div>

                                </td>

                                <td align="right" valign="bottom">

                                    <div style="
                                        display:inline-block;
                                        background:#eff6ff;
                                        color:#1d4ed8;
                                        border:1px solid #bfdbfe;
                                        padding:6px 10px;
                                        border-radius:6px;
                                        font-size:10px;
                                        font-weight:bold;
                                        text-transform:uppercase;
                                    ">
                                        Consolidated
                                    </div>

                                </td>

                            </tr>

                        </table>

                    </td>
                </tr>

                <tr>
                    <td style="padding:0 32px 30px 32px;">

                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                               style="
                                   border-collapse:collapse;
                                   font-size:12px;
                                   border:1px solid #e2e8f0;
                                   border-radius:8px;
                                   overflow:hidden;
                               ">

                            <!-- TABLE HEADER -->

                            <thead>

                                <tr style="background:#1e293b;">

                                    <th align="center"
                                        style="
                                            padding:13px 8px;
                                            color:#ffffff;
                                            font-size:11px;
                                            font-weight:bold;
                                            border-right:1px solid #334155;
                                        ">
                                        No
                                    </th>

                                    <th align="left"
                                        style="
                                            padding:13px 9px;
                                            color:#ffffff;
                                            font-size:11px;
                                            font-weight:bold;
                                            border-right:1px solid #334155;
                                        ">
                                        Plant
                                    </th>

                                    <th align="left"
                                        style="
                                            padding:13px 9px;
                                            color:#ffffff;
                                            font-size:11px;
                                            font-weight:bold;
                                            border-right:1px solid #334155;
                                        ">
                                        Machine
                                    </th>

                                    <th align="left"
                                        style="
                                            padding:13px 9px;
                                            color:#ffffff;
                                            font-size:11px;
                                            font-weight:bold;
                                            border-right:1px solid #334155;
                                        ">
                                        Production Order
                                    </th>

                                    <th align="left"
                                        style="
                                            padding:13px 9px;
                                            color:#ffffff;
                                            font-size:11px;
                                            font-weight:bold;
                                            border-right:1px solid #334155;
                                        ">
                                        Item Code
                                    </th>

                                    <th align="left"
                                        style="
                                            padding:13px 9px;
                                            color:#ffffff;
                                            font-size:11px;
                                            font-weight:bold;
                                            border-right:1px solid #334155;
                                        ">
                                        Serial Number
                                    </th>

                                    <th align="center"
                                        style="
                                            padding:13px 8px;
                                            color:#ffffff;
                                            font-size:11px;
                                            font-weight:bold;
                                        ">
                                        Status
                                    </th>

                                    <th align="center"
                                        style="
                                            padding:13px 8px;
                                            color:#ffffff;
                                            font-size:11px;
                                            font-weight:bold;
                                        ">
                                        Stopped At
                                    </th>

                                    <th align="center"
                                        style="
                                            padding:13px 8px;
                                            color:#ffffff;
                                            font-size:11px;
                                            font-weight:bold;
                                        ">
                                        Stopped By
                                    </th>

                                </tr>

                            </thead>

                            <tbody>

                                @foreach($records as $index => $record)

                                    <tr style="background:{{ $index % 2 == 0 ? '#ffffff' : '#f8fafc' }};">

                                        <td align="center"
                                            style="
                                                padding:14px 8px;
                                                border-bottom:1px solid #e5e7eb;
                                                color:#64748b;
                                                font-weight:bold;
                                            ">
                                            {{ $index + 1 }}
                                        </td>

                                        <td style="
                                            padding:14px 9px;
                                            border-bottom:1px solid #e5e7eb;
                                            color:#334155;
                                            white-space: nowrap;
                                        ">
                                            {{ $plantName }}
                                        </td>


                                        <!-- MACHINE -->

                                        <td style="
                                            padding:14px 9px;
                                            border-bottom:1px solid #e5e7eb;
                                            color:#1e293b;
                                            font-weight:bold;
                                        ">
                                            {{ $machineName }}
                                        </td>

                                        <td style="
                                            padding:14px 9px;
                                            border-bottom:1px solid #e5e7eb;
                                            color:#1e293b;
                                            font-weight:bold;
                                        ">
                                            {{ $record->aufnr }}
                                        </td>


                                        <!-- ITEM CODE -->

                                        <td style="
                                            padding:14px 9px;
                                            border-bottom:1px solid #e5e7eb;
                                            color:#475569;
                                        ">
                                            {{ $record->item?->code ?? $record->item_id }}
                                        </td>


                                        <!-- SERIAL NUMBER -->

                                        <td style="
                                            padding:14px 9px;
                                            border-bottom:1px solid #e5e7eb;
                                            color:#475569;
                                        ">
                                            {{ $record->gernr }}
                                        </td>


                                        <!-- STATUS -->

                                        <td align="center"
                                            style="
                                                padding:14px 8px;
                                                border-bottom:1px solid #e5e7eb;
                                            ">

                                            <span style="
                                                display:inline-block;
                                                background:#fff1f2;
                                                color:#be123c;
                                                border:1px solid #fecdd3;
                                                padding:5px 9px;
                                                border-radius:20px;
                                                font-size:9px;
                                                font-weight:bold;
                                                letter-spacing:.5px;
                                            ">
                                                STOPPED
                                            </span>

                                        </td>

                                        <td style="
                                            padding:14px 9px;
                                            border-bottom:1px solid #e5e7eb;
                                            color:#1e293b;
                                            font-weight:bold;
                                            white-space: nowrap;
                                        ">
                                            {{ $record->stopped_datetime }}
                                        </td>

                                        <td style="
                                            padding:14px 9px;
                                            border-bottom:1px solid #e5e7eb;
                                            color:#1e293b;
                                            font-weight:bold;
                                            white-space: nowrap;
                                        ">
                                            {{ $record->stopped_by }}
                                        </td>

                                    </tr>

                                @endforeach

                            </tbody>

                        </table>

                    </td>
                </tr>

                <tr>
                    <td style="padding:0 32px 28px 32px;">

                        <table width="100%" cellpadding="0" cellspacing="0" border="0"
                               style="
                                   background:#fffbeb;
                                   border:1px solid #fde68a;
                                   border-radius:9px;
                               ">

                            <tr>

                                <td width="6"
                                    style="
                                        background:#f59e0b;
                                        border-radius:9px 0 0 9px;
                                    ">
                                    &nbsp;
                                </td>

                                <td style="padding:15px 17px;">

                                    <div style="
                                        font-size:13px;
                                        font-weight:bold;
                                        color:#92400e;
                                    ">
                                        Action Required
                                    </div>

                                    <div style="
                                        font-size:12px;
                                        color:#78350f;
                                        line-height:18px;
                                        margin-top:4px;
                                    ">
                                        Please review the above stopped machine records
                                        and take the necessary corrective action.
                                    </div>

                                </td>

                            </tr>

                        </table>

                    </td>
                </tr>

                <tr>

                    <td style="
                        background:#f8fafc;
                        padding:22px 32px;
                        border-top:1px solid #e2e8f0;
                    ">

                        <table width="100%" cellpadding="0" cellspacing="0" border="0">

                            <tr>

                                <td align="center">

                                    <div style="
                                        font-size:12px;
                                        color:#64748b;
                                        line-height:19px;
                                    ">

                                        This is an automated report from

                                        <strong style="color:#334155;">
                                            CRI Digital Manufacturing
                                        </strong>.

                                        <br>

                                        Please do not reply to this automated notification.

                                    </div>


                                    <div style="
                                        margin-top:12px;
                                        font-size:11px;
                                        color:#94a3b8;
                                    ">

                                        © {{ date('Y') }} {{ $company }}

                                        &nbsp;•&nbsp;

                                        Automated Laser Marking Stopped Consolidated Report

                                    </div>

                                </td>

                            </tr>

                        </table>

                    </td>

                </tr>

            </table>

        </td>
    </tr>

</table>

</body>
</html>
