/* ============================
   내원 진료 예약 팝업 공통 폰트/자간 리셋
   - 다른 CSS에서 div, p, button, label, span 등에
     font-family / letter-spacing / font-size / font-weight 를
     전역으로 걸어도 팝업 내부에서는 이 설정이 우선 적용되도록 함
============================ */
#reservationPopup,
#reservationPopup * {
  font-family: inherit;
  letter-spacing: normal;
}

/* span 기본값 별도 초기화 (전역 span 규칙 무효화용) */
#reservationPopup span {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
}

/* 캘린더 년/월 스팬은 한 번 더 안전하게 초기화 */
#reservationPopup .rs-cal-title span {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
}

/* label 전역 transform 무력화 */
#reservationPopup label {
  transform: none !important;
  margin-right: 0;
  font-size: inherit;
  font-weight: inherit;
}

/* ============================
   body 스크롤 제어 (예약 모달 전용)
============================ */
body.modal-open--reservation {
  overflow: hidden;
}

/* 내원 진료 예약 모달 공통 스크롤 설정 */
#reservationPopup .reservation-dialog,
#reservationPopup .reservation-body {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ============================
   내원 진료 예약 모달
============================ */

/* 내원 진료 예약 모달 기본 */
#reservationPopup.reservation-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

#reservationPopup.reservation-modal.is-open {
  display: flex;
}

#reservationPopup .reservation-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

#reservationPopup .reservation-dialog {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 16px;
  max-width: 1120px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 모바일에서는 상하 여백 없이 풀스크린 */
@media (max-width: 768px) {
  #reservationPopup.reservation-modal {
    align-items: stretch;
    justify-content: stretch;
  }

  #reservationPopup .reservation-dialog {
    position: fixed;
    inset: 0;
    max-width: 100%;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* 바디(스크롤 영역) */
#reservationPopup .reservation-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 0 24px; /* 히어로는 여백 없이, 아래만 여백 */
}

/* 히어로(이미지 풀폭 + 닫기 버튼) */
#reservationPopup .reservation-hero {
  position: relative;
  margin: 0 0 24px;
}

#reservationPopup .reservation-hero-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0;
}

/* 히어로 오른쪽 상단 닫기 버튼 */
#reservationPopup .reservation-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.48);
  color: #fff;
  font-size: 18px;
  line-height: 32px;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  #reservationPopup .reservation-close:hover {
    background: rgba(0, 0, 0, 0.65);
  }
}

/* 폼 내용 좌우 여백 */
#reservationPopup .reservation-form {
  padding: 0 24px;
}

/* 섹션 공통 */
#reservationPopup .reservation-section {
  margin-bottom: 20px;
}

#reservationPopup .reservation-section:nth-child(2) {
  margin-bottom: 10px;
}

#reservationPopup
  .reservation-section:nth-child(2)
  .section-title.section-title--bar {
  margin-bottom: 5px;
}

#reservationPopup .section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

#reservationPopup .req {
  color: #ff4b6a;
  margin-left: 2px;
}

/* ============================
   진료과목 그리드 / 체크박스
============================ */

#reservationPopup .dept-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}

/* 기본 체크박스 + 텍스트 스타일 */
#reservationPopup .dept-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0;
  border: 0;
}

/* 팝업 내부 체크박스 모양 강제 (네모) */
#reservationPopup input[type="checkbox"] {
  -webkit-appearance: checkbox !important;
  appearance: checkbox !important;
  border-radius: 2px !important;

  width: 16px;
  height: 16px;
  margin: 0 4px 0 0;
  padding: 0;
}

/* 인풋은 기본 체크박스 그대로 노출 */
#reservationPopup .dept-item input {
  display: inline-block;
  /* width/height는 위의 공통 checkbox 규칙으로 제어 */
  transform: scale(1); /* 혹시 전역에서 scale 걸려있을 수 있어 초기화 */
  transform-origin: center;
  margin: 0;
}

/* 텍스트 */
#reservationPopup .dept-item span {
  position: static;
  color: #000;
  font-weight: normal;
  font-size: 0.95rem;
}

