/* ============================================
   WeChat AI Chat - Chat Interface Styles
   聊天界面样式：消息气泡、输入栏、系统消息
   ============================================ */

.chat-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--wx-bg-chat);
  overflow: hidden;
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.chat-messages-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 12px;
}

.msg-time {
  text-align: center;
  padding: 4px 0;
}

.msg-time span {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.15);
  color: white;
  font-size: 11px;
  border-radius: 4px;
  line-height: 1.4;
}

.msg-system {
  text-align: center;
  padding: 4px 16px;
}

.msg-system span {
  display: inline-block;
  max-width: 80%;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.15);
  color: white;
  font-size: 12px;
  border-radius: 4px;
  line-height: 1.5;
  word-break: break-all;
}

.msg-system.important span {
  background: rgba(250, 81, 81, 0.85);
}

.msg-system.success span {
  background: rgba(7, 193, 96, 0.85);
}

.msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 100%;
}

.msg-row.self {
  flex-direction: row-reverse;
}

.msg-row .msg-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--wx-bg-light);
}

.msg-row .msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.msg-row .msg-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: calc(100% - 56px);
  min-width: 0;
}

.msg-row.self .msg-body {
  align-items: flex-end;
}

.msg-row .msg-sender {
  font-size: 11px;
  color: var(--wx-text-secondary);
  padding: 0 4px;
}

.msg-row.self .msg-sender {
  display: none;
}

.msg-bubble {
  position: relative;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  cursor: pointer;
  transition: filter var(--wx-transition-fast);
}

.msg-bubble:active {
  filter: brightness(0.95);
}

.msg-row:not(.self) .msg-bubble {
  background: var(--wx-bubble-other);
  color: var(--wx-text);
}

.msg-row:not(.self) .msg-bubble::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid var(--wx-bubble-other);
}

.msg-row.self .msg-bubble {
  background: var(--wx-bubble-self);
  color: var(--wx-text);
}

.msg-row.self .msg-bubble::before {
  content: '';
  position: absolute;
  right: -5px;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid var(--wx-bubble-self);
}

.msg-bubble a {
  color: var(--wx-text-link);
  text-decoration: underline;
  word-break: break-all;
}

.msg-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--wx-font-mono);
  font-size: 13px;
}

.msg-bubble pre {
  background: #282C34;
  color: #ABB2BF;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
  line-height: 1.5;
}

.msg-bubble pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.msg-bubble .msg-image {
  max-width: 200px;
  max-height: 250px;
  border-radius: 4px;
  cursor: pointer;
  margin: -4px;
}

.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 6px;
  min-width: 200px;
}

.msg-file .file-icon {
  width: 40px;
  height: 40px;
  background: var(--wx-green);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.msg-file .file-info {
  flex: 1;
  min-width: 0;
}

.msg-file .file-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-file .file-size {
  font-size: 11px;
  color: var(--wx-text-secondary);
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator .dot {
  width: 8px;
  height: 8px;
  background: var(--wx-text-tertiary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.thinking-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--wx-text-secondary);
  padding: 2px 4px;
}

.tool-call-card {
  background: rgba(7, 193, 96, 0.08);
  border: 1px solid rgba(7, 193, 96, 0.2);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 6px 0;
  font-size: 12px;
}

.tool-call-card .tool-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--wx-green);
  font-weight: 500;
  margin-bottom: 4px;
}

.tool-call-card .tool-args {
  color: var(--wx-text-secondary);
  font-family: var(--wx-font-mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-call-card .tool-result {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(7, 193, 96, 0.2);
  color: var(--wx-text);
  max-height: 100px;
  overflow-y: auto;
}

.msg-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--wx-text-tertiary);
  padding: 0 4px;
}

.msg-status.read {
  color: var(--wx-green);
}

.msg-failed {
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-failed .retry-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wx-red);
  cursor: pointer;
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  padding: 8px 10px;
  background: var(--wx-bg-light);
  border-top: 1px solid var(--wx-border-light);
  gap: 8px;
  flex-shrink: 0;
  padding-bottom: calc(8px + var(--safe-bottom));
}

.chat-input-bar .input-action {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--wx-text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--wx-transition-fast);
}

