/* ─── 기본 설정 ─────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* ─── 로그인/회원가입 페이지 전체 배경 ────────────────────────── */
#page-login, #page-register {
  margin-top: -80px;
  padding-top: 0;
}

/* ─── 네비게이션 ─────────────────────────────────────────────── */
nav { backdrop-filter: blur(8px); }

.nav-btn { font-size: 14px; }

/* ─── 관리자 탭 ──────────────────────────────────────────────── */
.admin-tab {
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  border: none;
}

.admin-tab.active {
  background: white;
  color: #2563eb;
  box-shadow: 0 1px 6px rgba(0,0,0,0.10);
}

.admin-tab:hover:not(.active) {
  background: rgba(255,255,255,0.6);
  color: #374151;
}

/* ─── 월간 멀티주차 그리드 (Excel 스타일) ───────────────────────── */
.month-grid-wrapper {
  width: 100%;
  overflow-x: auto;
}

.month-grid-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

/* 주차 라벨 셀 */
.week-label-cell {
  width: 44px;
  min-width: 44px;
  background: #e8f0fe;
  border: 1px solid #c5d5f0;
  border-right: 2px solid #93b4ea;
  text-align: center;
  vertical-align: middle;
  padding: 4px 2px;
}

/* 슬롯 행의 주차 열 자리 유지용 빈 셀 */
.week-label-col {
  width: 44px;
  min-width: 44px;
  background: #e8f0fe;
  border: 1px solid #c5d5f0;
  border-right: 2px solid #93b4ea;
  padding: 0;
}

.week-label-text {
  display: block;
  writing-mode: horizontal-tb;
  font-weight: 800;
  font-size: 12px;
  color: #1e40af;
  white-space: pre-line;
  word-break: keep-all;
  text-align: center;
  line-height: 1.4;
}

/* 시간 컬럼 헤더 (날짜행의 "날짜" 셀) */
.time-header-cell {
  width: 110px;
  min-width: 110px;
  background: #dbeafe;
  border: 1px solid #c5d5f0;
  text-align: center;
  font-weight: 700;
  font-size: 11px;
  color: #1e40af;
  padding: 6px 4px;
}

/* 날짜 헤더 행 */
.week-date-header-row {
  background: #dbeafe;
}

.date-header-cell {
  background: #dbeafe;
  border: 1px solid #c5d5f0;
  text-align: center;
  padding: 5px 3px;
  font-size: 11px;
  font-weight: 600;
  color: #1e3a8a;
  vertical-align: middle;
}

.date-header-cell.empty-date {
  background: #f1f5f9;
}

.date-header-cell.today-date {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.date-header-cell .date-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #1e3a8a;
}

.date-header-cell.today-date .date-label {
  color: #92400e;
}

.date-header-cell .day-label {
  display: inline-block;
  font-size: 11px;
  color: #3b82f6;
  font-weight: 600;
}

.date-header-cell.today-date .day-label {
  color: #d97706;
}

/* 시간대 셀 라벨 */
.time-cell-label {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  text-align: center;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  padding: 3px 4px;
  white-space: nowrap;
  /* 1시간 레이블이 rowspan=2로 2슬롯 높이 차지 */
}

/* 일정 데이터 셀 */
.sched-cell {
  border: 1px solid #e5e7eb;
  vertical-align: top;
  padding: 2px 3px;
  min-height: 18px;
  height: 18px;
  cursor: pointer;
  background: #ffffff;
  transition: background 0.1s;
}

/* 일정이 있는 셀: padding 제거 후 div가 꽉 채움 */
.sched-cell.has-sched {
  padding: 0;
  vertical-align: top;
}

.sched-cell:hover {
  background: #f0f7ff;
}

.sched-cell.has-sched:hover {
  background: transparent;
}

.sched-cell.empty-day {
  background: #f8fafc;
  cursor: default;
}

.sched-cell.today-sched-cell {
  background: #fffbeb;
}

/* 30분 슬롯 행 — 정시 행은 약간 굵은 경계선 */
.hour-mark-row .sched-cell,
.hour-mark-row .time-cell-label {
  border-top: 1px solid #c7d2e8;
}