/* 기존 “보라색 칩” 스타일 무력화 */
#reservationPopup .dept-item input:checked + span,
#reservationPopup .dept-item input:checked + span::before {
  color: inherit;
}

#reservationPopup .dept-item input:checked + span::before {
  content: none;
}

/* ============================
   온라인 예약 - 달력 (rs-calendar)
============================ */

/* 섹션 공통 타이틀 기본 */
#reservationPopup .section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

/* 예약 날짜/시간 바 스타일 */
#reservationPopup .section-title--bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  background: #e5e5e5;
  padding: 10px 14px;
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 500;
}

/* 아이콘 래퍼 */
#reservationPopup .section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* SVG 크기 통일 (width/height 속성이 있어도 한 번 더 잡아줌) */
#reservationPopup .section-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* 텍스트 라벨 */
#reservationPopup .section-label {
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 600;
}

/* 별표 위치 보정 */
#reservationPopup .section-title--bar .req {
  margin-left: 4px;
}

#reservationPopup .calendar-wrapper {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 14px 14px;
  background: #fff;
}

/* 전체 캘린더 박스 */
#reservationPopup .rs-calendar {
  width: 100%;
  font-size: 13px;
  font-family: inherit;
}

/* 헤더 (이전/다음 + 년월) */
#reservationPopup .rs-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

#reservationPopup .rs-cal-title {
  font-weight: 600;
  font-size: 14px;
}

/* rs-cal-title 안의 span 은 전역 span 규칙 무효화 */
#reservationPopup .rs-cal-title span {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
}

#reservationPopup .rs-cal-arrow {
  border: none;
  background: transparent;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
}

#reservationPopup .rs-cal-arrow:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

@media (hover: hover) {
  #reservationPopup .rs-cal-arrow:hover {
    background: #f3f4f6;
  }
}

/* 요일 영역 */
#reservationPopup .rs-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
  font-size: 12px;
  color: #6b7280;
}

#reservationPopup .rs-cal-weekday.is-sun {
  color: #ef4444;
}

#reservationPopup .rs-cal-weekday.is-sat {
  color: #2563eb;
}

/* 날짜들 */
#reservationPopup .rs-cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 32px;
  gap: 2px;
}

/* 날짜 버튼 기본 */
#reservationPopup .rs-cal-day {
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 비어 있는 칸(이달 범위 밖) */
#reservationPopup .rs-cal-day.is-empty {
  cursor: default;
}

/* 오늘 날짜 (회색 박스) */
#reservationPopup .rs-cal-day.is-today {
  background: #e5e7eb;
  color: #111827;
}

/* 선택된 날짜 (보라색 박스) */
#reservationPopup .rs-cal-day.is-selected {
  background: #ab94eb;
  color: #ffffff;
}

/* 일/토 색상 */
#reservationPopup .rs-cal-day.is-sun {
  color: #ef4444;
}

#reservationPopup .rs-cal-day.is-sat {
  color: #2563eb;
}

/* 선택 + 요일 색상 같이 적용될 때 우선 순위 */
#reservationPopup .rs-cal-day.is-selected.is-sun,
#reservationPopup .rs-cal-day.is-selected.is-sat {
  color: #ffffff;
}

/* 예약 달력: 오늘 이전 날짜 비활성(회색) 표시 */
#reservationPopup .rs-cal-day.is-disabled {
  color: #c4c4c4; /* 글자색 회색 */
  cursor: default; /* 마우스 손가락 안 나오게 */
}

/* 필요하면 배경도 살짝 흐리게 */
#reservationPopup .rs-cal-day.is-disabled.is-sun,
#reservationPopup .rs-cal-day.is-disabled.is-sat {
  color: #d0d0d0;
}

#reservationPopup .rs-cal-day.is-disabled:hover {
  background-color: transparent; /* 호버해도 색 안 바뀌게 */
}

/* 호버 효과 (PC) */
@media (hover: hover) {
  #reservationPopup .rs-cal-day:not(.is-empty):hover {
    background: #f3f4f6;
  }
}

/* 모바일에서 버튼 터치 영역 조금 키움 */
@media (max-width: 480px) {
  #reservationPopup .rs-cal-days {
    grid-auto-rows: 34px;
  }
}

