/* =========================================================
 * HS Reservation Document - Calendar
 * 역할: 문서 페이지의 달력/연간 보기/일정 모달 전용
 * =======================================================*/

.hs-doc-schedule-viewer {
  display: flex;
  flex-direction: column;
}

.hs-doc-view-panel,
.hs-doc-date-panel {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 20px;
  background: #fff;
}

#hs-doc-calendar-view {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

#hs-doc-selected-date-view[hidden],
#hs-doc-year-view[hidden],
#hs-doc-month-view[hidden],
.hs-doc-modal[hidden] {
  display: none !important;
}

/* =========================
 * Calendar topbar
 * =======================*/

.hs-calendar__header-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.hs-doc-calendar-title-wrap,
.hs-header-left {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.hs-header-left {
  gap: 8px;
  margin-left: 4px;
}

.hs-calendar__title {
  font-size: 18px;
  font-weight: 800;
  color: #111827;
  line-height: 1;
  white-space: nowrap;
}

.hs-header-left button,
.hs-doc-calendar-switch button {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
  line-height: 1;
}

.hs-header-left button {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f3f4f6;
  color: #475569;
  font-size: 15px;
  font-weight: 700;
  transition: background .15s ease, color .15s ease;
}

.hs-header-left button:hover {
  background: #e5e7eb;
  color: #334155;
}

.hs-header-left button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.hs-header-left button[hidden] {
  display: none !important;
}

.hs-doc-calendar-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 4px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f3f4f6;
}

.hs-doc-calendar-switch button {
  min-width: 48px;
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  color: #6b7280;
  font-size: 13px;
  font-weight: 700;
}

.hs-doc-calendar-switch button.is-active {
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

/* =========================
 * Month calendar
 * =======================*/

.hs-calendar__header,
.hs-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
}

.hs-calendar__header {
  margin-bottom: 0;
  border: 1px solid #e5e7eb;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

.hs-calendar__header > div {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #e5e7eb;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.hs-calendar__header > div:last-child {
  border-right: 0;
}

.hs-calendar {
  margin-top: 0;
  border-left: 1px solid #e5e7eb;
  border-top: 0;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

.hs-calendar__day {
  min-height: 92px;
  margin: 0;
  padding: 10px;
  border: 0;
  border-right: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  cursor: default;

  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
  transition: background .15s ease;
}

.hs-calendar__day:nth-child(-n + 7) {
  border-top: 1px solid #e5e7eb;
}

.hs-calendar__day:not(.hs-calendar__day--empty) {
  cursor: pointer;
}

.hs-calendar__day:hover {
  background: #fafafa;
}

.hs-calendar__day--empty {
  background: #fafafa;
  cursor: default;
}

.hs-calendar__day--today {
  background: #fff;
  box-shadow: inset 0 0 0 1px #a855f7;
}

.hs-calendar__day--active,
.hs-calendar__day--today.hs-calendar__day--active {
  background: #faf5ff;
  box-shadow: inset 0 0 0 2px #a855f7;
}

.hs-calendar__day-number {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
}

.hs-calendar__day-number--muted {
  color: #cbd5e1;
}

.hs-calendar__day--today .hs-calendar__day-number {
  color: #6d28d9;
  font-weight: 800;
}

.hs-calendar__events {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.hs-calendar__event-pill {
  border-radius: 3px;
  padding: 3px 5px;
  background: #fff1c2;
  color: #374151;
  font-size: 10px;
  line-height: 1.35;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hs-calendar__event-pill + .hs-calendar__event-pill {
  background: #ecfdf5;
}

.hs-calendar__more {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: #7c3aed;
  text-align: right;
}

/* =========================
 * Year calendar
 * =======================*/

.hs-doc-year-title {
  margin-bottom: 14px;
  font-size: 18px;
  font-weight: 800;
  color: #111827;
}

.hs-doc-year-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.hs-doc-year-month-box {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 14px 14px 12px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}

.hs-doc-year-month-box:hover {
  border-color: #d8b4fe;
  background: #fcfcff;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.08);
  transform: translateY(-1px);
}

.hs-doc-year-month-title {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 800;
  color: #111827;
  text-align: left;
}

.hs-doc-year-mini-calendar {
  margin-top: 8px;
}

.hs-doc-mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.hs-doc-mini-day {
  min-height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #374151;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, color .12s ease;
}

.hs-doc-mini-day:hover {
  background: #faf5ff;
  box-shadow: 0 0 0 1px #c4b5fd inset, 0 3px 10px rgba(124, 58, 237, 0.08);
  transform: translateY(-1px);
}

.hs-doc-mini-day.empty {
  opacity: 0.2;
  cursor: default;
}

.hs-doc-mini-day.is-sunday {
  color: #ef4444;
}

.hs-doc-mini-day.is-saturday {
  color: #3b82f6;
}

.hs-doc-mini-day.is-today {
  border-color: #8b5cf6;
  background: #fff;
  color: #6d28d9;
  font-weight: 700;
}

.hs-doc-mini-day.is-selected {
  background: #faf5ff;
  box-shadow: 0 0 0 2px #8b5cf6 inset;
  color: #6d28d9;
  font-weight: 800;
}

.hs-doc-mini-day.event-1 {
  background: #ede9fe;
  color: #6d28d9;
}

.hs-doc-mini-day.event-2 {
  background: #8b5cf6;
  color: #fff;
}

.hs-doc-mini-day.event-3 {
  background: #5b21b6;
  color: #fff;
}

/* =========================
 * Day modal
 * =======================*/

.hs-doc-modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overscroll-behavior: contain;
}

.hs-doc-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
}

.hs-doc-modal__dialog {
  position: relative;
  width: min(430px, calc(100% - 28px));
  max-height: min(76vh, 680px);
  margin: auto;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.2);
  overscroll-behavior: contain;
}

.hs-doc-modal__head {
  flex: 0 0 auto;
  min-height: 52px;
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hs-doc-modal__title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: #111827;
}

.hs-doc-modal__close {
  all: unset;
  box-sizing: border-box;
  width: 28px;
  height: 28px;
  margin: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.hs-doc-modal__close:hover {
  background: #f1f5f9;
  color: #111827;
}

.hs-doc-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.hs-doc-modal__body::-webkit-scrollbar {
  width: 8px;
}

.hs-doc-modal__body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.hs-doc-modal__body::-webkit-scrollbar-track {
  background: transparent;
}

.hs-doc-day-layout {
  display: block;
  height: auto;
  min-height: 0;
}

.hs-doc-day-detail {
  display: none;
}

.hs-doc-day-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 0;
  overflow: visible;
  overscroll-behavior: contain;
}

.hs-doc-modal-program {
  --phase-strong: #2563eb;
  --phase-head: #dbeafe;
  --phase-soft: #eff6ff;
  border-left: 4px solid var(--phase-strong);
  background: var(--phase-soft);
}

.hs-doc-modal-program + .hs-doc-modal-program {
  margin-top: 10px;
}

.hs-doc-modal-program:has(.hs-doc-modal-phase.is-quote) {
  --phase-strong: #f59e0b;
  --phase-head: #fef3c7;
  --phase-soft: #fffbeb;
}

.hs-doc-modal-program:has(.hs-doc-modal-phase.is-confirm),
.hs-doc-modal-program:has(.hs-doc-modal-phase.is-remind),
.hs-doc-modal-program:has(.hs-doc-modal-phase.is-finish) {
  --phase-strong: #16a34a;
  --phase-head: #dcfce7;
  --phase-soft: #f0fdf4;
}

.hs-doc-modal-program:has(.hs-doc-modal-phase.is-cancel) {
  --phase-strong: #dc2626;
  --phase-head: #fee2e2;
  --phase-soft: #fef2f2;
}

.hs-doc-modal-program__head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  background: var(--phase-head);
}

