/* 好价簿 PWA —— 安装入口 / 离线提示 / 更新条 / 说明卡片
 *
 * 全部使用 position: fixed，不进入文档流，因此不会挤压 Switch 的顶栏、筛选条
 * 或移动端底部导航，也不会影响 PS 面板（Shadow DOM）内部布局。
 * 层级：安装按钮 70 < PS 遮罩 90 / Switch 抽屉 100 < 离线提示 135 < 更新条 139
 *       < 轻提示 141 < 安装说明 150（弹层/抽屉打开时安装按钮会被自然盖住）
 */

[hidden] {
  display: none !important;
}

.pwa-offline,
.pwa-install,
.pwa-update,
.pwa-toast,
.pwa-help {
  box-sizing: border-box;
  font-family: inherit;
}

/* ---------- 离线 / 缓存提示（贴底通栏，断网时最醒目） ---------- */
.pwa-offline {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 135;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom, 0px));
  background: #2b1113;
  color: #ffd9dd;
  border-top: 1px solid rgba(255, 90, 104, 0.5);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
}

.pwa-offline-refresh {
  height: 26px;
  padding: 0 12px;
  border: 1px solid rgba(255, 217, 221, 0.45);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pwa-offline-refresh:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ---------- 安装按钮（低干扰小药丸） ---------- */
.pwa-install {
  position: fixed;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--line, #e4e8ee);
  border-radius: 999px;
  background: var(--card, #fff);
  color: var(--text, #14171c);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.12);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.pwa-install svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--red, #e60012);
}

.pwa-install:hover {
  border-color: var(--line-strong, #d4dae3);
}

.pwa-install:active {
  transform: scale(0.97);
}

/* ---------- 新版本提示条 ---------- */
.pwa-update {
  position: fixed;
  left: 50%;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  z-index: 139;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 14px;
  border-radius: 999px;
  background: rgba(20, 22, 28, 0.96);
  color: #fff;
  font-size: 12.5px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
}

.pwa-update-go {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #e60012;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.pwa-update-close {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.62);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.pwa-update-close:hover {
  color: #fff;
}

/* ---------- 轻提示 ---------- */
.pwa-toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  z-index: 141;
  max-width: min(88vw, 360px);
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(20, 22, 28, 0.94);
  color: #fff;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%);
}

/* ---------- 手动添加桌面说明 ---------- */
.pwa-help {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(58px + env(safe-area-inset-bottom, 0px));
  z-index: 150;
  max-width: 430px;
  margin: 0 auto;
  padding: 14px 16px 12px;
  border: 1px solid var(--line, #e4e8ee);
  border-radius: 14px;
  background: var(--card, #fff);
  color: var(--text, #14171c);
  font-size: 12.5px;
  line-height: 1.6;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}

.pwa-help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pwa-help-head b {
  font-size: 13.5px;
}

.pwa-help-close {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--bg, #f4f6f9);
  color: var(--muted, #6a7280);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.pwa-help ul {
  margin: 8px 0 4px;
  padding-left: 17px;
}

.pwa-help li {
  margin: 5px 0;
}

.pwa-help li b {
  font-size: 12.5px;
}

.pwa-help-note {
  margin: 8px 0 0;
  color: var(--muted, #6a7280);
  font-size: 11.5px;
  line-height: 1.6;
}

/* PS 面板恒为浅色底，安装控件跟随它，避免深色变量压在浅色背景上 */
html[data-platform="ps"] .pwa-install,
html[data-platform="ps"] .pwa-help {
  background: #ffffff;
  color: #14171c;
  border-color: #e4e8ee;
}

html[data-platform="ps"] .pwa-help-close {
  background: #f4f6f9;
  color: #6a7280;
}

html[data-platform="ps"] .pwa-help-note {
  color: #6a7280;
}

@media (max-width: 520px) {
  .pwa-install {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    height: 32px;
    padding: 0 11px 0 9px;
    font-size: 11.5px;
  }

  .pwa-help {
    left: 10px;
    right: 10px;
    font-size: 12px;
  }

  .pwa-offline {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-install {
    transition: none;
  }
}
