/* ai-chat/widget/widget.css — v240826 */
/* 容器/面板 100% 占满 iframe；打开后隐藏气泡；聊天区内部滚动；发送栏始终可见 */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

/* 容器覆盖整个 iframe 视口 */
#ai-chat, .ai-chat {
  position: fixed !important;
  inset: 0 !important;                 /* top/right/bottom/left: 0 */
  width: 100% !important;
  height: 100% !important;
  z-index: 2147483647 !important;
  font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Arial,"Noto Sans",sans-serif;
}

/* 气泡：默认右下角，仅在“关闭状态”显示；打开后隐藏 */
.ai-chat-bubble {
  position: absolute;
  right: 8px; bottom: 8px;
  width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: #4a90e2; color: #fff; font-size: 28px; cursor: pointer;
  box-shadow: 0 6px 14px rgba(0,0,0,.15);
  z-index: 3;
}
.ai-chat.open .ai-chat-bubble { display: none; }  /* 打开时隐藏气泡 */

/* 面板铺满容器（不要固定像素高度） */
.ai-chat-window {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  background: #fff; border: 1px solid #ddd; border-radius: 12px;
  box-shadow: 0 14px 28px rgba(0,0,0,.15);
  display: flex; flex-direction: column; overflow: hidden;
  min-height: 0; z-index: 2;
}

/* 头部 + 右上角 X */
.ai-chat-header {
  position: relative;
  padding: 12px 56px 12px 12px;  /* 右上角 X 的空间 */
  background: #4a90e2; color: #fff; font-weight: 600;
}
.ai-chat-close {
  position: absolute; top: 8px; right: 8px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: #ff4d4f; color: #fff; font-size: 20px; line-height: 36px;
  box-shadow: 0 8px 18px rgba(255,77,79,.35);
}

/* 聊天区滚动 */
.ai-chat-messages {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; touch-action: pan-y;
  padding: 12px; background: #f7f7f7;
  display: flex; flex-direction: column; gap: 6px;
  scroll-behavior: smooth;
}

/* 发送区始终可见，预留 iOS 安全区 */
.ai-chat-input {
  flex-shrink: 0; display: flex; border-top: 1px solid #eee; padding: 8px; background: #fff;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.ai-chat-input input { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 6px; }
.ai-chat-input button { padding: 10px 12px; margin-left: 6px; border: 0; background: #4a90e2; color: #fff; border-radius: 6px; cursor: pointer; white-space: nowrap; }

/* 消息样式 */
.message { margin: 0; padding: 8px 10px; border-radius: 8px; max-width: 90%; line-height: 1.5; }
.message.user { background: #e3f2ff; align-self: flex-end; }
.message.assistant { background: #fff; border: 1px solid #ddd; align-self: flex-start; }