/* 智能助手 · 拟人气泡界面（v1.3.0）
   ADR-085：只用 CSS 变量，禁止 style= 硬编码；fallback 沿用项目惯例。 */

.pv-chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.pv-chat-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--pv-border, #e2e8f0);
  background: linear-gradient(135deg,
              var(--pv-primary-light, #eef2ff), var(--pv-surface, #fff));
}

.pv-chat-head-text h2 { margin: 0 0 2px; font-size: 18px; }
.pv-chat-head-text p { margin: 0; font-size: 12px; }

/* 机器人头像：纯 CSS，不用图片 */
.pv-chat-bot {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 46px;
  border-radius: 14px;
  background: var(--pv-primary, #4f46e5);
  box-shadow: 0 3px 10px rgba(79, 70, 229, .25);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pv-chat-bot-face {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
}
.pv-chat-bot-ant {
  position: absolute;
  top: -7px;
  left: 50%;
  width: 3px;
  height: 8px;
  margin-left: -1px;
  background: var(--pv-primary, #4f46e5);
  border-radius: 2px;
}
.pv-chat-bot-ant::after {
  content: '';
  position: absolute;
  top: -3px;
  left: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pv-warn, #d97706);
}

/* 消息列表 */
.pv-chat-log {
  flex: 1 1 auto;
  min-height: 280px;
  max-height: min(58vh, 560px);
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  background: var(--pv-bg, #f8fafc);
}

/* flex column 下交叉轴宽度默认由内容决定，若不显式给宽度，气泡会被压成竖条。
   用 align-self + width:fit-content 让气泡随内容伸缩，max-width 限幅。 */
.pv-chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: fit-content;
  max-width: 88%;
  min-width: 0;
  align-self: flex-start;
}
.pv-chat-user { align-self: flex-end; flex-direction: row-reverse; }

.pv-chat-avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.pv-chat-avatar-bot {
  background: var(--pv-primary, #4f46e5);
  font-size: 11px;
}
.pv-chat-avatar-user { background: var(--pv-muted, #64748b); }

.pv-chat-bubble {
  min-width: 0;
  padding: 10px 14px;
  border-radius: 14px;
  border-top-left-radius: 4px;
  background: var(--pv-surface, #fff);
  border: 1px solid var(--pv-border, #e2e8f0);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.pv-chat-user .pv-chat-bubble {
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
  background: var(--pv-primary, #4f46e5);
  color: #fff;
  border-color: transparent;
}
.pv-chat-bubble p { margin: 0 0 6px; }
.pv-chat-bubble p:last-child { margin-bottom: 0; }
.pv-chat-bubble strong { color: var(--pv-primary, #4f46e5); }
.pv-chat-user .pv-chat-bubble strong { color: #fff; }
.pv-chat-warn { color: var(--pv-warn, #d97706); }

.pv-chat-time {
  align-self: flex-end;
  font-size: 10px;
  color: var(--pv-muted, #94a3b8);
  margin-top: 2px;
}

/* 打字动画 */
.pv-chat-typing .pv-chat-bubble { display: flex; gap: 5px; align-items: center; }
.pv-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pv-muted, #94a3b8);
  animation: pv-blink 1.2s infinite ease-in-out;
}
.pv-dot:nth-child(2) { animation-delay: .2s; }
.pv-dot:nth-child(3) { animation-delay: .4s; }
@keyframes pv-blink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* 表格（助手回复内） */
.pv-chat-table { margin: 8px 0 4px; max-height: 260px; overflow: auto; }
.pv-chat-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pv-chat-table th,
.pv-chat-table td {
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--pv-border, #e2e8f0);
  white-space: nowrap;
}
.pv-chat-table th { color: var(--pv-muted, #64748b); font-weight: 600; }
.pv-chat-table tfoot th { border-top: 2px solid var(--pv-border, #e2e8f0); border-bottom: none; }

/* 卡片（助手回复内） */
.pv-chat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.pv-chat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--pv-bg, #f8fafc);
  border: 1px solid var(--pv-border, #e2e8f0);
  min-width: 0;
}
.pv-chat-card-title { font-weight: 700; font-size: 13px; word-break: break-word; }
.pv-chat-card-sub { font-size: 11px; color: var(--pv-muted, #64748b); }

/* 建议芯片 */
.pv-chat-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-top: 1px solid var(--pv-border, #e2e8f0);
  font-size: 12px;
}
.pv-chat-chip {
  min-height: 30px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--pv-primary, #4f46e5);
  background: var(--pv-surface, #fff);
  color: var(--pv-primary, #4f46e5);
  font-size: 12px;
  cursor: pointer;
}
.pv-chat-chip:hover,
.pv-chat-chip:focus-visible { background: var(--pv-primary-light, #eef2ff); }

/* 输入区 */
.pv-chat-form {
  display: flex;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--pv-border, #e2e8f0);
}
.pv-chat-input { flex: 1 1 auto; min-width: 0; }
.pv-chat-send { flex: 0 0 auto; white-space: nowrap; }

@media (max-width: 760px) {
  .pv-chat-head { padding: 12px 14px; gap: 10px; }
  .pv-chat-head-text h2 { font-size: 16px; }
  .pv-chat-log { padding: 14px; max-height: min(52vh, 460px); }
  .pv-chat-msg { max-width: 94%; }
  .pv-chat-suggest { padding: 10px 14px; }
  .pv-chat-form { padding: 10px 14px 14px; }
  .pv-chat-bubble { font-size: 13px; }
}

@media (pointer: coarse) {
  .pv-chat-chip,
  .pv-chat-send { min-height: 44px; padding: 10px 16px; }
  .pv-chat-input { min-height: 44px; }
}
