/* Full-height flex layout */
html, body {
  min-height: 100%;
  margin: 0; padding: 0;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: fixed;
  top: 0; left: 0;
  overflow: hidden;
}

/* native-scroll 模式：解除 iframe 全屏锁定，让内容自然延伸 */
.app.native-scroll {
  position: relative;
  height: auto;
  min-height: 100vh;
  overflow: visible;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.main-content.native-scroll {
  display: block;
  overflow: visible;
  min-height: auto;
  flex: none;
}

.iframe-wrap {
  flex: 1;
  position: relative;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #fafafa;
}

.iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Iframe fallback for blocked sites */
.iframe-blocked {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: #fafafa;
  gap: 12px;
  padding: 20px;
  text-align: center;
  z-index: 100;
}

.avatar-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}

/* ===== Shop 商城嵌入样式 ===== */
.shop-content {
  flex: 1;
  /* 横向锁死：内部布局任何微小溢出都不会变成底部那条横向滚动条（竖向照常滚动） */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #f5f5f5;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  color: #333;
  line-height: 1.5;
}

/* native-scroll 模式：解除内部滚动锁死，让文档自然延伸 */
.shop-content.native-scroll {
  overflow-x: visible;
  overflow-y: visible;
  flex: none;
}
.shop-content *{margin:0;padding:0;box-sizing:border-box}
.shop-content a{text-decoration:none;color:inherit}
.shop-content img{max-width:100%;display:block;height:auto}

