/* HE Forms — 기본 스타일
   테마와 충돌하지 않도록 he- 접두사만 사용하고, 색상은 최소한만 지정한다. */

.he-form { max-width: 720px; margin: 0 auto; }

.he-form-fields {
	display: flex;
	flex-wrap: wrap;
	gap: 16px 16px;
}

.he-field {
	flex: 1 1 100%;
	/* flex 항목은 기본값(min-width:auto)이라 '내용보다 작게' 줄어들지 않는다.
	   이 값을 0 으로 풀어 줘야 안쪽의 넓은 표가 밖으로 삐져나오지 않고
	   스크롤 영역 안에서 처리된다. */
	min-width: 0;
}
.he-field--half { flex: 1 1 calc(50% - 8px); }

@media (max-width: 600px) {
	.he-field--half { flex: 1 1 100%; }
}

/* 조건부 필드 — JS가 조건을 만족시키면 이 클래스를 뗀다 */
.he-field--hidden { display: none; }

.he-field-label,
.he-field > .he-field-label {
	display: block;
	margin-bottom: 6px;
	font-weight: 600;
}

.he-required { color: #d63638; margin-left: 2px; }

.he-field-input input[type="text"],
.he-field-input input[type="email"],
.he-field-input input[type="tel"],
.he-field-input input[type="number"],
.he-field-input select,
.he-field-input textarea {
	width: 100%;
	box-sizing: border-box;
	padding: 10px 12px;
	border: 1px solid #ccc;
	border-radius: 4px;
	font-size: 15px;
	line-height: 1.5;
	background: #fff;
}

.he-field-input textarea { resize: vertical; }

.he-choices { display: flex; flex-direction: column; gap: 8px; }
.he-choice { display: flex; align-items: flex-start; gap: 8px; line-height: 1.5; }
.he-choice input { margin-top: 3px; flex: 0 0 auto; }

/* consent — 약관 본문은 길어질 수 있으므로 높이를 제한하고 스크롤 */
.he-consent-text {
	max-height: 160px;
	overflow-y: auto;
	padding: 12px 14px;
	margin-bottom: 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
	background: #fafafa;
	font-size: 13px;
	line-height: 1.7;
	color: #444;
}
.he-consent-text p { margin: 0 0 8px; }
.he-consent-text p:last-child { margin-bottom: 0; }

.he-field-desc { margin: 6px 0 0; font-size: 13px; color: #666; }
.he-field-error { margin: 6px 0 0; font-size: 13px; color: #d63638; }
.he-field--error .he-field-input input,
.he-field--error .he-field-input select,
.he-field--error .he-field-input textarea { border-color: #d63638; }

.he-field--section { margin-top: 12px; border-top: 1px solid #e0e0e0; padding-top: 16px; }
.he-field--section h3 { margin: 0 0 4px; font-size: 17px; }

.he-form-errors {
	margin-bottom: 20px;
	padding: 14px 16px;
	border: 1px solid #d63638;
	border-left-width: 4px;
	background: #fdf2f2;
	border-radius: 4px;
}
.he-form-errors p { margin: 0 0 6px; font-weight: 600; }
.he-form-errors ul { margin: 0; padding-left: 18px; }

.he-form-success {
	padding: 16px;
	border: 1px solid #2f7d32;
	border-left-width: 4px;
	background: #f2faf3;
	border-radius: 4px;
}

.he-form-actions { margin-top: 24px; }
.he-form-submit {
	padding: 12px 28px;
	font-size: 16px;
	cursor: pointer;
}
.he-form-submit[disabled] { opacity: .6; cursor: default; }

/* 허니팟 — 사람 눈에 보이지 않게 감춘다.
   display:none 은 일부 봇이 알아채므로 화면 밖으로 밀어낸다. */
.he-form-hp {
	position: absolute !important;
	left: -9999px !important;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ================================================================
   반복 입력 (repeater) — 목록 표 + 추가 버튼
   ================================================================ */

.he-repeater-table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 10px;
	font-size: 14px;
}
.he-repeater-table th,
.he-repeater-table td {
	border: 1px solid #e0e0e0;
	padding: 8px 10px;
	text-align: left;
	vertical-align: middle;
	word-break: break-word;
}
.he-repeater-table thead th {
	background: #f5f5f5;
	font-weight: 600;
	white-space: nowrap;
}
.he-repeater-table .he-col-no  { width: 44px; text-align: center; }
.he-repeater-table .he-col-act { width: 110px; white-space: nowrap; text-align: center; }

.he-row-edit,
.he-row-del {
	padding: 4px 10px;
	margin: 0 2px;
	font-size: 13px;
	border: 1px solid #ccc;
	border-radius: 3px;
	background: #fff;
	cursor: pointer;
}
.he-row-del { color: #d63638; border-color: #e5a3a3; }
.he-row-edit:hover { background: #f1f1f1; }
.he-row-del:hover  { background: #fdf2f2; }

.he-repeater-empty {
	margin: 0 0 10px;
	padding: 16px;
	border: 1px dashed #ccc;
	border-radius: 4px;
	background: #fafafa;
	color: #777;
	font-size: 14px;
	text-align: center;
}

.he-repeater-add {
	padding: 10px 18px;
	font-size: 15px;
	border: 1px solid #2271b1;
	border-radius: 4px;
	background: #fff;
	color: #2271b1;
	cursor: pointer;
}
.he-repeater-add:hover:not([disabled]) { background: #f0f6fc; }
.he-repeater-add[disabled] { opacity: .5; cursor: not-allowed; }

/* 표를 감싸는 스크롤 영역.
   화면 크기를 기준으로 삼지 않는다 — '표가 들어갈 자리보다 넓을 때' 스크롤이 생긴다.
   그래서 모바일뿐 아니라 좁은 사이드바나 창을 줄였을 때도 똑같이 동작한다. */
.he-table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;  /* iOS 에서 부드럽게 */
	max-width: 100%;
	margin-bottom: 10px;
}
.he-table-scroll .he-repeater-table {
	min-width: 520px;   /* 이보다 좁아지면 칸이 뭉개지므로 스크롤로 넘긴다 */
	margin-bottom: 0;
}

/* 스크롤이 가능하다는 것을 알 수 있도록 옅은 테두리를 준다 */
.he-table-scroll::-webkit-scrollbar { height: 8px; }
.he-table-scroll::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.he-table-scroll::-webkit-scrollbar-track { background: #f5f5f5; }

/* ================================================================
   입력 팝업
   ================================================================ */

.he-modal[hidden] { display: none; }

.he-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;   /* 테마 헤더보다 위 */
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.he-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .5);
}

.he-modal-box {
	position: relative;
	width: 100%;
	max-width: 560px;
	max-height: 90vh;
	overflow-y: auto;
	background: #fff;
	border-radius: 6px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}

.he-modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid #e0e0e0;
}
.he-modal-head h4 { margin: 0; font-size: 17px; }

.he-modal-x {
	border: 0;
	background: none;
	font-size: 26px;
	line-height: 1;
	color: #666;
	cursor: pointer;
	padding: 0 4px;
}

.he-modal-body {
	padding: 20px;
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
}
.he-modal-body .he-field { flex: 1 1 100%; }
.he-modal-body .he-field--half { flex: 1 1 calc(50% - 7px); }

.he-modal-error {
	flex: 1 1 100%;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid #d63638;
	border-radius: 4px;
	background: #fdf2f2;
	color: #d63638;
	font-size: 13px;
}
.he-modal-error[hidden] { display: none; }

.he-modal-foot {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 14px 20px;
	border-top: 1px solid #e0e0e0;
	background: #fafafa;
}

.he-btn-ghost,
.he-btn-primary {
	padding: 9px 20px;
	font-size: 15px;
	border-radius: 4px;
	cursor: pointer;
}
.he-btn-ghost   { border: 1px solid #ccc; background: #fff; color: #444; }
.he-btn-primary { border: 1px solid #2271b1; background: #2271b1; color: #fff; }
.he-btn-ghost:hover   { background: #f1f1f1; }
.he-btn-primary:hover { background: #135e96; }

/* 팝업이 열려 있는 동안 뒤쪽 본문은 스크롤되지 않게 */
body.he-modal-open { overflow: hidden; }

/* ================================================================
   우편번호 찾기 / 파일 첨부
   ================================================================ */

.he-postcode { display: flex; gap: 8px; align-items: stretch; }
.he-postcode input[type="text"] { flex: 1 1 auto; background: #fafafa; cursor: default; }

.he-postcode-btn {
	flex: 0 0 auto;
	padding: 0 16px;
	white-space: nowrap;
	border: 1px solid #2271b1;
	border-radius: 4px;
	background: #fff;
	color: #2271b1;
	font-size: 14px;
	cursor: pointer;
}
.he-postcode-btn:hover { background: #f0f6fc; }

/* 우편번호 검색 팝업 — 반복입력 팝업과 같은 모양을 쓴다 */
.he-postcode-modal .he-modal-box {
	max-width: 500px;
	overflow: hidden;   /* 검색창이 모서리 밖으로 나오지 않도록 */
}
.he-postcode-embed { height: 450px; }
.he-postcode-embed iframe { width: 100%; height: 100%; border: 0; display: block; }

@media (max-width: 600px) {
	.he-postcode-modal .he-modal-box { max-width: 100%; }
	.he-postcode-embed { height: 60vh; }
}

.he-field--file input[type="file"] {
	width: 100%;
	box-sizing: border-box;
	padding: 8px;
	border: 1px solid #ccc;
	border-radius: 4px;
	background: #fff;
	font-size: 14px;
}
