/**
 * 积分页样式
 * 图标: Tabler Icons (MIT)
 */

/* ===== 余额总览 ===== */
.credits-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 236px);
  gap: 22px;
  align-items: stretch;
  padding: 18px 20px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.credits-hero-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.credits-hero-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.credits-hero-label {
  font-size: 12.5px;
  color: var(--text-3);
}

.credits-status {
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--inset);
  color: var(--text-3);
  font-size: 11px;
  line-height: 17px;
}

.credits-status.is-ok {
  border-color: transparent;
  background: var(--success-soft);
  color: var(--success);
}

.credits-status.is-low {
  border-color: transparent;
  background: rgba(234, 179, 8, 0.12);
  color: var(--warning);
}

.credits-status.is-out {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.credits-hero-balance {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 2px;
}

.credits-hero-value {
  font-family: var(--mono);
  font-size: 38px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.5px;
  color: var(--text);
}

.credits-hero-unit {
  font-size: 12.5px;
  color: var(--text-3);
}

.credits-hero-hint {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-2);
}

.credits-hero-hint b {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}

.credits-hero-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-width: 0;
}

/* 收支构成条 */
.credits-split {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.credits-split-bar {
  display: flex;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow: hidden;
}

.credits-split-seg {
  height: 100%;
  transition: width var(--t) var(--ease);
}

.credits-split-seg.is-left {
  background: var(--accent);
}

.credits-split-seg.is-used {
  background: var(--border-2);
}

.credits-split-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 11.5px;
  color: var(--text-3);
}

.credits-legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.credits-legend b {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}

.credits-legend-dot {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 50%;
}

.credits-legend-dot.is-left {
  background: var(--accent);
}

.credits-legend-dot.is-used {
  background: var(--border-2);
}

.credits-hero-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.credits-kpi {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 7px 10px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.credits-kpi-label {
  font-size: 11.5px;
  color: var(--text-3);
}

.credits-kpi-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.credits-kpi-value.is-earned {
  color: var(--success);
}

.credits-kpi-value.is-spent {
  color: var(--warning);
}

/* ===== 近 7 天趋势 ===== */
.credits-trend {
  display: flex;
  align-items: stretch;
  gap: 7px;
  height: 104px;
  padding-top: 16px;
}

.credits-trend-day {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.credits-trend-value {
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-bottom: 3px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  color: var(--text-3);
  white-space: nowrap;
  transform: translateX(-50%);
}

.credits-trend-day.is-today .credits-trend-value {
  color: var(--text);
}

.credits-trend-bar-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
}

.credits-trend-bar {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 100%;
  max-width: 32px;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
  opacity: 0.58;
  transform: translateX(-50%);
  transition: height var(--t) var(--ease), opacity var(--t) var(--ease);
}

.credits-trend-day.is-today .credits-trend-bar {
  opacity: 1;
}

.credits-trend-label {
  font-size: 11px;
  white-space: nowrap;
  color: var(--text-3);
}

.credits-trend-day.is-today .credits-trend-label {
  color: var(--text);
}

/* ===== 获得 / 消耗切换 ===== */
.credits-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.credits-tab {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: none;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}

.credits-tab:hover {
  color: var(--text);
}

.credits-tab.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 500;
}

.credits-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  margin-left: 5px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1;
}

.credits-tab.active .credits-tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ===== 积分构成 ===== */
/* 图标与进度条配色由 JS 通过 --color-source-color 注入，此处为兜底值 */
.credits-source-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  --color-source-color: var(--accent);
}

.credits-source-list.hidden,
.credits-tx-list.hidden,
.credits-more.hidden {
  display: none;
}

.credits-source-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.credits-source-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.credits-source-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--inset);
  color: var(--color-source-color, var(--accent));
}

.credits-source-name {
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credits-source-count {
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--text-3);
}

.credits-source-amount {
  margin-left: auto;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
}

.credits-source-percent {
  width: 38px;
  flex-shrink: 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
}

.credits-source-bar {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow: hidden;
}

.credits-source-bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--color-source-color, var(--accent));
  transition: width var(--t) var(--ease);
}

/* ===== 积分明细 ===== */
.credits-tx-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.credits-day {
  display: flex;
  flex-direction: column;
}

.credits-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 7px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}

.credits-day-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.credits-day-sum {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-3);
}

.credits-tx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.credits-tx-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.credits-tx-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--inset);
  color: var(--color-source-color, var(--text-2));
}

.credits-tx-body {
  flex: 1;
  min-width: 0;
}

.credits-tx-title {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credits-tx-meta {
  display: flex;
  gap: 7px;
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--text-3);
}

.credits-tx-meta span {
  white-space: nowrap;
}

.credits-tx-meta span + span::before {
  content: '·';
  margin-right: 7px;
}

.credits-tx-amount {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}

.credits-tx-amount.earned {
  color: var(--success);
}

.credits-tx-amount.spent {
  color: var(--warning);
}

.credits-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--inset);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}

.credits-more:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ===== 积分规则 ===== */
.credits-rules {
  display: flex;
  flex-direction: column;
}

.credits-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.credits-rule:first-child {
  padding-top: 0;
}

.credits-rule:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.credits-rule-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--inset);
  color: var(--text-2);
}

.credits-rule-body {
  flex: 1;
  min-width: 0;
}

.credits-rule-name {
  font-size: 13.5px;
}

.credits-rule-desc {
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--text-3);
}

.credits-rule-amount {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
}

.credits-rule-amount.is-earned {
  color: var(--success);
}

.credits-rule-amount.is-spent {
  color: var(--warning);
}

/* ===== 空态 ===== */
.credits-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 12px;
  font-size: 13px;
  color: var(--text-3);
  background: var(--inset);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-sm);
}

.credits-empty.hidden {
  display: none;
}

@media (max-width: 640px) {
  .credits-hero {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .credits-hero-value {
    font-size: 30px;
  }

  .credits-trend {
    height: 88px;
  }

  .credits-source-count {
    display: none;
  }
}