.shop-content .nav-wrap{background:#ffffffde;border-bottom:1px solid #eee;position:sticky;top:0;z-index:100}
.shop-content .nav-main{display:flex;align-items:center;justify-content:space-between;padding:1px 12px;gap:8px}
.shop-content .nav-inner{display:flex;flex-wrap:wrap;gap:6px 12px;justify-content:center;flex:1}
.shop-content .nav-item{padding:6px 14px;border-radius:20px;font-size:15px;color:#666;cursor:pointer;white-space:nowrap;transition:all .2s}
.shop-content .nav-item:hover,.shop-content .nav-item.active{background:#ff4757;color:#fff}

.shop-content .nav-search{position:relative;display:flex;align-items:center}
.shop-content .search-toggle{width:36px;height:36px;border:none;background:transparent;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;color:#666;transition:all .2s;flex-shrink:0}
.shop-content .search-toggle:hover{color:#ff4757;transform:scale(1.1)}
.shop-content .search-panel{display:none;position:absolute;right:0;top:44px;background:#fff;border:1px solid #eee;border-radius:8px;padding:8px;box-shadow:0 4px 16px rgba(0,0,0,.12);z-index:101;white-space:nowrap;animation:fadeIn .2s ease}
.shop-content .search-panel.active{display:flex;gap:6px}
@keyframes fadeIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}
.shop-content .search-panel input{padding:8px 12px;border:1px solid #d9d9d9;border-radius:6px;font-size:14px;width:180px;outline:none}
.shop-content .search-panel input:focus{border-color:#ff4757}
.shop-content .search-panel button{padding:8px 16px;background:#ff4757;color:#fff;border:none;border-radius:6px;font-size:14px;cursor:pointer;white-space:nowrap}
.shop-content .search-panel button:hover{opacity:.9}

@media(max-width:480px){
  .shop-content .nav-main{padding:6px 8px;gap:4px}
  .shop-content .nav-inner{padding:0;gap:4px 6px}
  .shop-content .nav-item{padding:4px 10px;font-size:13px;border-radius:16px}
  .shop-content .search-toggle{width:32px;height:32px}
  .shop-content .search-toggle svg{width:16px;height:16px}
  .shop-content .search-panel{top:40px;padding:6px}
  .shop-content .search-panel input{width:140px;padding:6px 10px;font-size:13px}
  .shop-content .search-panel button{padding:6px 12px;font-size:13px}
}

/* ========== 商品布局 ========== */
.shop-content .products-wrap {
  padding: 0 10px 40px;
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
  grid-auto-flow: dense;
}

.shop-content .product-card {
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.04);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  display: block;
  text-decoration: none;
  color: inherit;
}
.shop-content .product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.08);
}

.shop-content .product-card.wide {
  grid-column: span 2;
}
.shop-content .product-card.wide .img-wrap {
  padding-top: 56.25% !important;
}

.shop-content .img-wrap {
  position: relative;
  padding-top: 100%;
  overflow: hidden;
  background: #fafafc;
}
.shop-content .img-wrap img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.shop-content .product-card:hover .img-wrap img {
  transform: scale(1.04);
}

/* 平台标签 */
.shop-content .platform-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.shop-content .platform-taobao { background: #ff5000; }
.shop-content .platform-pdd { background: #e02e24; }
.shop-content .platform-jd { background: #e4393c; }
.shop-content .platform-tmall { background: #ff0036; }

.shop-content .info {
  padding: 14px;
}

.shop-content .product-title {
  font-size: 13.5px;
  line-height: 1.5;
  color: #0f0f0f;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
  font-weight: 500;
}

.shop-content .price-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 6px;
}

.shop-content .price-label {
  font-size: 11px;
  color: #8e8e93;
  font-weight: 500;
}

.shop-content .price {
  font-size: 18px;
  font-weight: 700;
  color: #007aff;
  letter-spacing: -0.5px;
}

.shop-content .price-symbol {
  font-size: 13px;
  font-weight: 600;
}

.shop-content .coupon-tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #007aff;
  color: #007aff;
  font-size: 12px;
  border-radius: 4px;
  margin-bottom: 6px;
}

.shop-content .sold {
  font-size: 11px;
  color: #8e8e93;
  margin-top: 4px;
}

.shop-content .loading-tip {
  text-align: center;
  padding: 20px;
  color: #8e8e93;
  font-size: 14px;
  grid-column: 1 / -1;
}

.shop-content .no-more {
  text-align: center;
  padding: 20px;
  color: #8e8e93;
  font-size: 14px;
  grid-column: 1 / -1;
}

/* 底部 */
.shop-content .site-footer {
  background: #fff;
  margin-top: 20px;
  padding: 20px 12px;
  text-align: center;
  border-top: 1px solid #eee;
  font-size: 13px;
  color: #666;
}

/* 手机端(<640px)：紧凑双列 */
@media (max-width: 639px) {
  .shop-content .products-wrap { padding: 0 8px 40px; gap: 8px; }
  .shop-content .img-wrap { padding-top: 120% !important; }
  .shop-content .info { padding: 8px; }
  .shop-content .product-title { font-size: 12px; margin-bottom: 4px; line-height: 1.35; }
  .shop-content .price-row { gap: 2px; margin-bottom: 4px; }
  .shop-content .price-label { font-size: 10px; }
  .shop-content .price { font-size: 14px; }
  .shop-content .price-symbol { font-size: 11px; }
  .shop-content .sold { font-size: 10px; margin-top: 2px; }
  .shop-content .platform-tag { padding: 2px 6px; font-size: 9px; border-radius: 4px; margin-right: 4px; }
  .shop-content .product-card { border-radius: 14px; }
  .shop-content .product-card.wide { grid-column: span 2; }
  .shop-content .product-card.wide .img-wrap { padding-top: 56.25% !important; }
  .shop-content .coupon-tag { font-size: 11px; padding: 1px 6px; }
}

/* 桌面端(≥640px)：3列网格 + 宽卡跨2列 */
@media (min-width: 640px) {
  .shop-content .products-wrap { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 0 16px 40px; }
  .shop-content .product-card.wide { grid-column: span 2; }
}

/* 桌面端(≥1024px)：4列网格 + 宽卡跨2列 */
@media (min-width: 1024px) {
  .shop-content .products-wrap { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; padding: 0 20px 40px; }
  .shop-content .product-card.wide { grid-column: span 2; }
}
/* ===== Shop 商城嵌入样式结束 ===== */

/* ===== iframe 模式（打开商品/外部链接）重新锁定布局 =====
   native-scroll 解锁是为了商城首页让窗口自然滚动（Edge 自动隐藏地址栏），
   但解锁同样作用于 iframe 模式，导致 iframe 占满视口又被顶栏下推，
   文档比视口高出顶栏高度 → 外层多出一条滚动条。
   这里只对 iframe 模式（body.iframe-mode）恢复锁死布局，商城首页不受影响。 */
body.iframe-mode .app.native-scroll {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
body.iframe-mode .main-content.native-scroll {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
body.iframe-mode .iframe-wrap {
  flex: 1;
  overflow: auto;
}

/* ===== iframe 模式：子文档下滑时收起外层搜索框 =====
   外层文档被锁死不滚动，滚动全在 iframe 子文档里，
   所以由 app.js 监听子文档滚动后给 body 加 .hide-urlbar。
   .top-bar 本来是静态定位，这里给上定位和 z-index，
   让搜索框上滑时从顶栏后面滑过去而不是压在顶栏上。 */
body.iframe-mode .top-bar {
  position: relative;
  z-index: 100;
  background: #ffffff;
}

body.iframe-mode .url-bar {
  /* 真实高度由 JS 量出后写进 --ubh；这里只是兜底值 */
  --ubh: 42px;
  transition: margin-top 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

body.iframe-mode.hide-urlbar .url-bar {
  /* 负 margin 只让出占位，不裁切 .url-suggestions 下拉 */
  margin-top: calc(var(--ubh) * -1);
  opacity: 0;
  pointer-events: none;
}

/* ===== 商城首页（native 模式）：顶栏常驻 + 搜索框随滚动方向收起/展开 =====
   原来 .top-bar.floating2 在滚动 10px 时把顶栏抽成 fixed，
   搜索框是流内元素，会被顶栏挤出屏幕，只有滚回顶部才回来。
   这里让顶栏常驻、用 padding 占位（内容不再跳），
   搜索框固定在顶栏下方，由 app.js 按滚动方向收起/展开：
   上滑（往下滚）收起，下滑（往上滚）立即展开，回到顶部始终展开。
   注意：这里不能用 sticky —— body 上有 overflow-x:hidden，
   sticky 会改以 body 为滚动容器，导致粘不住、展开时停在视口外，只能用 fixed。 */
body:not(.iframe-mode) .top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  /* 去掉顶栏自带的那条 0.5px 分隔线：与搜索框衔接处不再出现细缝 */
  border-bottom: none;
}

/* floating2 仍会被 JS 加上，但内边距与常态完全一致（含 ≤640px 断点），
   顶栏高度不随滚动变化，搜索框才能始终紧贴顶栏下沿、不露缝 */
body:not(.iframe-mode) .top-bar.floating2 {
  padding: 8px 16px;
}

@media (max-width: 640px) {
  body:not(.iframe-mode) .top-bar.floating2 {
    padding: 4px 6px;
  }
}

/* 顶栏与搜索框都是 fixed、不占文档流，这里补足两块高度。
   与 iframe 页对齐：搜索框展开/收起时，这块占位高度用同一条缓动跟着变，
   内容随之上/下平移，观感与 iframe 页（margin 收起带动内容）一致。
   overflow-anchor: none 关掉滚动锚定，否则浏览器会把内容位移自动补偿掉。 */
body:not(.iframe-mode) .app.native-scroll {
  padding-top: calc(var(--tbh, 48px) + var(--ubh, 42px));
  transition: padding-top 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-anchor: none;
}

body:not(.iframe-mode) .url-bar {
  /* fixed 常驻在顶栏下方；--tbh 由 app.js 量出后写到根元素 */
  position: fixed;
  top: var(--tbh, 48px);
  left: 0;
  right: 0;
  z-index: 900;
  /* 与 Logo 栏（.top-bar）同款半透明毛玻璃：露出下方内容并做模糊 */
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

body:not(.iframe-mode).hide-urlbar .url-bar {
  /* 只上移自身高度：整条正好缩到 Logo 栏下沿后面（不占位，也不会裁切 .url-suggestions 下拉）。
     收起时同步减少 .app 的 padding-top、展开时同步增加，
     于是「搜索框从 Logo 栏下沿推出来、下方内容一起被顶下去」的观感与 iframe 页一致。 */
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

body:not(.iframe-mode).hide-urlbar .app.native-scroll {
  padding-top: var(--tbh, 48px);
}

/* ===== 头像上传进度条（注册 / 换头像弹窗） ===== */
.upload-progress {
  margin: 10px 0 0;
}

.upload-progress-bar {
  height: 8px;
  border-radius: 4px;
  background: #f0f0f3;
  overflow: hidden;
}

.upload-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 4px;
  background: #ff4757;
  transition: width 0.2s ease;
}

.upload-progress-text {
  margin-top: 6px;
  font-size: 12px;
  color: #999;
}

/* 文件已发完、服务端还在裁剪+去背景：这段没有百分比可报，
   改成流动条纹表示"还在处理"，避免进度条卡在 100% 让人以为死掉 */
.upload-progress.indeterminate .upload-progress-fill {
  background: linear-gradient(90deg, #ffd0d4 0%, #ff4757 50%, #ffd0d4 100%);
  background-size: 200% 100%;
  -webkit-animation: upload-progress-stripe 1.1s linear infinite;
  animation: upload-progress-stripe 1.1s linear infinite;
}

@-webkit-keyframes upload-progress-stripe {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

@keyframes upload-progress-stripe {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}
