/* ========== 公共组件 ========== */

/* 页面容器 */
.page {
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + var(--space-lg) + 22px);
}

.page-no-tab {
  padding-bottom: var(--space-lg);
}

/* 顶部导航栏 */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  color: white;
}

.header-title {
  font-size: var(--text-lg);
  font-weight: bold;
  flex: 1;
  text-align: center;
}

.header-back,
.header-action {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  color: white;
}

/* 卡片 */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin: var(--space-sm) var(--space-lg);
  padding: var(--space-md);
  overflow: hidden;
}

.card-flat {
  box-shadow: none;
  border: 1px solid var(--border);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: var(--shadow-primary);
}

.btn-primary:active {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.btn-outline {
  border: 1px solid var(--primary);
  color: var(--primary);
  background: transparent;
}

.btn-ghost {
  color: var(--text-secondary);
  background: var(--bg);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--text-lg);
  border-radius: var(--radius-xl);
  width: 100%;
}

.btn-round {
  border-radius: var(--radius-full);
}

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
}

.tag-primary {
  background: var(--tag-bg);
  color: var(--tag-text);
}

.tag-success {
  background: var(--tag-green-bg);
  color: var(--tag-green-text);
}

.tag-outline {
  border: 1px solid var(--border);
  color: var(--text-tertiary);
}

/* 输入框 */
.input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--text-primary);
  border: 1px solid transparent;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.input::placeholder {
  color: var(--text-tertiary);
}

/* 列表项 */
.list-item {
  display: flex;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
  position: relative;
}

.list-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--space-lg);
  right: var(--space-lg);
  height: 1px;
  background: var(--divider);
  transform: scaleY(0.5);
}

.list-item:last-child::after {
  display: none;
}

.list-item-icon {
  width: 24px;
  height: 24px;
  margin-right: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-item-content {
  flex: 1;
}

.list-item-title {
  font-size: var(--text-base);
  color: var(--text-primary);
}

.list-item-desc {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: 2px;
}

.list-item-arrow {
  color: var(--text-tertiary);
  font-size: var(--text-lg);
  margin-left: var(--space-sm);
}

/* 底部导航栏 */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: calc(var(--tab-bar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 1000;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs) 0;
  transition: color 0.2s;
}

.tab-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.tab-label {
  font-size: var(--text-xs);
  margin-top: 2px;
  color: var(--text-tertiary);
}

.tab-item.active .tab-label {
  color: var(--primary);
}

.tab-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 20px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: white;
  font-size: var(--text-xs);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 加载动画 */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  animation: loader-spin 0.8s steps(8) infinite;
}

@keyframes loader-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: var(--space-md);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
}

.empty-state img {
  width: 120px;
  height: 120px;
  margin-bottom: var(--space-md);
  opacity: 0.6;
}

.empty-state-title {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* 分割线 */
.divider {
  height: 1px;
  background: var(--divider);
  margin: var(--space-md) var(--space-lg);
  transform: scaleY(0.5);
}

/* 价格显示 */
.price {
  font-family: var(--font-num);
  font-weight: bold;
}

.price-current {
  color: var(--danger);
  font-size: var(--text-lg);
}

.price-original {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  text-decoration: line-through;
  margin-left: var(--space-xs);
}

.price-unit {
  font-size: var(--text-sm);
  font-weight: normal;
}

/* 评分星星 */
.stars {
  display: flex;
  gap: 4px;
}

.star {
  width: 20px;
  height: 20px;
  transition: transform 0.2s;
}

.star:active {
  transform: scale(1.2);
}

/* 浮动按钮 */
.fab {
  position: fixed;
  right: var(--space-lg);
  bottom: calc(var(--tab-bar-height) + var(--safe-bottom) + var(--space-lg));
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  font-size: var(--text-2xl);
}

/* 遮罩层 */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 800;
  opacity: 0;
  transition: opacity 0.3s;
}

.mask.show {
  opacity: 1;
}

/* 底部弹窗 */
.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: var(--max-width);
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 900;
  transition: transform 0.3s ease-out;
  max-height: 80vh;
  overflow-y: auto;
}

.bottom-sheet.show {
  transform: translateX(-50%) translateY(0);
}

.bottom-sheet-header {
  padding: var(--space-md) var(--space-lg);
  text-align: center;
  font-size: var(--text-lg);
  font-weight: bold;
  border-bottom: 1px solid var(--divider);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 10;
}

/* 步骤条 */
.steps {
  display: flex;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
}

.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.step-dot {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  z-index: 2;
}

.step.active .step-dot {
  background: var(--primary);
  color: white;
}

.step.completed .step-dot {
  background: var(--success);
  color: white;
}

.step-line {
  position: absolute;
  top: 12px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 1;
}

.step.completed .step-line,
.step.active .step-line {
  background: var(--success);
}

.step-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

.step.active .step-label {
  color: var(--primary);
}

/* 优惠券卡片 */
.coupon-card {
  display: flex;
  height: 100px;
  margin: var(--space-sm) var(--space-lg);
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.coupon-left {
  width: 100px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  position: relative;
}

.coupon-left::before,
.coupon-left::after {
  content: '';
  position: absolute;
  right: -6px;
  width: 12px;
  height: 12px;
  background: var(--bg);
  border-radius: var(--radius-full);
}

.coupon-left::before { top: -6px; }
.coupon-left::after { bottom: -6px; }

.coupon-amount {
  font-size: var(--text-3xl);
  font-weight: bold;
  font-family: var(--font-num);
}

.coupon-condition {
  font-size: var(--text-xs);
  opacity: 0.9;
}

.coupon-right {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.coupon-title {
  font-size: var(--text-base);
  font-weight: bold;
  color: var(--text-primary);
}

.coupon-valid {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
}

.coupon-btn {
  align-self: flex-start;
  margin-top: var(--space-sm);
}

/* 商品数量控制器 */
.quantity-control {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.quantity-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  color: var(--text-secondary);
  transition: all 0.2s;
}

.quantity-btn:active {
  background: var(--bg);
}

.quantity-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.quantity-value {
  font-size: var(--text-base);
  font-weight: bold;
  min-width: 24px;
  text-align: center;
  font-family: var(--font-num);
}
