/* ===== Statistics View ===== */

/* Header */
.statistics-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  max-width: 600px;
  margin: 0 auto;
}

.statistics-header h2 {
  font-size: 1.15rem;
}

/* Content container */
.statistics-content {
  padding: 0 1.5rem 2rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Section cards */
.stats-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.stats-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

/* Pie chart container */
.pie-chart-container {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  position: relative;
}

.pie-chart-mini {
  justify-content: center;
}

.pie-canvas {
  flex-shrink: 0;
}

/* Legend */
.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pie-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.pie-legend-label {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.pie-legend-amount {
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: auto;
}

/* Tooltip */
.pie-tooltip {
  position: absolute;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Stats list items */
.stats-list {
  display: flex;
  flex-direction: column;
}

.stats-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
}

.stats-item:first-child {
  border-top: none;
}

.stats-item-clickable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.stats-item-clickable:hover {
  background: var(--bg-input);
}

.stats-item-expanded {
  background: var(--bg-input);
}

.stats-item-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-item-amount {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 0.5rem;
}

/* Category badge */
.category-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Drill-down panel */
.drill-down-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin: 0.25rem 0;
}

.drill-down-panel.drill-down-open {
  max-height: 600px;
  transition: max-height 0.3s ease-in;
}

.drill-down-content {
  padding: 0.75rem;
}

.drill-down-subheading {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0.5rem 0 0.25rem;
}

.drill-down-subheading:first-child {
  margin-top: 0;
}

.drill-down-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.drill-down-item:first-child {
  border-top: none;
}

.drill-down-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}

.drill-down-amount {
  white-space: nowrap;
  font-weight: 600;
}

/* Year-Category blocks */
.stats-year-cat-block {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.stats-year-cat-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.stats-year-cat-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* No data message */
.no-data-msg {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem 0;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .statistics-header {
    padding: 1rem;
  }

  .statistics-content {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .pie-chart-container {
    flex-direction: column;
    align-items: center;
  }

  .pie-legend-label {
    max-width: 100px;
  }

  .stats-item-label {
    font-size: 0.85rem;
  }

  .stats-item-amount {
    font-size: 0.82rem;
  }
}
