/* field wrapper */
.field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.field--gap-12 {
  gap: 12px;
}

/* field label */
.field-label {
  display: block;
  color: var(--color-system-200);
  line-height: 21px;
}

.field-row {
  display: flex;
  gap: 16px;
}

.field-row.field-row--gap-8 {
  gap: 8px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 360px;
}

.input {
  display: inline-flex;
  align-items: center;
  width: 100%;
  height: 50px;
  border-radius: 4px;
  padding: 0 12px;

  border: 1px solid var(--color-border);
  background-color: inherit;

  color: var(--color-system-100);
  font-size: 14px;
  font-weight: 400;

  @media screen and (max-width: 768px) {
    font-size: 16px!important;
  }

  transition:
    border-color 0.15s ease,
    box-shadow 0.12s ease,
    background-color 0.15s ease;
}

/* placeholder */
.input::placeholder {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-system-400);
  
  @media screen and (max-width: 768px) {
    font-size: 16px!important;
  }
}

/* hover */

/* focus (키보드 포커스) */
.input:focus-visible,
.input:hover:not(:disabled) {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-primary-400);
  border-color: var(--color-border-focus);
}

/* disabled */
.input:disabled {
  color: var(--color-system-400);
  border-color: var(--color-border);
  background-color: var(--color-system-600);
  cursor: not-allowed;
}

.input-clear {
  position: absolute;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background-color: inherit;
  padding: 0;

  opacity: 0;              /* 기본 숨김 */
  pointer-events: none;    /* 클릭 불가로 */
  transition: opacity 0.15s ease;
}

.input-clear img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

/* input에 값 있을 때만 보이게 */
.input-wrap.has-value .input-clear {
  opacity: 1;
  pointer-events: auto;
}

/* 에러 상태 (wrapper 기준) */
.field--error .input,
.field.is-error .input {
  border-color: var(--color-border-error);
  background-color: rgba(255, 0, 0, 0.1);
}

/* 에러 텍스트 */
.error-message {
  display: none;
  margin: 4px 0 0;
}

.field--error .error-message,
.field.is-error .error-message {
  display: block;
  color: var(--color-error);
}

/* 성공 메시지 */
.success-message {
  display: none;
  margin: 4px 0 0;
  color: var(--color-success, #4caf50);
}

.field--success .success-message {
  display: block;
}

/* input-wrap 안에 들어가는 counter */
.field--count .field-counter {
  position: absolute;
  right: 12px;
  top: 18px;
  color: var(--color-system-400);
  pointer-events: none;
}

.field--count .field-counter.field-counter--bottom {
  top: unset;
  bottom: 2px;
  line-height: 21px;
}

.field--count .input-clear {
  right: 48px;
}

/* input-wrap 안에 들어가는 unit text */
.field--unit .input-unit {
  position: absolute;
  right: 12px;
  top: 18px;
  color: var(--color-system-400);
  pointer-events: none;
}

.field--unit .input-clear {
  right: 48px;
}

/* eye 버튼 */
.input-eye {
  position: absolute;
  right: 12px;
  width: 24px;
  height: 24px;
  top: 50%;
  transform: translateY(-50%);

  display: flex;
  align-items: center;
  justify-content: center;

  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.input-eye img {
  width: 24px;
  height: 24px;
  display: block;
}

/* clear 버튼은 eye보다 왼쪽으로 */
.field--password .input-clear {
  position: absolute;
  right: 40px;    /* eye(24px) + 여백 8px */
  width: 24px;
  height: 24px;
  top: 50%;
  transform: translateY(-50%);

  display: flex;
  align-items: center;
  justify-content: center;

  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* 그룹 정렬 (선택) */
.sub-select-group {
  display: flex;
  gap: 12px;
}

/* radio 숨기기 */
.sub-select-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* 기본 버튼 스타일 */
.sub-select-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 172px;
  height: 50px;
  background-color: var(--color-system-600);
  color: var(--color-system-400);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

/* 선택된(on) 상태 */
.sub-select-group input:checked + .sub-select-btn {
  background-color: var(--color-primary-400);
  color: var(--color-system-950);
}

/* 선택 안 된(off) 상태 */
.sub-select-group input:not(:checked) + .sub-select-btn {
  background-color: var(--color-system-600);
  color: var(--color-system-400);
}

/* (off 상태에만 hover색 적용) */
.sub-select-group input:not(:checked) + .sub-select-btn:hover {
  background-color: var(--color-primary-700);
}

/* textarea */
.custom-textarea {
  width: 100%;
  height: 50px;          /* 시작 높이 */
  min-height: 50px;
  border-radius: 4px;
  border: 1px solid var(--color-system-500);
  background-color: transparent;
  font-size: 14px;
  font-weight: 400;
  line-height: 21px;
  color: var(--color-system-100);
  padding: 14.5px 12px;
  resize: vertical;
}

.custom-textarea.custom-textarea--h120 {
  height: 120px;
  min-height: 120px;
}

/* textarea disabled */
.custom-textarea:disabled {
  background-color: var(--color-system-600);
  cursor: not-allowed;
}

/* textarea focus (키보드 포커스) */
.custom-textarea:focus-visible,
.custom-textarea:hover:not(:disabled) {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-primary-400);
  border-color: var(--color-border-focus);
}

/* 공통 체크박스 래퍼 */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* 실제 체크박스 숨기기 */
.checkbox-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* 체크박스 아이콘 */
.checkbox-icon {
  width: 24px;
  height: 24px;
  display: inline-block;
  background-image: url('/assets/icons/chbox_off.png');
  background-size: contain;
  background-repeat: no-repeat;
}

/* 체크 됐을 때 아이콘 변경 */
.checkbox-input:checked + .checkbox-icon {
  background-image: url('/assets/icons/chbox_on.png');
}

/* 텍스트 */
.checkbox-label {
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-system-100);
}

/* input + select 함께 있는 버전 */
.input-with-select-left {
  position: relative;
}

/* select가 왼쪽에 들어가므로 input padding-left 조정 */
.input-with-select-left .input {
  padding-left: 70px;
}

/* select 스타일 - input 안 왼쪽 */
.carrier-select {
  position: absolute;
  left: 4px;              /* input 좌여백 */
  top: 50%;
  transform: translateY(-50%);
  height: 30px;

  padding: 0 8px;
  border: none;
  background: none;

  color: var(--color-primary-400);

  appearance: none;
  cursor: pointer;

  z-index: 2;
}

/* 화살표 아이콘 사용 시 */
.carrier-select {
  background-image: url('/assets/icons/arrow_drop_down.png');
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 18px;
  padding-right: 22px;
  outline: 0;
}

/* clear 버튼 위치 (select 오른쪽) */
.input-with-select-left .input-clear {
  right: 12px;
}

/* 타이머 들어가는 버전 */
.input-with-timer {
  position: relative;
}

/* input 오른쪽 안 여백 늘려주기 (타이머 + X 공간) */
.input-with-timer .input {
  padding-right: 96px; /* 타이머(약 40~50px) + X버튼(24px) + 여백 */
}

/* 타이머 위치 */
.input-timer {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-system-400);
  pointer-events: none; /* 클릭 막지 않기 */
}

