@use "sass:color";

/* 颜色变量定义 */
$mountain-green: #5d8c5a;
$primary-blue: #42a5f5;
$light-yellow: #fff9e6;
$light-green-border: #c8e6c9;

.chat-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 350px;
  max-width: 90%;
  height: 500px;
  background: $light-yellow; /* 淡黄色背景 */
  border: 2px solid $light-green-border; /* 淡绿色边框 */
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  animation: fadeInUp 0.3s ease-out forwards;

  /* 确保在最上层 */
  &:not(:defined) {
    display: none;
  }
}

/* 头部样式 */
.chat-header {
  background: linear-gradient(
    90deg, 
    $mountain-green, 
    color.adjust($mountain-green, $lightness: -10%)
  );
  color: white;
  padding: 15px;
  display: flex;
  align-items: center;
  position: relative;

  i {
    font-size: 1.2rem;
    margin-right: 10px;
  }

  h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
  }

  .close-btn {
    position: absolute;
    right: 15px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s;

    &:hover {
      transform: scale(1.1);
    }
  }
}

/* 消息区域 */
.chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  background: $light-yellow; /* 淡黄色背景 */

  .message {
    display: flex;
    margin-bottom: 15px;
    transition: transform 0.3s ease;

    &:hover {
      transform: translateX(5px);
    }

    /* 用户消息气泡 */
    &.user {
      justify-content: flex-end;
      
      .content {
        background: $primary-blue; /* 蓝色气泡 */
        color: white;
        border-radius: 15px 15px 0 15px;
        box-shadow: 0 2px 5px rgba($primary-blue, 0.3);
      }
    }

    /* AI消息气泡 */
    &.assistant {
      justify-content: flex-start;
      
      .content {
        background: white;
        color: #333;
        border-radius: 15px 15px 15px 0;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        border: 1px solid #eee;
      }
    }

    .avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: #f5f5f5;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0 10px;
      flex-shrink: 0;

      i {
        color: $mountain-green;
      }
    }

    .content {
      max-width: 70%;
      padding: 10px 15px;
      
      .text {
        white-space: pre-wrap;
        line-height: 1.4;
        font-size: 0.9rem;
      }
    }
  }
}

/* 输入区域 */
.chat-input {
  display: flex;
  padding: 10px;
  border-top: 1px solid #eee;
  background: white;

  input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 30px;
    outline: none;
    font-size: 0.9rem;
    transition: all 0.3s;

    &:focus {
      border-color: $primary-blue;
      box-shadow: 0 0 0 2px rgba($primary-blue, 0.2);
    }
  }

  button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: $mountain-green;
    color: white;
    border: none;
    margin-left: 10px;
    cursor: pointer;
    transition: all 0.3s;

    &:hover {
      background: color.adjust($mountain-green, $lightness: -10%);
    }

    &:disabled {
      background: #ccc;
      cursor: not-allowed;
    }
  }
}

/* 动画 */
@keyframes fadeInUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}