/*!
 * JennyCalendar v0.2.0 — embeddable calendar/scheduler (air-gapped ready)
 * (c) Jennysoft. All rights reserved. Commercial license.
 * No external requests (fonts/images/CDN). Theme via --jcal-* variables.
 */

.jcal-container {
  /* 테마 변수 — KRDS 등 디자인시스템 톤은 이 변수만 바꿔서 대응한다 */
  --jcal-border: #d9dee5;
  --jcal-bg: #ffffff;
  --jcal-text: #1e2530;
  --jcal-muted: #6b7684;
  --jcal-weekend: #c22a2a;
  --jcal-saturday: #2a5bc2;
  --jcal-other-month: #b6bec9;
  --jcal-today-bg: #eef4ff;
  --jcal-today-ring: #2a5bc2;
  --jcal-primary: #205081;
  --jcal-primary-text: #ffffff;
  --jcal-hover: #f3f6fa;
  --jcal-focus: #1a49a0;
  --jcal-dialog-bg: #ffffff;
  --jcal-dialog-shadow: 0 6px 24px rgba(20, 30, 50, 0.25);
  --jcal-event-text: #ffffff;
  --jcal-font: -apple-system, "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", sans-serif;

  position: relative;
  display: flex;
  flex-direction: column;
  height: 700px;
  font-family: var(--jcal-font);
  font-size: 13px;
  color: var(--jcal-text);
  background: var(--jcal-bg);
  border: 1px solid var(--jcal-border);
  border-radius: 4px;
  box-sizing: border-box;
}
.jcal-container *, .jcal-container *::before, .jcal-container *::after { box-sizing: border-box; }

.jcal-container button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}
.jcal-container button:focus-visible,
.jcal-container a:focus-visible,
.jcal-container input:focus-visible,
.jcal-container select:focus-visible {
  outline: 2px solid var(--jcal-focus); /* KWCAG: 포커스 표시 유지 */
  outline-offset: 1px;
}

/* ------------------------------------------------------------------ 툴바 */
.jcal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--jcal-border);
  flex: 0 0 auto;
}
.jcal-toolbar .jcal-btn {
  padding: 5px 12px;
  border: 1px solid var(--jcal-border);
  border-radius: 4px;
  background: var(--jcal-bg);
  color: var(--jcal-text);
}
.jcal-toolbar .jcal-btn:hover { background: var(--jcal-hover); }
.jcal-toolbar .jcal-btn[aria-pressed="true"] {
  background: var(--jcal-primary);
  border-color: var(--jcal-primary);
  color: var(--jcal-primary-text);
}
.jcal-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 8px;
  min-width: 140px;
  text-align: center;
}
.jcal-toolbar-spacer { flex: 1 1 auto; }

