/* ============================================================
   retail.css — 真实 H5 单页应用的容器样式
   覆盖原型展示用的 #app 布局,提供:
   - 移动端: 全屏占满 viewport
   - 桌面端: 居中 375x667 手机框, 周围带渐变背景
   ============================================================ */

/* 重置原型布局 */
html, body {
  margin: 0; padding: 0;
  background: #fff;
  overflow: hidden;
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

#app {
  min-height: 0 !important;
  padding: 0 !important;
  display: block !important;
  width: 100%;
  height: 100vh;
  height: 100dvh; /* 移动端 dynamic viewport */
}

/* ===== 真实 H5 容器 ===== */
.retail-app {
  width: 100%;
  height: 100%;
  position: relative;
  background: #fff;
  overflow: hidden;
}

.retail-frame {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  position: relative;
  overflow: hidden;
}

/* statusbar 在真实 H5 里隐藏(移动端有原生状态栏,桌面预览不需要) */
.retail-frame > .statusbar {
  display: none;
}

/* 平板/小桌面 (768-1023px): 仍用居中 phone frame 样式(平板预览体验) */
@media (min-width: 768px) and (max-width: 1023px) {
  html, body {
    background: linear-gradient(135deg, #FFE4EA 0%, #FFF8F1 50%, #F5F0E6 100%);
    overflow: auto;
  }
  #app {
    min-height: 100vh;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 24px !important;
  }
  .retail-app {
    width: 390px;
    height: 844px;
    max-height: calc(100vh - 48px);
    border-radius: 44px;
    box-shadow:
      0 0 0 12px #0B0B0B,
      0 0 0 13px rgba(255,255,255,0.1) inset,
      0 30px 80px -20px rgba(0,0,0,0.4),
      0 18px 40px -18px rgba(0,0,0,0.5);
    overflow: hidden;
  }
  .retail-frame {
    border-radius: 32px;
    overflow: hidden;
  }
  .retail-frame > .statusbar {
    display: flex;
  }
}

