/* ============================================================
   Sentimind — Stats Components
   꽃 차트, 히트맵, 감정 성장, 주간 비교, 상관관계,
   리포트 히스토리, 연간 내러티브, 인과 네트워크, 감정 흐름
   ============================================================ */

/* --- Emotion Flower Chart + Heatmap --- */
/* Emotion Flower Chart */
#emotionFlowerChart {
  text-align: center;
  padding: 0.5rem 0;
}
#emotionFlowerChart svg {
  max-width: 320px;
  width: 100%;
  height: auto;
  overflow: visible;
}
.flower-subtitle {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 0.5rem;
  margin-top: -0.25rem;
}
.flower-petal {
  transition: opacity 0.2s;
  cursor: pointer;
}
.flower-petal:hover { opacity: 0.75; }
.flower-petal-label {
  font-family: var(--font-ui, sans-serif);
  fill: var(--color-text);
}
.flower-tooltip {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  white-space: nowrap;
  z-index: 9999;
  display: none;
}
.flower-center-label {
  font-family: var(--font-ui, sans-serif);
  fill: var(--color-text);
}
.flower-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}
.flower-legend {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0 0.25rem;
}
.flower-legend-item {
  display: grid;
  grid-template-columns: 10px 3.5rem 1fr 2.2rem 2.4rem;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
}
.flower-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.flower-legend-name {
  color: var(--color-text-light);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flower-legend-bar {
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}
.flower-legend-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}
.flower-legend-count {
  color: var(--color-text-muted);
  text-align: right;
  font-size: 0.73rem;
}
.flower-legend-pct {
  color: var(--color-text);
  font-weight: 600;
  text-align: right;
  font-size: 0.73rem;
}
.flower-legend-item:first-child .flower-legend-name {
  color: var(--color-text);
  font-weight: 600;
}
.flower-legend-hidden {
  font-size: 0.73rem;
  color: var(--color-text-muted);
  text-align: right;
  margin-top: 0.2rem;
  display: block;
}
.flower-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 0 0.5rem;
}
.flower-empty-state svg {
  opacity: 0.18;
  width: 120px;
  height: 120px;
}
.flower-empty-state p {
  font-size: 0.83rem;
  color: var(--color-text-muted);
  text-align: center;
  line-height: 1.5;
}

/* Emotion × Situation Heatmap */
#emotionSituationHeatmap { overflow-x: auto; }
#emotionSituationHeatmap svg { min-width: 300px; display: block; max-width: 100%; }
.heatmap-cell { transition: opacity 0.2s; cursor: pointer; }
.heatmap-cell:hover { stroke: var(--color-text); stroke-width: 2; }
.heatmap-tooltip {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  color: var(--color-text);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  white-space: nowrap;
  z-index: 9999;
  display: none;
}
.heatmap-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}

/* --- Emotion Growth + Week Compare + Correlation --- */
/* ===== Emotion Growth Graph ===== */
.growth-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}
.growth-legend {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.growth-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.growth-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ===== Week Comparison ===== */
.week-compare-empty {
  text-align: center; color: var(--color-text-muted); font-size: 0.85rem; padding: 1.5rem 0;
}
.week-compare-grid {
  display: flex; align-items: center; gap: 0.5rem; justify-content: center;
}
.week-compare-arrow {
  font-size: 1.2rem; color: var(--color-text-muted); flex-shrink: 0;
}
.week-card {
  flex: 1; background: var(--color-surface-warm); border-radius: var(--radius-md);
  padding: 0.75rem; text-align: center; max-width: 180px;
}
.week-card-label {
  display: block; font-size: 0.7rem; font-weight: 600; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.4rem;
}
.week-card-stat { margin-bottom: 0.4rem; }
.week-card-num {
  font-size: 1.5rem; font-weight: 700; color: var(--color-primary); line-height: 1;
}
.week-card-unit { font-size: 0.75rem; color: var(--color-text-muted); margin-left: 2px; }
.week-card-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.75rem; padding: 0.15rem 0;
}
.week-card-sub { color: var(--color-text-muted); }
.week-card-value { color: var(--color-text); font-weight: 500; }
.week-compare-insight {
  text-align: center; font-size: 0.85rem; color: var(--color-text-light);
  margin-top: 0.75rem; line-height: 1.5;
}

