/* =========================================
   Trip Print - A4
   ========================================= */

:root {
    /* ขนาดกระดาษจริง (mm) — ค่าตั้งต้น A4 ถ้าหน้าไม่ได้ override ผ่าน HeadContent
       (ดูหน้า "จัดตำแหน่งใบทริป" สำหรับการตั้งค่าขนาดกระดาษจริงต่อ Template) */
    --print-page-width: 210mm;
    --print-page-height: 297mm;
}

@page {
    size: 210mm 297mm;
    margin: 0;
}


/* =========================================
   Base
   ========================================= */

html,
body {
    margin: 0;
    padding: 0;
}


/* =========================================
   A4 Paper
   ========================================= */

.trip-print-page {
    position: relative;

    width: var(--print-page-width, 210mm);
    height: var(--print-page-height, 297mm);

    min-width: var(--print-page-width, 210mm);
    max-width: var(--print-page-width, 210mm);

    min-height: var(--print-page-height, 297mm);
    max-height: var(--print-page-height, 297mm);

    margin: 0 auto;
    padding: 0;

    box-sizing: border-box;

    overflow: hidden;

    background-repeat: no-repeat;
    background-position: 0 0;
    background-size: var(--print-page-width, 210mm) var(--print-page-height, 297mm);

    font-family: Tahoma, sans-serif;
    font-size: 12pt;

    color: #000;
}


/* =========================================
   Form Background
   ========================================= */

.trip-print-page.show-template {
    background-image:
        url('/forms/trip-form-a4-template-300dpi_v3.png');
}


/* =========================================
   Fields
   ========================================= */

.trip-print-field {

    position: absolute;

    margin: 0;
    padding: 0;

    box-sizing: border-box;

    white-space: nowrap;

    line-height: 1;

    font-family: Tahoma, sans-serif;
    font-size: 12pt;

    color: red;
}


/* =========================================
   จุดอ้างอิงมุมกระดาษ (Calibration Corner Marks)
   ========================================= */

.corner-mark {
    display: flex;
    align-items: center;
    justify-content: center;

    text-align: center;
    line-height: 1;

    font-size: 18pt;
    font-weight: 700;

    color: #ff0000;

    white-space: normal;
}


/* =========================================
   ตัวอย่างตำแหน่ง
   ========================================= */

.trip-no {
    left: 167mm;
    top: 19mm;
}

.vehicle-no {
    left: 62mm;
    top: 28mm;
}

.depart-date {
    left: 64mm;
    top: 37mm;
}

.return-date {
    left: 130mm;
    top: 37mm;
}

.days {
    left: 145mm;
    top: 45mm;
}

.distance {
    left: 64mm;
    top: 46mm;
}

.driver {
    left: 42mm;
    top: 195mm;
}

.expense-total {
    left: 150mm;
    top: 130mm;
}

.prepared-by {
    left: 40mm;
    top: 211mm;
}


/* =========================================
   Toolbar
   ========================================= */

.trip-print-toolbar {
    width: 100%;

    padding: 15px;

    background: #f5f6f8;

    box-sizing: border-box;
}

.trip-print-toolbar button {
    padding: 8px 18px;

    border: 0;
    border-radius: 6px;

    background: #0f2742;
    color: white;

    cursor: pointer;
}

.trip-print-toolbar label {
    margin-left: 15px;
}


/* =========================================
   Calibration
   ========================================= */

.trip-print-page.calibration
.trip-print-field {

    cursor: move;

    user-select: none;
}

.trip-print-page.calibration
.trip-print-field:hover {

    outline: 1px dashed #2563eb;

    background: rgba(37, 99, 235, 0.08);
}

.trip-print-page.calibration
.trip-print-field.dragging {

    outline: 2px solid #2563eb;

    background: rgba(37, 99, 235, 0.15);

    z-index: 9999;

    cursor: grabbing;
}


/* =========================================
   Position Panel
   ========================================= */

.trip-position-panel {

    position: fixed;

    right: 20px;
    bottom: 20px;

    min-width: 220px;

    padding: 14px 16px;

    background: white;

    border: 1px solid #ddd;

    border-radius: 8px;

    box-shadow: 0 5px 20px rgba(0,0,0,.15);

    z-index: 10000;

    font-family: Tahoma, sans-serif;
    font-size: 13px;
}

.trip-position-panel .title {

    font-weight: 600;

    margin-bottom: 8px;
}

.trip-position-row {

    display: flex;

    justify-content: space-between;

    margin-top: 4px;
}

.trip-position-value {

    font-weight: 600;

    color: #2563eb;
}


/* =========================================
   PRINT
   ========================================= */

@media print {

    /* -----------------------------
       Paper
       ----------------------------- */

    @page {
        size: 210mm 297mm;
        margin: 0;
    }


    html,
    body {

        width: var(--print-page-width, 210mm) !important;
        height: var(--print-page-height, 297mm) !important;

        min-width: var(--print-page-width, 210mm) !important;
        min-height: var(--print-page-height, 297mm) !important;

        margin: 0 !important;
        padding: 0 !important;

        overflow: hidden !important;

        background: transparent !important;
    }


    /* -----------------------------
       Hide UI
       ----------------------------- */

    .no-print,
    .trip-print-toolbar,
    .trip-position-panel {

        display: none !important;
    }


    /* -----------------------------
       A4
       ----------------------------- */

    .trip-print-page {

        position: relative;

        width: var(--print-page-width, 210mm) !important;
        height: var(--print-page-height, 297mm) !important;

        min-width: var(--print-page-width, 210mm) !important;
        max-width: var(--print-page-width, 210mm) !important;

        min-height: var(--print-page-height, 297mm) !important;
        max-height: var(--print-page-height, 297mm) !important;

        margin: 0 !important;
        padding: 0 !important;

        box-sizing: border-box;

        overflow: hidden !important;

        transform: none !important;
    }


    /* -----------------------------
       Field
       ----------------------------- */

    .trip-print-field {

        position: absolute !important;

        margin: 0 !important;
        padding: 0 !important;

        transform: none !important;

        color: #000 !important;
    }


    /* -----------------------------
       Calibration
       ----------------------------- */

    .trip-print-page.calibration
    .trip-print-field {

        cursor: default;

        outline: none !important;

        background: transparent !important;
    }


    /* -----------------------------
       Background
       
       กรณีใช้ฟอร์มกระดาษจริง
       ไม่ต้องพิมพ์ Background
       ----------------------------- */

    .trip-print-page.show-template {

        background-image: none !important;
    }
}