@font-face {
  font-family: 'TH Sarabun New';
  src: url('font/THSarabunNew.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
@page {
  size: A4;
  margin: 5mm;
}
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: 'TH Sarabun New', sans-serif;
  margin: 0;
  padding: 0;
  background: white;
}
.container {
  font-family: 'TH Sarabun New', sans-serif;
  width: 210mm;
  max-height: 297mm;
  margin: auto;
  padding: 5mm;
  box-sizing: border-box;
  background: white;
  box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.5);
}

/* ตาราง Responsive */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 5px;
  min-width: 700px; /* กว้างขั้นต่ำเพื่อ layout ไม่เสีย */
}
table, tr, th, td {
  border: 1px solid #000;
}
input, select, textarea {
  font-family: 'TH Sarabun New', sans-serif;
}
h1 {
  text-align: center;
  box-sizing: border-box;
}
.head-table th, .in {
  text-align: center;
}
.head-table th, .underline-suggest, table, tr, th, td, input {
  font-size: 20px;
}
::placeholder, span, label {
  font-size: 23px;
}
::placeholder {
  padding-left: 14px;
}
.suggest {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 2px;
  padding: 5px 0;
}

/* ส่วนสำคัญ: ครั้งที่สำรวจ/วันที่สำรวจ อยู่บรรทัดเดียว */
.survey-row, .info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  padding-left: 20px;
  padding-right: 20px;
  margin-bottom: 4px;
}
.survey-row .sub_title, .survey-col,
.info-left, .info-right {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 23px;
}
.survey-col { min-width: 200px; }
.survey-left { justify-content: flex-start; }
.survey-right { justify-content: flex-end; }
.info-left { text-align: left; flex:1; }
.info-right { text-align: right; flex:1; }
.info-location {
  font-size: 20px;
  text-align: left;
  padding-left: 20px;
  margin-bottom: 8px;
}
.underline-inputF, .underline-previewF {
  border: none;
  border-bottom: 1px dotted #000;
  outline: none;
  font-size: 20px;
  background: transparent;
  min-width: 60px;
  display: inline-block;
  padding: 1px 2px;
  text-align: center;
}
.underline-input {
  border: none;
  outline: none;
  width: 180px;
  font-size: 20px;
  padding: 1px 2px;
}
.underline-inputw {
  border: none;
  border-bottom: 1px dotted #000;
  outline: none;
  width: 70%;
  font-family: 'TH Sarabun New', sans-serif;
  padding: 1px ;
  box-sizing: border-box;
  text-align: center;
}
.underline-suggest {
  border: none;
  border-bottom: 1px dotted #000;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  padding: 3px;
  font-size: 20px;
}
.sub_title {
  margin-left: 20px;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 23px;
}
/* กล่องชื่อ/ตำแหน่ง/ลายเซ็น */
.wrapper {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 50px; /* ระยะห่างระหว่างกล่อง */
  flex-wrap: wrap; /* รองรับจอเล็ก */
}
.left-box,
.right-box {
  flex: 1 1 40%;
  box-sizing: border-box;
}
.signature-pad, .signature-preview {
  border: 1px solid #ccc;
  width: 100%;
  max-width: 300px;
  height: 100px;
  display: block;
  margin-top: 5px;
  margin-bottom: 2px;
  background: #fff;
}

.bt {
  font-family: 'TH Sarabun New', sans-serif;
  font-size: 18px;
  font-weight: bold;
  background-color: rgb(192, 194, 196);
  border: none;
  color: #121312;
  padding: 7px 30px;
  border-radius: 4px;
  cursor: pointer;
}
.photo-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 22px;
    margin-top: 20px;
    margin-bottom: 20px;
}
.photo-box {
    border: 1.5px solid #222;
    border-radius: 6px;
    padding: 8px 8px 0 8px;
    background: #fff;
    width: 340px;
    max-width: 96vw;
    box-sizing: border-box;
    text-align: center;
}
.photo-box img {
    max-width: 100%;
    max-height: 440px;
    display: block;
    margin: auto;
}
.photo-label {
    margin-top: 7px;
    font-size: 19px;
    color: #222;
    text-align: center;
}
.photo-summary {
  font-size: 19px;
  color: #222;
  margin: 16px 0 8px 0;
}

.photo-print-only {
  display: none;
}

