/* ChatArea 消息列表样式 */

.area {
  --chat-pull-offset: 0px;

  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding:
    var(--spacing-lg, 16px)
    calc(var(--chat-inline-padding, 20px) + var(--app-safe-right, 0px))
    var(--spacing-lg, 16px)
    calc(var(--chat-inline-padding, 20px) + var(--app-safe-left, 0px));
}

.pullIndicator {
  position: absolute;
  top: var(--spacing-sm, 8px);
  left: 50%;
  z-index: 2;
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(24, 20, 30, 0.86);
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--responsive-caption, var(--font-size-sm, 12px));
  font-weight: 700;
  opacity: 1;
  pointer-events: none;
  transform: translate(-50%, calc(var(--chat-pull-offset) - 42px));
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

.pullIndicator[aria-hidden="true"] {
  opacity: 0;
}

.pullIndicator svg[data-spinning="true"] {
  animation: pullIndicatorSpin 0.8s linear infinite;
}

.content {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3, 12px);
  min-width: 0;
  transform: translateY(var(--chat-pull-offset));
  transition: transform 180ms ease;
  will-change: transform;
}

.area[data-pulling="true"] .content {
  transition: none;
}

.dateHeader {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--spacing-2, 8px) 0;
}

.dateChip {
  background: var(--color-surface-muted, rgba(255, 255, 255, 0.06));
  border-radius: var(--radius-md, 8px);
  padding: var(--spacing-1, 4px) var(--spacing-3, 12px);
  font-size: var(--responsive-micro, var(--font-size-xs, 11px));
  color: #000;
  opacity: 0.75;
}

.aiDisclosure {
  align-self: center;
  background: var(--color-surface-muted, rgba(255, 255, 255, 0.06));
  border-radius: var(--radius-md, 8px);
  padding: var(--spacing-2, 8px) var(--spacing-4, 16px);
  font-size: var(--responsive-caption, var(--font-size-sm, 12px));
  color: #8c8b8b;
  text-align: center;
}

.bubbleRowAi {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  align-self: flex-start;
  gap: var(--spacing-1, 4px);
}

.bubbleRowUser {
  display: flex;
  flex-direction: row;
  /* 与 AI 行保持一致：头像顶部对齐气泡首行。
   * 原 flex-end 在气泡多行换行时会把头像贴到气泡底部（视觉上像 "脚注"），
   * 跟 AI 行不对称，改成 flex-start 跟 AI 行对齐方式统一 */
  align-items: flex-start;
  align-self: flex-end;
  gap: var(--spacing-1, 4px);
}

.bubbleInlineSpacer {
  flex: 0 0 var(--spacing-sm, 8px);
  width: var(--spacing-sm, 8px);
}

.bubbleAvatarSpacer {
  flex: 0 0 var(--chat-avatar-size, 43px);
  width: var(--chat-avatar-size, 43px);
}

.messageContent {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  flex-direction: column;
  gap: var(--spacing-sm, 8px);
}

.messageContentAi {
  align-items: flex-start;
}

.messageContentUser {
  align-items: flex-end;
}

.commercialAction {
  width: min(100%, 286px);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(25, 21, 31, 0.92);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.commercialActionHeader {
  display: flex;
  min-height: 24px;
  align-items: center;
  justify-content: space-between;
  color: #f4b860;
}

.commercialActionDismiss {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.66);
  cursor: pointer;
}

.commercialActionCopy {
  margin: 7px 0 11px;
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--responsive-caption, var(--font-size-sm, 13px));
  line-height: 1.45;
}

.commercialActionButton {
  display: inline-flex;
  min-height: 38px;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: #f4b860;
  color: #201710;
  cursor: pointer;
  font-size: var(--responsive-caption, var(--font-size-sm, 13px));
  font-weight: 700;
}

.commercialActionButton span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.commercialActionButton:disabled {
  cursor: wait;
  opacity: 0.72;
}

.commercialActionError {
  margin: -4px 0 10px;
  color: #ffb4ab;
  font-size: 12px;
  line-height: 1.4;
}

.commercialActionSpinner {
  animation: commercial-action-spin 0.8s linear infinite;
}

@keyframes commercial-action-spin {
  to { transform: rotate(360deg); }
}

.bubbleAi {
  max-width: var(--chat-bubble-max-width, 75%);
  background: var(--color-bubble-ai, rgba(255, 255, 255, 0.08));
  padding: var(--spacing-3, 12px) var(--spacing-4, 16px);
  border-radius: var(--radius-lg, 12px);
  font-size: var(--responsive-body, var(--font-size-base, 14px));
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubbleUser {
  max-width: var(--chat-bubble-max-width, 75%);
  background: var(--color-bubble-user, #4f46e5);
  padding: var(--spacing-3, 12px) var(--spacing-4, 16px);
  border-radius: var(--radius-lg, 12px);
  font-size: var(--responsive-body, var(--font-size-base, 14px));
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #fff;
}

.bubbleTime {
  font-size: var(--responsive-micro, var(--font-size-xs, 11px));
  opacity: 0.5;
}

.typingBubble {
  display: flex;
  align-items: center;
  gap: var(--spacing-1, 4px);
  padding: var(--spacing-3, 12px) var(--spacing-4, 16px);
  background: var(--color-bubble-ai, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 12px);
  width: fit-content;
}

.typingDot {
  display: inline-block;
  width: var(--responsive-dot-size, 6px);
  height: var(--responsive-dot-size, 6px);
  border-radius: 50%;
  background: currentColor;
  margin: 0 2px;
  animation: typingBlink 1.2s infinite;
}
.typingDot:nth-child(2) { animation-delay: 0.15s; }
.typingDot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBlink {
  0%, 60%, 100% { opacity: 0.2; }
  30% { opacity: 1; }
}

@keyframes pullIndicatorSpin {
  to {
    transform: rotate(360deg);
  }
}
