/* Save as pkl-styles.css */
.pkl-container {
    font-family: 'Sarabun', sans-serif;
}

/* Modal Styles */
.pkl-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.pkl-modal-content {
    background: #fff;
    margin: 15% auto;
    padding: 20px;
    width: 80%;
    max-width: 500px;
    border-radius: 5px;
}

/* Print Preview Styles */
.pkl-preview {
    display: none;
}

.pkl-a5-landscape {
    width: 210mm;
    height: 148mm;
    padding: 15mm 10mm;
    margin: 0 auto;
    background: white;
    box-sizing: border-box;
}

.pkl-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.pkl-company-info h1 {
    font-size: 20px;
    font-weight: bold;
    margin: 0;
}

.pkl-customer-info p {
    margin: 3px 0;
    font-size: 14px;
}

/* Table Styles */
.pkl-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 12px;
}

.pkl-items-table th,
.pkl-items-table td {
    border: 1px solid #000;
    padding: 5px;
    text-align: center;
}

.pkl-items-table th {
    background: #f5f5f5;
    font-weight: bold;
    white-space: nowrap;
}

.pkl-items-table td {
    padding: 3px 5px;
}

/* First column (รายการ) alignment */
.pkl-items-table td:first-child {
    text-align: left;
}

/* Summary section */
.pkl-summary {
    margin: 10px 0;
    font-size: 14px;
}

/* Signatures section */
.pkl-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding: 0 10px;
}

.pkl-sign-box {
    flex: 1;
    margin: 0 5px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.pkl-sign-box p {
    margin: 2px 0;
    font-size: 11px;
    order: 2; /* จัดลำดับให้ข้อความอยู่หลังเส้น */
}

/* สำหรับชื่อผู้บันทึกที่มีอยู่แล้ว */
.pkl-sign-box p:last-child {
    order: 2;
}



.pkl-sign-line {
    border-top: 1px solid #000;
    margin-bottom: 5px; /* ระยะห่างระหว่างเส้นกับข้อความ */
    width: 100%;
    order: 1; /* จัดลำดับให้เส้นอยู่ก่อน */
}

/* Print-specific styles */
@media print {
    @page {
        size: A5 landscape;
        margin: 0;
    }
    
    body * {
        visibility: hidden;
    }
    
    .pkl-preview, .pkl-preview * {
        visibility: visible;
    }
    
    .pkl-preview {
        position: absolute;
        left: 0;
        top: 0;
        width: 210mm;
        height: 148mm;
    }

    .pkl-a5-landscape {
        padding: 15mm 10mm;
        margin: 0;
        border: none;
        box-shadow: none;
    }

    /* Ensure table doesn't break across pages */
    .pkl-items-table {
        page-break-inside: avoid;
    }

    /* Ensure signatures stay at bottom */
    .pkl-signatures {
        page-break-inside: avoid;
    }
	
	.pkl-sign-box {
        padding: 0 !important;
        margin: 0 5px !important;
    }
	
	.pkl-sign-line {
        margin-bottom: 5px !important;
    }
	
	.pkl-sign-box p {
        margin: 2px 0 !important;
    }
}

/* Button styles */
.pkl-button {
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
}

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

/* Table column widths */
.pkl-items-table th:nth-child(1) { width: 35%; } /* รายการ */
.pkl-items-table th:nth-child(2) { width: 8%; }  /* ชุบ */
.pkl-items-table th:nth-child(3) { width: 15%; } /* จำนวน/บรรจุภัณฑ์ */
.pkl-items-table th:nth-child(4) { width: 10%; } /* จำนวนชุด */
.pkl-items-table th:nth-child(5) { width: 10%; } /* ประเภทชุด */
.pkl-items-table th:nth-child(6) { width: 7%; }  /* ลัง No. */
.pkl-items-table th:nth-child(7) { width: 7%; }  /* พาเลท No. */
.pkl-items-table th:nth-child(8) { width: 8%; }  /* จำนวนรวม */


/* PackingList Print Styles for Chrome */

/* Reset browser print margins */
@page {
    size: A5 landscape;
    margin: 0 !important;
}

/* Basic styles */
.pkl-container {
    font-family: 'Sarabun', sans-serif;
}

/* Preview container */
.pkl-preview {
    display: none;
    background: white;
}

/* A5 Landscape layout */
.pkl-a5-landscape {
    width: 210mm;
    height: 148mm;
    padding: 8mm;
    margin: 0;
    box-sizing: border-box;
    position: relative;
    background: white;
}

/* Regular styles remain the same... */

/* Print-specific styles */
@media print {
    /* Reset all elements */
    * {
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* Hide everything except preview */
    body * {
        visibility: hidden;
    }
    
    /* Show only preview content */
    .pkl-preview, 
    .pkl-preview * {
        visibility: visible;
    }
    
    /* Position preview absolute */
    .pkl-preview {
        display: block !important;
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 210mm !important;
        height: 148mm !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    .pkl-a5-landscape {
        margin: 0 !important;
        padding: 8mm !important;
        border: none !important;
        box-shadow: none !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    /* Header adjustments */
    .pkl-header {
        margin-bottom: 8mm !important;
    }

    /* Table adjustments */
    .pkl-items-table {
        width: 100% !important;
        margin: 8mm 0 !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .pkl-items-table th,
    .pkl-items-table td {
        padding: 3px !important;
    }

    /* Signatures positioning */
    .pkl-signatures {
		display: flex;
		justify-content: space-between;
		position: absolute;
		bottom: 8mm;
		left: 8mm;
		right: 8mm;
		padding-top: 10px;
	}

    /* Hide non-printable elements */
    .pkl-modal,
    .pkl-button,
    .no-print {
        display: none !important;
    }

    /* Force background colors in Chrome */
    .pkl-items-table th {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        background-color: #f5f5f5 !important;
    }
}

/* Chrome-specific media query */
@media print and (-webkit-min-device-pixel-ratio:0) {
    .pkl-a5-landscape {
        zoom: 1;
        transform-origin: top left;
        margin: 0 !important;
    }

    .pkl-preview {
        transform-origin: top left;
        margin: 0 !important;
    }
}