/* ============================================================
   캘린더 — 우측 갤럭시 엣지 위젯 9번째 (panel.css)
   ============================================================
   톤: 갤럭시 단색 (Sky/Indigo)
   특징: 월 그리드 mini + 이벤트 dot + 일자 클릭 패널 + 에디터
   ============================================================ */

.calapp-section {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 10px;
  padding: 12px 12px 16px;
  box-sizing: border-box;
}

/* ─── 헤더 ─── */
.cal-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #f0f9ff 0%, #eef2ff 100%);
  border: 1px solid #c7d2fe;
  border-radius: 14px;
}

.cal-scope-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cal-scope {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cal-scope-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}
.cal-scope-value {
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  color: #fff;
  border: 0;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cal-new-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.35);
}
.cal-new-btn svg { stroke: #fff; }

/* ─── 네비게이션 (이전/다음 월·오늘) ─── */
.cal-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.cal-nav-title {
  font-size: 14px;
  font-weight: 800;
  color: #0c4a6e;
  letter-spacing: 0.01em;
}
.cal-nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cal-nav-btn:hover {
  background: #fff;
  border-color: #818cf8;
  color: #4f46e5;
}
.cal-today-btn {
  padding: 0 10px;
  height: 26px;
  font-size: 11px;
  font-weight: 700;
  width: auto;
}

/* ─── 월 그리드 ─── */
.cal-grid-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.cal-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 2px;
}
.cal-weekday {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #94a3b8;
  padding: 4px 0;
}
.cal-weekday.is-sun { color: #ef4444; }
.cal-weekday.is-sat { color: #3b82f6; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  min-height: 38px;
  padding: 4px 0 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.cal-cell:hover {
  background: rgba(99, 102, 241, 0.06);
  border-color: #c7d2fe;
}
.cal-cell.is-other-month { color: #cbd5e1; }
.cal-cell.is-sun { color: #ef4444; }
.cal-cell.is-sat { color: #3b82f6; }
.cal-cell.is-other-month.is-sun,
.cal-cell.is-other-month.is-sat { color: #fecaca; }
.cal-cell.is-today {
  background: linear-gradient(135deg, #e0f2fe 0%, #e0e7ff 100%);
  border-color: #818cf8;
  color: #1e293b;
  font-weight: 800;
}
.cal-cell.is-selected {
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  border-color: #4f46e5;
  color: #fff !important;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}
.cal-cell.is-selected .cal-dot { background: #fff !important; }

.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #4f46e5;
  display: inline-block;
}
.cal-cell.is-today .cal-dot { background: #4f46e5; }

/* ─── 일자 패널 (그날 일정 목록) ─── */
.cal-day-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.cal-day-panel::-webkit-scrollbar { width: 6px; }
.cal-day-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.cal-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 2px;
}
.cal-day-title {
  font-size: 12px;
  font-weight: 800;
  color: #1e293b;
}
.cal-day-subtitle {
  font-size: 10px;
  color: #64748b;
  font-weight: 600;
}

.cal-event-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px 9px 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #4f46e5;
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cal-event-card:hover {
  border-color: #818cf8;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.1);
}

.cal-event-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}
.cal-event-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  word-break: break-word;
  flex: 1 1 auto;
}
.cal-event-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.cal-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cal-icon-btn:hover {
  background: rgba(79, 70, 229, 0.08);
  border-color: #c7d2fe;
  color: #4f46e5;
}
.cal-icon-btn.is-danger:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: #fecaca;
  color: #dc2626;
}

.cal-event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}
.cal-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.cal-meta-chip svg { color: #94a3b8; }
.cal-event-desc {
  font-size: 11px;
  line-height: 1.5;
  color: #475569;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 2px;
}

/* ─── 빈 상태 ─── */
.cal-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 16px;
  color: #94a3b8;
  text-align: center;
}
.cal-empty-text { font-size: 12px; font-weight: 600; color: #64748b; }
.cal-empty-sub { font-size: 10px; color: #94a3b8; }

/* ─── 에디터 모달 (overlay) ─── */
.cal-editor-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: stretch;
  justify-content: stretch;
  z-index: 10;
  backdrop-filter: blur(2px);
}
.cal-editor-overlay.is-open { display: flex; }

.cal-editor {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: #fff;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.25);
  margin-top: auto;
  max-height: 90%;
  overflow-y: auto;
}
.cal-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid #e2e8f0;
}
.cal-editor-title {
  font-size: 13px;
  font-weight: 800;
  color: #0c4a6e;
}
.cal-editor-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
}
.cal-editor-close:hover { background: #f1f5f9; }

.cal-editor-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
}

.cal-field { display: flex; flex-direction: column; gap: 4px; }
.cal-field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}
.cal-input,
.cal-textarea {
  width: 100%;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: #0f172a;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cal-textarea { min-height: 60px; resize: vertical; line-height: 1.5; }
.cal-input:focus,
.cal-textarea:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}

.cal-time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.cal-allday-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #475569;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.cal-allday-row input { accent-color: #4f46e5; }

.cal-editor-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 4px;
}
.cal-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 100px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cal-btn.secondary {
  background: #fff;
  color: #475569;
  border-color: #cbd5e1;
}
.cal-btn.secondary:hover { background: #f1f5f9; border-color: #94a3b8; }
.cal-btn.primary {
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}
.cal-btn.primary:hover { transform: translateY(-1px); }
.cal-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── 토스트 ─── */
.cal-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: #1e293b;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 100px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}
.cal-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.cal-loading {
  padding: 24px 16px;
  text-align: center;
  color: #64748b;
  font-size: 12px;
}
