/* 云途AI助手 — 全屏聊天浮层（移动端默认打开，桌面端右下角悬浮按钮） */

.ai-fab {
  position: fixed;
  right: 18px;
  bottom: 72px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-family: var(--font);
  box-shadow: var(--shadow-hover);
  cursor: pointer;
}
.ai-fab:active { transform: scale(.96); }
.ai-fab .ai-fab-icon { font-size: 18px; }

.ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  flex-direction: column;
  background: var(--cream);
}
.ai-overlay.open { display: flex; }

/* 桌面端：右侧抽屉式面板 */
@media (min-width: 769px) {
  .ai-overlay {
    inset: 0 0 0 auto;
    width: 430px;
    box-shadow: -8px 0 32px rgba(30, 58, 95, .25);
  }
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--blue);
  color: #fff;
  flex-shrink: 0;
}
.ai-header-text { flex: 1; min-width: 0; }
.ai-title { font-size: 17px; font-weight: 600; }
.ai-subtitle {
  font-size: 12px;
  opacity: .82;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-close {
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, .55);
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-family: var(--font);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.ai-close:active { background: rgba(255, 255, 255, .15); }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  -webkit-overflow-scrolling: touch;
}

.ai-msg { display: flex; margin-bottom: 14px; }
.ai-msg.user { justify-content: flex-end; }

.ai-bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg.assistant .ai-bubble {
  background: #fff;
  color: var(--ink);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow);
}
.ai-msg.user .ai-bubble {
  background: var(--blue-light);
  color: #fff;
  border-top-right-radius: 4px;
}
.ai-bubble.ai-error {
  background: #fdecea;
  color: #b3261e;
  box-shadow: none;
}

/* Markdown 渲染样式 */
.ai-bubble p { margin: 0 0 8px; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble ul { margin: 0 0 8px; padding-left: 20px; }
.ai-bubble ul:last-child { margin-bottom: 0; }
.ai-bubble li { margin: 3px 0; }
.ai-bubble em { font-style: italic; }
.ai-bubble blockquote {
  margin: 0 0 8px;
  padding: 6px 12px;
  border-left: 3px solid var(--gold);
  background: var(--cream);
  border-radius: 0 8px 8px 0;
  color: var(--ink-soft);
}
.ai-bubble blockquote p { margin: 0 0 4px; }
.ai-bubble blockquote p:last-child { margin-bottom: 0; }
.ai-bubble blockquote:last-child { margin-bottom: 0; }
.ai-bubble code {
  background: var(--cream-deep);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.ai-bubble a { color: var(--blue-light); }
.ai-cursor::after {
  content: "▍";
  color: var(--gold);
  animation: ai-blink .8s infinite;
}
@keyframes ai-blink { 50% { opacity: 0; } }

.ai-inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.ai-input {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 21px;
  font-size: 15px;
  font-family: var(--font);
  resize: none;
  outline: none;
  background: var(--cream);
}
.ai-input:focus { border-color: var(--blue-light); }

.ai-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-btn-mic { background: var(--cream-deep); }
.ai-btn-mic.recording {
  background: #d93025;
  animation: ai-pulse 1.2s infinite;
}
@keyframes ai-pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 48, 37, .45); }
  70% { box-shadow: 0 0 0 12px rgba(217, 48, 37, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 48, 37, 0); }
}
.ai-btn-send { background: var(--blue); color: #fff; }
.ai-btn:disabled { opacity: .45; cursor: default; animation: none; }

.ai-status {
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 2px 0 6px;
  background: #fff;
  display: none;
}
.ai-status.show { display: block; }
