/* ==========================================================================
   print.css - จัดรูปแบบตามแบบฟอร์ม "สถิติจำนวนนักเรียน โรงเรียนบ้านห้วยปอ"
   ขนาด A4 แนวตั้ง พอดี 1 หน้ากระดาษ
   ========================================================================== */

@page {
  size: A4 portrait;
  margin: 10mm 14mm 10mm 14mm;
}

@media print {
  .top-navbar,
  .control-bar,
  .report-action-bar,
  .duty-topic-card,
  #dutyTeacherCard,
  .duty-editor-card,
  .toast-container,
  .btn,
  .nav-tabs,
  #tabEntry,
  .modal-overlay {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: 'Sarabun', 'TH Sarabun New', sans-serif !important;
    font-size: 13.5px !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .main-wrapper {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .report-preview-sheet {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .huai-po-document {
    width: 100% !important;
    page-break-after: avoid;
    page-break-inside: avoid;
  }
}

/* ==========================================================================
   สไตล์แบบฟอร์มเอกสาร "โรงเรียนบ้านห้วยปอ"
   ========================================================================== */
.huai-po-document {
  font-family: 'Sarabun', 'TH Sarabun New', sans-serif;
  color: #000000;
  max-width: 780px;
  margin: 0 auto;
}

/* หัวกระดาษ */
.doc-header {
  text-align: center;
  margin-bottom: 12px;
}

.doc-title {
  font-family: 'Sarabun', sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: #000000;
}

.doc-subtitle {
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: #000000;
}

.doc-date-line {
  font-size: 14px;
  margin: 0;
  color: #000000;
}

.doc-date-val {
  font-weight: 600;
  border-bottom: 1px dotted #333;
  padding: 0 6px;
}

/* ตารางสถิติแบบทางการ */
.huai-po-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
  border: 1.5px solid #000000;
}

.huai-po-table th,
.huai-po-table td {
  border: 1.2px solid #000000;
  padding: 4px 6px;
  font-size: 13.5px;
  line-height: 1.25;
}

.huai-po-table th {
  background-color: #ffffff;
  font-weight: 700;
  text-align: center;
  color: #000000;
}

.huai-po-table td.col-class {
  text-align: left;
  padding-left: 8px;
  white-space: nowrap;
}

.huai-po-table td.col-num {
  text-align: center;
}

.huai-po-table td.col-note {
  text-align: left;
  font-size: 12px;
}

.row-subtotal td {
  font-weight: 700;
  background-color: #fafafa;
}

.font-bold {
  font-weight: 700 !important;
}

/* ส่วนบันทึกเวรและรายการที่ปฏิบัติ */
.duty-section {
  margin-top: 12px;
  margin-bottom: 14px;
}

.duty-title {
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #000000;
}

.duty-lines-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.duty-line {
  border-bottom: 1px solid #777777;
  min-height: 20px;
  height: 20px;
  position: relative;
  display: flex;
  align-items: flex-end;
}

.duty-line-text {
  font-size: 13px;
  line-height: 1;
  color: #000000;
  padding-left: 4px;
}

/* รายชื่อครูเวร */
.teachers-section {
  margin-top: 12px;
  font-size: 13.5px;
}

.teachers-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.teachers-label {
  font-weight: 700;
  width: 75px;
  flex-shrink: 0;
}

.teacher-slot {
  flex: 1;
  white-space: nowrap;
}

/* ลายเซ็นผู้อำนวยการ */
.director-sign-box {
  margin-top: 26px;
  margin-left: auto;
  width: 290px;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.4;
}

.director-sign-line {
  margin-bottom: 6px;
}

.director-name {
  font-weight: 700;
}

.director-position {
  font-size: 13px;
}

/* ==========================================================================
   Responsive สำหรับมือถือ - จัดตารางรายงานให้พอดีหน้าจอมือถือ
   ========================================================================== */
@media (max-width: 768px) {
  .huai-po-document {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
  }

  /* ตารางรายงาน - เลื่อนซ้าย-ขวาได้อย่างนุ่มนวล */
  .report-table-scroll-container,
  .report-preview-sheet .huai-po-document {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .huai-po-table {
    width: 100% !important;
    min-width: 330px !important; /* พอดีหน้าจอมือถือทั่วไป ไม่ล้นออกนอกจอ */
    border-collapse: collapse;
    margin-bottom: 10px;
    font-size: 10.5px;
  }

  .huai-po-table th,
  .huai-po-table td {
    padding: 3px 1px !important;
    font-size: 10.5px !important;
    line-height: 1.25;
    text-align: center;
  }

  .huai-po-table th {
    font-size: 10px !important;
    font-weight: 700;
  }

  .huai-po-table td.col-class {
    padding-left: 3px !important;
    text-align: left !important;
    font-size: 10px !important;
    white-space: normal;
    line-height: 1.2;
    width: 25% !important;
  }

  .huai-po-table th.col-class {
    width: 25% !important;
  }

  .huai-po-table td.col-num,
  .huai-po-table th.col-num {
    width: 8.5% !important;
  }

  .huai-po-table td.col-note,
  .huai-po-table th.col-note {
    width: 15.5% !important;
    font-size: 9px !important;
    text-align: left !important;
  }

  .doc-title {
    font-size: 16px;
    margin-bottom: 2px;
  }

  .doc-subtitle {
    font-size: 13px;
    margin-bottom: 4px;
  }

  .doc-date-line {
    font-size: 11px;
    line-height: 1.4;
  }

  .duty-section {
    margin-top: 8px;
    margin-bottom: 10px;
  }

  .duty-title {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .duty-line {
    min-height: 18px;
    height: 18px;
  }

  .duty-line-text {
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 2px;
  }

  .teachers-section {
    margin-top: 10px;
    font-size: 11px;
  }

  .teachers-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 6px;
    margin-bottom: 4px;
  }

  .teachers-label {
    width: 100%;
    margin-bottom: 2px;
    font-size: 11px;
  }

  .teacher-slot {
    flex: 1 1 calc(50% - 6px);
    font-size: 10.5px;
    white-space: normal;
  }

  .director-sign-box {
    width: 100%;
    margin-top: 14px;
    margin-left: 0;
    text-align: center;
    font-size: 11.5px;
  }

  .director-sign-line {
    font-size: 11px;
    letter-spacing: -1px;
  }

  .director-name {
    font-size: 12px;
  }

  .director-position {
    font-size: 11px;
  }
}
