﻿/* ✅ 인쇄 전용 설정 */
@page {
  size: A4 landscape;
  margin: 6mm 5mm 5mm 5mm;
}

@media print {
  .a4-container {
    page-break-after: always;
    height: 215mm;
    overflow: hidden;
  }

  .c-table tbody tr {
    page-break-inside: avoid;
  }

  /* 🖨️ 인쇄 시 모든 버튼 및 컨트롤 숨기기 */
  .side-controls,
  .page-controls,
  .form-selector-header,
  #fixedControlPanel,
  #searchModal,
  #templateManagerModal,
  #loginModal,
  #signModal,
  #signatureSelectionPanel,
  #deleteModeBanner,
  button,
  .modal,
  .delete-banner,
  .banner,
  .popup,
  [class*="modal"],
  [class*="banner"],
  [id*="Modal"],
  [id*="Banner"],
  /* showNotification으로 생성된 알림 요소들 */
  div[style*="position: fixed"][style*="top: 20px"][style*="right: 20px"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }

  #formHub,
  #blank-form {
    display: none !important;
  }
}

/* ✅ A4 사이즈 고정 컨테이너 */
.a4-container {
  width: 297mm;
  min-height: 215mm;
  height: auto;
  margin: 0px auto;
  background-color: white;
  box-shadow: 0 0 0px rgba(0, 0, 0, 0.2);
  padding: 0px 10px;
  box-sizing: border-box;
  overflow: visible;
  position: relative;
  page-break-after: always;
}

.page-controls {
  position: fixed;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  background: white;
  padding: 8px 15px;
  border: 1px solid #ccc;
  border-radius: 8px;
  z-index: 1000;
}

.side-controls {
  position: fixed;
  top: 100px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: white;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.side-controls button {
  padding: 8px 12px;
  font-size: 16px;
  cursor: pointer;
}

/* ✅ 상단 심플 컨트롤 */
.top-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.top-controls-main,
.top-controls-more {
  display: flex;
  gap: 8px;
  background: #fff;
  border: none;
  padding: 0;
}

.top-btn {
  border: 1px solid #000;
  background: #fff;
  color: #000;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.top-btn:hover {
  background: #000;
  color: #fff;
}

/* ✅ 서식 선택 헤더 스타일 */
.form-selector-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #fff;
  box-shadow: none;
  border-bottom: 1px solid #000;
  z-index: 10000;
  padding: 15px 0;
}

.form-selector-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
}

.form-selector-container.kras-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.form-selector-container.kras-header h1 {
  justify-self: start;
}

.form-selector-container.kras-header .menu-center {
  justify-self: center;
}

.form-selector-container.kras-header .menu-right {
  justify-self: end;
}

.form-selector-header h1 {
  color: #000;
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  text-shadow: none;
}

.form-selector-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.form-selector-btn {
  padding: 10px 20px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: none;
  letter-spacing: 0;
}

.form-selector-btn:hover {
  background: #000;
  color: #fff;
  transform: none;
  box-shadow: none;
}

.form-selector-btn.active {
  background: #000;
  color: #fff;
  box-shadow: none;
}

.form-selector-btn.active:hover {
  background: #000;
  transform: none;
}

/* ✅ 서식 허브 */
.form-hub {
  max-width: 1200px;
  margin: 110px auto 40px;
  padding: 0 20px;
}

.form-hub-inner h2 {
  font-size: 22px;
  margin: 0 0 16px;
  color: #000;
}

.form-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-card {
  border: 1px solid #000;
  background: #fff;
  color: #000;
  padding: 18px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
}

.form-card:hover {
  background: #000;
  color: #fff;
}

.form-card-title {
  font-size: 16px;
  font-weight: 700;
}

.form-card-sub {
  font-size: 12px;
  opacity: 0.9;
}

.form-hub.hidden {
  display: none;
}

body.hub-mode .side-controls,
body.hub-mode .page-controls,
body.hub-mode #deleteModeBanner,
body.hub-mode #searchModal,
body.hub-mode #templateManagerModal,
body.hub-mode #signModal {
  display: none !important;
}

body.hub-mode .a4-container {
  display: none;
}

body.blank-mode .side-controls,
body.blank-mode .page-controls {
  display: none !important;
}

