/* ============================================
   프로그램 신청 달력 + 회차 목록
   ============================================ */

/* 프로그램 페이지: 본문 살짝 넓힘 + 가운데 정렬 (기본 #container float:left 보정) */
#container {
  float: none !important;
  margin-left: auto !important;
  margin-right: auto !important;
  width: 1200px !important;
  max-width: 100%;
  box-sizing: border-box;
}
#container .scontainer {
  width: 1200px !important;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}
#container .r_contents {
  width: 920px !important;
  max-width: 100%;
  box-sizing: border-box;
}
#container .r_contents .r_title {
  width: 920px !important;
  max-width: 100%;
  box-sizing: border-box;
}

/* 2단 레이아웃 */
.pgm-wrap {
  display: flex;
  gap: 28px;
  align-items: stretch;
  margin-top: 15px;
  width: 100%;
}
.pgm-calendar {
  flex: 0 0 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pgm-schedule {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}
#pgm-slot-area {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* 빈 표일 때 slot-area가 달력 높이만큼 채워지도록 */
#pgm-slot-area:has(.pgm-slot-empty) {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- 달력 네비게이션 (달력 위, 오른쪽 타이틀과 정렬) ---- */
.pgm-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.pgm-nav .nav-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
  color: #555;
}
.pgm-nav .nav-btn:hover {
  background: #f5f5f5;
  border-color: #999;
}
.pgm-nav .nav-title {
  font-size: 20px;
  font-weight: bold;
  min-width: 150px;
  text-align: center;
}

/* ---- 달력 테이블 ---- */
.pgm-cal-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1px solid #ddd;
}
.pgm-cal-table th {
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  background: #f8f8f8;
  border-bottom: 2px solid #ddd;
  color: #333;
}
.pgm-cal-table th.sun {
  color: #e74c3c;
}
.pgm-cal-table th.sat {
  color: #3498db;
}

.pgm-cal-table td {
  height: 52px;
  text-align: center;
  vertical-align: middle;
  border: 1px solid #eee;
  padding: 4px;
  position: relative;
}

/* 날짜 셀 */
.pgm-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

/* 일요일/토요일 색상 */
td.sun .pgm-day {
  color: #e74c3c;
}
td.sat .pgm-day {
  color: #3498db;
}

/* 예약가능 날짜 - 테두리만, 선택 시에만 채움 */
td.available .pgm-day {
  border: 2px solid #6dbdbf;
  color: #6dbdbf;
  cursor: pointer;
  font-weight: bold;
}
td.available:hover .pgm-day {
  background: #e8f7f7;
}
/* 선택한 날짜만 안에 색상 칠함 */
td.available.active .pgm-day {
  background: #6dbdbf;
  color: #fff;
}

/* 휴관일 - 동그라미 없음, 날짜만 회색 */
td.closed .pgm-day {
  color: #999;
}
td.closed::after {
  content: '휴관';
  display: block;
  font-size: 10px;
  color: #e74c3c;
  margin-top: -2px;
}

/* 지난 날짜 - 동그라미 없음, 날짜만 회색 */
td.past .pgm-day {
  color: #999;
}

/* 프로그램 등록됐으나 전부 신청불가 - 회색 동그라미 */
td.full .pgm-day {
  background: #ddd;
  color: #999;
}

/* 범례 */
.pgm-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 10px;
  font-size: 13px;
  color: #666;
}
.pgm-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.pgm-legend .dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.pgm-legend .dot.available {
  border: 2px solid #6dbdbf;
}
.pgm-legend .dot.unavailable {
  border: 2px solid #ddd;
  background: #ddd;
}

/* ---- 오른쪽: 회차 목록 ---- */
.pgm-schedule-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 12px;
  padding-top: 5px;
  text-align: center;
}
.pgm-schedule-title .date-text {
  color: #333;
}
.pgm-schedule-title .day-text {
  color: #888;
  font-weight: normal;
  font-size: 14px;
  margin-left: 6px;
}

.pgm-schedule-empty {
  padding: 60px 20px;
  text-align: center;
  color: #999;
  font-size: 14px;
}
/* 빈 표 상태 - 외곽선만으로 영역 채움, 달력 높이에 맞춤 */
.pgm-slot-empty {
  flex: 1;
  min-height: 0;
  height: 100%;
}
.pgm-slot-empty tbody td {
  height: 100%;
  vertical-align: middle;
  border: 1px solid #eee;
  background: #fafafa;
}
.pgm-slot-empty .pgm-schedule-empty {
  padding: 60px 20px;
}

