@import url('https://cdn.jsdelivr.net/npm/pretendard/dist/web/static/pretendard.css');

/* 디자인 토큰 */
:root {
  /* 배경 */
  --color-bg: #eef4f9;
  --color-surface: #f7fafd;
  --color-surface-alt: #e8f1f8;

  /* 테두리 */
  --color-border: #c8daea;
  --color-border-soft: #daeaf5;

  /* 텍스트 */
  --color-text-primary: #1e3040;
  --color-text-secondary: #5a7a90;
  --color-text-muted: #96b4c8;

  /* 포인트 컬러 */
  --color-blue: #3a8fc7;
  --color-blue-soft: #d0e8f5;
  --color-green: #4aaa7f;
  --color-green-soft: #d0f0e4;
  --color-red: #d05a5a;
  --color-red-soft: #fae0e0;
  --color-orange: #e8a020;

  /* 반경 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* 그림자 */
  --shadow-card: 0 2px 16px rgba(58, 100, 140, 0.08);
  --shadow-inset: inset 0 1px 3px rgba(58, 100, 140, 0.07);

  /* 폰트 */
  --font: 'Pretendard', sans-serif;

  /* 타이포그래피 */
  --text-xs: 0.73rem;
  --text-sm: 0.82rem;
  --text-md: 0.88rem;
  --text-lg: 1.05rem;
  --text-xl: 1.45rem;
}

/* 리셋 */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 레이아웃 */
html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background-image:
    radial-gradient(
      ellipse at 15% 60%,
      rgba(180, 215, 240, 0.35) 0%,
      transparent 55%
    ),
    radial-gradient(
      ellipse at 85% 15%,
      rgba(200, 225, 245, 0.25) 0%,
      transparent 45%
    );
}

#app {
  width: 100%;
  max-width: 1100px;
  height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

#appHeader {
  border-bottom: 1.5px solid var(--color-border);
  padding: 20px 36px;
  text-align: center;
  background: var(--color-surface);
  flex-shrink: 0;
}

#appHeader h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-primary);
}

#appMain {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 달력 섹션 */
#calendarSection {
  width: 420px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1.5px solid var(--color-border);
  padding: 28px;
  background: var(--color-surface-alt);
  overflow-y: auto;
}

#calendar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#calendarHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#calendarTitle {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text-primary);
}

#prevMonthBtn,
#nextMonthBtn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  padding: 6px 9px;
  border-radius: var(--radius-sm);
}

#prevMonthBtn:hover,
#nextMonthBtn:hover {
  background: var(--color-border-soft);
}

#calendarWeekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}

#calendarWeekdays span {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  padding: 6px 0;
}

#calendarDays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.day {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: var(--text-md);
  color: var(--color-text-primary);
  padding: 9px 2px;
  border-radius: var(--radius-sm);
  text-align: center;
  position: relative;
}

.day:hover {
  background: var(--color-border-soft);
}

.day.other-month {
  color: var(--color-text-muted);
  font-weight: 300;
}

.day.today {
  color: var(--color-orange);
  font-weight: 600;
}

.day.today::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-orange);
}

.day.selected {
  background: var(--color-blue) !important;
  color: #fff !important;
  font-weight: 600;
}

.day.selected::after {
  display: none;
}

.day.has-todos::before {
  content: '';
  position: absolute;
  top: 3px;
  right: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-green);
}

/* 통계 */
#todayStats {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#todayStatsHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#todayStatsText {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

#todayStatsPercent {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-blue);
}

#todayProgressBarTrack {
  width: 100%;
  height: 6px;
  background: var(--color-border-soft);
  border-radius: 99px;
  overflow: hidden;
}

#todayProgressBarFill {
  height: 100%;
  width: 0%;
  background: var(--color-blue);
  border-radius: 99px;
  transition: width 0.4s ease;
}

#monthStats {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#statsHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#statsText {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

#statsPercent {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-blue);
}

#progressBarTrack {
  width: 100%;
  height: 6px;
  background: var(--color-border-soft);
  border-radius: 99px;
  overflow: hidden;
}

#progressBarFill {
  height: 100%;
  width: 0%;
  background: var(--color-blue);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* ── 투두 섹션 ── */
#todoSection {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 32px;
  gap: 14px;
  overflow: hidden;
}

#selectedDateTitle {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border-soft);
  flex-shrink: 0;
}

#todoListWrapper {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

#todoListWrapper::-webkit-scrollbar {
  width: 5px;
}
#todoListWrapper::-webkit-scrollbar-track {
  background: transparent;
}
#todoListWrapper::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 99px;
}

#todoList {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.todoItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
}

.todoItem.done {
  opacity: 0.5;
}

.todoItem.done .todoText {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.todoText {
  flex: 1;
  font-size: var(--text-md);
  color: var(--color-text-primary);
  line-height: 1.5;
  word-break: break-all;
}

.todoActions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.doneBtn,
.deleteBtn {
  border: 1px solid;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.doneBtn {
  background: var(--color-green-soft);
  border-color: var(--color-green);
  color: var(--color-green);
}

.deleteBtn {
  background: var(--color-red-soft);
  border-color: var(--color-red);
  color: var(--color-red);
}

#todoList:empty::after {
  content: '할 일이 없어요';
  display: block;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  padding: 36px 0;
}

/* ── 입력창 ── */
#todoInputArea {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-soft);
}

#todoInput {
  flex: 1;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  box-shadow: var(--shadow-inset);
  font-family: var(--font);
  font-size: var(--text-md);
  color: var(--color-text-primary);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}

#todoInput::placeholder {
  color: var(--color-text-muted);
}

#todoInput:focus {
  border-color: var(--color-blue);
}

#todoAddBtn {
  background: var(--color-blue-soft);
  border: 1px solid var(--color-blue);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: var(--text-md);
  font-weight: 600;
  padding: 10px 20px;
  color: var(--color-blue);
  cursor: pointer;
  white-space: nowrap;
}

/* 반응형 */
@media (max-width: 900px) {
  body {
    padding: 0;
    align-items: flex-start;
  }
  #app {
    border-radius: 0;
    border: none;
    box-shadow: none;
    min-height: 100vh;
  }
  #appMain {
    flex-direction: column;
  }
  #calendarSection {
    width: 100%;
    border-right: none;
    border-bottom: 1.5px solid var(--color-border);
    padding: 16px;
  }
  .day {
    padding: 6px 2px;
    font-size: var(--text-sm);
  }
  #calendarSection {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  #calendar {
    grid-column: 1 / -1;
  }
  #todayStats {
    margin-top: 12px;
    margin-right: 6px;
  }
  #monthStats {
    margin-top: 12px;
    margin-left: 6px;
  }
}
