/**
 * 茶九度茶饮培训 - 通用组件样式
 * Universal Components
 */

/* ========== 重置样式 ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background: var(--color-bg-page);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea {
  font-family: inherit;
  border: none;
  outline: none;
}

/* ========== 手机模拟器容器 ========== */
.phone-frame {
  width: var(--screen-width);
  height: var(--screen-height);
  margin: 20px auto;
  background: var(--color-bg-white);
  border-radius: 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  position: relative;
}

.phone-screen {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: var(--color-bg-page);
}

.phone-screen::-webkit-scrollbar {
  display: none;
}

/* 状态栏 */
.status-bar {
  height: var(--statusbar-height);
  padding: 12px var(--page-padding);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: transparent;
}

.status-bar.light {
  color: var(--color-text-white);
}

.status-bar.dark {
  color: var(--color-text-primary);
}

/* ========== 玻璃拟态卡片 ========== */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.glass-card-light {
  background: var(--glass-bg-light);
  backdrop-filter: var(--glass-blur-light);
  -webkit-backdrop-filter: var(--glass-blur-light);
}

/* ========== 按钮组件 ========== */

/* 主按钮 - 渐变 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  height: var(--button-height-lg);
  padding: 0 var(--space-xl);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-lg);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--gradient-primary-button);
  color: var(--color-text-white);
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-primary-lg);
}

.btn-primary:active {
  transform: scale(0.98);
}

/* 次按钮 - 边框 */
.btn-secondary {
  background: var(--color-bg-white);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn-secondary:hover {
  background: rgba(255, 107, 53, 0.05);
}

/* 文字按钮 */
.btn-text {
  background: transparent;
  color: var(--color-primary);
  padding: 0 var(--space-md);
  height: auto;
}

.btn-text:hover {
  opacity: 0.8;
}

/* 按钮尺寸 */
.btn-sm {
  height: var(--button-height-sm);
  padding: 0 var(--space-lg);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
}

.btn-md {
  height: var(--button-height-md);
  padding: 0 var(--space-xl);
  font-size: var(--font-size-base);
}

.btn-lg {
  height: var(--button-height-lg);
  padding: 0 var(--space-2xl);
  font-size: var(--font-size-lg);
}

/* 块级按钮 */
.btn-block {
  width: 100%;
}

/* 禁用状态 */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* 按钮水波纹效果 */
.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::after {
  width: 300px;
  height: 300px;
}

/* ========== 卡片组件 ========== */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-4px);
}

.card-flat {
  box-shadow: none;
}

.card-flat:hover {
  transform: none;
  box-shadow: none;
}

/* 3D倾斜卡片效果 */
.card-3d {
  transform-style: preserve-3d;
  perspective: 1000px;
}

.card-3d:hover {
  transform: rotateX(-2deg) rotateY(2deg) translateY(-4px);
}

/* ========== 输入框组件 ========== */
.input-group {
  position: relative;
}

.input {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--space-lg);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

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

/* 搜索框 - 玻璃拟态 */
.search-input {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur-light);
  -webkit-backdrop-filter: var(--glass-blur-light);
  border: var(--glass-border);
  border-radius: var(--radius-full);
  padding-left: 44px;
}

.search-input-icon {
  position: absolute;
  left: var(--space-lg);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-tertiary);
}

/* ========== 标签组件 ========== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-sm);
  background: rgba(255, 107, 53, 0.1);
  color: var(--color-primary);
}

.tag-success {
  background: rgba(82, 196, 26, 0.1);
  color: var(--color-success);
}

.tag-warning {
  background: rgba(250, 173, 20, 0.1);
  color: var(--color-warning);
}

.tag-error {
  background: rgba(255, 77, 79, 0.1);
  color: var(--color-error);
}

.tag-info {
  background: rgba(24, 144, 255, 0.1);
  color: var(--color-info);
}

/* 芯片标签（可滑动分类） */
.chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
  background: var(--color-bg-white);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  transition: all var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chip.active {
  background: var(--gradient-primary-button);
  color: var(--color-text-white);
  border-color: transparent;
  box-shadow: var(--shadow-primary);
}

/* 芯片组容器 */
.chip-group {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding: var(--space-sm) var(--page-padding);
  margin: 0 calc(var(--page-padding) * -1);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chip-group::-webkit-scrollbar {
  display: none;
}

/* ========== 头像组件 ========== */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-white);
  font-weight: var(--font-weight-semibold);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--font-size-sm); }
.avatar-md { width: 48px; height: 48px; font-size: var(--font-size-lg); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--font-size-xl); }
.avatar-xl { width: 80px; height: 80px; font-size: var(--font-size-2xl); }

/* ========== 徽标/角标组件 ========== */
.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-white);
  background: var(--color-error);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: badge-bounce 0.3s var(--transition-bounce);
}

@keyframes badge-bounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ========== 分割线 ========== */
.divider {
  height: 1px;
  background: var(--color-divider);
  margin: var(--space-lg) 0;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--color-divider);
  margin: 0 var(--space-lg);
}

/* ========== 列表项组件 ========== */
.list-item {
  display: flex;
  align-items: center;
  padding: var(--space-lg);
  background: var(--color-bg-white);
  transition: background var(--transition-fast);
}

.list-item:active {
  background: rgba(0, 0, 0, 0.02);
}

.list-item + .list-item {
  border-top: 1px solid var(--color-border-light);
}

.list-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-bg-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  margin-right: var(--space-md);
  flex-shrink: 0;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

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

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

.list-item-arrow {
  color: var(--color-text-placeholder);
  margin-left: var(--space-sm);
}

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

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

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

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

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

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

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-sm);
}

.skeleton-title {
  height: 20px;
  width: 60%;
  margin-bottom: var(--space-md);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-image {
  width: 100%;
  padding-top: 100%;
  border-radius: var(--radius-md);
}

/* ========== 价格展示组件 ========== */
.price {
  font-family: var(--font-family-number);
  color: var(--color-primary);
  font-weight: var(--font-weight-bold);
}

.price-symbol {
  font-size: 0.7em;
  margin-right: 1px;
}

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

.price-lg {
  font-size: var(--font-size-3xl);
}

.price-md {
  font-size: var(--font-size-xl);
}

.price-sm {
  font-size: var(--font-size-md);
}

/* ========== 进度环组件 ========== */
.progress-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring-track {
  stroke: var(--color-border-light);
  fill: none;
}

.progress-ring-progress {
  stroke: url(#progress-gradient);
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.progress-ring-text {
  position: absolute;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

/* ========== 数量选择器 ========== */
.quantity-selector {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.quantity-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-page);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  transition: all var(--transition-fast);
}

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

.quantity-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.quantity-value {
  min-width: 32px;
  text-align: center;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
}

/* ========== Toast 提示组件 ========== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: var(--space-md) var(--space-xl);
  background: rgba(0, 0, 0, 0.75);
  color: var(--color-text-white);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  z-index: var(--z-toast);
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ========== 底部弹出层组件 ========== */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.bottom-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-bg-white);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  z-index: var(--z-modal);
  transform: translateY(100%);
  transition: transform var(--transition-normal);
  max-height: 80vh;
  overflow: hidden;
}

.bottom-sheet.active {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  margin: var(--space-md) auto;
}

.bottom-sheet-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bottom-sheet-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
}

.bottom-sheet-content {
  padding: var(--space-lg);
  overflow-y: auto;
  max-height: calc(80vh - 100px);
}
