/* ==========================================================================
   海若心语 · 对话流与输入交互样式表 (Chat Stream & Input Area)
   ========================================================================== */

/* 主聊天滚动视口 */
.chat-scroll-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  scroll-behavior: smooth;
}
.chat-scroll-area::-webkit-scrollbar {
  width: 6px;
}
.chat-scroll-area::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 6px;
}

/* 消息流居中容器 (限制最大阅读舒适宽度 840px) */
.messages-container {
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ==========================================================================
   空状态与欢迎卡片 (Welcome / Empty State)
   ========================================================================== */
.welcome-card-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px 20px;
  text-align: center;
  margin: auto auto;
  max-width: 700px;
}

.welcome-symbol {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2C5E8A 0%, #4A89BF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #FFF;
  box-shadow: 0 8px 24px rgba(44, 94, 138, 0.25);
  margin-bottom: 20px;
  animation: floatOcean 3.5s ease-in-out infinite;
}

@keyframes floatOcean {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.welcome-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.welcome-desc {
  font-size: 14.5px;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 520px;
  margin-bottom: 32px;
}

/* 治愈系倾听快捷气泡网格 */
.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
}

.suggestion-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: pointer;
}
.suggestion-chip:hover {
  background: var(--primary-soft);
  border-color: #B8D3EB;
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.chip-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.chip-text {
  flex: 1;
  font-weight: 500;
  line-height: 1.4;
}

/* ==========================================================================
   对话气泡体系 (Chat Bubbles)
   ========================================================================== */
.message-row {
  display: flex;
  gap: 14px;
  width: 100%;
  animation: messageAppear 0.22s ease-out;
}

@keyframes messageAppear {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 用户发言行 */
.message-row.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border: 1px solid var(--border);
}
.msg-avatar.user-avatar {
  background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
  color: #FFF;
}
.msg-avatar.assistant-avatar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #FFF;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.2);
}

.msg-body-wrap {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}
.message-row.user .msg-body-wrap {
  align-items: flex-end;
}
.message-row.assistant .msg-body-wrap {
  align-items: flex-start;
  width: 100%;
}

/* 用户气泡 (按内容精致贴合，避免内边距过大空旷) */
.bubble-user {
  background-color: var(--primary-light);
  color: #FFFFFF;
  padding: 8px 14px;
  border-radius: 14px 14px 4px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  word-break: break-word;
  white-space: pre-wrap;
  width: fit-content;
  max-width: 100%;
}

/* 助手回复卡片 (洁白纸质手记感) */
.bubble-assistant {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 18px 18px 18px 4px;
  padding: 18px 22px;
  font-size: 15px;
  line-height: 1.75;
  box-shadow: var(--shadow-sm);
  width: 100%;
  word-break: break-word;
}

/* Markdown 排版细化 */
.bubble-assistant p.md-p {
  margin-bottom: 12px;
}
.bubble-assistant p.md-p:last-child {
  margin-bottom: 0;
}

.bubble-assistant .md-h1,
.bubble-assistant .md-h2,
.bubble-assistant .md-h3 {
  color: var(--primary);
  margin: 16px 0 8px;
  font-weight: 700;
  line-height: 1.4;
}
.bubble-assistant .md-h1 { font-size: 18px; }
.bubble-assistant .md-h2 { font-size: 16.5px; }
.bubble-assistant .md-h3 { font-size: 15px; }

.bubble-assistant .md-quote {
  border-left: 3px solid var(--primary-light);
  padding: 6px 14px;
  margin: 12px 0;
  background: var(--primary-soft);
  color: #334155;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  font-style: normal;
}

.bubble-assistant .md-ul,
.bubble-assistant .md-ol {
  margin: 8px 0 12px 20px;
}
.bubble-assistant .md-li,
.bubble-assistant .md-oli {
  margin-bottom: 4px;
}

.bubble-assistant .inline-code {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

/* 代码块与一键复制 */
.code-block-wrapper {
  background-color: #0F172A;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid #334155;
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background-color: #1E293B;
  color: #94A3B8;
  font-size: 12px;
  user-select: none;
}
.code-lang {
  text-transform: lowercase;
  font-weight: 600;
}
.copy-code-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #94A3B8;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
}
.copy-code-btn:hover {
  background-color: #334155;
  color: #FFF;
}
.copy-code-btn.copied {
  color: #34D399;
}
.code-content {
  padding: 14px 16px;
  overflow-x: auto;
  color: #E2E8F0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
}
.code-content code {
  font-family: inherit;
}

/* ==========================================================================
   思考与微波流式动画 (Thinking Wave Dots)
   ========================================================================== */
.thinking-wave-container {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 4px;
}
.wave-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--primary-light);
  animation: waveBounce 1.4s infinite ease-in-out both;
}
.wave-dot:nth-child(1) { animation-delay: -0.32s; }
.wave-dot:nth-child(2) { animation-delay: -0.16s; }
.wave-dot:nth-child(3) { animation-delay: 0s; }

@keyframes waveBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* 流式打字闪烁微光标 (温和淡蓝) */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background-color: var(--primary-light);
  margin-left: 2px;
  vertical-align: -2px;
  animation: cursorBlink 0.9s infinite;
}
@keyframes cursorBlink {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* ==========================================================================
   底部悬浮输入区域 (Bottom Floating Input)
   ========================================================================== */
.chat-input-area {
  flex-shrink: 0;
  padding: 10px 20px 20px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0) 0%, rgba(248, 250, 252, 0.9) 30%, #F8FAFC 100%);
  position: relative;
  z-index: 10;
}

.input-box-wrapper {
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow-float);
  padding: 8px 10px 8px 18px;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-box-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 10px 28px rgba(44, 94, 138, 0.14);
}

.chat-textarea {
  flex: 1;
  min-height: 24px;
  max-height: 140px;
  padding: 6px 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-main);
  resize: none;
  overflow-y: auto;
  border: none;
  background: transparent;
}
.chat-textarea::placeholder {
  color: var(--text-light);
}

.input-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: 2px;
}

/* 发送按钮 (右侧常驻) */
.btn-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(44, 94, 138, 0.25);
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-send:hover {
  background-color: var(--primary);
  transform: scale(1.05);
}
.btn-send:disabled {
  background-color: #CBD5E1;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 停止生成按钮 (流式中展示) */
.btn-stop-generation {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background-color: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #FECDD3;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-stop-generation:hover {
  background-color: var(--danger);
  color: #FFF;
}
.btn-stop-generation.active {
  display: flex;
}

.stop-icon {
  width: 9px;
  height: 9px;
  background-color: currentColor;
  border-radius: 2px;
}

/* 底部免责声明 */
.chat-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 8px;
  user-select: none;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .messages-container {
    padding: 16px 14px 24px;
    gap: 18px;
  }
  .msg-body-wrap {
    max-width: 90%;
  }
  .suggestions-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .welcome-title {
    font-size: 20px;
  }
  .welcome-desc {
    font-size: 13.5px;
    margin-bottom: 24px;
  }
  .chat-input-area {
    padding: 8px 12px 14px;
  }
  .input-box-wrapper {
    padding: 6px 8px 6px 14px;
    border-radius: 22px;
    gap: 8px;
  }
  .btn-send {
    width: 34px;
    height: 34px;
  }
}
