* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --success-color: #10b981;
  --error-color: #ef4444;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --bg-light: #f9fafb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Logo & Header */
.header {
  text-align: center;
  margin-bottom: 40px;
}

.logo {
  font-size: 2rem;
  font-weight: 700;
  color: white;
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
}

/* Card */
.card {
  background: white;
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}

/* Form Elements */
.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input::placeholder {
  color: #9ca3af;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

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

/* Product Info */
.product-info {
  display: none;
  animation: slideDown 0.3s ease;
}

.product-info.show {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.product-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.product-description {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-light);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary-color);
}

.product-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 24px;
}

.divider {
  height: 1px;
  background: var(--border-color);
  margin: 24px 0;
}

/* Alert Messages */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  animation: slideDown 0.3s ease;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

/* Payment Methods */
.payment-methods {
  margin-bottom: 24px;
}

.payment-method {
  display: flex;
  align-items: center;
  padding: 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.payment-method:hover {
  border-color: var(--primary-color);
  background: var(--bg-light);
}

.payment-method input[type="radio"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.payment-method label {
  cursor: pointer;
  font-weight: 500;
  flex: 1;
}

/* Order Summary */
.order-summary {
  background: var(--bg-light);
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.order-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.order-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.order-label {
  color: var(--text-secondary);
}

.order-value {
  font-weight: 500;
  color: var(--text-primary);
}

.order-total {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* Card Key Display */
.card-key-box {
  background: var(--bg-light);
  border: 2px dashed var(--primary-color);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin: 24px 0;
}

.card-key {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  word-break: break-all;
  margin: 16px 0;
}

.copy-btn {
  background: white;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  padding: 10px 20px;
  margin-top: 12px;
}

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

/* Success Icon */
.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  background: var(--success-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scaleIn 0.4s ease;
}

.success-icon::before {
  content: '✓';
  color: white;
  font-size: 3rem;
  font-weight: bold;
}

@keyframes scaleIn {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

/* Responsive */
@media (max-width: 640px) {
  .container {
    padding: 20px 10px;
  }
  
  .card {
    padding: 24px 16px;
  }
  
  .logo {
    font-size: 1.75rem;
  }
  
  .product-title {
    font-size: 1.25rem;
  }
  
  .product-price {
    font-size: 1.75rem;
  }
  
  .card-key {
    font-size: 1.25rem;
  }
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* ========== 礼物打赏样式 ========== */

/* 礼物选择区域 */
.gift-selection {
  margin: 24px 0;
  animation: slideDown 0.3s ease;
}

.gift-selection-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  text-align: center;
}

.gift-selection-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
}

/* 礼物网格 */
.gifts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

/* 单个礼物卡片 */
.gift-item {
  position: relative;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  user-select: none;
}

.gift-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.gift-item.selected {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(99, 102, 241, 0.05) 100%);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.gift-item input[type="radio"],
.gift-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* 选中标记 */
.gift-item.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 礼物图标 */
.gift-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  display: block;
}

/* 礼物名称 */
.gift-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

/* 礼物价格 */
.gift-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* 自定义金额输入 */
.custom-amount-input {
  margin-top: 8px;
  display: none;
}

.gift-item.selected .custom-amount-input {
  display: block;
}

.custom-amount-input input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: center;
}

.custom-amount-input input:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* 已选礼物提示 */
.selected-gifts-info {
  text-align: center;
  padding: 12px;
  background: var(--bg-light);
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.selected-gifts-info .total-amount {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-left: 8px;
}

/* ========== 优化的二维码样式 ========== */

/* 微信支付二维码区域 */
.wechat-qrcode {
  margin: 24px 0;
  padding: 0;
  background: transparent;
  border: none;
}

.qrcode-container {
  text-align: center;
  background: white;
  border-radius: 16px;
  padding: 32px 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.qrcode-container h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.qrcode-amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 24px;
}

/* 二维码画布 */
.qrcode-canvas {
  display: inline-block;
  padding: 20px;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 20px;
  position: relative;
}

.qrcode-canvas::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  z-index: -1;
  opacity: 0.1;
}

.qrcode-canvas img {
  display: block;
  margin: 0 auto;
  border-radius: 8px;
}

/* 二维码提示文字 */
.qrcode-tips {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.qrcode-tips::before {
  content: '📱';
  font-size: 1.2rem;
}

/* 支付状态 */
.payment-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(99, 102, 241, 0.05) 100%);
  border-radius: 24px;
  color: var(--primary-color);
  font-weight: 500;
  font-size: 0.95rem;
}

.payment-status .spinner {
  width: 16px;
  height: 16px;
  margin: 0;
}

/* 支付倒计时 */
.payment-timeout {
  margin-top: 16px;
  padding: 8px 16px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  color: var(--error-color);
  font-size: 0.85rem;
  display: none;
}

.payment-timeout.show {
  display: block;
}

/* 响应式调整 */
@media (max-width: 640px) {
  .gifts-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .gift-item {
    padding: 12px 8px;
  }
  
  .gift-icon {
    font-size: 1.75rem;
  }
  
  .gift-name {
    font-size: 0.85rem;
  }
  
  .gift-price {
    font-size: 1rem;
  }
  
  .qrcode-container {
    padding: 24px 16px;
  }
  
  .qrcode-canvas {
    padding: 16px;
  }
  
  /* 在移动设备上缩小二维码 */
  .qrcode-canvas img {
    max-width: 220px;
    height: auto;
  }
}