/* ✅ 빈 서식 */
.blank-form-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  padding: 12px 0;
  border-bottom: 1px solid #000;
}

.blank-form-body {
  padding: 20px;
}

.blank-form-box {
  border: 1px solid #000;
  height: 170mm;
}

/* ✅ 전체 문서 기본 스타일 */
body {
  font-family: Arial, sans-serif;
  font-size: 12px;
  padding: 80px 20px 20px 20px;
}

body[data-page="kras"] {
  padding-top: 140px;
}

h2 {
  text-align: center;
  margin-bottom: 20px;
}

/* ✅ 테이블 공통 스타일 */
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border: 1px solid #000;
  text-align: center;
  vertical-align: middle;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

th {
  background-color: #f0f0f0;
}

/* ✅ 입력창 기본 스타일 */
input {
  width: 100%;
  border: none;
  padding: 4px;
  font-size: 12px;
  font-family: inherit;
  box-sizing: border-box;
  text-align: center;
  vertical-align: middle;
}

/* 날짜 입력 칸은 셀 가운데에 고정 배치 */
.ekrAppDate,
.krasWrittenDateday,
#krasWrittenDate,
.approvalDate {
  display: block;
  margin: 0 auto;
  text-align: center;
}

input:focus {
  outline: none;
  background-color: #ffffe0;
}

/* ✅ A 테이블 전용 스타일 */
.a-table {
  font-size: 12px;
  height: 100px;
  margin-bottom: -30px;
  margin-top: 30px;
}

.a-table th,
.a-table td {
  padding: 3px;
  vertical-align: middle;
}

.a-table th {
  background-color: #f0f0f0;
}

.c-table {
  padding: 0px;
  margin-top: 60px;
}

.a-memo {
  background-color: #fff;
  vertical-align: top;
  min-width: 150px;
}

.a-table thead th,
.a-table thead td {
  padding: 3px 10px;

}

.c-table thead th,
.c-table thead td {
  margin-top: 10px;
  padding: 1px 10px;
  vertical-align: middle;
}

.c-table tbody th,
.c-table tbody td {
  padding: 3px 10px;
  height: 55px;
}

@media print {

  #printBtn,
  #removePageGlobal,
  #nextPageBtn {
    display: none;
  }

  @page {
    size: A4 landscape;
    margin: 15mm 5mm 5mm 5mm;
  }

  body {
    zoom: 88%;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  /* 첫 번째 컨테이너는 작은 패딩으로 헤더 공간 최소화 */
  .a4-container:first-of-type {
    padding: 3mm 0 0 0 !important;
    margin-top: 0;
  }
  
  /* 두 번째부터는 적절한 상단 여백 추가 */
  .a4-container:not(:first-of-type) {
    padding: 3mm 0 0 0 !important;
    margin-top: 0;
  }

  .a4-container {
    /* @page 여백(좌우 5mm, 상2/하5mm) 안에 확실히 들어오도록 고정 */
    width: calc(297mm - 10mm);
    height: calc(210mm - 11mm);
    padding: 3mm 0 0 0;
    box-sizing: border-box;
    margin: 0 auto;
    overflow: hidden;
    page-break-after: always;
  }

  /* EKR 표가 인쇄 영역을 넘지 않도록 높이/간격을 축소 */
  .a-table {
    margin-top: 8px !important;
    margin-bottom: 0 !important;
  }

  .c-table {
    margin-top: 8px !important;
  }

  .c-table thead th,
  .c-table thead td {
    padding: 1px 6px !important;
  }

  .c-table tbody th,
  .c-table tbody td {
    height: 48px !important;
    padding: 2px 6px !important;
  }

  .global-controls {
    display: none !important;
  }
}

select {
  border: none;
  background: transparent;
  font-size: 12px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding: 4px;
  text-align-last: center;
  text-align: center;
}

.search-row-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

/* 🔧 개선된 모달 스타일 */
#searchModal {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);

  /* 📏 모달 크기 설정 */
  width: 500px;
  /* 너비: 500px */
  max-width: 90vw;
  /* 최대 너비: 화면의 90% */
  min-width: 400px;
  /* 최소 너비: 400px */

  max-height: 70vh;
  /* 최대 높이: 화면의 70% */
  min-height: 300px;
  /* 최소 높이: 300px */

  /* 🎨 모달 스타일 */
  background: #fff;
  border: 1px solid #000;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 9999;

  /* 📱 반응형 설계 */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#searchModal.hidden {
  display: none;
}