/* ------------------------------------------------------------------ 월 뷰 */
.jcal-month {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.jcal-weekdays {
  display: flex;
  border-bottom: 1px solid var(--jcal-border);
  flex: 0 0 auto;
}
.jcal-weekday {
  flex: 1 1 0;
  padding: 6px 8px;
  text-align: center;
  font-weight: 600;
  color: var(--jcal-muted);
}
.jcal-weekday.jcal-sun { color: var(--jcal-weekend); }
.jcal-weekday.jcal-sat { color: var(--jcal-saturday); }

.jcal-month-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.jcal-week {
  position: relative;
  display: flex;
  flex: 1 1 0;
  min-height: 96px;
  border-bottom: 1px solid var(--jcal-border);
}
.jcal-week:last-child { border-bottom: 0; }
.jcal-day {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  border-right: 1px solid var(--jcal-border);
  padding: 26px 4px 2px;
  overflow: hidden;
  cursor: pointer;
}
.jcal-day:last-child { border-right: 0; }
.jcal-day:hover { background: var(--jcal-hover); }
.jcal-day-num {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 10px;
}
.jcal-holiday-name {
  position: absolute;
  top: 6px;
  right: 4px;
  max-width: 60%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 10px;
  color: var(--jcal-weekend);
}
.jcal-day.jcal-holiday .jcal-day-num,
.jcal-col-head.jcal-holiday { color: var(--jcal-weekend); }
.jcal-day.jcal-sun .jcal-day-num { color: var(--jcal-weekend); }
.jcal-day.jcal-sat .jcal-day-num { color: var(--jcal-saturday); }
.jcal-day.jcal-other .jcal-day-num { color: var(--jcal-other-month); }
.jcal-day.jcal-today { background: var(--jcal-today-bg); }
.jcal-day.jcal-today .jcal-day-num {
  background: var(--jcal-today-ring);
  color: #ffffff;
  font-weight: 700;
}
.jcal-more {
  position: absolute;
  bottom: 2px;
  font-size: 11px;
  border: 0;
  background: transparent;
  color: var(--jcal-primary);
  padding: 1px 4px;
  border-radius: 3px;
}
.jcal-more:hover { background: var(--jcal-hover); text-decoration: underline; }

/* 주(row) 위에 절대배치되는 스패닝 이벤트 바 */
.jcal-event {
  position: absolute;
  height: 20px;
  border: 0;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 12px;
  text-align: left;
  color: var(--jcal-event-text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 18px;
}
.jcal-event:hover { filter: brightness(0.92); }
.jcal-event .jcal-event-time { font-weight: 600; margin-right: 4px; opacity: 0.9; }
.jcal-event.jcal-cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.jcal-event.jcal-cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* -------------------------------------------------------------- 주/일 뷰 */
.jcal-timeview {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.jcal-timeview-head {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--jcal-border);
}
.jcal-cols {
  display: flex;
}
.jcal-gutter {
  flex: 0 0 52px;
  border-right: 1px solid var(--jcal-border);
  font-size: 11px;
  color: var(--jcal-muted);
  text-align: right;
  padding-right: 4px;
}
.jcal-col {
  flex: 1 1 0;
  min-width: 0;
  border-right: 1px solid var(--jcal-border);
  position: relative;
}
.jcal-col:last-child { border-right: 0; }
.jcal-col-head {
  text-align: center;
  padding: 6px 4px;
  font-weight: 600;
}
.jcal-col-head.jcal-sun { color: var(--jcal-weekend); }
.jcal-col-head.jcal-sat { color: var(--jcal-saturday); }
.jcal-col-head.jcal-today .jcal-col-head-num {
  background: var(--jcal-today-ring);
  color: #fff;
  border-radius: 10px;
  padding: 0 7px;
}
.jcal-allday {
  position: relative;
  display: flex;
  min-height: 26px;
  border-top: 1px solid var(--jcal-border);
}
.jcal-allday-label {
  flex: 0 0 52px;
  border-right: 1px solid var(--jcal-border);
  font-size: 11px;
  color: var(--jcal-muted);
  text-align: right;
  padding: 4px 4px 0 0;
}
.jcal-allday-cols {
  position: relative;
  flex: 1 1 auto;
  display: flex;
}
.jcal-allday-cell {
  flex: 1 1 0;
  border-right: 1px solid var(--jcal-border);
  cursor: pointer;
}
.jcal-allday-cell:last-child { border-right: 0; }
.jcal-allday-cell:hover { background: var(--jcal-hover); }

.jcal-timegrid {
  flex: 1 1 auto;
  overflow-y: auto;
  position: relative;
}
.jcal-hour-row {
  display: flex;
  height: 44px;
  border-bottom: 1px solid var(--jcal-border);
}
.jcal-hour-row .jcal-gutter { transform: translateY(-6px); border-right: 1px solid var(--jcal-border); }
.jcal-hour-cell {
  flex: 1 1 0;
  border-right: 1px solid var(--jcal-border);
  cursor: pointer;
}
.jcal-hour-cell:last-child { border-right: 0; }
.jcal-hour-cell:hover { background: var(--jcal-hover); }
.jcal-timegrid-events {
  position: absolute;
  top: 0;
  left: 52px;
  right: 0;
  bottom: 0;
  pointer-events: none;
}
.jcal-tevent {
  position: absolute;
  border: 0;
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 11px;
  text-align: left;
  color: var(--jcal-event-text);
  overflow: hidden;
  pointer-events: auto;
  border-left: 3px solid rgba(0, 0, 0, 0.25);
}
.jcal-tevent:hover { filter: brightness(0.92); }
.jcal-tevent .jcal-tevent-title { font-weight: 600; display: block; }

/* ------------------------------------------------------------------ 팝업 */
.jcal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 50, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
.jcal-dialog {
  background: var(--jcal-dialog-bg);
  border-radius: 6px;
  box-shadow: var(--jcal-dialog-shadow);
  width: 320px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 16px;
}
.jcal-dialog h3 {
  margin: 0 0 12px;
  font-size: 15px;
}
.jcal-field { margin-bottom: 10px; }
.jcal-field label {
  display: block;
  font-size: 12px;
  color: var(--jcal-muted);
  margin-bottom: 3px;
}
.jcal-field input[type="text"],
.jcal-field input[type="date"],
.jcal-field input[type="datetime-local"],
.jcal-field select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--jcal-border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  color: var(--jcal-text);
  background: var(--jcal-bg);
}
.jcal-field-inline { display: flex; align-items: center; gap: 6px; }
.jcal-field-inline label { margin: 0; color: var(--jcal-text); font-size: 13px; }
.jcal-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 14px;
}
.jcal-dialog-actions .jcal-btn {
  padding: 6px 14px;
  border: 1px solid var(--jcal-border);
  border-radius: 4px;
  background: var(--jcal-bg);
  color: var(--jcal-text);
}
.jcal-dialog-actions .jcal-btn:hover { background: var(--jcal-hover); }
.jcal-dialog-actions .jcal-btn-primary {
  background: var(--jcal-primary);
  border-color: var(--jcal-primary);
  color: var(--jcal-primary-text);
}
.jcal-dialog-actions .jcal-btn-danger {
  background: #b3261e;
  border-color: #b3261e;
  color: #ffffff;
}
.jcal-detail-row { display: flex; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.jcal-detail-row .jcal-detail-label { flex: 0 0 52px; color: var(--jcal-muted); }
.jcal-cal-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: baseline;
}
.jcal-more-list { list-style: none; margin: 0; padding: 0; }
.jcal-more-list li { margin-bottom: 4px; }
.jcal-more-list .jcal-event {
  position: static;
  display: block;
  width: 100%;
}

/* ------------------------------------------------------- 드래그 상호작용 */
.jcal-day.jcal-selecting,
.jcal-allday-cell.jcal-selecting,
.jcal-hour-cell.jcal-selecting { background: var(--jcal-today-bg); }
.jcal-day.jcal-drop-target,
.jcal-allday-cell.jcal-drop-target { outline: 2px dashed var(--jcal-primary); outline-offset: -2px; }
.jcal-event.jcal-dragging,
.jcal-tevent.jcal-dragging { opacity: 0.55; }
.jcal-select-ghost {
  position: absolute;
  border: 2px dashed var(--jcal-primary);
  background: var(--jcal-today-bg);
  border-radius: 3px;
  opacity: 0.7;
  pointer-events: none;
}
.jcal-resize {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  cursor: ns-resize;
}

/* 스크린리더 전용 텍스트 (KWCAG) */
.jcal-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
