/* Receipt document — screen preview & print */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;600;700&display=swap');

.receipt-print-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow: auto;
}
.receipt-print-modal[hidden] {
  display: none !important;
}
.receipt-print-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}
.receipt-print-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(794px, 100%);
  margin: 0 auto;
}
.receipt-print-modal__toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}
.receipt-print-modal__toolbar button {
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #d4dce8;
  background: #fff;
  cursor: pointer;
}
.receipt-print-modal__toolbar .receipt-print-modal__print {
  background: linear-gradient(135deg, #1f379d, #008654);
  color: #fff;
  border: none;
}
.receipt-print-modal__body {
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}

.receipt-doc {
  width: 100%;
  max-width: 794px;
  margin: 0 auto;
  padding: 10mm 10mm 12mm;
  background: #fff;
  color: #111;
  font-family: 'Sarabun', 'TH Sarabun New', sans-serif;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  box-sizing: border-box;
  overflow: hidden;
}
.receipt-doc *,
.receipt-doc *::before,
.receipt-doc *::after {
  box-sizing: border-box;
}
.receipt-doc p {
  margin: 0 0 2px;
}
.receipt-doc table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.receipt-doc th,
.receipt-doc td {
  border: 1px solid #222;
  padding: 7px 8px;
  vertical-align: middle;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.receipt-doc th {
  font-weight: 650;
  background: #f7f8fa;
}
.receipt-doc .c { text-align: center; }
.receipt-doc .l { text-align: left; }
.receipt-doc .r { text-align: right; font-variant-numeric: tabular-nums; }

.receipt-doc__head {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto minmax(200px, 0.9fr);
  gap: 12px 14px;
  align-items: start;
  margin-bottom: 12px;
}
.receipt-doc__shop {
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
}
.receipt-doc__shop-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px !important;
}
.receipt-doc__brand {
  text-align: center;
}
.receipt-doc__logo {
  width: 80px;
  height: 80px;
  display: block;
  margin: 0 auto 6px;
  object-fit: contain;
}
.receipt-doc__doc-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.receipt-doc__meta {
  width: 100%;
  font-size: 12.5px;
}
.receipt-doc__meta th {
  width: 48%;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
  padding: 6px 8px;
  background: #f7f8fa;
}
.receipt-doc__meta td {
  text-align: left;
  padding: 6px 8px;
  background: #fff;
}

/* Customer info — separate table so columns don't fight the items grid */
.receipt-doc__customerTable {
  margin: 0 0 10px;
  font-size: 12.5px;
}
.receipt-doc__customerTable th {
  width: 11%;
  text-align: center;
  white-space: nowrap;
  font-size: 12px;
  padding: 6px 4px;
}
.receipt-doc__customerTable td {
  width: 14%;
  text-align: center;
  padding: 6px 6px;
  background: #fff;
  overflow-wrap: break-word;
  word-break: normal;
}
.receipt-doc__customerTable th:nth-child(5),
.receipt-doc__customerTable td:nth-child(6) {
  width: 12%;
}
.receipt-doc__customerTable td:nth-child(6) {
  width: 18%;
}

.receipt-doc__sheet {
  margin-top: 0;
  font-size: 13px;
}
.receipt-doc__col-no { width: 10%; }
.receipt-doc__col-item { width: 46%; }
.receipt-doc__col-qty { width: 12%; }
.receipt-doc__col-price { width: 16%; }
.receipt-doc__col-total { width: 16%; }

.receipt-doc__items-head th {
  text-align: center;
  font-weight: 650;
  font-size: 12px;
  padding: 8px 6px;
}
.receipt-doc__sheet tbody td {
  min-height: 30px;
  height: 30px;
  background: #fff;
}
.receipt-doc__sheet tbody td.l {
  padding-left: 10px;
}
.receipt-doc__sheet tbody td.r {
  padding-right: 10px;
  white-space: nowrap;
}
.receipt-doc__total th,
.receipt-doc__total td {
  font-weight: 650;
  background: #f7f8fa;
}
.receipt-doc__words {
  text-align: left !important;
  font-weight: 400 !important;
  padding-left: 10px !important;
  white-space: normal !important;
  background: #fff !important;
}
.receipt-doc__grand {
  font-weight: 700 !important;
  font-size: 14px;
  white-space: nowrap !important;
}

.receipt-doc__foot {
  margin-top: 28px;
  padding: 0 4px;
  font-size: 13px;
}
.receipt-doc__foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
}
.receipt-doc__sign-line {
  flex: 0 0 140px;
  width: 140px;
  border-bottom: 1px dotted #000;
  height: 18px;
}
.receipt-doc__sign-label {
  display: block;
  width: 140px;
  margin-top: 4px;
  text-align: center;
}
.receipt-doc__thanks {
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}

@media print {
  body.receipt-modal-open {
    overflow: visible !important;
  }
  body.receipt-modal-open > *:not(#receiptPrintModal) {
    display: none !important;
  }
  #receiptPrintModal {
    position: static !important;
    display: block !important;
    padding: 0 !important;
    overflow: visible !important;
  }
  #receiptPrintModal[hidden] {
    display: block !important;
  }
  .receipt-print-modal__backdrop,
  .receipt-print-modal__toolbar {
    display: none !important;
  }
  .receipt-print-modal__dialog,
  .receipt-print-modal__body {
    display: block !important;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  #receiptPrintPreview {
    padding: 0 !important;
    background: transparent !important;
  }
  #receiptDocPrint {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
}

@media (max-width: 768px) {
  .receipt-print-modal__dialog {
    width: 100%;
  }
  .receipt-doc__head {
    grid-template-columns: 1fr;
  }
  .receipt-doc__brand {
    order: -1;
  }
  .receipt-doc {
    padding: 8mm 5mm;
    font-size: 12px;
  }
  .receipt-doc__sheet,
  .receipt-doc__customerTable {
    font-size: 11px;
  }
  .receipt-doc th,
  .receipt-doc td {
    padding: 5px 4px;
  }
}
