/* ===== 公共 UI 组件样式 ===== */

/* ----- 自定义导航栏 ----- */
.custom-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 997;
  display: flex;
  align-items: center;
  height: calc(var(--nav-height) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 0.6rem;
  padding-right: 0.6rem;
  background-color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.custom-bar .bar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.4rem;
  color: #333;
  cursor: pointer;
}
.custom-bar .bar-btn + .bar-btn { margin-left: 0.3rem; }
.custom-bar .bar-title {
  flex: 1;
  margin-right: 5.3rem;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- 语言切换下拉框 ----- */
.lang-switch {
  flex: none;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background-color: #fff;
  color: #333;
  font-size: 0.8rem;
  line-height: 1.2;
  padding: 0.25rem 1.4rem 0.25rem 0.65rem;
  cursor: pointer;
  /* 自绘下拉箭头 */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23666' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}
.lang-switch:focus { outline: none; border-color: var(--color-primary); }
/* 首页顶部：绝对定位到右侧 */
.index-top-container .lang-switch {
  position: absolute;
  right: 1rem;
  top: calc(var(--safe-top) + var(--nav-height) / 2);
  transform: translateY(-50%);
  z-index: 5;
}

/* ----- Toast ----- */
.toast-wrap {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.toast-item {
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  max-width: 80vw;
  text-align: center;
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  animation: toast-in 0.2s ease;
}
.toast-item .toast-icon { font-size: 1.8rem; }
.toast-item.loading { pointer-events: auto; }
.toast-spinner {
  width: 1.8rem;
  height: 1.8rem;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

/* ----- 图片预览 ----- */
.image-preview {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.image-preview img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
}
/* 预览层操作控件（关闭 / 左右切换 / 计数），点击不冒泡到背景关闭 */
.preview-close,
.preview-prev,
.preview-next {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}
.preview-close:hover,
.preview-prev:hover,
.preview-next:hover {
  background-color: rgba(255, 255, 255, 0.25);
}
.preview-close {
  top: calc(env(safe-area-inset-top, 0px) + 1rem);
  right: 1rem;
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.4rem;
}
.preview-prev,
.preview-next {
  top: 50%;
  transform: translateY(-50%);
  width: 2.8rem;
  height: 2.8rem;
  font-size: 1.6rem;
}
.preview-prev { left: 1rem; }
.preview-next { right: 1rem; }
.preview-counter {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.2rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: #fff;
  font-size: 0.9rem;
  background-color: rgba(0, 0, 0, 0.45);
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
}

/* ----- 骨架屏 ----- */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton-block {
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 25%,
    rgba(0, 0, 0, 0.12) 37%,
    rgba(0, 0, 0, 0.06) 63%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding: 0 1rem;
}
.skeleton-grid.single { grid-template-columns: 1fr; }
.skeleton-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.skeleton-card .skeleton-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
}
.skeleton-card .skeleton-line {
  height: 0.8rem;
  margin: 0.6rem 0.7rem;
  border-radius: 0.4rem;
}
.skeleton-card .skeleton-line.short { width: 55%; }
@media (min-width: 768px) {
  .skeleton-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .skeleton-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ----- 轮播图 ----- */
.swiper-box {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.swiper-track {
  display: flex;
  height: 100%;
  transition: transform 0.4s ease;
}
.swiper-item {
  width: 100%;
  height: 100%;
}
.swiper-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* 轮播图底部渐变阴影（对应小程序 banner 的 swiper-shadow） */
.swiper-shadow {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 10rem;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(to top, rgba(46, 45, 45, 0.3) 0%, rgba(165, 165, 165, 0) 100%);
}
.swiper-dots {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.35rem;
  z-index: 3;
}
.swiper-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.6);
  transition: all 0.3s;
}
.swiper-dot.active {
  width: 1rem;
  border-radius: 0.2rem;
  background-color: var(--color-primary);
}

/* ----- 按钮 ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  padding: 0.65rem 1.4rem;
  transition: opacity 0.2s, transform 0.1s;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; }
.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-outline {
  background-color: #fff;
  color: #333;
  border-color: var(--color-border);
  box-shadow: 2px 4px 10px -4px var(--color-shadow);
}
.btn-block { width: 100%; }
.btn-lg { height: 3rem; font-size: 1.05rem; }

/* ----- 图标（用 emoji/SVG 代替 vant icon） ----- */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
}

/* ----- 评分 ----- */
.rate {
  display: inline-flex;
  gap: 0.4rem;
}
.rate-star {
  font-size: 2rem;
  color: #ddd;
  cursor: pointer;
  transition: color 0.15s;
  user-select: none;
}
.rate-star.active { color: var(--color-primary); }

/* ----- 输入框 ----- */
.field {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: #fff;
  font-size: 0.95rem;
  resize: none;
}
.field:focus { border-color: var(--color-primary); }

/* ----- 滑块 ----- */
.slider {
  position: relative;
  width: 100%;
  height: 1.6rem;
  display: flex;
  align-items: center;
}
.slider-track-bar {
  position: relative;
  width: 100%;
  height: 0.5rem;
  border-radius: 0.25rem;
  background-color: #c4c3be;
}
.slider-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 0.25rem;
  background-color: var(--color-primary);
}
.slider-button {
  position: absolute;
  top: 50%;
  width: 1.6rem;
  height: 1.6rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff url('../assets/icons/slider.png') center/cover no-repeat;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: grab;
}

/* ----- 圆形进度 ----- */
circle-progress {
  display: inline-block;
}
.circle-progress {
  position: relative;
  width: 8rem;
  height: 8rem;
}
.circle-progress svg { transform: rotate(-90deg); }
.circle-progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgb(111, 204, 199);
  font-size: 0.9rem;
}

/* ----- 二维码图标按钮 ----- */
.qr-icon {
  font-size: 1.3rem;
  color: #000;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