/* 회차 테이블 — auto 레이아웃(마지막 열 nowrap·고정폭과 fixed 조합 시 잘림 방지) */
.pgm-slot-table {
  width: 100%;
  max-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  border: 1px solid #ddd;
}
.pgm-slot-table th,
.pgm-slot-table td {
  box-sizing: border-box;
  padding: 10px 6px;
  text-align: center;
  font-size: 13px;
  border: 1px solid #eee;
  vertical-align: middle;
  /* 좁은 칸에서도 줄바꿈으로 칸 경계 유지 */
  overflow-wrap: break-word;
  word-break: break-word;
}
.pgm-slot-table thead th {
  border: 1px solid #ddd;
  background: #f8f8f8;
  font-weight: 600;
  color: #333;
}
/* 두 줄 헤더: 대상/연령, 정원·신청 / 대기 */
.pgm-slot-table thead th.pgm-th-target-age,
.pgm-slot-table thead th.pgm-th-capacity {
  white-space: normal;
  line-height: 1.35;
  padding: 8px 6px;
  font-size: 12px;
  vertical-align: middle;
}
/* 프로그램명 열 */
.pgm-slot-table th.pgm-th-title {
  white-space: normal;
}
.pgm-slot-table td.pgm-col-title {
  line-height: 1.45;
}
/* 대상(위) + 연령(아래) 한 칸 — 블록이 칸 폭을 넘지 않게 */
.pgm-slot-table td.pgm-col-target-age {
  padding: 10px 6px;
}
.pgm-slot-table td.pgm-col-target-age .pgm-ta-target,
.pgm-slot-table td.pgm-col-target-age .pgm-ta-age {
  display: block;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.pgm-slot-table .pgm-ta-target {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  line-height: 1.4;
  margin-bottom: 4px;
}
.pgm-slot-table .pgm-ta-age {
  font-size: 12px;
  color: #555;
  line-height: 1.45;
}

/* 상태 뱃지 */
.pgm-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}
.pgm-badge.accepting {
  color: #2e7d32;
  border-color: #2e7d32;
  background: #e8f5e9;
}
.pgm-badge.waiting {
  color: #e65100;
  border-color: #e65100;
  background: #fff3e0;
}
.pgm-badge.closed {
  color: #999;
  border-color: #ccc;
  background: #f5f5f5;
}
.pgm-badge.preparing {
  color: #1565c0;
  border-color: #1565c0;
  background: #e3f2fd;
}
.pgm-badge.btn {
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}
.pgm-badge.btn:hover {
  opacity: 0.85;
}

/* 신청 버튼 */
.pgm-apply-btn {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  color: #fff;
  background: #ff9800;
  transition: background 0.15s;
}
.pgm-apply-btn:hover {
  background: #e65100;
}
.pgm-apply-btn.wait {
  background: #ff9800;
}
.pgm-apply-btn.disabled {
  background: #ccc;
  cursor: default;
  pointer-events: none;
}

/* 정원 표시 — 윗줄: 신청/정원, 아랫줄: 대기 */
.pgm-capacity {
  font-size: 13px;
}
.pgm-capacity .pgm-cap-line1,
.pgm-capacity .pgm-cap-line2 {
  display: block;
  line-height: 1.45;
}
.pgm-capacity .pgm-cap-line2 {
  margin-top: 4px;
  font-size: 12px;
  color: #444;
}
.pgm-capacity .pgm-cap-line2.pgm-cap-wait-none {
  color: #aaa;
}
.pgm-capacity .current {
  font-weight: bold;
  color: #e74c3c;
}
/* 레거시(과거) 일정: 정원 숫자만 — 신청 수 대비 빨간색 처리 없음 */
.pgm-capacity .pgm-cap-legacy-only {
  font-weight: 600;
  color: inherit;
}

/* 서버시간 */
.pgm-server-time {
  font-size: 12px;
  color: #999;
  margin-bottom: 8px;
}

/* 로딩 */
.pgm-loading {
  text-align: center;
  padding: 40px 0;
  color: #999;
}

/* 상태 / 교육(보기 버튼) */
.pgm-slot-table td.pgm-col-status {
  font-size: 13px;
  font-weight: 600;
}
.pgm-slot-table td.pgm-col-status.pgm-status-accepting {
  color: #2e7d32;
}
.pgm-slot-table td.pgm-col-status.pgm-status-waiting {
  color: #ef6c00;
}
.pgm-slot-table td.pgm-col-status.pgm-status-preparing {
  color: #1565c0;
}
.pgm-slot-table td.pgm-col-status.pgm-status-finished {
  color: #757575;
  font-weight: 500;
}
.pgm-slot-table td.pgm-col-status.pgm-status-closed {
  color: #c62828;
}
.pgm-slot-table td.pgm-col-status.pgm-status-archive {
  color: #5c6bc0;
  font-weight: 500;
}
/* 교육(보기): 고정 너비 — width:1% + fixed 테이블이면 셀이 테이블 밖으로 밀림 */
.pgm-slot-table th.pgm-th-guide,
.pgm-slot-table td.pgm-col-guide {
  width: 4.75rem;
  min-width: 4.75rem;
  max-width: 4.75rem;
  white-space: nowrap;
  padding: 8px 4px;
  box-sizing: border-box;
  vertical-align: middle;
}
.pgm-slot-table .pgm-btn-view {
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
  line-height: 1.2;
}

/* 교육 보기 버튼 */
.pgm-btn-view {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #6dbdbf;
  background: #fff;
  color: #2c7a7b;
  border-radius: 4px;
  cursor: pointer;
}
.pgm-btn-view:hover {
  background: #e8f7f7;
}

/* 교육 레이어(모달) + iframe */
.pgm-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}
.pgm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.pgm-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: min(92vh, 900px);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  align-self: center;
}
.pgm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8f8f8;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}
.pgm-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #333;
}
.pgm-modal-close {
  border: none;
  background: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
}
.pgm-modal-close:hover {
  color: #000;
}
.pgm-modal-body {
  flex: 0 1 auto;
  min-height: 0;
  position: relative;
  background: #fafafa;
}
.pgm-modal-body iframe {
  display: block;
  width: 100%;
  min-height: 240px;
  height: min(78vh, 760px);
  max-height: min(88vh, 760px);
  border: none;
  background: #fff;
}

/* ---- 반응형 ---- */
@media (max-width: 768px) {
  #container,
  #container .scontainer,
  #container .r_contents,
  #container .r_contents .r_title {
    width: 100% !important;
    max-width: 100% !important;
  }
  #container .r_contents {
    max-width: 100% !important;
  }
  .pgm-wrap {
    flex-direction: column;
  }
  .pgm-calendar {
    flex: none;
    width: 100%;
  }
  .pgm-schedule {
    width: 100%;
  }
}
