/* calendar.css */

/* ── 컨테이너 그리드 재정의 ── */
.container {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "calendar calendar"
    "theme    stock";
  gap: 16px;
}

#calendar-container {
  grid-area: calendar;
  margin-bottom: 10px;
}

.panel.left-panel  { grid-area: theme; }
.panel.right-panel { grid-area: stock; }


/* ── 아코디언 기본 ── */
.calendar {
  width: 100%;
  overflow: hidden;
  transition: max-height 0.4s ease;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
}

/* 접힌 상태: 헤더 높이만 보이도록 */
.calendar.collapsed {
  max-height: 48px;
}

/* 펼쳐진 상태: 컨테이너는 overflow 비허용 → 내부 wrapper 만 스크롤 */
.calendar.expanded {
  max-height: none;
  overflow: visible;
}


/* ── 헤더 (항상 노출) ── */
.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 48px;
  padding: 0 12px;
  background: #f5f5f5;
  cursor: pointer;
  box-sizing: border-box;
}

#accordion-title {
  font-size: 0.9rem;
  font-weight: 500;
}

#accordion-icon {
  width: 30px;
  transition: transform 0.3s ease;
}

.calendar.expanded #accordion-icon {
  transform: rotate(180deg);
}


/* ── 본문: 오직 이 영역만 스크롤 ── */
.calendar-wrapper {
  padding: 10px;
  box-sizing: border-box;

  /* 새로 늘린 높이 */
  height: 600px;      /* 필요에 따라 조절 가능 */
  overflow-y: auto;
}


.month-block {
  margin-bottom: 20px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.calendar-header h3 {
  margin: 0;
  font-weight: 600;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.calendar-cell {
  border: 1px solid #eee;
  min-height: 80px;
  border-radius: 6px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  background: #fafafa;
}

.calendar-cell.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.day-number {
  font-weight: bold;
  margin-bottom: 4px;
}

.date-move-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.theme-row {
  display: flex;
  align-items: center;
  padding: 2px 4px;
  border-radius: 8px;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
  color: #949494;
}

/* 활성화된 테마 */
.theme-row.active {
  background-color: var(--theme-color) !important;
  color: #fff !important;
}

.medal {
  width: 16px;
  height: 16px;
  background-size: contain;
  background-repeat: no-repeat;
  margin-right: 4px;
}

.medal.medal-1 {
  background-image: url('../../static/images/medal_gold.png');
}

.medal.medal-2 {
  background-image: url('../../static/images/medal_silver.png');
}

.medal.medal-3 {
  background-image: url('../../static/images/medal_brown.png');
}

.accordion-header #accordion-title .weekday {
  color: #e71909;
}

@media (max-width: 768px) {
  /* 기존 달력 그리드 제거 → 리스트형 */
  .calendar-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .calendar-cell {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: auto;
    padding: 6px 8px;
  }

  /* 날짜는 왼쪽에 작게 */
  .calendar-cell .day-number {
    flex: 0 0 auto;
    font-size: 0.75rem;
    font-weight: 500;
    color: #555;
    margin: 0;
    margin-right: 8px;
  }

  /* theme-row들을 가로로 나열 (버튼/뱃지 느낌) */
  .calendar-cell .theme-row {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    margin: 0 4px 0 0;
    border-radius: 12px;
    background: #eee;
    font-size: 0.75rem;
    cursor: pointer;
  }

  /* 메달 아이콘 작게 */
  .calendar-cell .theme-row .medal {
    width: 14px;
    height: 14px;
    margin-right: 3px;
  }

  /* 등락률 텍스트는 너무 길면 숨기거나 줄여도 됨 */
  .calendar-cell .theme-row .avg-change {
    font-size: 0.7rem;
    margin-left: 2px;
  }
}

@media (max-width: 768px) {
  /* 달력 그리드 → 리스트 */
  .calendar-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .calendar-cell {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    min-height: auto;
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fafafa;
  }

  /* 날짜는 맨 왼쪽 */
  .calendar-cell .day-number {
    flex: 0 0 auto;
    font-size: 0.75rem;
    font-weight: 500;
    color: #555;
    margin-right: 8px;
  }

  /* 테마들은 오른쪽으로 가로 정렬 */
  .calendar-cell .theme-row {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    margin-right: 6px;
    border-radius: 12px;
    background: #eee;
    font-size: 0.75rem;
    cursor: pointer;
  }

  /* 메달 아이콘 작게 */
  .calendar-cell .theme-row .medal {
    width: 14px;
    height: 14px;
    margin-right: 3px;
  }

  /* 등락률 텍스트 */
  .calendar-cell .theme-row .avg-change {
    font-size: 0.7rem;
    margin-left: 2px;
  }
}

@media (max-width: 768px) {
  .calendar-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .calendar-cell {
    display: grid;
    grid-template-columns: 60px 1fr; /* 왼쪽 = 날짜+버튼, 오른쪽 = 테마 */
    padding: 6px 8px;
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fafafa;
  }

  /* 왼쪽 날짜 */
  .calendar-cell .day-number {
    grid-column: 1;
    grid-row: 1;
    font-size: 0.75rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
  }

  /* 날짜 밑에 이동 버튼 */
  .calendar-cell .move-button {
    grid-column: 1;
    grid-row: 2;
    font-size: 0.7rem;
    padding: 2px 6px;
    margin-top: 2px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #f0f0f0;
    cursor: pointer;
  }

  /* 오른쪽 테마 뱃지들 */
  .calendar-cell .theme-row {
    grid-column: 2;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;   /* 이름-퍼센트 정렬 */
    width: 100%;                      /* ✅ 전부 같은 너비 */
    padding: 4px 8px;
    margin-bottom: 6px;               /* ✅ 테마들 사이 간격 */
    border-radius: 8px;
    background: #eee;
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
    box-sizing: border-box;
  }

  .calendar-cell .theme-row:last-child {
    margin-bottom: 0;
  }

  .calendar-cell .medal {
    width: 14px;
    height: 14px;
    margin-right: 6px;
    flex-shrink: 0;
  }

  .calendar-cell .theme-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .calendar-cell .avg-change {
    font-size: 0.7rem;
    margin-left: 6px;
    flex-shrink: 0;
  }
}

@media (max-width: 768px) {
  .calendar-cell .date-move-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .calendar-cell .move-button {
    display: block;
    width: fit-content;
    font-size: 0.65rem;
    padding: 2px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f5f5f5;
    cursor: pointer;
  }
  .calendar-cell .day-number {
    cursor: default;
    text-decoration: none;
  }
}

body { position: relative; }

/* ── 모바일에서 캘린더 크기 축소 (70%) ── */
@media (max-width: 1023px) {
  .calendar.collapsed {
    max-height: 34px;
  }

  .accordion-header {
    height: 34px;
    padding: 0 8px;
  }

  #accordion-title {
    font-size: 0.7rem;
  }

  #accordion-icon {
    width: 20px;
  }
}



#accordion-icon {
  width: 30px;
  transition: transform 0.6s ease; /* 조금 더 부드럽게 */
  transform-style: preserve-3d;    /* 3D 효과 */
}

.calendar.expanded #accordion-icon {
  transform: rotateY(180deg);  /* 시계방향 회전 → 손바닥 뒤집듯이 */
}