/* Responsive: มือถือ/Tablet */
@media (max-width: 1024px) {
  html, body {
    width: 100%;
  }
  .container {
    width: 210mm;
    max-height: 297mm;
    margin: auto;
    padding: 5mm;
    box-sizing: border-box;
    background: white;
    box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.5);
  }
  .head-table th, .underline-suggest, table, tr, th, td, input, .underline-inputw, .underline-inputF {
    font-size: 19px;
  }
  ::placeholder, span, label {
    font-size: 19px;
  }
}
@media (max-width: 768px) {
  .container {
    width: 210mm;
    max-height: 297mm;
    margin: auto;
    padding: 5mm;
    box-sizing: border-box;
    background: white;
    box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.5);
  }
  .head-table th, .underline-suggest, table, tr, th, td, input, .underline-inputw, .underline-inputF {
    font-size: 18px;
  }
  ::placeholder, span, label {
    font-size: 18px;
  }
}
@media (max-width: 700px) {
  .container {
    width: 99vw;
    padding: 2vw;
    box-shadow: none;
  }
  .survey-row, .info-row {
    flex-direction: column;
    gap: 6px;
    padding: 0 2vw;
    align-items: stretch;
  }
  .survey-row .sub_title, .survey-col,
  .info-left, .info-right, .info-location {
    font-size: 16px;
  }
  .head-table th, .underline-suggest, table, tr, th, td, input, .underline-inputw, .underline-inputF, .underline-input {
    font-size: 15px;
  }
  ::placeholder, span, label {
    font-size: 15px;
  }
  table, th, td {
    padding: 2px 4px;
  }
  .wrapper {
    flex-direction: column;
    gap: 12px;
  }
  table {
    min-width: 700px; /* ยังคงกว้างขั้นต่ำ ถ้าจอแคบ scroll-x ได้ */
  }
}

/* เปิด scroll-x บนมือถือ/จอแคบ (กรณีตารางกว้างกว่าจอ) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

/* style.css (ต่อท้าย หรือวางไว้ด้านล่าง) */

@media print {
  @page {
    size: A4;
    margin: 5mm 10mm 5mm 10mm;  /* top, right, bottom, left */
  }
  body {
    margin: 0;
    padding: 0;
    background: #fff;
  }
  /* โชว์เฉพาะ #printArea กับ .photo-print-only */
  body > *:not(#printArea):not(.photo-print-only) {
    display: none !important;
  }
  #printArea, .photo-print-only {
    display: block !important;
  }
  .photo-print-only {
    /* ปิด scroll, background, ... */
    page-break-before: always;
  }
  /* Container กล่องรูป 1 หน้า */
  .photo-page-container {
    width: 100%;
    max-width: none;
    min-height: 265mm;
    margin: 0;
    padding: 0;
    background: #fff;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    page-break-after: always;
    break-after: page;
    border: none;
  }
  /* ถ้ามีหลายหน้า ใส่ break ก่อนหน้าใหม่ */
  .photo-page-break {
    page-break-before: always !important;
    break-before: page !important;
  }
  /* กล่องแต่ละรูป */
  .photo-print-box {
    display: flex;
    flex-direction: column;
    align-items: center;    /* กึ่งกลางแนวนอน */
    justify-content: flex-start;
    border: none;
    margin: 20px auto 18px auto;
    padding: 14px 0 8px 0;
    background: #fafafa;
    box-sizing: border-box;
    width: 90%;            /* หรือกำหนดเช่น 90% */
    max-width: 700px;      /* ลด max-width จาก 800px เพื่อไม่ล้น */
}

.photo-print-img {
    display: block;
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;      /* ไม่ล้น box */
    max-height: 320px;
    object-fit: contain;
    border: 1px solid #888;
    background: #fff;
    margin-bottom: 10px;
    box-shadow: 0 0 8px #eee;
}

  .photo-print-label {
    font-size: 18px;
    text-align: center;
    color: #333;
  }
  .photo-title {
    text-align: center;
    font-weight: bold;
    font-size: 23px;
    margin: 0 0 18px 0;
    padding-top: 30px;
    letter-spacing: 1px;
  }

  /* ปิด box-shadow, padding, margin, container ทุกหน้า */
  .container {
    margin: 0 !important;
    padding: 5mm 7mm 5mm 7mm  !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: none !important;
    background: #fff !important;
  }
  /* ซ่อนทุกอย่างที่ไม่ต้อง print */
  .btn-group, .box_button, button, .actions, .pdf-btn, .photo-summary {
    display: none !important;
  }
}