/* ===== PC 端 (>=1024px): 真正的桌面网站布局 ===== */
@media (min-width: 1024px) {
  html, body {
    background: #fff;
    overflow: auto;
  }
  #app {
    min-height: 100vh;
    display: block !important;
    padding: 0 !important;
  }
  .retail-app {
    width: 100%;
    height: auto;
    min-height: 100vh;
    background: #fff;
    overflow: visible;
    position: relative;  /* drawer absolute 锚点 */
  }
  /* CurrencyDrawer PC 模式 - 居中 modal 而不是底部 sheet */
  .retail-app .drawer-mask { position: fixed; }
  .retail-app .drawer {
    position: fixed;
    left: 50% !important; right: auto !important;
    bottom: auto !important; top: 50%;
    transform: translate(-50%, -50%) scale(0.95) !important;
    width: 420px;
    border-radius: 16px;
    max-height: 80vh; overflow-y: auto;
    transition: transform 240ms var(--ease), opacity 240ms var(--ease);
    opacity: 0;
  }
  .retail-app .drawer.open {
    transform: translate(-50%, -50%) scale(1) !important;
    opacity: 1;
  }
  .retail-frame {
    width: 100%;
    height: auto;
    min-height: 100vh;
  }
  .retail-frame > .statusbar { display: none; }
  .retail-frame .wx-capsule { display: none; }
  .retail-frame .tabbar { display: none; }   /* PC 端用顶部 nav 替代 */

  /* PC topnav */
  .pc-nav {
    position: sticky; top: 0; z-index: 100;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-1);
  }
  .pc-nav-row {
    max-width: 1280px; margin: 0 auto;
    padding: 14px 24px;
    display: flex; align-items: center; gap: 24px;
  }
  .pc-brand {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--font-display); font-weight: 800;
    font-size: 22px; letter-spacing: -0.02em;
    color: inherit; text-decoration: none;
  }
  .pc-brand .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
  .pc-brand-sub {
    font-size: 10px; color: var(--fg-3); font-weight: 600;
    letter-spacing: 0.12em; text-transform: uppercase;
    margin-left: 2px;
  }
  .pc-cats {
    display: flex; gap: 4px; align-items: center;
    flex: 1; overflow-x: auto; scrollbar-width: none;
  }
  .pc-cats::-webkit-scrollbar { display: none; }
  .pc-cat {
    padding: 8px 14px; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    color: var(--fg-1); text-decoration: none;
    white-space: nowrap;
    transition: all 150ms var(--ease);
  }
  .pc-cat:hover { background: var(--brand-soft); color: var(--brand); }
  .pc-cat.active { background: var(--brand); color: var(--brand-on); font-weight: 600; }

  .pc-search {
    display: flex; align-items: center; gap: 8px;
    background: #F5F5F5; border-radius: 999px;
    padding: 8px 16px; min-width: 240px;
  }
  .pc-search input {
    border: none; background: none; outline: none;
    font-size: 13px; color: var(--fg-1); flex: 1; min-width: 0;
  }
  .pc-search input::placeholder { color: var(--fg-3); }

  .pc-nav-actions { display: flex; align-items: center; gap: 4px; }
  .pc-nav-btn {
    position: relative;
    display: flex; align-items: center; gap: 4px;
    padding: 8px 12px; border-radius: 8px;
    background: transparent; border: none;
    font-size: 12px; color: var(--fg-1); cursor: pointer;
    text-decoration: none;
    transition: background 150ms var(--ease);
  }
  .pc-nav-btn:hover { background: rgba(0,0,0,0.04); }

  /* secondary bar — building filters */
  .pc-subnav {
    background: #FAFAFA;
    border-top: 1px solid rgba(0,0,0,0.04);
    border-bottom: 1px solid var(--border-1);
  }
  .pc-subnav {
    max-width: 1280px; margin: 0 auto;
    padding: 8px 24px;
    display: flex; align-items: center; gap: 6px;
    flex-wrap: wrap;
  }
  .pc-subnav-label {
    font-size: 11px; color: var(--fg-3); font-weight: 600;
    margin-right: 4px;
  }
  .pc-subnav-chip {
    font-size: 11px; padding: 4px 10px; border-radius: 999px;
    background: #fff; border: 1px solid var(--border-1);
    color: var(--fg-2); text-decoration: none;
    transition: all 150ms var(--ease);
  }
  .pc-subnav-chip:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
  .pc-subnav-chip-live {
    background: #0B0B0B; color: #fff; border-color: #0B0B0B;
    font-weight: 600;
  }

  /* main content */
  .pc-main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
  }
  .pc-main .appbody {
    padding: 24px 0 64px;
    background: transparent !important;
    overflow: visible;
  }

  /* Hero / banner 在 PC 上更大 */
  .pc-main .appbody > div[style*="height: 180px"] {
    height: 360px !important;
    border-radius: 16px !important;
  }
  .pc-main .appbody > div[style*="height: 180px"] > div:nth-child(3) > div:first-child {
    font-size: 44px !important;
  }

  /* Sticky app-header 顶部公告条 在 PC 上变成全宽橫條 */
  .pc-main .app-header {
    background: transparent !important;
    border-bottom: none !important;
    padding: 16px 0 !important;
  }
  .pc-main .app-header .searchbar { display: none; }      /* 用顶部 nav 的 search */
  .pc-main .app-header .curpill { display: none; }        /* 用顶部 nav 的 curpill */

  /* 商品 grid 在 PC 上多列 - React 渲染成 kebab-case style */
  .pc-main .appbody div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
  }
  /* CategoryScreen 单列 grid 在 PC 改 3 列 */
  .pc-main .appbody div[style*="grid-template-columns: 1fr"]:not([style*="1fr 1fr"]) {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
  }

  /* PC footer */
  .pc-footer {
    margin-top: 64px;
    background: #0B0B0B; color: #fff;
    padding: 48px 0 24px;
  }
  .pc-footer-grid {
    max-width: 1280px; margin: 0 auto;
    padding: 0 24px;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px;
  }
  .pc-footer h4 {
    font-size: 13px; font-weight: 700; margin: 0 0 14px;
    color: var(--apm-gold);
    letter-spacing: 0.06em; text-transform: uppercase;
  }
  .pc-footer ul { list-style: none; padding: 0; margin: 0; }
  .pc-footer ul li {
    font-size: 12px; line-height: 1.9;
    color: rgba(255,255,255,0.7);
  }
  .pc-footer-meta {
    max-width: 1280px; margin: 32px auto 0;
    padding: 24px 24px 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; color: rgba(255,255,255,0.5);
  }

  /* 商品详情 PC 模式 — 限宽 + 主图限高 */
  .retail-app[data-route="pdp"] .pc-main {
    max-width: 800px;
  }
  .retail-app[data-route="pdp"] .appbody {
    padding-bottom: 100px !important;
  }
  .retail-app[data-route="pdp"] .appbody > div:first-child {
    border-radius: 16px;
    overflow: hidden;
    max-height: 560px;
  }
  .retail-app[data-route="pdp"] .appbody > div:first-child .ph {
    max-height: 560px;
  }
  /* PDP 底部固定按钮 PC 模式 - fixed 居中横条 */
  .retail-app[data-route="pdp"] .pc-main .appbody > div[style*="position: absolute"][style*="bottom: 0"] {
    position: fixed !important;
    bottom: 0; left: 0; right: 0;
    z-index: 50;
    background: rgba(255,255,255,0.96) !important;
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-1) !important;
  }
}

/* 滚动区域 */
.retail-frame .appbody {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 当前路由是 live 时,占满整个屏幕(无 tabbar 预留位) */
.retail-app[data-route="live"] .retail-frame {
  background: #000;
}

/* 全屏页背景兜底 */
.retail-app[data-route="login"] .retail-frame,
.retail-app[data-route="pdp"] .retail-frame,
.retail-app[data-route="me"] .retail-frame {
  background: #fff;
}
