/* ========== 立即使用页（嵌入版）：产品演示页的承载舞台 ==========
 * 配合 js/functions-embed.js。被 nginx 缓存 2 天，改动后同步改 HTML 里的 ?v= 版本号。
 */

/* 整页不滚动：页头以下恰好一屏，滚动交给嵌入的产品页自己 */
.page-embed .functions-main,
.page-embed .functions-app {
  min-height: 0;
  height: calc(100vh - var(--header-height, 90px));
  height: calc(100dvh - var(--header-height, 90px));
}
.page-embed .functions-content { min-height: 0; }
.functions-content--embed {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- 面板与工具条 ---------- */
.embed-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.embed-panel[hidden], .embed-toosmall[hidden], .embed-slot[hidden],
.embed-variants[hidden], .embed-action[hidden] { display: none !important; }

.embed-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 16px 0 40px;   /* 左侧给侧边栏折叠按钮让位 */
  background: var(--color-white, #fff);
  border-bottom: 1px solid var(--color-border, #e3e6ee);
}
.embed-bar h3 {
  margin: 0;
  font-family: var(--font-functions-heading, inherit);
  font-size: 17px;
  font-weight: 700;
  color: var(--color-heading, #1c1c28);
  white-space: nowrap;
}
.embed-variants {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--color-bg-light, #f1f2f6);
}
.embed-variant {
  padding: 4px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text, #4a4a5a);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.embed-variant.is-active {
  background: #fff;
  color: var(--color-primary, #7456f1);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.embed-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.embed-action {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--color-border, #d9dce6);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text, #4a4a5a);
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.embed-action:hover {
  color: var(--color-primary, #7456f1);
  border-color: var(--color-primary, #7456f1);
  background: rgba(116, 86, 241, 0.06);
}

/* ---------- 舞台 ---------- */
.embed-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--color-bg-lighter, #f6f7fa);
}
.embed-stage:fullscreen { background: #fff; }

.embed-slot {
  position: absolute;
  inset: 0;
  visibility: hidden;      /* 切走只隐藏不销毁：切回来不丢进度 */
  pointer-events: none;
}
.embed-slot.is-current {
  visibility: visible;
  pointer-events: auto;
}
.embed-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
/* 拖拽侧边栏时指针会滑进 iframe，事件就丢了 */
.is-sidebar-dragging .embed-iframe { pointer-events: none; }

/* 工作台：按设计宽度渲染后由 JS 等比缩小 */
.embed-desk {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.embed-desk .embed-iframe { transform-origin: 0 0; }

/* 患者端：手机框 */
.embed-slot--phone {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
/* 手机框：宽 428、高度占舞台 92%（≈ 原 475 / 90% 在浏览器 90% 缩放下的观感；框内内容由 JS 缩到 0.9） */
.embed-phone {
  position: relative;
  width: 100%;
  max-width: 428px;
  height: 92%;
  padding: 8px;
  background: #111118;
  border: 4px solid #1c1c24;
  border-radius: 44px;
  box-shadow:
    0 0 0 1px #2a2a35,
    0 24px 48px rgba(0, 0, 0, 0.28),
    0 6px 18px rgba(0, 0, 0, 0.18);
}
.embed-phone .embed-iframe { border-radius: 38px; transform-origin: 0 0; }

/* ---------- 加载 / 失败 ---------- */
.embed-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--color-text, #4a4a5a);
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}
.embed-overlay p { margin: 0; }
.embed-slot[data-state="loading"] .embed-overlay--loading { display: flex; }
.embed-slot[data-state="error"] .embed-overlay--error {
  display: flex;
  pointer-events: auto;
  background: rgba(246, 247, 250, 0.96);
}
.embed-slot[data-state="loading"] .embed-iframe { opacity: 0; }
.embed-slot--phone .embed-overlay { color: #666; }
.embed-overlay-actions { display: flex; gap: 8px; }
.embed-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(116, 86, 241, 0.2);
  border-top-color: var(--color-primary, #7456f1);
  border-radius: 50%;
  animation: embedSpin 0.8s linear infinite;
}
@keyframes embedSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .embed-spinner { animation-duration: 2.4s; } }

/* ---------- 提示卡（屏幕太窄；登录遮罩见 css/auth-gate.css） ---------- */
.embed-toosmall {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.embed-card {
  max-width: 420px;
  padding: 32px 28px;
  background: #fff;
  border: 1px solid var(--color-border, #e3e6ee);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(28, 28, 40, 0.08);
  text-align: center;
}
.embed-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-functions-heading, inherit);
  font-size: 19px;
  color: var(--color-heading, #1c1c28);
}
.embed-card p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text, #4a4a5a);
}

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
  .embed-bar { padding-left: 56px; }   /* 汉堡按钮 */
}
@media (max-width: 600px) {
  /* 放不下就折行：标题 + 操作一行，版本切换单独一行 */
  .embed-bar { height: auto; min-height: 44px; flex-wrap: wrap; gap: 6px 8px; padding: 7px 10px 7px 56px; }
  .embed-bar h3 { flex: 1; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
  .embed-actions { flex-shrink: 0; }
  .embed-variants { order: 3; }
  .embed-action { height: 28px; padding: 0 8px; font-size: 12px; }
  #embed-fullscreen { display: none; }   /* 手机上全屏嵌入没有意义，用「新窗口打开」 */
  /* 手机里再套一个手机壳是多余的：铺满 */
  .embed-slot--phone { padding: 0; }
  .embed-phone {
    max-width: none;
    max-height: none;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }
  .embed-phone .embed-iframe { border-radius: 0; }
}