#loginModal {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 380px;
  max-width: 92vw;
  background: #fff;
  border: 1px solid #000;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  overflow: hidden;
}

#loginModal.hidden {
  display: none;
}

/* 🔧 모달 헤더 스타일 */
.modal-header {
  background: #000;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 16px;
  cursor: move;
  /* 드래그 가능 표시 */
}

.modal-header span {
  flex-grow: 1;
}

#closeModalBtn,
#closeLoginModalBtn {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

#closeModalBtn:hover,
#closeLoginModalBtn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.login-modal-content {
  padding: 16px;
}

#loginForm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#loginForm label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

#loginForm input {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 10px;
  font-size: 14px;
}

.login-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* 🔧 모달 내용 영역 */
.modal-content {
  padding: 16px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#templateResetBtn {
  border: 1px solid #000;
  background: #fff;
  color: #000;
  padding: 6px 10px;
  cursor: pointer;
}

#templateResetBtn:hover {
  background: #000;
  color: #fff;
}

.template-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.template-filters input,
.template-filters select {
  border: 1px solid #000;
  background: #fff;
  padding: 6px 8px;
  font-size: 12px;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.template-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

/* 🔧 템플릿 리스트 스타일 */
#templateList {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;

  /* 📏 리스트 크기 설정 */
  max-height: 350px;
  /* 리스트 최대 높이 */
  min-height: 200px;
  /* 리스트 최소 높이 */

  overflow-y: auto;
  /* 세로 스크롤 */
  border: 1px solid #000;
  border-radius: 4px;
  background: #fff;
}

#templateList li {
  padding: 12px 16px;
  margin: 0;
  cursor: pointer;
  border-bottom: 1px solid #000;
  transition: all 0.2s ease;

  /* 📱 텍스트 처리 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#templateList li:last-child {
  border-bottom: none;
}

#templateList li:hover {
  background-color: #000;
  color: #fff;
  transform: none;
}

#templateList li.selected {
  background-color: #000;
  color: #fff;
  font-weight: bold;
}

#templateList li.selected:hover {
  background-color: #000;
}

/* 🔧 다중 선택 템플릿 아이템 스타일 */
.template-item {
  display: flex;
  align-items: flex-start;
  padding: 10px 12px !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
}

.template-item-content {
  line-height: 1.4;
}

.template-item-content strong {
  font-size: 14px;
  font-weight: 600;
  color: #000;
  display: block;
  margin-bottom: 4px;
}

.template-item-content small {
  font-size: 12px;
  color: #000;
  display: block;
}

/* 체크된 아이템 스타일 */
.template-item.selected {
  background-color: #f5f5f5 !important;
  border-left: 4px solid #000;
}

/* 🔧 버튼 스타일 */
#insertTemplateBtn {
  background-color: #000;
  color: #fff;
  border: 1px solid #000;
  padding: 12px 24px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
  align-self: flex-end;
}

#insertTemplateBtn:disabled {
  background-color: #cccccc;
  color: #666666;
  cursor: not-allowed;
}

#insertTemplateBtn:hover:not(:disabled) {
  background-color: #000;
  color: #fff;
}

#insertTemplateBtn:active:not(:disabled) {
  background-color: #000;
}

/* 🔧 스크롤바 커스터마이징 */
#templateList::-webkit-scrollbar {
  width: 8px;
}

#templateList::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

#templateList::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

#templateList::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 📱 반응형 디자인 */
@media (max-width: 600px) {
  #searchModal {
    width: 95vw;
    min-width: 280px;
    top: 10%;
    max-height: 80vh;
  }

  #templateList {
    min-height: 150px;
    max-height: 250px;
  }

  .modal-header {
    padding: 10px 12px;
    font-size: 14px;
  }

  #templateList li {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* 기존 스타일들 유지 */
#fixedControlPanel {
  position: fixed;
  top: 100px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

#fixedControlPanel button {
  padding: 8px 10px;
  font-size: 16px;
  cursor: pointer;
}

