/* ============================================================
   盐城地方文献总库 — AI 助手 样式
   ============================================================ */

/* ── 悬浮按钮 ──────────────────────────────────────────── */
.ai-fab {
  position: fixed;
  right: 22px;
  bottom: 100px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d9a53c, #a87018);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9990;
  box-shadow: 0 4px 16px rgba(120, 90, 20, 0.35);
  transition: transform 0.18s ease, opacity 0.2s ease, box-shadow 0.18s ease;
  user-select: none;
  -webkit-user-select: none;
}
.ai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(120, 90, 20, 0.45);
}
.ai-fab.ai-hide { opacity: 0; pointer-events: none; transform: scale(0.8); }
.ai-fab-icon {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: Arial, sans-serif;
}

/* ── 遮罩 ──────────────────────────────────────────────── */
.ai-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9991;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.ai-overlay.ai-hidden { display: none; }

/* ── 面板（中等弹窗） ───────────────────────────────────── */
.ai-panel {
  position: fixed;
  right: 22px;
  bottom: 168px;
  width: 400px;
  max-width: calc(100vw - 24px);
  height: 560px;
  max-height: calc(100vh - 200px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.25);
  z-index: 9992;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}
.ai-panel.ai-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* 全屏模式 */
.ai-panel.ai-fullscreen {
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
}

/* ── 头部 ──────────────────────────────────────────────── */
.ai-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(135deg, #d9a53c, #a87018);
  color: #fff;
  flex-shrink: 0;
}
.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
}
.ai-logo {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.ai-panel-actions { display: flex; gap: 4px; }

.ai-btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.ai-btn.ai-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.ai-btn.ai-icon:hover { background: rgba(255, 255, 255, 0.32); }

/* ── 消息区 ────────────────────────────────────────────── */
.ai-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #faf7f0;
}
.ai-msgs::-webkit-scrollbar { width: 6px; }
.ai-msgs::-webkit-scrollbar-thumb { background: rgba(168, 112, 24, 0.25); border-radius: 3px; }

.ai-msg {
  margin-bottom: 10px;
  padding: 10px 12px;
  max-width: 86%;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  animation: aiIn 0.2s ease;
}
@keyframes aiIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ai-msg.ai-user {
  margin-left: auto;
  background: #d9a53c;
  color: #fff;
  border-bottom-right-radius: 3px;
}
.ai-msg.ai-assistant {
  margin-right: auto;
  background: #fff;
  color: #333;
  border: 1px solid #e8dfce;
  border-bottom-left-radius: 3px;
}

/* ── 快捷话题 ──────────────────────────────────────────── */
.ai-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border-top: 1px solid #eee7da;
  flex-shrink: 0;
}
.ai-topic {
  background: #f6ecd8;
  color: #8a5a10;
  border: 1px solid #e8d5b0;
  border-radius: 14px;
  padding: 4px 11px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.ai-topic:hover { background: #d9a53c; color: #fff; border-color: #d9a53c; }

/* ── 状态行 ────────────────────────────────────────────── */
.ai-status {
  min-height: 18px;
  padding: 0 14px 2px;
  font-size: 12px;
  color: #a87018;
  background: #fff;
  flex-shrink: 0;
}

/* ── 输入行 ───────────────────────────────────────────── */
.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #eee7da;
  flex-shrink: 0;
}
.ai-input {
  flex: 1;
  border: 1px solid #ddd2bd;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
.ai-input:focus { border-color: #d9a53c; }
.ai-send {
  background: #d9a53c;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.ai-send:hover { background: #a87018; }
.ai-send:disabled, .ai-input:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── 响应式 ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ai-fab { right: 14px; bottom: 150px; width: 48px; height: 48px; }
  .ai-panel {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
    height: calc(100vh - 120px);
    max-height: calc(100vh - 16px);
  }
}