/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
  touch-action: manipulation; /* 优化触摸操作 */
}

body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

ul,
ol {
  list-style: none;
}

a {
  text-decoration: none;
  color: inherit;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

body {
  background-color: #f5f5f5;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* 应用容器 */
.app-container {
  width: 100%;
  max-width: 1200px;
  height: 700px;
  display: flex;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  overflow: hidden;
}

/* 侧边栏 */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

.sidebar {
  width: 260px;
  background-color: #f9f9f9;
  border-right: 1px solid #eaeaea;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #eaeaea;
  position: relative;
}

.close-sidebar-button {
  display: none;
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  color: #666;
  justify-content: center;
  align-items: center;
}

.close-sidebar-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
}
.new-chat-box {
  padding: 16px;
}
.new-chat-button {
  width: 100%;
  padding: 10px;
  background-color: #4f6af5;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.2s;
}

.new-chat-button:hover {
  background-color: #4059d8;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-item {
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.conversation-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.delete-conversation-button {
  visibility: hidden;
  opacity: 0;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  margin-left: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-conversation-button:hover {
  color: #ff4d4f;
  background-color: rgba(255, 77, 79, 0.1);
}

.conversation-item:hover .delete-conversation-button {
  visibility: visible;
  opacity: 1;
}

.conversation-item:hover {
  background-color: #f0f0f0;
}

.conversation-item.active {
  background-color: #e6e9fd;
  color: #4f6af5;
}

/* 聊天容器 */
.chat-container {
  flex: 1;
  background-color: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 聊天头部 */
.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
}

.header-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#currentConversationTitle {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.action-button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: transparent;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: #666;
  transition: background-color 0.2s;
}

.action-button:hover {
  background-color: #f5f5f5;
}

/* 欢迎屏幕 */
.welcome-screen {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 500px;
}

.logo {
  width: 60px;
  height: 60px;
}

.welcome-text h1 {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
}

.welcome-text p {
  font-size: 16px;
  color: #666;
  line-height: 1.5;
}

/* 聊天主体 */
.chat-body {
  flex: 1;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 消息容器 */
.messages-container {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  padding-bottom: 140px; /* 为输入框留出空间 */
  flex: 1;
  width: 100%;
}

/* 隐藏欢迎屏幕，当有消息时 */
.messages-container:not(:empty) ~ .welcome-screen {
  display: none;
}

/* 消息样式 */
.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

/* 加载指示器 */
.loading-dots {
  display: inline-flex;
  align-items: center;
  height: 20px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  margin: 0 2px;
  background-color: #999;
  border-radius: 50%;
  display: inline-block;
  animation: loading 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes loading {
  0%,
  80%,
  100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

.message.user {
  align-self: flex-end;
}

.message.ai {
  align-self: flex-start;
}

.message-content {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 26px;
  word-break: break-word;
}

.message.user .message-content {
  background-color: #4f6af5;
  color: white;
  border-radius: 12px 12px 0 12px;
}

.message.ai .message-content {
  background-color: #f5f7fa;
  color: #333;
  border-radius: 12px 12px 12px 0;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin-bottom: 6px;
}

.message.user .message-avatar {
  align-self: flex-end;
  display: none; /* 用户头像默认隐藏 */
}

.message.ai .message-avatar {
  align-self: flex-start;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

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

/* 消息输入区域 */
.message-input-container {
  position: absolute;
  bottom: 0px;
  left: 0px;
  right: 0px;
  transition: all 0.2s;
  padding: 20px;
  z-index: 10;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.input-container {
  background-color: #f5f7fa;
  border-radius: 8px;
  padding: 11px 49px 11px 11px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 1px solid transparent;
  position: relative;
}

.message-input {
  width: 100%;
  min-height: 24px;
  max-height: 150px;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  padding: 0;
}

.input-container:focus-within {
  box-shadow: 0 0 0 2px rgba(79, 106, 245, 0.1);
  border: 1px solid rgba(79, 106, 245, 0.3);
}

.message-input::placeholder {
  color: #aaa;
}

.send-button,
.stop-button {
  position: absolute;
  right: 40px;
  bottom: 20px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.7;
}

.send-button {
  background-color: #e9ecf0;
}

.stop-button {
  background-color: #ffebee;
}

.send-button:hover {
  background-color: #d9dce0;
  opacity: 1;
}

.stop-button:hover {
  background-color: #ffcdd2;
  opacity: 1;
}

.send-button:disabled,
.stop-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.send-button i,
.stop-button i {
  color: #666;
  font-size: 14px;
}

.stop-button i {
  color: #e53935;
}

.message-input:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* 响应式设计 */
/* 平板设备 */
@media (max-width: 1024px) {
  .app-container {
    max-width: 100%;
    height: 90vh;
    margin: 20px;
  }

  .sidebar {
    width: 220px;
  }

  .message {
    max-width: 90%;
  }
}

/* PC */
@media (min-width: 768px) {
  .mobile-menu-button {
    display: none;
  }
}
/* 移动设备 */
@media (max-width: 768px) {
  body {
    padding: 0;
    margin: 0;
  }

  .app-container {
    height: 100vh;
    max-width: 100%;
    border-radius: 0;
    flex-direction: column;
    margin: 0;
    box-shadow: none;
  }

  .sidebar {
    width: 85%;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .close-sidebar-button {
    display: flex;
  }

  .chat-container {
    height: 100%;
  }

  .chat-header {
    padding: 12px 16px;
  }

  .header-title {
    position: relative;
    padding-left: 40px; /* 为菜单按钮留出空间 */
  }

  /* 添加移动端菜单按钮 */
  .mobile-menu-button {
    display: flex;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: transparent;
    border: none;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    color: #666;
  }

  .messages-container {
    padding: 12px;
    padding-bottom: 80px;
  }

  .message {
    max-width: 95%;
  }

  .message-content {
    padding: 10px 14px;
    font-size: 14px;
  }

  .message-input-container {
    left: 10px;
    right: 10px;
    bottom: 10px;
    padding: 15px 10px;
    background-color: #fff;
  }

  .input-container {
    padding: 8px 45px 8px 8px;
  }

  .send-button,
  .stop-button {
    right: 20px;
    bottom: 20px;
    width: 28px;
    height: 28px;
  }

  .welcome-screen {
    padding: 16px;
  }

  .logo {
    width: 50px;
    height: 50px;
  }

  .welcome-text h1 {
    font-size: 20px;
  }

  .welcome-text p {
    font-size: 14px;
  }
}

/* 小型移动设备 */
@media (max-width: 480px) {
  .message {
    max-width: 98%;
  }

  .message-content {
    padding: 8px 12px;
    font-size: 13px;
  }

  .welcome-text h1 {
    font-size: 18px;
  }

  .welcome-text p {
    font-size: 13px;
  }

  .header-actions {
    gap: 4px;
  }

  .action-button {
    width: 28px;
    height: 28px;
  }

  .logo-container {
    max-width: 280px;
  }
}
