/* ========================================
   농수산 - 테이블 스타일
   ======================================== */

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.4;
}

.stats-table thead th {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-align: center;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.stats-table tbody td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.stats-table tbody tr:hover {
  background-color: var(--bg-tertiary);
}
.stats-table tbody tr:hover td:first-child {
  background-color: var(--bg-tertiary);
}

.stats-table tbody tr.clickable,
.stats-table tbody tr.item-row {
  cursor: pointer;
}

/* 첫 번째 컬럼 (품목명) 좌측 정렬 + 고정 */
.stats-table tbody td:first-child,
.stats-table thead th:first-child {
  text-align: left;
  font-weight: 500;
  position: sticky;
  left: 0;
  z-index: 2;
  background-color: var(--bg-primary);
}
.stats-table thead th:first-child {
  background-color: var(--bg-secondary);
  z-index: 6;
}

/* 가격 컬럼 우측 정렬 */
.stats-table .price-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 등락 표시 */
.price-up {
  color: var(--color-up);
  font-weight: 600;
}
.price-down {
  color: var(--color-down);
  font-weight: 600;
}
.price-steady {
  color: var(--color-steady);
}

/* 등락율 배지 */
.badge-change {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}
.badge-change.up {
  background-color: rgba(211, 47, 47, 0.1);
  color: var(--color-up);
}
.badge-change.down {
  background-color: rgba(21, 101, 192, 0.1);
  color: var(--color-down);
}
.badge-change.steady {
  background-color: rgba(117, 117, 117, 0.1);
  color: var(--color-steady);
}

/* 정렬 가능 헤더 */
.stats-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}
.stats-table thead th.sortable:hover {
  background-color: var(--bg-tertiary);
}
.stats-table thead th.sortable::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 4px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid var(--text-muted);
}
.stats-table thead th.sort-asc::after {
  border-top: none;
  border-bottom: 4px solid var(--accent-primary);
}
.stats-table thead th.sort-desc::after {
  border-top: 4px solid var(--accent-primary);
}

/* 반응형 */
@media (max-width: 640px) {
  .stats-table {
    font-size: 12px;
  }
  .stats-table thead th {
    padding: 6px 6px;
    white-space: nowrap;
  }
  .stats-table tbody td {
    padding: 6px 6px;
    white-space: normal;
  }
  .stats-table .price-col,
  .stats-table .badge-change {
    white-space: nowrap;
  }
  .stats-table .item-name {
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  .stats-table .item-name.expanded {
    white-space: normal;
    max-width: none;
    overflow: visible;
  }
  .stats-table thead th,
  .stats-table tbody td {
    letter-spacing: -0.5px;
  }
}