/* 주차 구분선 */
.week-divider-row .week-divider-cell {
  height: 6px;
  background: #e2e8f0;
  border: none;
  padding: 0;
}

/* ─── 교육과정명 행 ─────────────────────────────────────────────── */
.course-name-row {
  background: #f0f9ff;
  cursor: pointer;
  user-select: none;
}

.course-name-row:hover {
  background: #e0f2fe;
}

.course-name-row.expanded .course-name-label-cell {
  background: #bae6fd;
  color: #0c4a6e;
}

.course-name-label-cell {
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  text-align: center;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 700;
  color: #0369a1;
  padding: 4px;
  white-space: nowrap;
  transition: background 0.2s;
}

/* 토글 아이콘 */
.week-toggle-icon {
  font-size: 10px;
  margin-right: 3px;
  transition: transform 0.2s;
  color: #0369a1;
}

/* ─── 주차 슬롯 행 숨김/펼침 ───────────────────────────────────── */
/* 기본: 슬롯 행 숨김 */
.week-slot-row {
  display: none;
}

/* 펼쳐진 상태 */
.week-slot-row:not(.week-slot-hidden) {
  display: table-row;
}

/* 접힘 강제 */
.week-slot-row.week-slot-hidden {
  display: none !important;
}

.course-name-cell {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  vertical-align: middle;
  padding: 3px 5px;
  min-height: 28px;
}

.course-name-cell.empty-day {
  background: #f8fafc;
}