/* X 버튼은 그대로 맨 오른쪽 */
.input-with-timer .input-clear {
  position: absolute;
  right: 48px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background-color: transparent;
  padding: 0;
  cursor: pointer;
}

.input-with-timer .input-clear img {
  width: 24px;
  height: 24px;
  display: block;
}

.field-text {
  color: var(--color-system-200);
}

.field-row--half {
  display: flex;
  align-items: center;
  gap: 20px;
}

.field-row--half .field-text {
  flex: 1;          /* 50% */
}

.field-row--half .btn {
  flex: 1;          /* 50% */
  max-width: 172px;
}

.field-control {
  flex: 1;
}

.field-action {
  width: 78px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.custom-select {
  position: relative;
  width: 100%;
  max-width: 360px;
}

/* 네이티브 select는 화면에서만 숨김 (폼 전송용) */
.custom-select-native {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

/* 트리거 영역 (기존 .input 느낌으로) */
.custom-select-trigger {
  width: 100%;
  height: 50px;
  padding: 0 13px 0 12px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-system-400);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.15s ease;
  outline: none;
}

.custom-select-trigger:hover {
  border-color: var(--color-border-focus);
}

/* 화살표 아이콘 */
.custom-select-icon {
  display: inline-flex;
  margin-left: 8px;
}

.custom-select-icon img {
  width: 24px;
  height: 24px;
}

/* 옵션 리스트 (기본은 숨김) */
.custom-select-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 12px);
  max-height: 220px;
  overflow-y: auto;
  background-color: var(--color-bg-back);
  border-radius: 4px;
  border: 1px solid var(--color-primary-400);

  list-style: none;
  margin: 0;
  padding: 6px 0;
  display: none;
  z-index: 10;
}

/* 열렸을 때 */
.custom-select.is-open .custom-select-list {
  display: block;
}

.custom-select.is-open .custom-select-trigger {
  border-color: var(--color-border-focus);
  color: var(--color-primary-400);
}

/* 옵션 하나 */
.custom-select-option {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  color: var(--color-primary-400);
}

.custom-select-option:hover {
  background: var(--color-primary-800);
}

.custom-select-option.is-selected {
  font-weight: 700;
  color: var(--color-primary-400);
}

.custom-select-option.disabled {
  color: var(--color-primary-900);
  cursor: default;
  pointer-events: none; /* 클릭 불가 */
  background: transparent; /* hover 영향 안 받도록 */
}

/* hover 제거 (일반 hover보다 우선 적용되도록) */
.custom-select-option.disabled:hover {
  background: transparent;
}

