/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay:not(.hidden) { opacity: 1; visibility: visible; }

.modal-content {
  background-color: var(--white);
  width: 100%; 
  max-width: 600px;
  max-height: 90vh;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  transform: translateY(20px);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}

.modal-overlay:not(.hidden) .modal-content { transform: translateY(0); }

.modal-header {
  background-color: var(--primary-color);
  color: var(--white);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-header h2 { 
  font-size: 1.125rem; 
  font-weight: 600; 
  letter-spacing: -0.02em;
}

.modal-header .btn-icon {
  color: #FFFFFF !important;
  cursor: pointer;
  background: none !important;
  border: none !important;
}

.modal-header .btn-icon i,
.modal-header .btn-icon svg {
  width: 20px !important; /* Original natural size */
  height: 20px !important;
  stroke: #FFFFFF !important;
}

.modal-header .btn-icon:hover {
  background: none !important;
}

.modal-body { 
  padding: 1.5rem; 
  overflow-y: auto;
  flex: 1;
}

.grid-form { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 1.25rem; 
}

.form-group { 
  display: flex; 
  flex-direction: column; 
  gap: 0.375rem; 
}

.form-group.full-width { 
  grid-column: span 2; 
}

/* Section Title for Grouping */
.form-section-title {
  grid-column: span 2;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary-color);
  padding: 1.5rem 0 0.5rem 0; /* 패딩 조정 */
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
}

/* Modal Readonly/Edit Mode Interaction */
.grid-form.is-view-mode input,
.grid-form.is-view-mode select,
.grid-form.is-view-mode textarea {
  border-color: transparent !important;
  background-color: transparent !important;
  padding-left: 0;
  padding-right: 0;
  pointer-events: none;
  color: var(--text-main);
  font-weight: 500;
}

.grid-form.is-edit-mode input,
.grid-form.is-edit-mode select,
.grid-form.is-edit-mode textarea {
  color: #FF3D00; /* 수정 시 글자색 변경 */
  border: 1px solid var(--border-color);
}

.grid-form.is-edit-mode input:focus,
.grid-form.is-edit-mode select:focus,
.grid-form.is-edit-mode textarea:focus {
  border-color: #FF3D00;
  box-shadow: 0 0 0 2px rgba(255, 61, 0, 0.1);
}

.form-section-title:first-child {
  padding-top: 0.5rem;
}

.form-group label { 
  font-size: 0.8125rem; 
  font-weight: 600; 
  color: var(--text-muted);
}

.form-group input, 
.form-group select, 
.form-group textarea {
  padding: 0.625rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: inherit; 
  font-size: 0.875rem;
  outline: none; 
  transition: all 0.2s;
  background-color: var(--white);
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus { 
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(30, 81, 73, 0.1);
}

.modal-footer {
  padding: 1rem 1.5rem; 
  border-top: 1px solid var(--border-color);
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  background-color: #FAFAFA;
  flex-shrink: 0;
}

.footer-actions { 
  display: flex; 
  gap: 0.5rem; 
}

/* Wide Modal for History/Detail */
.modal-content.wide {
  max-width: 950px;
}

.modal-body-split {
  display: flex;
  gap: 2rem;
  min-height: 480px;
}

.modal-form-area {
  flex: 1.2;
}

.modal-history-area {
  flex: 0.8;
  border-left: 1px solid var(--border-color);
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
}

.history-header {
  margin-bottom: 1rem;
}

.history-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.history-timeline {
  flex: 1;
  overflow-y: auto;
  max-height: 500px;
  padding-right: 0.5rem;
}

.history-item {
  position: relative;
  padding-left: 1.25rem;
  padding-bottom: 1.5rem;
  border-left: 2px solid var(--border-color);
}

.history-item::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--white);
  border: 2px solid var(--primary-color);
}

.history-item:last-child {
  border-left: 2px solid transparent;
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.history-user {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.history-details {
  font-size: 0.8125rem;
  color: var(--text-main);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-all;
}

.empty-history {
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
