/*
 * TFERP Document Print V2
 * The purchase preview, Chrome print preview and Save as PDF all use the
 * same .purchase-document DOM and these document rules. Viewer zoom is
 * intentionally screen-only and never changes document layout.
 */

@page purchase-a4 {
  size: A4 portrait;
  margin: 0;
}

.erp-document.purchase-document {
  page: purchase-a4;
  box-sizing: border-box;
  width: 210mm;
  min-width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 10mm;
  border: 1px solid #b8c0c5;
  background: #fff;
  color: #111;
  font-family: "Microsoft JhengHei", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.35;
}

.erp-document.purchase-document .sheet-head {
  text-align: center;
}

.erp-document.purchase-document .sheet-head h2,
.erp-document.purchase-document .sheet-head h3,
.erp-document.purchase-document .sheet-head p {
  margin: 0;
}

.erp-document.purchase-document .sheet-head h2 {
  font-size: 24px;
}

.erp-document.purchase-document .sheet-head p {
  margin-top: 4px;
}

.erp-document.purchase-document .sheet-head h3 {
  margin-top: 8px;
  font-size: 20px;
  letter-spacing: 0;
}

.erp-document.purchase-document .sheet-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr);
  column-gap: 22px;
  margin: 16px 0 8px;
  font-size: 14px;
}

.erp-document.purchase-document .sheet-meta p {
  margin: 0 0 6px;
}

.erp-document.purchase-document .sheet-order-no {
  margin-bottom: 10px;
}

.erp-document.purchase-document .expected-date-box {
  display: grid;
  min-height: 58px;
  align-content: center;
  gap: 4px;
  align-self: start;
  margin-top: 14px;
  padding: 8px 12px;
  border: 2px solid #111;
}

.erp-document.purchase-document .expected-date-box span {
  font-size: 14px;
  font-weight: 700;
}

.erp-document.purchase-document .expected-date-box strong {
  font-size: 22px;
  font-weight: 800;
}

.erp-document.purchase-document .preview-table {
  width: 100%;
  table-layout: fixed;
  border: 0.75pt solid #7f8b91;
  border-collapse: collapse;
  font-size: 16px;
}

.erp-document.purchase-document .preview-table th,
.erp-document.purchase-document .preview-table td {
  padding: 8px 7px;
  border: 0.75pt solid #7f8b91;
  text-align: center;
  vertical-align: middle;
}

.erp-document.purchase-document .preview-table td {
  min-width: 0;
  max-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.erp-document.purchase-document .preview-table th {
  position: relative;
  color: #111;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.erp-document.purchase-document .preview-table th > span:first-child {
  display: block;
  min-width: 0;
  overflow: hidden;
}

.erp-document.purchase-document .preview-table .preview-cell-part-no,
.erp-document.purchase-document .preview-table .preview-cell-name,
.erp-document.purchase-document .preview-table .preview-cell-spec {
  white-space: normal;
}

.erp-document.purchase-document .preview-table .preview-cell-qty,
.erp-document.purchase-document .preview-table .preview-cell-unit,
.erp-document.purchase-document .preview-table .preview-cell-price,
.erp-document.purchase-document .preview-table .preview-cell-amount {
  white-space: nowrap;
}

.erp-document.purchase-document .preview-table .preview-cell-qty,
.erp-document.purchase-document .preview-table .preview-cell-price,
.erp-document.purchase-document .preview-table .preview-cell-amount {
  font-variant-numeric: tabular-nums;
}

.erp-document.purchase-document .preview-table thead {
  display: table-header-group;
}

.erp-document.purchase-document .preview-table tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

.erp-document.purchase-document .sheet-note {
  position: relative;
  min-height: var(--preview-note-height, 120px);
  padding: 8px;
  border: 0.75pt solid #7f8b91;
  border-top: 0;
}

.erp-document.purchase-document .sheet-total {
  display: grid;
  gap: 8px;
  padding: 12px 8px;
  border: 0.75pt solid #7f8b91;
  border-top: 0;
}

.erp-document.purchase-document .sheet-note,
.erp-document.purchase-document .sheet-total,
.erp-document.purchase-document .sheet-footer {
  break-inside: avoid;
  page-break-inside: avoid;
}

.erp-document.purchase-document .sheet-total div {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 20px;
}

.erp-document.purchase-document .sheet-total strong {
  text-align: right;
}

.erp-document.purchase-document .sheet-footer {
  display: grid;
  grid-template-columns: 190px 190px;
  gap: 120px;
  margin-top: 18px;
  font-size: 16px;
}

.erp-document.purchase-document .sheet-image-row .note-image img {
  max-height: 260px;
  object-fit: contain;
}

@media screen {
  .purchase-preview-panel .erp-document.purchase-document {
    zoom: var(--document-viewer-scale, 0.8);
  }
}

@media print {
  .erp-document.purchase-document {
    display: block !important;
    position: static !important;
    width: 210mm !important;
    min-width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 10mm !important;
    border: 0 !important;
    zoom: 1 !important;
    overflow: visible !important;
  }

  .erp-document.purchase-document .col-resize-handle,
  .erp-document.purchase-document .note-resize-handle {
    display: none !important;
  }
}
