body * {
  box-sizing: border-box;
  flex-shrink: 0;
}

body {
  font-family: PingFangSC-Regular, Roboto, Helvetica Neue, Helvetica, Tahoma,
    Arial, PingFang SC-Light, Microsoft YaHei;
  max-width: 100%;
  max-height: 100%;
  min-width: 100%;
  min-height: 100%;
}

input {
  background-color: transparent;
  border: 0;
}

button {
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  outline: none;
  background-color: transparent;
}

button:active {
  opacity: 0.6;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.flex-row {
  display: flex;
  flex-direction: row;
}

.justify-start {
  display: flex;
  justify-content: flex-start;
}

.justify-center {
  display: flex;
  justify-content: center;
}

.justify-end {
  display: flex;
  justify-content: flex-end;
}

.justify-evenly {
  display: flex;
  justify-content: space-evenly;
}

.justify-around {
  display: flex;
  justify-content: space-around;
}

.justify-between {
  display: flex;
  justify-content: space-between;
}

.align-start {
  display: flex;
  align-items: flex-start;
}

.align-center {
  display: flex;
  align-items: center;
}

.align-end {
  display: flex;
  align-items: flex-end;
}

.chat-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.chat-wrapper {
  height: 100vh;
  background: #e4ecfc;
  background-size: cover;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

.chat-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 90vh;
  overflow: hidden;
  background-color: rgba(239, 244, 253, 0.8);
  border-radius: 20px;
  width: 1200px;
  height: 922px;
  margin: auto;
}

.sidebar {
  background-color: rgba(244, 247, 254, 1);
  border-radius: 20px 20px 0px 0px;
  width: 304px;
  height: 99% !important;
  border-radius: 20px;
  margin: 4px 0 0 4px;
  position: relative;
}

.ai-avatar {
  width: 106px;
  height: 125px;
  margin: 25px 0 0 95px;
}

.sidebar-title {
  width: 94px;
  height: 22px;
  overflow-wrap: break-word;
  color: rgba(58, 58, 58, 1);
  font-size: 24px;
  font-family: AlimamaShuHeiTi-Bold;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  line-height: 30px;
  margin: 19px 0 0 105px;
}

.new-chat {
  width: 100%;
  height: 49px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 26px auto 22px;
}

.new-chat-btn {
  border-radius: 24px;
  width: 60%;
  height: 49px;
  border: 1px solid rgba(85, 125, 255, 1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.new-chat-btn:hover {
  background-color: rgba(85, 125, 255, 0.1);
}

.new-chat-icon {
  width: 19px;
  height: 19px;
}

.new-chat-text {
  overflow-wrap: break-word;
  color: rgba(85, 125, 255, 1);
  font-size: 18px;
  font-family: NotoSansHans-Regular;
  font-weight: normal;
  text-align: left;
  white-space: nowrap;
}

.clear-icon {
  width: 25px;
  height: 25px;
  cursor: pointer;
}

.chat-list-title {
  width: 72px;
  height: 17px;
  overflow-wrap: break-word;
  color: rgba(63, 63, 63, 1);
  font-size: 18px;
  font-family: NotoSansHans-Regular;
  font-weight: normal;
  text-align: left;
  white-space: nowrap;
  line-height: 18px;
  margin: 42px 0 0 24px;
}

.chat-history {
  width: 100%;
  margin-top: 26px;
  overflow-y: auto;
  max-height: calc(100% - 200px);
}

.chat-history::-webkit-scrollbar {
  width: 4px;
}

.chat-history::-webkit-scrollbar-thumb {
  background-color: rgba(85, 125, 255, 0.3);
  border-radius: 2px;
}

.chat-history::-webkit-scrollbar-track {
  background-color: transparent;
}

.chat-item-icon-active {
  display: none;
}

.chat-item {
  /* width: 304px; */
  height: 54px;
  cursor: pointer;
  transition: background-color 0.2s ease-out, border-left 0.2s ease-out;
  padding: 0 0 0 25px;
  display: flex;
  align-items: center;
}

.chat-item:hover {
  background-color: rgba(85, 125, 255, 0.1);
}

.chat-item.active {
  background-color: rgba(85, 125, 255, 0.2);
  border-left: 3px solid rgba(85, 125, 255, 1);
}

.chat-item.active .chat-item-icon-active {
  display: block;
}

.chat-item.active .chat-item-icon {
  display: none;
}

.chat-item-content {
  width: 100%;
  height: 17px;
  display: flex;
  align-items: center;
}

.chat-item-icon-active {
  width: 19px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.chat-item-text {
  width: calc(100% - 40px);
  height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(82, 82, 82, 1);
  font-size: 16px;
  font-family: NotoSansHans-Regular;
  font-weight: normal;
  text-align: left;
  line-height: 16px;
  margin-left: 10px;
  transition: color 0.2s ease-out, font-weight 0.2s ease-out;
}

.chat-item.active .chat-item-text {
  color: rgba(85, 125, 255, 1);
  font-weight: 500;
}

.chat-item-icon {
  width: 19px;
  height: 16px;
  margin-top: 1px;
}

.load-more {
  width: 79px;
  height: 16px;
  overflow-wrap: break-word;
  color: rgba(189, 189, 189, 1);
  font-size: 16px;
  font-family: NotoSansHans-Regular;
  font-weight: normal;
  text-align: left;
  white-space: nowrap;
  line-height: 16px;
  width: 100%;
  text-align: center;
  margin-top: 10px;
}

.toggle-btn {
  background-color: rgba(108, 142, 251, 1);
  border-radius: 0px 0px 6px 6px;
  height: 64px;
  margin-top: 32%;
  width: 23px;
  cursor: pointer;
}

.toggle-icon {
  width: 10px;
  height: 15px;
  margin: 25px 0 0 5px;
  transition: transform 0.3s;
}

/* 收起时旋转180度 */
.chat-main.sidebar-collapsed .toggle-icon {
  transform: rotate(180deg);
}

.chat-area {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-width: 100%;
  background-color: rgba(239, 244, 253, 0.8);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  height: calc(100% - 100px);
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 20px;
  max-width: 100%;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: #bbb;
  border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-track {
  background-color: #f3f3f3;
}

.welcome-message {
  background-color: rgba(255, 255, 255, 1);
  border-radius: 10px;
  min-height: 188px;
  padding-bottom: 20px;
  margin-left: 1px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.welcome-content {
  width: 100%;
  min-height: 136px;
  overflow-wrap: break-word;
  font-size: 0;
  font-family: NotoSansHans-Medium;
  font-weight: 500;
  text-align: left;
  line-height: 30px;
  margin: 26px 0 0 29px;
}

.welcome-text {
  display: block;
  width: 100%;
  overflow-wrap: break-word;
  color: rgba(50, 50, 50, 1);
  font-size: 16px;
  font-family: NotoSansHans-Medium;
  font-weight: 500;
  text-align: left;
  line-height: 30px;
}

.example-questions {
  width: 357px;
  height: 136px;
  overflow-wrap: break-word;
  color: rgba(108, 142, 251, 1);
  font-size: 16px;
  font-family: NotoSansHans-Medium;
  font-weight: 500;
  text-align: left;
  line-height: 30px;
}

.example-questions a {
  color: rgba(108, 142, 251, 1);
  text-decoration: none;
  font-size: 16px;
  font-family: NotoSansHans-Medium;
  font-weight: 500;
  text-align: left;
  line-height: 30px;
  outline: none;
  cursor: pointer;
}

.message-bubble {
  display: inline-block;
  align-self: flex-end;
  min-width: 56px;
  max-width: 100%;
  /* 防止极长内容溢出 */
  box-sizing: border-box;
  word-break: break-all;
  overflow-wrap: break-word;
  margin-right: 40px;
  background: #557dff;
  border-radius: 20px 20px 4px 20px;
  min-height: 40px;
  margin-top: 38px;
  line-height: 2;
  text-align: left;
  padding: 12px 24px;
  color: #fff;
  vertical-align: middle;
  font-family: NotoSansHans;
  font-weight: 400;
  font-size: 16px;
  color: #ffffff;
  line-height: 30px;
}

.message-bubble.ai-message {
  align-self: flex-start;
  margin-left: 40px;
  margin-right: auto;
  background-color: rgba(85, 125, 255, 0.1);
  border-radius: 20px 20px 20px 4px;
}

@media (max-width: 600px) {
  .message-bubble {
    max-width: 90vw;
    margin-right: 10px;
    margin-left: auto;
  }

  .message-bubble.ai-message {
    margin-left: 10px;
    margin-right: auto;
  }
}

.message-bubble.ai-message .message-text {
  color: rgba(85, 125, 255, 1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.input-area {
  position: static;
  width: 100%;
  padding: 15px;
  background: transparent !important;
  border-top: 1px solid rgba(235, 238, 254, 1);
  gap: 16px;
}

.voice-input {
  background-color: rgba(255, 255, 255, 1);
  border-radius: 50%;
  height: 54px;
  width: 54px;
  cursor: pointer;
}

.voice-icon {
  width: 18px;
  height: 22px;
  margin: 16px 0 0 18px;
}

.input-box {
  background-color: rgba(255, 255, 255, 1);
  border-radius: 27px;
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}

.message-input {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: rgba(110, 110, 110, 1);
  font-family: NotoSansHans-Regular;
}

.message-input::placeholder {
  color: rgba(110, 110, 110, 1);
}

.send-btn {
  background-color: rgba(85, 125, 255, 1);
  border-radius: 22px;
  height: 44px;
  width: 85px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease-out;
}

.send-btn:hover {
  background-color: rgba(85, 125, 255, 0.8);
}

.send-text {
  color: rgba(255, 255, 255, 1);
  font-size: 16px;
  font-family: NotoSansHans-Regular;
  font-weight: normal;
  text-align: center;
}

.chat-item,
.welcome-content,
.input-area,
.message-bubble.flex-col {
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-break: break-all;
}

/* 收起时的样式 */
.chat-main.sidebar-collapsed .sidebar {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: none !important;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s;
  will-change: width, min-width, padding;
  position: relative;
}

.chat-main.sidebar-collapsed .toggle-btn {
  position: absolute;
  left: 0 !important;
  top: 50%;
  transform: translateY(-50%);
  margin-top: 0 !important;
}

.chat-main.sidebar-collapsed .chat-area {
  margin-left: 0 !important;
}

/* 展开收起按钮旋转动画 */
.toggle-icon {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-main.sidebar-collapsed .toggle-icon {
  transform: rotate(180deg);
}

.toggle-btn {
  cursor: pointer;
  z-index: 10;
  transition: left 0.3s;
  top: 50%;
  transform: translateY(-50%);
  margin-top: 0 !important;
  position: absolute;
  left: 285px  !important;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 0px;
}

/* 移动端适配样式 */
@media (max-width: 768px) {
  .chat-container {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
  }

  .chat-wrapper {
    width: 100%;
    height: 100%;
    padding: 0;
  }

  .chat-main {
    width: 100% !important;
    height: 100% !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  .sidebar {
    position: absolute !important;
    left: -280px !important;
    top: 0 !important;
    z-index: 1000 !important;
    transition: left 0.3s ease !important;
    background-color: rgba(244, 247, 254, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    width: 280px !important;
    height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }

  .chat-main.sidebar-collapsed .sidebar {
    left: 0 !important;
  }

  .chat-area {
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
  }

  .chat-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 15px !important;
    padding-bottom: 10px !important;
  }

  .input-area {
    position: static !important;
    width: 100% !important;
    padding: 10px 15px !important;
    min-height: 60px !important;
    background: #fff !important;
    border-top: 1px solid rgba(235, 238, 254, 1) !important;
  }

  .message-bubble {
    max-width: 85% !important;
    margin-bottom: 10px !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
  }

  .message-bubble.ai-message {
    margin-left: 0 !important;
    margin-right: auto !important;
    background-color: rgba(85, 125, 255, 0.1) !important;
    color: #557dff !important;
    border-radius: 18px 18px 18px 4px !important;
  }

  .welcome-message {
    margin-bottom: 20px !important;
    padding: 15px !important;
  }

  .welcome-text {
    font-size: 14px !important;
    line-height: 1.5 !important;
  }

  .example-questions {
    font-size: 13px !important;
    line-height: 1.6 !important;
  }

  .example-questions a {
    font-size: 13px !important;
    line-height: 1.6 !important;
  }

  .toggle-btn {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    z-index: 1001 !important;
    width: 40px !important;
    height: 40px !important;
    background: rgba(85, 125, 255, 0.9) !important;
    border-radius: 50% !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2) !important;
    cursor: pointer !important;
  }

  .toggle-icon {
    width: 15px !important;
    height: 15px !important;
    margin: 0 !important;
    margin-top: 2px !important;
    margin-right: 3px !important;
    filter: brightness(0) invert(1) !important;
  }

  .chat-main.sidebar-collapsed .toggle-icon {
    transform: rotate(180deg) !important;
  }

  .ai-avatar {
    width: 80px !important;
    height: 95px !important;
    margin: 20px auto 15px !important;
  }

  .sidebar-title {
    font-size: 20px !important;
    margin: 10px auto 20px !important;
    text-align: center !important;
  }

  .new-chat {
    margin: 20px 15px 15px !important;
    height: 45px !important;
  }

  .new-chat-btn {
    height: 45px !important;
    border-radius: 22px !important;
  }

  .new-chat-text {
    font-size: 16px !important;
  }

  .chat-list-title {
    margin: 15px 15px 10px !important;
    font-size: 14px !important;
  }

  .chat-history {
    margin: 0 10px !important;
    max-height: calc(100vh - 300px) !important;
  }

  .chat-item {
    margin-bottom: 8px !important;
    padding: 8px 12px !important;
    border-radius: 12px !important;
    display: none;
    
  }

  .chat-item-text {
    font-size: 13px !important;
    line-height: 1.3 !important;
  }

  .load-more {
    margin: 10px 15px !important;
    font-size: 12px !important;
  }

  .message-input {
    font-size: 14px !important;
    padding: 8px 12px !important;
  }

  .send-btn {
    padding: 8px 15px !important;
    border-radius: 18px !important;
  }

  .send-text {
    font-size: 14px !important;
  }

  .voice-input {
    margin-right: 10px !important;
  }
  /* 防止移动端输入时页面缩放 */
  input[type="text"], 
  input[type="email"], 
  input[type="password"], 
  textarea {
    font-size: 16px !important;
  }

  /* 移动端触摸优化 */
  .chat-item,
  .send-btn,
  .voice-input,
  .new-chat-btn,
  .clear-icon {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* 移动端滚动优化 */
  .chat-messages,
  .chat-history {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  /* 移动端安全区域适配 */
  @supports (padding: max(0px)) {
    .chat-container {
      padding-left: max(0px, env(safe-area-inset-left));
      padding-right: max(0px, env(safe-area-inset-right));
      padding-top: max(0px, env(safe-area-inset-top));
      padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
  }
}

/* 超小屏幕适配 */
@media (max-width: 480px) {
  .message-bubble {
    max-width: 90% !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
  }

  .welcome-text {
    font-size: 13px !important;
  }

  .example-questions {
    font-size: 12px !important;
  }

  .example-questions a {
    font-size: 12px !important;
  }

  .toggle-btn {
    top: 15px !important;
    left: 15px !important;
    width: 35px !important;
    height: 35px !important;
  }

  .toggle-icon {
    width: 18px !important;
    height: 18px !important;
  }

  .input-area {
    padding: 8px 12px !important;
    min-height: 55px !important;
  }

  .message-input {
    font-size: 13px !important;
    padding: 6px 10px !important;
  }

  .send-btn {
    padding: 6px 12px !important;
  }

  .send-text {
    font-size: 13px !important;
  }
}

/* 横屏模式适配 */
@media (max-width: 768px) and (orientation: landscape) {
  .chat-main {
    flex-direction: row !important;
  }

  .sidebar {
    width: 250px !important;
    left: -250px !important;
  }

  .chat-main.sidebar-collapsed .sidebar {
    left: 0 !important;
  }

  .chat-area {
    flex: 1 !important;
  }

  .input-area {
    min-height: 50px !important;
    padding: 8px 12px !important;
  }

  .chat-messages {
    padding: 10px !important;
  }

  .welcome-message {
    margin-bottom: 15px !important;
    padding: 10px !important;
  }
}