:host {
  display: block;
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  /* CSS变量定义 */
  --primary-color: #007AFF;
  --success-color: #34C759;
  --warning-color: #FF9500;
  --error-color: #FF3B30;
  --text-color: #000000;
  --text-color-secondary: #8E8E93;
  --background-color: #F2F2F7;
  --border-color: #C6C6C8;
  
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.1);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

.ai-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--primary-color);
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
  -webkit-overflow-scrolling: touch;
}

.chat-container::-webkit-scrollbar {
  width: 4px;
}

.chat-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.message {
  display: flex;
  margin-bottom: var(--spacing-lg);
  align-items: flex-start;
}

.message.user-message {
  flex-direction: row-reverse;
}

.message.user-message .message-content {
  align-items: flex-end;
}

.message.user-message .message-bubble {
  background-color: var(--primary-color);
  color: white;
  border-radius: 18px 18px 4px 18px;
}

.message.ai-message .message-bubble {
  background-color: white;
  color: var(--text-color);
  border-radius: 18px 18px 18px 4px;
  box-shadow: var(--shadow-sm);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin: 0 var(--spacing-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar .default-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-color-secondary);
}

.avatar.ai-avatar .default-avatar {
  background-color: var(--primary-color);
  color: white;
}

.avatar.user-avatar .default-avatar {
  background-color: var(--success-color);
  color: white;
}

.message-content {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  min-width: 60px;
}

.message-bubble {
  padding: var(--spacing-sm) var(--spacing-md);
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
  font-size: 14px;
}

/* 移动端优化 */
@media (max-width: 768px) {
  .message-bubble {
    max-width: 100%;
    font-size: 16px; /* 防止iOS缩放 */
  }
}

.message-time {
  font-size: 11px;
  color: var(--text-color-secondary);
  margin-top: var(--spacing-xs);
  text-align: right;
}

.message.user-message .message-time {
  text-align: right;
}

.message.ai-message .message-time {
  text-align: left;
}

/* 移动端触摸反馈 */
.message {
  transition: transform 0.1s ease;
}

.message:active {
  transform: scale(0.98);
}

/* 响应式设计 */
@media (max-width: 480px) {
  .chat-container {
    padding: var(--spacing-sm);
  }
  
  .message {
    margin-bottom: var(--spacing-md);
  }
  
  .message-content {
    max-width: 80%;
  }
  
  .avatar {
    width: 28px;
    height: 28px;
    margin: 0 var(--spacing-xs);
  }
}