/* 안내장 만들기 - 입력 UI 잔여물(리사이즈 핸들·스피너·스크롤바) 숨김 */

textarea.a4-input,
.a4-input--body,
.a4-input--item {
  resize: none;
  overflow: auto;
  scrollbar-width: none;
}

textarea.a4-input::-webkit-scrollbar,
.a4-input--body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

input.a4-input,
.a4-input--header,
.a4-input--sm,
.a4-input--info,
.a4-input--posting,
.a4-input--cell,
.schedule-input {
  resize: none;
}

input.a4-input[type="number"],
input.schedule-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input.a4-input[type="number"]::-webkit-outer-spin-button,
input.a4-input[type="number"]::-webkit-inner-spin-button,
input.schedule-input[type="number"]::-webkit-outer-spin-button,
input.schedule-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 정기점검 일정표 - 비고 열 넓게 */
.schedule-table th:nth-child(4),
.schedule-table td:nth-child(4) {
  min-width: 140px;
}

/* 정기검사 안내문 - 출력 글자 크기·줄간격 (기본값 약간 축소) */
.a4-doc {
  --guide-font-size: 12.5pt;
  --guide-line-height: 1.65;
  font-size: var(--guide-font-size) !important;
  line-height: var(--guide-line-height) !important;
}

.a4-doc .inspection-title {
  font-size: calc(var(--guide-font-size) * 1.35) !important;
}

.a4-doc .inspection-greeting,
.a4-doc .inspection-contact-box,
.a4-doc .inspection-caution-list,
.a4-doc .inspection-signature,
.a4-doc .inspection-schedule-title,
.a4-doc .inspection-cautions h3 {
  font-size: var(--guide-font-size) !important;
  line-height: var(--guide-line-height) !important;
}

/* 일정표: 비고 앞 열은 내용에 맞게, 비고는 줄바꿈 */
.inspection-schedule-table {
  table-layout: auto !important;
  font-size: calc(var(--guide-font-size) * 0.92) !important;
}

.inspection-schedule-table th:nth-child(1),
.inspection-schedule-table td:nth-child(1),
.inspection-schedule-table th:nth-child(2),
.inspection-schedule-table td:nth-child(2),
.inspection-schedule-table th:nth-child(3),
.inspection-schedule-table td:nth-child(3) {
  width: 1%;
  white-space: nowrap;
}

.inspection-schedule-table th:last-child,
.inspection-schedule-table .inspection-note-cell {
  width: auto;
  min-width: 120px;
  white-space: normal;
  word-break: break-word;
  text-align: left !important;
}

.inspection-note-text {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}

.inspection-note-cell .a4-input--cell {
  text-align: left !important;
  min-height: 2.4em;
}

.inspection-date-cell {
  white-space: nowrap;
}

/* 실제 A4 크기 미리보기 */
.a4-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}

/* 엘모아 워터마크 - 용지 오른쪽 아래 고정 */
.guide-elmoa-watermark {
  position: absolute;
  right: 10mm;
  bottom: 8mm;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 7pt;
  line-height: 1;
  color: #94a3b8;
  pointer-events: none;
  user-select: none;
  opacity: 0.9;
}

.guide-elmoa-watermark-icon {
  width: 12px;
  height: 12px;
  object-fit: contain;
  flex-shrink: 0;
}

.guide-elmoa-watermark-text {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.a4-wrapper.guide-fit-one-page-wrapper .guide-elmoa-watermark {
  right: 10mm;
  bottom: 8mm;
}

/* 한 페이지 맞추기 - 화면 미리보기 */
.a4-wrapper.guide-fit-one-page-wrapper {
  width: 210mm;
  height: 297mm;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.a4-wrapper.guide-fit-one-page-wrapper .a4-doc.guide-fit-one-page {
  position: absolute;
  top: 0;
  left: 0;
  transform: scale(var(--guide-fit-scale, 1));
  transform-origin: top left;
  width: calc(210mm / var(--guide-fit-scale, 1));
  min-height: auto !important;
  height: auto !important;
  margin: 0 !important;
}

.a4-doc.guide-true-size {
  transform: scale(var(--guide-screen-scale, 1));
  transform-origin: top center;
  margin-bottom: calc((1 - var(--guide-screen-scale, 1)) * -297mm);
}

.a4-wrapper.guide-fit-one-page-wrapper.guide-true-size-wrapper {
  transform: scale(var(--guide-screen-scale, 1));
  transform-origin: top center;
}

/* 항목 숨기기 */
.guide-section-hidden {
  display: none !important;
}

/* 출력 설정 패널 */
.guide-print-controls {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 12px 0 16px;
  font-size: 0.875rem;
}

.guide-print-controls-title {
  font-weight: 700;
  color: #0d233a;
  margin-bottom: 10px;
}

.guide-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.guide-control-row span {
  flex: 0 0 72px;
  color: #334155;
}

.guide-control-row input[type="range"] {
  flex: 1;
}

.guide-control-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: #334155;
  cursor: pointer;
}

.guide-control-sections {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #cbd5e1;
}

.guide-control-sections-title {
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  .guide-print-controls,
  .preview-toolbar,
  .preview-notice-type-label,
  .preview-actions,
  .restart-section {
    display: none !important;
  }

  .a4-input,
  textarea.a4-input,
  input.a4-input,
  .schedule-input {
    resize: none !important;
    overflow: hidden !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    scrollbar-width: none !important;
  }

  textarea.a4-input,
  .a4-input--body {
    height: auto !important;
    min-height: 0 !important;
  }

  input.a4-input[type="number"]::-webkit-outer-spin-button,
  input.a4-input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    display: none !important;
  }

  .a4-wrapper {
    overflow: hidden !important;
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
  }

  .a4-doc {
    margin: 0 !important;
    width: 210mm !important;
    min-height: auto !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* 한 페이지 맞추기: A4 한 장에 강제 축소 */
  html.guide-print-fit-one-page,
  html.guide-print-fit-one-page body {
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  html.guide-print-fit-one-page #root,
  html.guide-print-fit-one-page .container,
  html.guide-print-fit-one-page .preview {
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  html.guide-print-fit-one-page .a4-wrapper,
  html.guide-print-fit-one-page .a4-wrapper.guide-fit-one-page-wrapper {
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    overflow: hidden !important;
    position: relative !important;
    page-break-before: avoid !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    break-before: avoid !important;
    break-after: avoid !important;
    break-inside: avoid !important;
  }

  html.guide-print-fit-one-page .a4-doc,
  html.guide-print-fit-one-page .a4-doc.guide-fit-one-page {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    transform: scale(var(--guide-fit-scale, 1)) !important;
    transform-origin: top left !important;
    width: calc(210mm / var(--guide-fit-scale, 1)) !important;
    min-height: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  html.guide-print-fit-one-page .a4-doc * {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .inspection-note-cell {
    white-space: normal !important;
    word-break: break-word !important;
  }

  .guide-elmoa-watermark {
    position: fixed !important;
    right: 10mm !important;
    bottom: 8mm !important;
    z-index: 9999 !important;
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
  }
}
