/*
 * chart_bars.css — includes/chart_bars.php (render_bar_chart_vertical / render_bar_list_horizontal) 스타일.
 *
 * 컴포넌트 디렉터리에 두는 이유: header.php와 admin/includes/admin_header.php 양쪽 모두
 * assets/css/components/*.css 를 알파벳순으로 자동 스캔해 로드하므로, 이 파일 하나로
 * 공개 사이트(stats/business.php)와 관리자(admin/stats.php, admin/index.php) 양쪽에서
 * 별도 등록 없이 재사용된다. 외부 차트 라이브러리를 쓰지 않는다는 제약에 따라 순수 CSS 막대 +
 * <details> 로 접는 실제 <table> 조합으로 그린다. 색상/간격은 전부 tokens.css var() 참조.
 */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stat-chart {
  width: 100%;
}

.stat-chart__empty {
  color: var(--text-3);
  font-size: 0.875rem;
  padding: var(--sp-6) 0;
  text-align: center;
}

.stat-chart__bars {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  height: 160px;
  padding: 0 var(--sp-1);
}

.stat-chart__bar-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.stat-chart__bar-value {
  font-size: 0.6875rem;
  color: var(--text-2);
  margin-bottom: var(--sp-1);
  white-space: nowrap;
}

.stat-chart__bar {
  width: 100%;
  max-width: 28px;
  min-height: 3px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--color-line-soft);
  transition: height 0.2s ease;
}

.stat-chart__bar-col.is-current .stat-chart__bar {
  background: var(--main-color);
}

.stat-chart__bar-col.is-current .stat-chart__bar-value {
  color: var(--sub-color);
  font-weight: 700;
}

.stat-chart__bar-label {
  margin-top: var(--sp-2);
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
}

.stat-chart__table-toggle {
  margin-top: var(--sp-3);
}

.stat-chart__table-toggle summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--sub-color);
  font-weight: 500;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  list-style: none;
}

.stat-chart__table-toggle summary::-webkit-details-marker {
  display: none;
}

.stat-chart__table-toggle summary::before {
  content: '▸';
  margin-right: var(--sp-1);
  font-size: 0.75rem;
}

.stat-chart__table-toggle[open] summary::before {
  content: '▾';
}

.stat-chart__table-toggle summary:focus-visible {
  outline: 2px solid var(--main-color);
  outline-offset: 2px;
}

.stat-chart__table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--sp-2);
  font-size: 0.8125rem;
}

.stat-chart__table th,
.stat-chart__table td {
  padding: var(--sp-2);
  text-align: left;
  border-bottom: 1px solid var(--color-line-soft);
}

.stat-chart__table thead th {
  color: var(--text-3);
  font-weight: 700;
  background: var(--surface-1);
}

/* ==== 가로 막대(카테고리 비중) ==== */
.stat-hbars__list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.stat-hbars__row {
  display: grid;
  grid-template-columns: 4.5em 1fr 3em;
  align-items: center;
  gap: var(--sp-2);
}

.stat-hbars__label {
  font-size: 0.8125rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-hbars__track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-1);
  overflow: hidden;
}

.stat-hbars__fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--main-color);
}

.stat-hbars__pct {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-1);
  text-align: right;
}

@media (min-width: 768px) {
  .stat-chart__bars {
    height: 200px;
  }

  .stat-chart__bar {
    max-width: 40px;
  }
}
