/**
 * 组件样式
 * 包含Toast、Modal、Loading等微信小程序API对应的UI组件
 */

/* ==================== Toast样式 ==================== */
.wx-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.wx-toast.show {
  opacity: 1;
}

.wx-toast-content {
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 16px 24px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
  max-width: 80vw;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.wx-toast-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.wx-toast-icon.success {
  color: #52c41a;
  font-weight: bold;
}

.wx-toast-icon.loading {
  display: flex;
  align-items: center;
  justify-content: center;
}

.wx-toast-icon .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.wx-toast-title {
  font-size: 14px;
  text-align: center;
  word-wrap: break-word;
}

/* ==================== Loading样式 ==================== */
.wx-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wx-loading-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
}

.wx-loading-content {
  position: relative;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 24px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.wx-loading-content .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

.wx-loading-title {
  font-size: 14px;
  text-align: center;
}

/* ==================== Modal样式 ==================== */
.wx-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9997;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wx-modal-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.wx-modal-dialog {
  position: relative;
  background-color: #fff;
  border-radius: 12px;
  width: 80%;
  max-width: 400px;
  overflow: hidden;
  animation: modalSlideIn 0.3s ease;
}

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

.wx-modal-title {
  padding: 20px 20px 10px;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
  text-align: center;
}

.wx-modal-content {
  padding: 10px 20px 20px;
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  text-align: center;
}

.wx-modal-footer {
  display: flex;
  border-top: 1px solid #e5e7eb;
}

.wx-modal-btn {
  flex: 1;
  padding: 15px 0;
  font-size: 16px;
  border: none;
  background-color: transparent;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.wx-modal-btn:hover {
  background-color: #f9fafb;
}

.wx-modal-btn:active {
  background-color: #f3f4f6;
}

.wx-modal-btn.cancel {
  color: #6b7280;
  border-right: 1px solid #e5e7eb;
}

.wx-modal-btn.confirm {
  color: #6366f1;
  font-weight: 500;
}

/* ==================== 渐变背景 ==================== */
.gradient-bg {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-bg-light {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

/* ==================== 标签 ==================== */
.tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 12px;
  background-color: #e5e7eb;
  color: #4b5563;
  margin: 4px;
}

.tag-primary {
  background-color: #dbeafe;
  color: #1e40af;
}

.tag-success {
  background-color: #d1fae5;
  color: #065f46;
}

.tag-warning {
  background-color: #fed7aa;
  color: #92400e;
}

.tag-danger {
  background-color: #fee2e2;
  color: #991b1b;
}

/* ==================== 分割线 ==================== */
.divider {
  height: 1px;
  background-color: #e5e7eb;
  margin: 20px 0;
}

.divider-text {
  position: relative;
  text-align: center;
  margin: 20px 0;
}

.divider-text::before,
.divider-text::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background-color: #e5e7eb;
}

.divider-text::before {
  left: 0;
}

.divider-text::after {
  right: 0;
}

.divider-text span {
  display: inline-block;
  padding: 0 15px;
  background-color: #fff;
  font-size: 12px;
  color: #9ca3af;
}

/* ==================== 列表 ==================== */
.list {
  background-color: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.list-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background-color: #f9fafb;
}

.list-item:active {
  background-color: #f3f4f6;
}

.list-item-icon {
  font-size: 24px;
  margin-right: 15px;
}

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

.list-item-title {
  font-size: 16px;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.list-item-desc {
  font-size: 12px;
  color: #9ca3af;
}

.list-item-arrow {
  font-size: 16px;
  color: #d1d5db;
}

/* ==================== 徽章 ==================== */
.badge {
  position: relative;
  display: inline-block;
}

.badge-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background-color: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
}

.badge-count {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  background-color: #ef4444;
  color: #fff;
  border-radius: 10px;
  border: 2px solid #fff;
}

/* ==================== 进度条 ==================== */
.progress {
  width: 100%;
  height: 8px;
  background-color: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background-color: #6366f1;
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ==================== 头像 ==================== */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background-color: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.avatar-text {
  font-size: 20px;
  color: #6b7280;
  font-weight: 500;
}

.avatar-small {
  width: 32px;
  height: 32px;
}

.avatar-large {
  width: 64px;
  height: 64px;
}

/* ==================== 动画 ==================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

.slide-in-up {
  animation: slideInUp 0.3s ease;
}
