/* C 端 AI 采购助手：右下角浮钮 + 聊天面板（2026-10-20）。 */

.aiw {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1300;
  font-size: 14px;
}

/* 浮钮 */
.aiw-fab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(120deg, #189aed, #12b0bf);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(16, 110, 170, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.aiw-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(16, 110, 170, 0.42);
}

/* 面板 */
.aiw-panel {
  position: absolute;
  right: 0;
  bottom: 60px;
  width: 460px;
  height: 680px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(9, 32, 48, 0.28);
  overflow: hidden;
  border: 1px solid #e3eef6;
}
.aiw-panel[hidden] { display: none; }
.aiw-panel--resizing { user-select: none; }

.aiw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(120deg, #0f2b3d, #14506b);
  color: #fff;
}
.aiw-title { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.aiw-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #3ee0c2;
  box-shadow: 0 0 0 3px rgba(62, 224, 194, 0.22);
}
.aiw-head-actions { display: flex; align-items: center; gap: 6px; }
.aiw-head-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.aiw-head-btn:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.aiw-clear {
  border: 0; background: transparent; color: rgba(255,255,255,.72);
  font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.aiw-clear:hover { background: rgba(255,255,255,.12); color: #fff; }
.aiw-close {
  border: 0; background: transparent; color: rgba(255,255,255,.8);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.aiw-close:hover { color: #fff; }

/* 消息区 */
.aiw-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px;
  background: #f6fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.aiw-msg { display: flex; flex-direction: column; gap: 8px; }
.aiw-msg--user { align-items: flex-end; }
.aiw-msg--bot { align-items: flex-start; }
.aiw-bubble {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
  color: #14313f;
}
.aiw-msg--bot .aiw-bubble {
  background: #fff;
  border: 1px solid #e6eff6;
  border-top-left-radius: 4px;
}
.aiw-msg--user .aiw-bubble {
  background: #189aed;
  color: #fff;
  border-top-right-radius: 4px;
}
.aiw-bubble a { color: #0f7cc4; }
.aiw-msg--user .aiw-bubble a { color: #fff; text-decoration: underline; }

.aiw-suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.aiw-suggest button {
  border: 1px solid #d8e8f3;
  background: #fff;
  color: #12688f;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.aiw-suggest button:hover { border-color: #189aed; color: #0f7cc4; }

/* 打字中 */
.aiw-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.aiw-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9fc3d8; animation: aiw-bounce 1s infinite ease-in-out;
}
.aiw-typing i:nth-child(2) { animation-delay: .15s; }
.aiw-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes aiw-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* 商品引用 */
.aiw-products { display: flex; flex-wrap: wrap; gap: 6px; }
.aiw-products a {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #eef7fd;
  border: 1px solid #d8ebf8;
  color: #0f6ea0;
  font-size: 12px;
  text-decoration: none;
}
.aiw-products a:hover { background: #e2f1fb; }
.aiw-products em { font-style: normal; color: #7c9bb0; font-size: 11px; }

/* 图片预览 */
.aiw-preview {
  position: relative;
  padding: 8px 14px 0;
  background: #fff;
}
.aiw-preview img {
  height: 64px;
  width: auto;
  border-radius: 8px;
  border: 1px solid #e3eef6;
}
.aiw-preview button {
  position: absolute;
  left: 68px;
  top: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid #d6e3ec;
  background: #fff;
  color: #5b7284;
  line-height: 1;
  cursor: pointer;
}

/* 输入区 */
.aiw-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 6px;
  border-top: 1px solid #eaf2f7;
  background: #fff;
}
.aiw-attach {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: #6b8496;
  cursor: pointer;
}
.aiw-attach:hover { background: #f0f7fb; color: #189aed; }

.aiw-input textarea {
  flex: 1 1 auto;
  min-height: 36px;
  max-height: 120px;
  resize: none;
  border: 1px solid #dbe8f1;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13.5px;
  color: #14313f;
  line-height: 1.5;
}
.aiw-input textarea:focus {
  outline: none;
  border-color: #189aed;
  box-shadow: 0 0 0 3px rgba(24, 154, 237, .12);
}
.aiw-send {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border: 0; border-radius: 10px;
  background: #189aed; color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
}
.aiw-send:disabled { background: #b9d6e8; cursor: not-allowed; }

.aiw-hint {
  margin: 0;
  padding: 0 12px 8px;
  font-size: 11px;
  color: #93a9b8;
  text-align: center;
  background: #fff;
}

/* 对话记录面板 */
.aiw-history {
  position: absolute;
  left: 0;
  right: 0;
  top: 46px;
  bottom: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.aiw-history[hidden] { display: none; }
.aiw-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #eaf2f7;
  font-size: 14px;
  color: #14313f;
}
.aiw-history-head button {
  border: 0;
  background: #f0f7fb;
  color: #0f6ea0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.aiw-history-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.aiw-history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  padding: 2px;
}
.aiw-history-item:hover { background: #f4fafd; }
.aiw-history-item.active { background: #e8f5fd; }
.aiw-history-open {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
  min-width: 0;
}
.aiw-history-open b {
  font-size: 13px;
  color: #14313f;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.aiw-history-open span { font-size: 11px; color: #93a9b8; }
.aiw-history-del {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #a9bcc9;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.aiw-history-del:hover { color: #e05252; }
.aiw-history-empty {
  padding: 24px;
  text-align: center;
  color: #93a9b8;
  font-size: 13px;
  list-style: none;
}

/* 拖拽提示 */
.aiw-drop {
  position: absolute;
  inset: 46px 0 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(24, 154, 237, 0.08);
  border: 2px dashed rgba(24, 154, 237, 0.55);
  border-radius: 10px;
  margin: 8px;
  color: #0f6ea0;
  font-size: 14px;
  pointer-events: none;
  z-index: 4;
}
.aiw-drop.show { display: flex; }

/* 缩放手柄（左上角） */
.aiw-resize {
  position: absolute;
  left: 0;
  top: 46px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  z-index: 6;
  opacity: 0.55;
  background:
    linear-gradient(135deg, transparent 45%, #9fc3d8 45%, #9fc3d8 55%, transparent 55%),
    linear-gradient(135deg, transparent 20%, #9fc3d8 20%, #9fc3d8 28%, transparent 28%);
}
.aiw-resize:hover { opacity: 1; }

@media (max-width: 640px) {
  .aiw { right: 12px; bottom: 12px; }
  .aiw-fab span { display: none; }
  .aiw-fab { width: 50px; height: 50px; padding: 0; justify-content: center; border-radius: 50%; }
  .aiw-panel {
    position: fixed;
    right: 0; bottom: 0; left: 0; top: 0;
    width: auto !important; height: auto !important;
    max-height: none; border-radius: 0;
  }
  .aiw-resize { display: none; }
}