.course-name-tag {
  display: inline-block;
  background: #0ea5e9;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  margin: 1px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 일정 아이템 (월간 뷰) */
.month-sched-item {
  background: #eff6ff;
  border-left: 4px solid #2563eb;
  border-radius: 0;
  padding: 4px 6px;
  margin: 0;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.4;
  transition: filter 0.1s ease;
  overflow: hidden;
  box-sizing: border-box;
  /* 셀 전체 높이 꽉 채우기 */
  width: 100%;
  height: 100%;
  display: block;
}

/* full-height: 1시간 이상 — td 높이 100% 채움 */
.month-sched-item.full-height {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 100%;
}

/* has-sched td는 relative + 높이 지정 */
.sched-cell.has-sched {
  position: relative;
}

.month-sched-item:hover {
  filter: brightness(0.93);
}

/* 30분짜리 compact 아이템 */
.month-sched-item.compact {
  padding: 3px 5px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
}

.month-sched-item.status-completed {
  background: #dcfce7;
  border-left-color: #16a34a;
}
.month-sched-item.status-completed:hover { filter: brightness(0.93); }

.month-sched-item.status-cancelled {
  background: #f3f4f6;
  border-left-color: #9ca3af;
  opacity: 0.75;
}

/* 시간 표시 */
.month-sched-item .ms-time {
  font-size: 10px;
  color: #3b82f6;
  font-weight: 600;
  white-space: nowrap;
  margin-bottom: 1px;
}

.month-sched-item.compact .ms-time {
  display: none; /* 30분짜리는 시간 숨김 */
}

.month-sched-item .ms-course {
  font-weight: 700;
  color: #1e3a8a;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-sched-item.compact .ms-course {
  font-size: 11px;
}

.month-sched-item.status-completed .ms-course { color: #14532d; }
.month-sched-item.status-completed .ms-time   { color: #16a34a; }
.month-sched-item.status-cancelled .ms-course { color: #4b5563; }
.month-sched-item.status-cancelled .ms-time   { color: #9ca3af; }

.month-sched-item .ms-instructor {
  font-size: 10px;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.month-sched-item .ms-instructor i { color: #94a3b8; font-size: 9px; }

/* 하위 호환용 기존 sched-item 스타일 유지 */
.sched-item {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border-radius: 8px;
  padding: 5px 7px;
  margin-bottom: 3px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.4;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(37,99,235,0.2);
  overflow: hidden;
}

.sched-item.status-completed {
  background: linear-gradient(135deg, #10b981, #059669);
}

.sched-item.status-cancelled {
  background: linear-gradient(135deg, #9ca3af, #6b7280);
}

.sched-item .sched-course {
  font-weight: 700;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sched-item .sched-instructor {
  font-size: 10px;
  opacity: 0.85;
}

/* 시간표 반응형 컬럼 */
@media (max-width: 1200px) {
  .month-grid-table { min-width: 800px; font-size: 11px; }
  .time-header-cell { width: 90px; min-width: 90px; }
  .time-cell-label { font-size: 10px; }
  .month-sched-item .ms-course { font-size: 10px; }
}

/* 서브컬럼 구분선 (N등분된 날짜 열 경계) */
.sched-cell.subcol {
  border-left: 1px dashed #c7d2e8;
}
.sched-cell.subcol-0-of-2,
.sched-cell.subcol-0-of-3,
.sched-cell.subcol-0-of-4 {
  border-left: 1px solid #e5e7eb; /* 첫 서브컬럼은 기본 border */
}
.course-name-cell.subcol-header {
  border-left: 1px dashed #bae6fd;
}

/* ─── 드래그 선택 하이라이트 ────────────────────────────────────── */
.sched-cell {
  user-select: none;
  -webkit-user-select: none;
}

/* 드래그 가능 커서 */
.sched-cell:not(.empty-day) { cursor: crosshair; }
.month-sched-item            { cursor: pointer; }

/* 드래그 중 선택된 셀 */
.sched-cell.drag-selecting {
  background: #bfdbfe !important;
  outline: 2px solid #2563eb;
  outline-offset: -1px;
  position: relative;
  z-index: 1;
}

/* ─── 드래그 툴팁 ───────────────────────────────────────────────── */
.drag-tooltip {
  position: fixed;
  background: #1e40af;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(30,64,175,0.4);
  opacity: 0;
  transform: translateY(4px);
.drag-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── 상태 뱃지 ──────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-planned { background: #dbeafe; color: #1d4ed8; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #f3f4f6; color: #4b5563; }

/* ─── 테이블 공통 ─────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

/* ─── 드롭다운 검색 ──────────────────────────────────────────── */
.dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  transition: background 0.1s;
  border-bottom: 1px solid #f3f4f6;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: #eff6ff; color: #2563eb; }

.dropdown-item .sub {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 1px;
}

/* ─── 모달 ───────────────────────────────────────────────────── */
.modal-backdrop {
  backdrop-filter: blur(4px);
}

/* ─── 로딩 스피너 ─────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-radius: 50%;
  border-top-color: #2563eb;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 알림 토스트 ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.info { background: #2563eb; }

/* ─── 실적 수치 카드 ──────────────────────────────────────────── */
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.stat-chip.blue { background: #dbeafe; color: #1d4ed8; }
.stat-chip.green { background: #d1fae5; color: #065f46; }
.stat-chip.purple { background: #ede9fe; color: #6d28d9; }

/* ─── 반응형 ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  body { font-size: 14px; }
  .month-grid-table { font-size: 10px; }
  .week-label-cell { width: 32px; min-width: 32px; }
  .week-label-text { font-size: 11px; }
  .time-header-cell { width: 72px; min-width: 72px; }
  .time-cell-label { font-size: 9px; padding: 2px; }
  .month-sched-item { padding: 1px 3px; font-size: 10px; }
  .sched-cell { min-height: 16px; height: 16px; }
  .data-table { font-size: 13px; }
  .data-table th, .data-table td { padding: 10px 12px; }
}

/* ─── 스크롤바 커스터마이즈 ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── 빈 상태 ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #9ca3af;
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 16px; }

/* ─── 교육과정 색상 스와치 팔레트 ─────────────────────────────── */
.color-swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
  outline: none;
  position: relative;
}

.color-swatch:hover:not(.disabled) {
  transform: scale(1.12);
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.color-swatch.selected {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(29,78,216,0.25);
  transform: scale(1.08);
}

.color-swatch.selected::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: rgba(0,0,0,0.45);
}

.color-swatch.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(40%);
}

.color-swatch.disabled::before {
  content: '✕';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: rgba(0,0,0,0.4);
}

/* ─── 교육과정 색상 범례 배지 ─────────────────────────────────── */
.legend-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px 3px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(0,0,0,0.65);
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
  white-space: nowrap;
  letter-spacing: -0.01em;
}
