.ai-assistant {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1000;
}

.ai-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #e17055;
  border: none;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.ai-toggle:hover {
  transform: scale(1.05);
  background: #d35400;
}

.ai-panel {
  position: fixed;
  bottom: 100px;  /* 固定底部距离 */
  right: 30px;
  width: 380px;
  min-width: 300px;
  min-height: 500px;
  max-height: calc(100vh - 150px); /* 防止超出视窗 */
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 20px;
  display: none;
  resize: none;
  left: auto;
  height: 500px; /* 设置默认高度 */
}

.ai-panel.active {
  display: block;
  animation: slideIn 0.3s ease;
}

.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.ai-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ai-clear,
.ai-stop {
  background: none;
  border: none;
  color: #636e72;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  transition: color 0.3s ease;
}

.ai-clear:hover,
.ai-stop:hover {
  color: #e17055;
}

.ai-stop {
  color: #e17055;
}

.ai-stop:hover {
  color: #d35400;
}

.ai-title {
  font-size: 18px;
  font-weight: 600;
  color: #2d3436;
}

.ai-close {
  background: none;
  border: none;
  color: #636e72;
  cursor: pointer;
  font-size: 20px;
}

.ai-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.ai-action-btn {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e17055;
  background: transparent;
  color: #e17055;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
}

.ai-action-btn:hover {
  background: #e17055;
  color: white;
}

.ai-chat {
  overflow-y: auto;
  border-radius: 8px;
  background: #f8f9fa;
  height: calc(100% - 200px); /* 调整高度，为loading预留空间 */
  transition: height 0.1s ease;
  margin-bottom: 20px; /* 添加底部间距 */
}

.ai-input-container {
  position: relative;
  margin-top: 8px; /* 添加顶部间距 */
  margin-bottom: 8px; /* 添加底部间距 */
}

.ai-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #dfe6e9;
  border-radius: 8px;
  resize: none;
  font-size: 14px;
}

.ai-input:focus {
  outline: none;
  border-color: #e17055;
}

.ai-send,
.ai-stop {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.ai-send {
  background: #e17055;
  color: white;
}

.ai-send:hover {
  background: #d35400;
}

.ai-stop {
  background: #e74c3c;
  color: white;
}

.ai-stop:hover {
  background: #c0392b;
}

.ai-send {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: #e17055;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
}

.ai-message {
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 8px;
  max-width: 85%;
  line-height: 1.6;
}

.ai-message.user {
  background: #e17055;
  color: white;
  margin-left: auto;
}

.ai-message.assistant {
  background: white;
  border: 1px solid #dfe6e9;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ai-message.ai-streaming {
  border-left: 3px solid #e17055;
  animation: blink 1s infinite;
}

.ai-message pre {
  background: #f8f9fa;
  padding: 1em;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1em 0;
}

.ai-message code {
  background: #f1f3f5;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

.ai-message h1,
.ai-message h2,
.ai-message h3 {
  margin: 1em 0 0.5em;
  color: #2d3436;
  font-weight: 600;
}

.ai-message h1 { font-size: 1.4em; }
.ai-message h2 { font-size: 1.3em; }
.ai-message h3 { font-size: 1.2em; }

.ai-message blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 4px solid #e17055;
  color: #636e72;
}

.ai-message ul {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.ai-message li {
  margin: 0.3em 0;
}

.ai-message a {
  color: #e17055;
  text-decoration: none;
  border-bottom: 1px dotted #e17055;
}

.ai-message a:hover {
  color: #d35400;
  border-bottom-style: solid;
}

.ai-message em {
  font-style: italic;
  color: inherit;
}

.ai-message strong {
  font-weight: 600;
  color: inherit;
}

.loading-indicator {
  display: none;
  text-align: center;
  color: #636e72;
  min-height: 20px; /* 设置最小高度 */
}

.loading-indicator.active {
  display: block;
}

.resize-handle {
  position: absolute;
  background: transparent;
  z-index: 1;
}

.resize-e {
  cursor: e-resize;
  width: 10px;
  height: 100%;
  right: 0;
  top: 0;
}

.resize-s {
  cursor: s-resize;
  height: 10px;
  width: 100%;
  bottom: 0;
  left: 0;
}

.resize-se {
  cursor: se-resize;
  width: 20px;
  height: 20px;
  right: 0;
  bottom: 0;
}

.resize-w {
  cursor: w-resize;
  width: 10px;
  height: 100%;
  left: 0;
  top: 0;
}

.resize-n {
  cursor: n-resize;
  height: 10px;
  width: 100%;
  top: 0;
  left: 0;
}

.resize-nw {
  cursor: nw-resize;
  width: 20px;
  height: 20px;
  left: 0;
  top: 0;
}

.ai-panel.resizing {
  user-select: none;
  cursor: inherit;
}

.ai-panel.resizing .ai-chat {
  pointer-events: none;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0% { border-left-color: #e17055; }
  50% { border-left-color: transparent; }
  100% { border-left-color: #e17055; }
}

@media (max-width: 768px) {
  .resize-handle {
    display: none; /* 在移动设备上禁用调整大小功能 */
  }
  
  .ai-panel {
    width: 90vw;
    height: auto;
    max-height: 80vh;
  }
}

.api-calls-counter {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: #636e72;
  padding: 4px 8px;
  border-radius: 4px;
  background: #f8f9fa;
}

.api-calls-counter i {
  color: #e17055;
}

.ai-message.error {
  background: #fff3f3;
  color: #e74c3c;
  border: 1px solid #fab1a0;
}
