/* ============================================================
   Sentimind — Diary Response Components
   후속 대화, 인사이트, AI 피드백, 리텐션, 감정 테마,
   CBT 인지 재구성, 마음 구급상자
   ============================================================ */

/* --- AI Follow-up Conversation --- */
/* ===== AI Follow-up Conversation ===== */
.followup-start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: var(--space-md);
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}
.followup-start-btn[hidden] { display: none; }
.followup-start-btn:hover {
  opacity: 0.9;
}
.followup-start-btn:active { transform: scale(0.98); }
.followup-section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-top: 0.75rem;
  overflow-anchor: none;
  animation: fadeInUp 300ms ease both;
}
.followup-section[hidden] { display: none; }
.followup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.followup-stage-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-primary);
}
.followup-stages {
  display: flex;
  gap: 0.35rem;
}
.followup-stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background 200ms ease;
}
.followup-stage-dot.active {
  background: var(--color-primary);
}
.followup-stage-dot.completed {
  background: var(--color-success);
}
.followup-messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-right: 0.25rem;
}
.followup-msg {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-base);
  max-width: 85%;
  white-space: pre-line;
  animation: fadeInUp 250ms ease;
}
.followup-msg--ai {
  background: var(--color-background);
  color: var(--color-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.followup-msg--user {
  background: var(--color-primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.followup-msg--loading {
  padding: 0.6rem 1rem;
}
.followup-typing {
  display: inline-flex;
  gap: 3px;
}
.followup-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: typingBounce 1.2s infinite;
}
.followup-typing span:nth-child(2) { animation-delay: 0.2s; }
.followup-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}
.followup-input-row {
  display: flex;
  gap: 0.5rem;
  position: sticky;
  bottom: 0;
  background: var(--color-surface);
  padding: 0.5rem 0 0;
  z-index: 1;
}
.followup-input-row[hidden] { display: none; }
.followup-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color 200ms ease;
}
.followup-input:focus {
  border-color: var(--color-primary);
}
.followup-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 150ms ease;
  flex-shrink: 0;
}
.followup-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.followup-send:hover:not(:disabled) {
  opacity: 0.85;
}
/* Personalization Badge */
.personalization-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--color-primary);
  background: rgba(194, 113, 79, 0.06);
  border: 1px solid rgba(194, 113, 79, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.65rem;
  margin: 0.5rem 0 0;
  letter-spacing: 0.02em;
}
.personalization-badge[hidden] { display: none; }

/* Follow-up Complete */
.followup-complete {
  text-align: center;
  padding: 1rem 0;
}
.followup-complete[hidden] { display: none; }
.followup-complete-text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 0.75rem;
}
.followup-restart-btn {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s;
}
.followup-restart-btn:hover {
  background: var(--color-surface);
}

/* Follow-up Insight CTA */
.followup-insight-cta {
  text-align: center;
  padding: 0.75rem 0 0.25rem;
  border-top: 1px solid var(--color-border);
  margin-top: 0.5rem;
}
.followup-insight-text {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin: 0 0 0.6rem;
}
.followup-insight-btns {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.followup-cta-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.followup-cta-btn:hover {
  background: var(--color-surface-warm);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.followup-cta-btn--continue {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.followup-cta-btn--continue:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: #fff;
}
.followup-login-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
  margin: 0.5rem 0 0;
}


/* --- followup-done --- */
.followup-done {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  padding: 0.5rem 0;
  margin: 0;
}


/* --- Insight cards --- */
/* === Feature 4: Insight cards === */
.insight-card {
  padding: 0.85rem; margin-bottom: 0.6rem;
  background: var(--gradient-response);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  animation: fadeInUp 300ms ease both;
  display: flex;
  flex-direction: column;
}
.insight-card:last-child { margin-bottom: 0; }
.insight-icon { 
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.4rem;
}
.insight-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}
.insight-body {
  display: flex;
  flex-direction: column;
}
.insight-title {
  display: none; /* Hide the generic title, let the icon act as the header */
}
.insight-text {
  font-size: 0.9rem; color: var(--color-text); line-height: 1.5;
  font-family: var(--font-diary);
}
.insight-label {
  font-size: 0.65rem; color: var(--color-text-muted); margin-top: 0.25rem;
}
.insight-empty {
  font-size: 0.8rem; color: var(--color-text-muted); text-align: center;
  padding: 1rem 0; font-family: var(--font-diary);
}


