/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
    'Helvetica Neue', Arial, sans-serif;
  background: #ffffff;
  color: #333;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 主容器 */
.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
}

/* 授权引导页面 */
.auth-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-page.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-content {
  text-align: center;
  padding: 40px 20px;
  animation: fadeInScale 0.6s ease-out;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.auth-icon {
  margin-bottom: 24px;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.auth-title {
  color: white;
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
}

.auth-desc {
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  margin-bottom: 32px;
}

.auth-btn {
  background: #09bb07;
  color: white;
  border: none;
  padding: 16px 48px;
  font-size: 18px;
  font-weight: 600;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(9, 187, 7, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(9, 187, 7, 0.5);
}

.auth-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 16px rgba(9, 187, 7, 0.4);
}

/* 商品内容区 */
.product-content {
  display: flex;
  flex-direction: column;
  height: 100vh; /* 固定高度为视口高度 */
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.product-content.hidden {
  opacity: 0;
  visibility: hidden;
  height: 0;
  overflow: hidden;
}

/* 商品图片展示区 */
.product-gallery {
  flex: 1; /* 占据剩余空间 */
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 0;
  overflow: auto;
  overflow-y: auto; /* 允许垂直滚动 */
  overflow-x: hidden; /* 禁止水平滚动 */
  -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
}

.gallery-item {
  position: relative;
  width: 100%;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  background: transparent;
  backdrop-filter: none;
  animation: fadeInUp 0.6s ease-out forwards;
  opacity: 0;
  transform: translateY(20px);
  /* 微信浏览器优化：防止容器高度塌陷 */
  min-height: 50px;
  /* 提示浏览器该元素会发生变化，优化渲染 */
  will-change: transform, opacity;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  /* 微信浏览器兼容性优化 */
  min-height: 1px; /* 防止高度为0 */
  max-width: 100%; /* 确保不超出容器 */
  object-fit: contain; /* 保持图片比例，完整显示 */
  /* 强制硬件加速，优化渲染 */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* 购买按钮区域 */
.purchase-section {
  /* 不再使用 fixed，让它成为 flex 布局的一部分 */
  padding: 16px;
  background: #ffffff;
  flex-shrink: 0; /* 不缩小 */
  z-index: 100;
}

.purchase-btn {
  width: 100%;
  padding: 18px 32px;
  background: #e7a438;
  color: white;
  font-size: 18px;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(231, 164, 56, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  /* 禁止选中和高亮 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.purchase-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.purchase-btn:hover::before,
.purchase-btn:active::before {
  width: 300px;
  height: 300px;
}

.purchase-btn:hover,
.purchase-btn:focus {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(231, 164, 56, 0.5);
}

.purchase-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 16px rgba(231, 164, 56, 0.4);
}

.btn-text,
.btn-icon {
  position: relative;
  z-index: 1;
}

.btn-icon {
  font-size: 22px;
  transition: transform 0.3s ease;
}

.purchase-btn:hover .btn-icon {
  transform: translateX(4px);
}

/* 加载状态 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: 16px;
  color: white;
  font-size: 16px;
  font-weight: 500;
}

/* 提示信息 */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateY(20px);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 15px;
  z-index: 2000;
  max-width: 80%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.hidden {
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) translateY(0);
}

/* 响应式设计 */
@media (min-width: 768px) {
  .container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0;
  }

  .product-gallery {
    gap: 0;
  }

  .gallery-item {
    border-radius: 0;
  }
}

/* 滚动优化 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  body {
    background: #ffffff;
  }
}
/* 支付成功弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  width: 85%;
  max-width: 320px;
  background: white;
  border-radius: 24px;
  overflow: hidden;
  transform: scale(0.8) translateY(20px);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-overlay.show .modal-container {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 40px 24px 20px;
  text-align: center;
}

.success-icon-wrapper {
  width: 72px;
  height: 72px;
  background: #f0fdf4;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  animation: scaleBounce 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes scaleBounce {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

.success-icon {
  color: #22c55e;
  width: 36px;
  height: 36px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 15px;
  color: #666;
  line-height: 1.5;
}

.modal-footer {
  padding: 0 24px 32px;
}

.modal-btn {
  width: 100%;
  height: 52px;
  background: #09bb07;
  color: white;
  border: none;
  border-radius: 26px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 8px 20px rgba(9, 187, 7, 0.2);
  -webkit-tap-highlight-color: transparent;
}

.modal-btn:active {
  transform: scale(0.97);
  background: #08a606;
  box-shadow: 0 4px 10px rgba(9, 187, 7, 0.2);
}