.modal {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -30%);
  background-color: white;
  border: 1px solid #ccc;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  padding: 16px;
  z-index: 1000;
  width: 300px;
  cursor: move;
}

.delete-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 12px;
  background-color: #c0392b;
  color: white;
  font-weight: bold;
  text-align: center;
  z-index: 9999;
}

.hidden {
  display: none;
}

#signatureSelectionPanel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #4a90e2;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

#signatureSelectionPanel.hidden {
  display: none !important;
}

#applySignatureBtn {
  border: none;
  background: #2d74da;
  color: #fff;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}

.highlight-cell {
  background-color: rgba(255, 0, 0, 0.2) !important;
  outline: 2px solid #dc3545 !important;
  box-shadow: inset 0 0 8px rgba(220, 53, 69, 0.3) !important;
  animation: highlight-pulse 2s ease-in-out infinite;
}

@keyframes highlight-pulse {

  0%,
  100% {
    background-color: rgba(255, 0, 0, 0.2) !important;
  }

  50% {
    background-color: rgba(255, 0, 0, 0.35) !important;
  }
}

.selected-row {
  background-color: rgba(220, 53, 69, 0.1) !important;
}

.row-number-highlight {
  animation: number-bounce 0.5s ease-out;
}

@keyframes number-bounce {
  0% {
    transform: translateY(-50%) scale(0.5);
    opacity: 0;
  }

  50% {
    transform: translateY(-50%) scale(1.2);
    opacity: 0.8;
  }

  100% {
    transform: translateY(-50%) scale(1);
    opacity: 1;
  }
}

/* ✍️ 사인 모달 스타일 */
#signModal {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  max-width: 90vw;
  max-height: 70vh;
  background: white;
  border: 2px solid #4a90e2;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#signModal.hidden {
  display: none;
}

/* 사인 모달 헤더 */
#signModalHeader {
  background: #4a90e2;
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  font-size: 18px;
  cursor: move;
}

#closeSignModalBtn {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

#closeSignModalBtn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* 사인 모달 내용 */
.sign-modal-content {
  padding: 20px;
  flex-grow: 1;
  overflow-y: auto;
}

/* 생성된 서명 영역 */
.generated-sign-area {
  margin-bottom: 20px;
  padding: 15px;
  border: 2px dashed #4a90e2;
  border-radius: 8px;
  background: #f8f9ff;
  text-align: center;
}

.generated-sign-area p {
  margin: 0 0 10px 0;
  color: #666;
  font-size: 14px;
}


/* 생성된 서명 미리보기 */
.signature-preview {
  display: inline-block;
  padding: 10px;
  background: white;
  border: 2px solid #4a90e2;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(74, 144, 226, 0.2);
}

.signature-preview img {
  max-width: 150px;
  max-height: 80px;
  display: block;
}

/* 서명 방법 선택 */
.sign-methods {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.sign-method-btn {
  flex: 1;
  padding: 12px 20px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.sign-method-btn:hover {
  border-color: #4a90e2;
  background: #f8f9fa;
}

.sign-method-btn.active {
  border-color: #4a90e2;
  background: #4a90e2;
  color: white;
}

/* 서명 영역 공통 */
.sign-area {
  margin-bottom: 20px;
  padding: 15px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fafafa;
}

.sign-area.hidden {
  display: none;
}

/* 캔버스 스타일 */

#signCanvas {
  width: 100%;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: white;
  cursor: crosshair;
  margin-bottom: 10px;
}

.canvas-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.canvas-controls button {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.canvas-controls input[type="color"] {
  width: 35px;
  height: 25px;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.canvas-controls input[type="range"] {
  width: 80px;
}

/* 이미지 업로드 영역 */
.upload-container {
  text-align: center;
}

#selectImageBtn {
  padding: 10px 20px;
  background: #4a90e2;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 15px;
}

#selectImageBtn:hover {
  background: #357abd;
}

.image-preview {
  min-height: 100px;
  border: 2px dashed #ddd;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 14px;
}

.image-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
}

/* 모달 버튼들 */
.sign-modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 15px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.primary-btn {
  padding: 12px 25px;
  background: #4a90e2;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.primary-btn:hover {
  background: #357abd;
}