/* --- AI Feedback Section --- */
/* ===== AI Feedback Section ===== */
.feedback-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-divider);
  text-align: center;
}
.feedback-section[hidden] { display: none; }
.feedback-question {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.feedback-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
}
.feedback-buttons[hidden] { display: none; }
.feedback-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease;
}
.feedback-btn:hover {
  transform: scale(1.15);
  border-color: var(--color-primary);
  background: rgba(196, 139, 108, 0.1);
}
.feedback-btn:active { transform: scale(0.95); }
.feedback-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.feedback-btn.active {
  border-color: var(--color-primary);
  background: rgba(196, 139, 108, 0.2);
  transform: scale(1.1);
}
.feedback-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.feedback-icon { font-size: 1.2rem; line-height: 1; }
.feedback-thanks {
  font-size: 0.8rem;
  color: var(--color-success);
  animation: fadeInUp 300ms ease both;
}
.feedback-thanks[hidden] { display: none; }


/* --- Retention Card + Emotion theme + history item groups --- */
/* ===== Retention Card ===== */
.retention-card {
  margin-top: var(--space-sm);
  padding: 0.75rem 0 0;
  background: transparent;
  border-top: 1px solid var(--color-divider);
  border-radius: 0;
  animation: fadeInUp 400ms cubic-bezier(0.25,0.46,0.45,0.94) both;
  overflow-anchor: none;
  font-size: var(--text-xs);
}
.retention-card[hidden] { display: none; }
.retention-card-content {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.retention-card-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}
.retention-card-text {
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.5;
  font-family: var(--font-diary);
}
.retention-link {
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
}
.retention-link:hover { color: var(--color-primary-hover); }

/* Dark mode overrides */
[data-theme="dark"] .feedback-btn {
  background: var(--color-surface);
  border-color: var(--color-border);
}
[data-theme="dark"] .feedback-btn:hover {
  background: rgba(251, 146, 60, 0.15);
}
[data-theme="dark"] .feedback-btn.active {
  background: rgba(251, 146, 60, 0.25);
}
[data-theme="dark"] .retention-card {
  background: var(--gradient-response);
}