.hs-doc-modal-program__thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  background: #f3f4f6;
  flex: 0 0 44px;
}

.hs-doc-modal-program__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hs-doc-modal-program__thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #94a3b8;
}

.hs-doc-modal-program__title-wrap {
  min-width: 0;
}

.hs-doc-modal-program__title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  color: #111827;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.hs-doc-modal-program__link {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px;
  color: #2563eb;
  text-decoration: underline;
}

.hs-doc-modal-phase {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: #fff;
  color: var(--phase-strong);
  border: 1px solid rgba(255,255,255,0.7);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.hs-doc-modal-program__list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hs-doc-modal-schedule {
  cursor: default;
}

.hs-doc-modal-schedule__target {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.4;
  color: #111827;
}

.hs-doc-modal-schedule__meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hs-doc-modal-schedule__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
}

.hs-doc-modal-note {
  margin-top: 8px;
  color: #111827;
  font-size: 13px;
  line-height: 1.55;
}

.hs-doc-modal-note__text {
  color: #111827;
  white-space: pre-wrap;
  word-break: break-word;
}

.hs-doc-modal-note.is-collapsed .hs-doc-modal-note__text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hs-doc-modal-note.is-expanded .hs-doc-modal-note__text {
  display: block;
}

.hs-doc-modal-note__more {
  all: unset;
  display: inline-flex;
  margin-top: 4px;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

body.hs-doc-modal-open {
  overflow: hidden;
}

/* =========================
 * Responsive
 * =======================*/

@media (max-width: 900px) {
  .hs-doc-year-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .hs-doc-view-panel,
  .hs-doc-date-panel {
    padding: 14px;
  }

  .hs-calendar__header-bar {
    gap: 8px;
  }

  .hs-calendar__title {
    font-size: 14px;
  }

  .hs-doc-calendar-switch button {
    min-width: 38px;
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
  }

  .hs-calendar__day {
    min-height: 74px;
    padding: 6px;
  }

  .hs-calendar__day-number {
    font-size: 12px;
  }

  .hs-calendar__event-pill {
    font-size: 9px;
    padding: 2px 4px;
  }

  .hs-doc-modal {
    padding: 20px 14px;
  }

  .hs-doc-modal__dialog {
    width: calc(100% - 20px);
    max-height: 78vh;
  }

  .hs-doc-modal__body {
    padding: 10px;
  }

  .hs-doc-modal-program__head {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .hs-doc-modal-program__thumb {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .hs-doc-modal-program__title {
    font-size: 13px;
  }

  .hs-doc-modal-phase {
    min-height: 26px;
    padding: 0 8px;
    font-size: 11px;
  }
}

@media (max-width: 550px) {
  .hs-doc-year-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .hs-doc-year-month-box {
    padding: 12px;
  }

  .hs-doc-year-month-title {
    font-size: 15px;
  }
}