.secondary-btn {
  padding: 12px 25px;
  background: white;
  color: #666;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.secondary-btn:hover {
  background: #f5f5f5;
  border-color: #bbb;
}

/* 반응형 디자인 */
@media (max-width: 700px) {
  #signModal {
    width: 95vw;
    top: 5%;
    max-height: 90vh;
  }

  .sign-positions {
    grid-template-columns: 1fr;
  }

  .sign-methods {
    flex-direction: column;
  }

  .canvas-controls {
    justify-content: center;
  }

  #signCanvas {
    width: 100%;
    height: auto;
  }
}


/* 클릭 가능한 서명 셀 스타일 */
.signature-clickable {
  outline: 2px solid #4caf50 !important;
  background-color: rgba(76, 175, 80, 0.15) !important;
  cursor: pointer !important;
  transition: all 0.2s ease;
}

.signature-clickable:hover {
  outline: 3px solid #4caf50 !important;
  background-color: rgba(76, 175, 80, 0.25) !important;
  transform: scale(1.02);
}

/* 선택된 서명 셀 스타일 (다중 선택용) */
.signature-selected {
  outline: 3px solid #2196f3 !important;
  background-color: rgba(33, 150, 243, 0.3) !important;
  cursor: pointer !important;
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.5) !important;
  transform: scale(1.02) !important;
  transition: all 0.2s ease;
}

.signature-cell {
  position: relative;
  transition: all 0.2s;
}

.signature-cell:hover {
  background-color: rgba(74, 144, 226, 0.05);
}

/* 서명이 있는 셀에 마우스 오버 시 힌트 표시 */
td:has(img[src^="data:image/"]):hover::before,
th:has(img[src^="data:image/"]):hover::before {
  content: '더블클릭하여 서명 삭제';
  position: absolute;
  top: -20px;
  right: 0;
  background: rgba(231, 76, 60, 0.9);
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  z-index: 999;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 서명이 있는 셀에 호버 효과 */
td:has(img[src^="data:image/"]):hover,
th:has(img[src^="data:image/"]):hover {
  background-color: rgba(231, 76, 60, 0.1) !important;
  cursor: pointer;
  position: relative;
}

/* 🔧 템플릿 관리 모달 스타일 */
#templateManagerModal {
  position: fixed;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  max-width: 95vw;
  max-height: 90vh;
  background: white;
  border: 2px solid #4a90e2;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#templateManagerModal.hidden {
  display: none;
}

.template-manager-content {
  padding: 20px;
  flex-grow: 1;
  overflow-y: auto;
  max-height: calc(90vh - 60px);
}

/* 템플릿 관리 버튼들 */
.template-manager-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.template-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  min-width: 120px;
}

.template-btn.primary {
  background: #4a90e2;
  color: white;
}

.template-btn.primary:hover {
  background: #357abd;
}

.template-btn.secondary {
  background: #f8f9fa;
  color: #666;
  border: 1px solid #ddd;
}

.template-btn.secondary:hover {
  background: #e9ecef;
  border-color: #bbb;
}

/* 현재 템플릿 목록 */
.current-templates-section {
  margin-bottom: 25px;
}

.current-templates-section h3 {
  margin: 0 0 15px 0;
  color: #333;
  font-size: 16px;
  border-bottom: 2px solid #4a90e2;
  padding-bottom: 8px;
}

.templates-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fafafa;
}

.template-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  transition: background-color 0.2s;
}

.template-item:last-child {
  border-bottom: none;
}

.template-item:hover {
  background-color: #f0f8ff;
}

.template-info {
  flex-grow: 1;
}

.template-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
}

.template-detail {
  font-size: 12px;
  color: #666;
}

.template-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  padding: 6px 12px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.edit-btn {
  background: #28a745;
  color: white;
}

.edit-btn:hover {
  background: #1e7e34;
}

.delete-btn {
  background: #dc3545;
  color: white;
}

.delete-btn:hover {
  background: #c82333;
}

/* 템플릿 편집 폼 */
.template-edit-form {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  background: #f8f9fa;
  margin-top: 20px;
}

.template-edit-form h3 {
  margin: 0 0 20px 0;
  color: #333;
  font-size: 18px;
}

.form-group {
  margin-bottom: 15px;
}

.form-row {
  display: flex;
  gap: 15px;
}