/* === Feature 5: Emotion theme colors === */
[data-emotion-theme="joy"] .response-card { background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 50%, #FFCC80 100%); }
[data-emotion-theme="sadness"] .response-card { background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 50%, #90CAF9 100%); }
[data-emotion-theme="anger"] .response-card { background: linear-gradient(135deg, #FBE9E7 0%, #FFCCBC 50%, #FFAB91 100%); }
[data-emotion-theme="anxiety"] .response-card { background: linear-gradient(135deg, #F3E5F5 0%, #E1BEE7 50%, #CE93D8 100%); }
[data-emotion-theme="peace"] .response-card { background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 50%, #A5D6A7 100%); }
[data-emotion-theme="love"] .response-card { background: linear-gradient(135deg, #FCE4EC 0%, #F8BBD0 50%, #F48FB1 100%); }
[data-emotion-theme="tired"] .response-card { background: linear-gradient(135deg, #EFEBE9 0%, #D7CCC8 50%, #BCAAA4 100%); }
[data-theme="dark"][data-emotion-theme="joy"] .response-card { background: linear-gradient(135deg, #2a2418 0%, #33291e 50%, #2a2418 100%); }
[data-theme="dark"][data-emotion-theme="sadness"] .response-card { background: linear-gradient(135deg, #181e2e 0%, #1c2438 50%, #181e2e 100%); }
[data-theme="dark"][data-emotion-theme="anger"] .response-card { background: linear-gradient(135deg, #2a1818 0%, #331e1e 50%, #2a1818 100%); }
[data-theme="dark"][data-emotion-theme="anxiety"] .response-card { background: linear-gradient(135deg, #221830 0%, #281e38 50%, #221830 100%); }
[data-theme="dark"][data-emotion-theme="peace"] .response-card { background: linear-gradient(135deg, #182a1c 0%, #1e3322 50%, #182a1c 100%); }
[data-theme="dark"][data-emotion-theme="love"] .response-card { background: linear-gradient(135deg, #2a1822 0%, #331e28 50%, #2a1822 100%); }
[data-theme="dark"][data-emotion-theme="tired"] .response-card { background: linear-gradient(135deg, #201e1c 0%, #282522 50%, #201e1c 100%); }
.history-item[data-emotion-group="joy"] { border-left: 4px solid #F4A261; }
.history-item[data-emotion-group="sadness"] { border-left: 4px solid #7EB8DA; }
.history-item[data-emotion-group="anger"] { border-left: 4px solid #E76F51; }
.history-item[data-emotion-group="anxiety"] { border-left: 4px solid #9C89B8; }
.history-item[data-emotion-group="peace"] { border-left: 4px solid #A8DAAB; }
.history-item[data-emotion-group="love"] { border-left: 4px solid #F2A0A0; }
.history-item[data-emotion-group="tired"] { border-left: 4px solid #B0A89A; }

/* Emotion group — emoji background sync */
.history-item[data-emotion-group="joy"] .history-emoji { background: rgba(244, 162, 97, 0.12); }
.history-item[data-emotion-group="sadness"] .history-emoji { background: rgba(126, 184, 218, 0.12); }
.history-item[data-emotion-group="anger"] .history-emoji { background: rgba(231, 111, 81, 0.12); }
.history-item[data-emotion-group="anxiety"] .history-emoji { background: rgba(156, 137, 184, 0.12); }
.history-item[data-emotion-group="peace"] .history-emoji { background: rgba(168, 218, 171, 0.12); }
.history-item[data-emotion-group="love"] .history-emoji { background: rgba(242, 160, 160, 0.12); }
.history-item[data-emotion-group="tired"] .history-emoji { background: rgba(176, 168, 154, 0.12); }


/* --- Response Actions (CBT + Coping) --- */
/* ===== Response Actions (CBT + Coping 버튼) ===== */
.response-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-divider);
}
.response-action-btn {
  flex: 1;
  background: var(--color-surface-warm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 200ms ease;
}
.response-action-btn:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
  color: var(--color-text);
}
.response-action-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ===== CBT 입력 영역 ===== */
.cbt-input-area {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--color-surface-warm);
  border-radius: var(--radius-md);
  animation: fadeInUp 250ms ease both;
}
.cbt-input-label {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  margin: 0 0 0.5rem;
}
.cbt-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface);
  resize: vertical;
  min-height: 72px;
}
.cbt-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.cbt-input-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.cbt-submit-btn {
  flex: 1;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: opacity 200ms ease;
}
.cbt-submit-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.cbt-cancel-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
}

/* ===== CBT 결과 카드 ===== */
.cbt-result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--color-surface-warm);
  border-radius: var(--radius-md);
  animation: fadeInUp 300ms ease both;
}
.cbt-distortion {
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-weight: var(--weight-semibold);
  margin: 0 0 0.5rem;
}
.cbt-reframed {
  font-family: var(--font-diary);
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: var(--leading-relaxed);
  margin: 0.5rem 0;
}
.cbt-action {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  margin: 0.5rem 0 0;
}

/* ===== 마음 구급상자 결과 카드 ===== */
.coping-result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--color-surface-warm);
  border-radius: var(--radius-md);
  animation: fadeInUp 300ms ease both;
}
.coping-strategy {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
}
.coping-strategy + .coping-strategy {
  border-top: 1px solid var(--color-divider);
}
.coping-strategy-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}
.coping-strategy-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin: 0 0 0.25rem;
}
.coping-strategy-desc {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  line-height: var(--leading-base);
  margin: 0;
}
.coping-strategy-duration {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0.25rem 0 0;
}
.coping-encouragement {
  font-family: var(--font-diary);
  font-size: var(--text-sm);
  color: var(--color-primary);
  text-align: center;
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-divider);
}
