/* ============================================
   cart2 四步式购买流程 进度条组件 step-bar
   ============================================
   使用：在页面中 include step-bar.tpl 前设置 $stepCurrent (1/2/3/4)
   依赖：candycake.css 中的 --cc-brand* / --cc-border / --cc-text / --cc-muted
   配色：与设计规范 v1 一致，糖糕云绿（#229670 系）
*/

.cc-stepbar {
  background: linear-gradient(180deg, #ffffff 0%, #f5fffb 100%);
  border: 1px solid var(--cc-border, #e2e8f0);
  border-radius: var(--cc-radius, 16px);
  padding: 22px 28px;
  margin-bottom: 20px;
  box-shadow: 0 10px 28px rgba(15, 95, 71, 0.06);
}

.cc-stepbar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

/* === 单个步骤节点 === */
.cc-stepbar-item {
  flex: 0 0 auto;
  min-width: 0;
}

.cc-stepbar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  padding: 4px 6px;
  border-radius: 12px;
  transition: background 0.18s ease, transform 0.18s ease;
}
a.cc-stepbar-link { cursor: pointer; }
a.cc-stepbar-link:hover {
  background: rgba(var(--cc-brand-rgb, 34, 150, 112), 0.07);
  text-decoration: none;
  color: inherit;
}
a.cc-stepbar-link:hover .cc-stepbar-node {
  transform: scale(1.04);
}

/* === 圆形节点 === */
.cc-stepbar-node {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  background: #ffffff;
  border: 2px solid var(--cc-border, #e2e8f0);
  color: var(--cc-muted, #94a3b8);
  transition: background 0.25s ease, border-color 0.25s ease,
              color 0.25s ease, box-shadow 0.25s ease, transform 0.18s ease;
}
.cc-stepbar-node .bx { font-size: 22px; line-height: 1; }
.cc-stepbar-no { line-height: 1; }

/* === 文本块 === */
.cc-stepbar-text {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cc-stepbar-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--cc-text, #0f172a);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
}
.cc-stepbar-label .bx {
  font-size: 16px;
  color: var(--cc-muted, #94a3b8);
}
.cc-stepbar-desc {
  font-size: 12px;
  color: var(--cc-muted, #94a3b8);
  line-height: 1.3;
}

/* === 状态：已完成 === */
.cc-stepbar-item--done .cc-stepbar-node {
  background: linear-gradient(135deg, var(--cc-brand, #229670), var(--cc-brand-strong, #167a5b));
  border-color: var(--cc-brand-strong, #167a5b);
  color: #fff;
  box-shadow: 0 4px 12px rgba(var(--cc-brand-rgb, 34, 150, 112), 0.28);
}
.cc-stepbar-item--done .cc-stepbar-label,
.cc-stepbar-item--done .cc-stepbar-label .bx {
  color: var(--cc-brand-dark, #0f5f47);
}

/* === 状态：当前 === */
.cc-stepbar-item--current .cc-stepbar-node {
  background: linear-gradient(135deg, var(--cc-brand, #229670), var(--cc-brand-strong, #167a5b));
  border-color: var(--cc-brand, #229670);
  color: #fff;
  box-shadow: 0 0 0 6px rgba(var(--cc-brand-rgb, 34, 150, 112), 0.16),
              0 8px 18px rgba(var(--cc-brand-rgb, 34, 150, 112), 0.32);
  animation: ccStepbarPulse 2.4s ease-in-out infinite;
}
.cc-stepbar-item--current .cc-stepbar-label,
.cc-stepbar-item--current .cc-stepbar-label .bx {
  color: var(--cc-text, #0f172a);
}
.cc-stepbar-item--current .cc-stepbar-label {
  font-weight: 900;
  letter-spacing: -.01em;
}

@keyframes ccStepbarPulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(var(--cc-brand-rgb, 34, 150, 112), 0.16), 0 8px 18px rgba(var(--cc-brand-rgb, 34, 150, 112), 0.32); }
  50%      { box-shadow: 0 0 0 10px rgba(var(--cc-brand-rgb, 34, 150, 112), 0.08), 0 8px 18px rgba(var(--cc-brand-rgb, 34, 150, 112), 0.32); }
}

/* === 状态：未到达 === */
.cc-stepbar-item--pending .cc-stepbar-node {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
}
.cc-stepbar-item--pending .cc-stepbar-label {
  color: #64748b;
}
.cc-stepbar-item--pending .cc-stepbar-label .bx {
  color: #cbd5e1;
}

/* === 连接线 === */
.cc-stepbar-line {
  flex: 1 1 auto;
  position: relative;
  height: 44px;
  display: flex;
  align-items: center;
  margin: 0 4px;
  min-width: 32px;
}
.cc-stepbar-line-track,
.cc-stepbar-line-fill {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  border-radius: 999px;
  transform: translateY(-50%);
}
.cc-stepbar-line-track {
  background: #e2e8f0;
}
.cc-stepbar-line-fill {
  background: linear-gradient(90deg, var(--cc-brand, #229670), var(--cc-brand-strong, #167a5b));
  width: 0;
  transition: width 0.5s ease;
}
.cc-stepbar-line--done .cc-stepbar-line-fill { width: 100%; }
.cc-stepbar-line--pending .cc-stepbar-line-fill { width: 0; }

/* ============================================
   响应式
   ============================================ */

/* 平板：缩小节点 + 描述文字隐藏 */
@media (max-width: 992px) {
  .cc-stepbar { padding: 18px 20px; }
  .cc-stepbar-node { width: 38px; height: 38px; font-size: 14px; }
  .cc-stepbar-node .bx { font-size: 20px; }
  .cc-stepbar-label { font-size: 14px; }
  .cc-stepbar-desc { display: none; }
  .cc-stepbar-line { height: 38px; min-width: 24px; }
  .cc-stepbar-link { gap: 10px; }
}

/* 手机：纯节点 + 数字下方文字，连接线变细
   注：4 节点比 3 节点更紧，gap 与连接线 min-width 都进一步收窄 */
@media (max-width: 640px) {
  .cc-stepbar {
    padding: 14px 12px;
    border-radius: 12px;
    margin-bottom: 14px;
  }
  .cc-stepbar-list {
    align-items: center;
    gap: 2px;
  }
  .cc-stepbar-link {
    flex-direction: column;
    text-align: center;
    gap: 6px;
    padding: 2px;
  }
  .cc-stepbar-node {
    width: 32px;
    height: 32px;
    font-size: 12px;
    border-width: 2px;
  }
  .cc-stepbar-node .bx { font-size: 17px; }
  .cc-stepbar-label {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
  }
  .cc-stepbar-label .bx { display: none; }
  .cc-stepbar-line {
    align-self: flex-start;
    margin-top: 15px;
    min-width: 8px;
    height: 2px;
  }
  .cc-stepbar-line-track,
  .cc-stepbar-line-fill { height: 2px; }
}

/* 极窄屏幕 < 380：仅保留数字 + 连接线 */
@media (max-width: 380px) {
  .cc-stepbar { padding: 12px 8px; }
  .cc-stepbar-label { display: none; }
  .cc-stepbar-link { gap: 0; }
  .cc-stepbar-node {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  .cc-stepbar-line { margin-top: 13px; min-width: 4px; }
}
