/* public/assets/test/css/chat-widget.css */

/* Floating entry */
#fm_chat_widget{
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
}

#fm_chat_widget .fm-chat-toggle,
#fm_chat_widget .fm_chat_toggle{
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15,23,42,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: transform .12s ease, box-shadow .12s ease;
}

#fm_chat_widget .fm-chat-toggle:hover,
#fm_chat_widget .fm_chat_toggle:hover{
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(15,23,42,.28);
}

#fm_chat_widget .fm-chat-toggle__icon{
  font-size: 26px;
  line-height: 1;
}

/* Popup shell */
body.fm-chat-open{ overflow: hidden; }

#fm_chat_modal_v3.ac3pop{
  position: fixed;
  inset: 0;
  z-index: 999999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .16s ease;
}

#fm_chat_modal_v3.ac3pop.is-open{
  pointer-events: auto;
  opacity: 1;
}

#fm_chat_modal_v3 .ac3pop-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(2,6,23,.28);
  backdrop-filter: blur(6px);
}

#fm_chat_modal_v3 .ac3pop-panel{
  position: absolute;
  right: 18px;
  bottom: 18px;

  /* ✅ 大小“旋钮” */
  width: min(44vw, 520px);     /* 原 min(35vw,520px) */
  min-width: 360px;            /* 原 360px */
  height: min(78vh, 860px);    /* ✅ 新增：高度 */
  max-height: calc(100vh - (var(--hv2-h, 80px) + 48px)); /* ✅ 防顶到header */

  border-radius: 26px;
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(255,255,255,.55);
  box-shadow: 0 18px 60px rgba(0,0,0,.18);

  overflow: hidden;
  transform: translateX(12px);
  transition: transform .18s ease;
  display: flex;
  flex-direction: column;
}


#fm_chat_modal_v3.ac3pop.is-open .ac3pop-panel{
  transform: translateX(0);
}

#fm_chat_modal_v3 .ac3pop-close{
  position: absolute;
  top: 13px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: rgba(255,255,255,.76);
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fm_chat_modal_v3 .ac3pop-close .material-icons{
  font-size: 18px;
  color: rgba(17,24,39,.78);
}

#fm_chat_modal_v3 .ac3pop-frame{
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: transparent;
}
/* =========================================================
   Mobile: FORCE show header + tabbar (only via chat-widget.css)
   + avoid chat widget covering tabbar
   ========================================================= */
@media (max-width: 768px){

  /* 1) ✅ 手机端必须同时显示 header + tabbar */
  #site_header{
    display: block !important;
  }
  #mobile_tabbar{
    display: flex !important;
  }

  /* 你项目里桌面头是 #site_header_v2：手机端避免双头 */
  #site_header_v2{
    display: none !important;
  }

  /* 2) ✅ main 内容给 header / tabbar 让位（只用 CSS 兜底） */
  /* header 高度如果你不是 56px，可以改成你的真实高度 */
  #page_main{
  }

  /* 3) ✅ chat 浮动入口按钮：抬高到 tabbar 上方，避免挡住 */
  #fm_chat_widget{
    bottom: calc(24px + 72px + env(safe-area-inset-bottom)) !important;
    right: 18px !important;
    z-index: 99999 !important; /* 确保在 tabbar 上方可点（但不遮挡 tabbar区域） */
  }

  /* 4) ✅ chat 弹窗面板：也抬高，避免压住 tabbar */
  #fm_chat_modal_v3 .ac3pop-panel{
    bottom: calc(18px + 72px + env(safe-area-inset-bottom)) !important;
    right: 12px !important;
    left: 12px !important;          /* 手机端更像中间弹窗 */
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;

    height: calc(100vh - 56px - 72px - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 18px) !important;
    max-height: none !important;
    border-radius: 22px !important;
  }

  /* iframe 填满面板 */
  #fm_chat_modal_v3 .ac3pop-frame{
    width: 100% !important;
    height: 100% !important;
  }

  /* 关闭按钮别跑到屏幕外 */
  #fm_chat_modal_v3 .ac3pop-close{
    top: auto !important;
    right: 18px !important;
    bottom: calc(18px + 72px + env(safe-area-inset-bottom) + 12px) !important;
    z-index: 100000 !important;
  }

  /* 5) ✅ 如果你启用了 mb-use-backheader：允许 back header + tabbar 并存 */
  body.mb-use-backheader #mobile_back_header{
    display: flex !important;
  }
  /* 这条不要强行隐藏 site_header（因为你说“要 header”，默认你要的是 site_header；
     如果你要 backheader 而不是 site_header，就打开下一行注释 */
  /* body.mb-use-backheader #site_header{ display: none !important; } */

  /* 6) ✅ 防止某些页面全局 overflow 影响 tabbar/弹窗 */
  html, body{
    overflow-x: hidden !important;
  }
}