.chat-input-bar .input-action:active {
  background: var(--wx-bg-hover);
}

.chat-input-bar .input-action svg {
  width: 26px;
  height: 26px;
}

.chat-input-bar .input-action.active {
  color: var(--wx-green);
}

.chat-input-wrap {
  flex: 1;
  background: var(--wx-bg-white);
  border-radius: 6px;
  min-height: 36px;
  max-height: 120px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  position: relative;
}

.chat-input-wrap textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  max-height: 100px;
  padding: 8px 0;
  font-family: inherit;
  color: var(--wx-text);
}

.chat-input-wrap textarea::placeholder {
  color: var(--wx-text-tertiary);
}

.send-btn {
  min-width: 56px;
  height: 36px;
  background: var(--wx-green);
  color: white;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--wx-transition-fast);
}

.send-btn:active {
  background: var(--wx-green-dark);
}

.send-btn:disabled {
  background: var(--wx-border);
  cursor: not-allowed;
}

.emoji-panel {
  background: var(--wx-bg-light);
  border-top: 1px solid var(--wx-border-light);
  padding: 12px;
  max-height: 240px;
  overflow-y: auto;
  flex-shrink: 0;
}

.emoji-panel .emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.emoji-panel .emoji-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--wx-transition-fast);
}

.emoji-panel .emoji-item:active {
  background: var(--wx-bg-hover);
}

.more-panel {
  background: var(--wx-bg-light);
  border-top: 1px solid var(--wx-border-light);
  padding: 16px;
  flex-shrink: 0;
}

.more-panel .more-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.more-panel .more-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.more-panel .more-item .more-icon {
  width: 56px;
  height: 56px;
  background: var(--wx-bg-white);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wx-text-secondary);
  transition: all var(--wx-transition-fast);
}

.more-panel .more-item:active .more-icon {
  background: var(--wx-bg-hover);
  transform: scale(0.95);
}

.more-panel .more-item .more-icon svg {
  width: 28px;
  height: 28px;
}

.more-panel .more-item .more-label {
  font-size: 12px;
  color: var(--wx-text-secondary);
}

.msg-quote {
  background: rgba(0, 0, 0, 0.04);
  border-left: 3px solid var(--wx-green);
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--wx-text-secondary);
  cursor: pointer;
}

.msg-context-menu {
  position: fixed;
  background: var(--wx-bg-white);
  border-radius: 8px;
  box-shadow: var(--wx-shadow-lg);
  padding: 4px;
  z-index: 2000;
  min-width: 140px;
  animation: menuPop 0.15s ease;
}

@keyframes menuPop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.msg-context-menu .menu-item {
  padding: 10px 16px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--wx-transition-fast);
}

.msg-context-menu .menu-item:active {
  background: var(--wx-bg-hover);
}

.msg-context-menu .menu-item.danger {
  color: var(--wx-red);
}

.voice-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 80px;
  cursor: pointer;
}

.voice-msg .voice-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-msg .voice-duration {
  font-size: 14px;
  font-weight: 500;
}

.location-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
}

.location-msg .location-map {
  width: 200px;
  height: 100px;
  background: var(--wx-bg-light);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wx-text-tertiary);
  overflow: hidden;
}

.card-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 6px;
  min-width: 200px;
}

.card-msg .card-avatar {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
}

.chat-info-panel {
  padding: 16px;
  overflow-y: auto;
}

.chat-info-panel .panel-section {
  margin-bottom: 16px;
}

.chat-info-panel .ai-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 8px;
}

.chat-info-panel .ai-avatar-section .avatar {
  width: 64px;
  height: 64px;
  border-radius: 8px;
}

.chat-info-panel .quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.chat-info-panel .quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  background: var(--wx-bg-white);
  border-radius: 8px;
  cursor: pointer;
}

.scroll-bottom-btn {
  position: absolute;
  right: 16px;
  bottom: 80px;
  width: 36px;
  height: 36px;
  background: var(--wx-bg-white);
  border-radius: 50%;
  box-shadow: var(--wx-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  color: var(--wx-text-secondary);
  transition: all var(--wx-transition-fast);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.scroll-bottom-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