/* 값이 선택되었을 때 트리거 색상 변경 */
.custom-select.has-value .custom-select-trigger {
  color: var(--color-system-100);
}

/* calendar */
.input-calendar {
  position: absolute;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background-color: inherit;
  padding: 0;
}

.date-input-display[readonly] {
  cursor: pointer;
}

.input-calendar img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

/* 한 줄에서 마지막 필드의 달력 팝업만 오른쪽 정렬 */
.field-row .field:last-child .date-popup {
  left: auto;
  right: -2px;
}

/* 달력 팝업 */
.date-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 280px;           /* 최소 너비 확보 */
  width: max-content;         /* 안의 내용 기준으로 넓이 결정 */
  border-radius: 12px;
  background-color: var(--color-bg-front);
  border: 1px solid var(--color-border);
  padding: 12px;
  z-index: 20;                /* 겹쳤을 때 위로 */
  display: none;
}


/* 열렸을 때 */
.date-popup.is-open {
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 2;
}

.date-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.date-popup-header-date {
  display: flex;
  align-items: center;
  color: var(--color-system-wt);
  line-height: 27px;
  cursor: pointer;
  padding: 0;
  border: none;
  background: none;
}

.date-popup-header-date img {
  width: 24px;
  height: 24px;
}

.date-popup-header-control {
  display: flex;
  align-items: center;
  gap: 24px;
}

.date-popup-header-control .today {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 52px;
  height: 24px;
  color: var(--color-bg-back);
  border-radius: 18px;
  border: none;
  background: var(--color-primary-400);
  padding: 0;
  cursor: pointer;
}

.date-popup-header-control .arrow-wrap {
  display: flex;
  gap: 24px;
}

.date-popup-header-control .arrow-wrap button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.date-popup-header-control .arrow-wrap button img {
  width: 24px;
  height: 24px; 
}

/* 달력 body */
.date-popup-body {
  margin-top: 12px;
}

.date-popup-body .date-view {
  display: block;
  padding-bottom: 21px;
}

.date-popup-body .date-view .calendar .calendar-weekdays {
  display: flex;
  font-size: 10px;
  font-weight: 400;
  color: var(--color-system-300);
  line-height: 15px;
}

.date-popup-body .date-view .calendar .calendar-weekdays .weekday {
  width: 48px;
  text-align: center;
}

.date-popup-body .date-view .calendar .calendar-grid {
  display: grid; 
  grid-template-columns: repeat(7, 1fr);
  place-items: center;
}

.date-popup-body .date-view .calendar .calendar-grid .day-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  font-size: 14px;
  font-weight: 400;
  color: var(--color-system-wt);
  border: none;
  background: none;
  cursor: pointer;
}

.date-popup-body .date-view .calendar .calendar-grid .day-cell.is-outside {
  color: var(--color-system-400);
}

.date-popup-body .date-view .calendar .calendar-grid .day-cell.is-today {
  border-radius: 50%;
  background: var(--color-system-500);
}

.date-popup-body .date-view .calendar .calendar-grid .day-cell.is-selected {
  border-radius: 50%;
  color: var(--color-system-bk);
  background: var(--color-primary-400);
}

.date-popup-body .month-view {
  display: none;
  padding-bottom: 12px;
}

.date-popup-body .month-view .calendar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 x 5 */
}

.date-popup-body .month-view .calendar-grid .month-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  font-size: 14px;
  font-weight: 400;
  color: var(--color-system-wt);
  border: none;
  background: none;
  cursor: pointer;
  margin: 6px 24px;
}

.date-popup-body .month-view .calendar-grid .month-cell.is-outside {
  color: var(--color-system-400);
}

.date-popup-body .month-view .calendar-grid .month-cell.is-selected {
  border-radius: 50%;
  color: var(--color-system-bk);
  background: var(--color-primary-400);
}

.date-popup-body .year-view {
  display: none;
  padding-bottom: 12px;
}

.date-popup-body .year-view .calendar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 x 5 */
}

.date-popup-body .year-view .calendar-grid .year-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 70px;
  height: 48px;
  font-size: 14px;
  font-weight: 400;
  color: var(--color-system-wt);
  border: none;
  background: none;
  cursor: pointer;
  margin: 0 7px;
}

.date-popup-body .year-view .calendar-grid .year-cell.is-selected {
  border-radius: 39px;
  color: var(--color-system-bk);
  background: var(--color-primary-400);
}

/* ========================================
   PC (1024px 이상)
   ======================================== */
@media (min-width: 1024px) {
  .field-row .field {
    flex: 1;
  }

  .input-wrap {
    max-width: 384px;
  }

  .custom-select {
    max-width: 384px;
  }

  .date-popup {
    width: 100%;
  }

  .date-popup-body .date-view .calendar .calendar-weekdays .weekday {
    width: 52px;
  }
}