.form-row .form-group {
  flex: 1;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #555;
  font-size: 14px;
}

.form-group input[type="text"],
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s;
  text-align: center;
}

.form-group input[type="text"]:focus,
.form-group select:focus {
  outline: none;
  border-color: #4a90e2;
  box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.form-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #ddd;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  #templateManagerModal {
    width: 95vw;
    top: 2%;
  }

  .template-manager-buttons {
    flex-direction: column;
  }

  .template-btn {
    min-width: auto;
  }

  .form-row {
    flex-direction: column;
    gap: 10px;
  }

  .template-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .template-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* 삭제 모드에서 테이블 전체 스타일 */
.c-table.delete-mode {
  border: 2px dashed #dc3545;
  background-color: rgba(220, 53, 69, 0.05);
}

.c-table.delete-mode td {
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.c-table.delete-mode td:hover {
  background-color: rgba(220, 53, 69, 0.1) !important;
}

/* 삭제 모드 시 버튼 비활성화 스타일 */
body.delete-mode-active .side-controls button:not(#clearRowBtn):not(#undoDeleteBtn) {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #6c757d !important;
  border-color: #6c757d !important;
}

body.delete-mode-active .side-controls button:not(#clearRowBtn):not(#undoDeleteBtn):hover {
  background-color: #6c757d !important;
  border-color: #6c757d !important;
  transform: none !important;
}

/* ✅ KRAS 서식 전용 스타일 */
.form-container.hidden {
  display: none;
}

.kras-approval-table {
  width: 30%;
  margin: 0 0 20px auto;
  border-collapse: collapse;
  table-layout: fixed;
}

.kras-approval-table td {
  border: 1px solid #333;
  text-align: center;
  vertical-align: middle;
  height: 30px;
}

.kras-approval-table td.signature {
  background-color: #f9f9f9;
  position: relative;
  height: 50px;
}

/* KRAS 헤더 테이블 */
.kras-header-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0px;
  border: none;
}

.kras-header-table td {
  border: none;
  padding: 5px;
  vertical-align: middle;
}

/* KRAS 메인 테이블 */
.kras-main-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
  margin-bottom: 20px;
}

.kras-main-table th,
.kras-main-table td {
  border: 1px solid #000;
  padding: 4px 2px;
  text-align: center;
  vertical-align: middle;
  word-wrap: break-word;
  line-height: 1.2;
}

.kras-main-table th {
  background-color: #f0f0f0;
  font-weight: 600;
  font-size: 10px;
}

.kras-main-table tbody td {
  height: 50px;
  font-size: 10px;
}

.kras-possibility,
.kras-severity {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 10px;
  text-align: center;
  padding: 2px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.kras-risk-score {
  font-weight: bold;
  color: #333;
  background-color: #f8f9fa;
}

/* KRAS 3x3 위험도 색상 시스템 */
.kras-risk-score.risk-1 {
  background-color: #d4edda !important;
  color: #155724 !important;
}

.kras-risk-score.risk-2 {
  background-color: #d4edda !important;
  color: #155724 !important;
}

.kras-risk-score.risk-3 {
  background-color: #fff3cd !important;
  color: #856404 !important;
}

.kras-risk-score.risk-4 {
  background-color: #fff3cd !important;
  color: #856404 !important;
}

.kras-risk-score.risk-6 {
  background-color: #f8d7da !important;
  color: #721c24 !important;
}

.kras-risk-score.risk-9 {
  background-color: #f5c6cb !important;
  color: #721c24 !important;
  font-weight: bold;
}

/* 반응형 디자인 - KRAS */
@media (max-width: 768px) {
  .kras-main-table {
    font-size: 9px;
  }
  
  .kras-main-table th {
    font-size: 8px;
    padding: 2px 1px;
  }
  
  .kras-main-table tbody td {
    height: 40px;
    font-size: 8px;
  }
}


@media print {
  .kras-approval-table {
    width: 30% !important;
    margin: 0 0 6mm auto !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .kras-approval-table tr,
  .kras-approval-table td {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}


/* 개선 후 위험성 선택칸 중앙 정렬 고정 */
.c-table select.after-improvement {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  text-align: center;
  text-align-last: center;
}

.c-table select.after-improvement option {
  text-align: center;
}