/* ============================
   시간 그리드 / 슬롯
============================ */

#reservationPopup .time-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 768px) {
  #reservationPopup .time-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

#reservationPopup .time-slot {
  padding: 8px 0;
  border-radius: 999px;
  border: 1px solid #ddd;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

#reservationPopup .time-slot.is-selected {
  border-color: transparent;
  color: #fff;
  background: #ab94eb;
}

/* 예약된 시간: 빨간 취소선 + 흐린 색 */
#reservationPopup .time-slot.is-reserved {
  position: relative;
  color: #b91c1c;
  border-color: #fecaca;
  background: #fee2e2;
}

#reservationPopup .time-slot.is-reserved::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
}

/* 이미 지난 시간: 회색 + 비활성 느낌 */
#reservationPopup .time-slot.is-past {
  color: #9ca3af;
  border-color: #e5e7eb;
  background: #f9fafb;
  cursor: default;
}

/* 로딩 문구 (예약 가능한 시간을 불러오는 중...) */
#reservationPopup .time-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 16px 8px;
  font-size: 14px;
  color: #6b7280;
  line-height: 1.4;
}

/* 공통 애니메이션 */
#reservationPopup .calendar-wrapper,
#reservationPopup .time-grid {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.28s ease, opacity 0.28s ease, padding 0.28s ease;
}

/* 열렸을 때 */
#reservationPopup .calendar-wrapper.is-open,
#reservationPopup .time-grid.is-open {
  max-height: 500px;
  opacity: 1;
  padding-top: 12px;
  padding-bottom: 16px;
}

/* 접혀 있을 때는 거의 여백 없게 */
#reservationPopup .calendar-wrapper:not(.is-open),
#reservationPopup .time-grid:not(.is-open) {
  padding-top: 0;
  padding-bottom: 4px;
}

/* ============================
   입력 필드 (전역 input[type=text], [type=tel] 무력화)
============================ */

#reservationPopup .input-text,
#reservationPopup input.input-text[type="text"],
#reservationPopup input.input-text[type="tel"] {
  all: unset; /* 전역에 걸린 모든 스타일 싹 지우기 */
  box-sizing: border-box;
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* iOS 확대 방지 */
  line-height: 1.4;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
}

/* placeholder만 글자 크기 작게 */
#reservationPopup input.input-text::placeholder {
  font-size: 14px;
}

/* 사파리/옛 iOS 대응용 */
#reservationPopup input.input-text::-webkit-input-placeholder {
  font-size: 14px;
}

/* 포커스 스타일 */
#reservationPopup .input-text:focus {
  outline: none;
  border-color: #b36bff;
  box-shadow: 0 0 0 1px rgba(179, 107, 255, 0.3);
}

/* 연락처 */
#reservationPopup .phone-row {
  display: flex;
  gap: 8px;
}

#reservationPopup .phone-prefix {
  min-width: 70px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
  font-size: 14px;
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================
   개인정보 동의
============================ */

#reservationPopup .consent-section .chk {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

/* 체크박스는 위의 공통 checkbox 규칙을 그대로 사용 */

/* ===== 개인정보 동의 토글 ===== */
#reservationPopup .privacy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#reservationPopup .privacy-header .chk {
  flex: 1 1 auto;
}

#reservationPopup .privacy-toggle {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  #reservationPopup .privacy-toggle:hover {
    color: #111827;
  }
}

#reservationPopup .privacy-detail {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  max-height: 160px;
  overflow-y: auto;
  font-size: 12px;
  color: #4b5563;
}

#reservationPopup .privacy-title {
  font-weight: 600;
  margin: 0 0 6px;
}

#reservationPopup .privacy-text {
  margin: 0 0 6px;
  line-height: 1.5;
}

#reservationPopup .privacy-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: #4b5563;
  text-decoration: underline;
}

/* ============================
   하단 버튼
============================ */

#reservationPopup .reservation-footer {
  margin-top: 8px;
  padding-bottom: 8px;
}

#reservationPopup .btn-reserve {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  background: #ab94eb;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