/* ===== Activity Correlation Chart ===== */
.correlation-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 0;
}
.correlation-bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.correlation-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.correlation-label {
  font-size: 0.8rem;
  color: var(--color-text);
  min-width: 3rem;
  text-align: right;
  flex-shrink: 0;
}
.correlation-track {
  flex: 1;
  height: 20px;
  background: var(--color-background);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.correlation-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 400ms ease;
}
.correlation-fill--positive { background: var(--color-success); }
.correlation-fill--negative { background: var(--color-error); }
.correlation-fill--neutral { background: var(--color-primary); opacity: 0.6; }
.correlation-meta {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  min-width: 5rem;
  flex-shrink: 0;
}


/* --- Report History --- */
/* Report History */
.report-history {
  margin-top: 1rem;
}
.report-history[hidden] { display: none; }
.report-history-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem;
  cursor: pointer;
  user-select: none;
}
.report-history-title::before {
  content: '▸ ';
}
.report-history-title.expanded::before {
  content: '▾ ';
}
.report-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.report-history-list[hidden] { display: none; }
.report-history-item {
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--color-border);
  cursor: pointer;
}
.report-history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.report-history-period {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
}
.report-history-date {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}
.report-history-summary {
  font-size: 0.8rem;
  color: var(--color-text);
  margin: 0;
  line-height: 1.5;
}
.report-history-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.report-history-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-sm);
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}
.report-history-delete-btn:hover {
  opacity: 1;
  color: var(--color-danger, #e53e3e);
}
.report-history-detail {
  margin-top: 0.75rem;
  border-top: 1px solid var(--color-border);
  padding-top: 0.75rem;
}
.report-history-detail[hidden] { display: none; }
.report-history-detail-section {
  margin-bottom: 0.6rem;
}
.report-history-detail-section:last-child {
  margin-bottom: 0;
}
.report-history-detail-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.2rem;
}
.report-history-detail-text {
  font-size: 0.8rem;
  color: var(--color-text);
  margin: 0;
  line-height: 1.5;
}


/* --- Yearly Narrative Card --- */
/* ---------------------------------------------------------------------------
   Yearly Narrative Card (올해의 마음 이야기)
   --------------------------------------------------------------------------- */
.narrative-card { text-align: center; padding: 1rem 0; }
.narrative-emoji { font-size: 3rem; display: block; margin-bottom: 0.5rem; }
.narrative-title {
  font-family: var(--font-diary);
  font-size: var(--text-lg);
  color: var(--color-text);
  margin: 0 0 1rem;
}
.narrative-text {
  font-family: var(--font-diary);
  font-size: var(--text-base);
  color: var(--color-text-light);
  line-height: var(--leading-relaxed);
  text-align: left;
  margin: 0 0 1rem;
}
.narrative-growth {
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-weight: var(--weight-semibold);
  margin: 0;
}

/* --- Causal Network + Recovery Path + Emotion Flow --- */
/* ===== Causal Network + Recovery Path ===== */
.causal-legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.causal-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-xs);
  color: var(--color-text-light);
}
.causal-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.causal-network-desc, .recovery-path-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  line-height: var(--leading-base);
}
/* Emotion Flow List */
.emotion-flow-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.emotion-flow-group-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.emotion-flow-group-count {
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
  color: var(--color-text-muted);
  margin-left: 0.25rem;
}
.emotion-flow-card {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  margin-bottom: 0.35rem;
  font-size: var(--text-sm);
  line-height: var(--leading-base);
}
.emotion-flow-node {
  color: var(--color-text-muted);
  font-family: var(--font-body);
}
.emotion-flow-node.is-emotion {
  color: var(--color-primary);
  font-weight: var(--weight-semibold);
}
.emotion-flow-arrow {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  flex-shrink: 0;
}
.emotion-flow-weight {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--bg-secondary);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}
[data-theme="dark"] .emotion-flow-card {
  background: var(--color-surface);
  border-color: var(--color-border);
}
/* Emotion flow polarity colors */
.emotion-flow-card.is-recovery {
  border-left: 3px solid var(--color-success);
}
.emotion-flow-card.is-deepening {
  border-left: 3px solid var(--color-error);
  opacity: 0.85;
}
.emotion-flow-card.is-enrichment {
  border-left: 3px solid var(--color-secondary);
}
.emotion-flow-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.6rem 0.75rem;
  background: var(--color-surface-warm);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--color-text-light);
}
.emotion-flow-stat strong {
  font-weight: var(--weight-bold);
  color: var(--color-text);
}
.emotion-flow-stat.is-recovery strong {
  color: var(--color-success);
}
.emotion-flow-stat.is-deepening strong {
  color: var(--color-error);
}
