.ai-search-button {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background-color: #1a73e8;
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 9999;
  transition: all 0.2s ease;
  opacity: 0.9;
}

.ai-search-button:hover {
  transform: scale(1.1);
  opacity: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ai-search-button img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.ai-floating-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background-color: #1a73e8;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9998;
  transition: all 0.3s ease;
}

.ai-floating-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.ai-floating-button img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.ai-search-result {
  position: fixed;
  top: 20px;
  right: 20px;
  transform: none;
  width: 700px;
  height: 550px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 999999;
  overflow: hidden;
}

.ai-search-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1a73e8;
  color: white;
  border-radius: 8px 8px 0 0;
  font-weight: 500;
  min-height: 24px;
  flex-shrink: 0;
}

.ai-search-result-close {
  cursor: pointer;
  font-size: 20px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
  color: white;
}

.ai-search-result-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.ai-search-result-content-wrapper {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ai-search-result-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  color: #333;
  background: #fff;
  height: calc(100% - 150px);
  box-sizing: border-box;
}

.ai-search-result-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.ai-search-result-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.ai-search-result-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.ai-search-result-content::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.ai-search-result-content p,
.ai-search-result-content pre,
.ai-search-result-content blockquote,
.ai-search-result-content ul,
.ai-search-result-content ol {
  max-width: 100%;
  margin: 8px 0;
  box-sizing: border-box;
}

/* 修复不同元素之间的间距问题 */
.markdown-body p {
  margin-top: 0;
  margin-bottom: 10px;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body pre,
.markdown-body ul,
.markdown-body ol,
.markdown-body table {
  margin-top: 10px;
  margin-bottom: 10px;
}

/* 确保相邻元素之间没有多余空白 */
.markdown-body p + pre,
.markdown-body pre + p,
.markdown-body p + ul,
.markdown-body ul + p,
.markdown-body p + ol,
.markdown-body ol + p,
.markdown-body p + table,
.markdown-body table + p {
  margin-top: 10px;
}

/* 修复表格和代码块在结尾处的多余空白 */
.markdown-body table:last-child,
.markdown-body pre:last-child {
  margin-bottom: 0;
}

/* 确保最后一个元素没有底部边距 */
.markdown-body > *:last-child {
  margin-bottom: 0;
}

.ai-search-result-content img {
  max-width: 100%;
  height: auto;
}

.ai-search-result-content pre {
  white-space: pre;
  word-break: break-all;
  overflow-x: auto;
  min-width: 100px;
  max-width: 100%;
}

.ai-search-result-content code {
  white-space: pre-wrap;
  word-break: break-all;
}

.ai-search-result-content {
  white-space: pre-wrap; /* 确保内容中的换行符被保留 */
}

.ai-search-result-content h1 {
  font-size: 1.5em;
  margin-top: 16px;
  margin-bottom: 12px;
}

.ai-search-result-content h2 {
  font-size: 1.3em;
  margin-top: 14px;
  margin-bottom: 10px;
}

.ai-search-result-content h3 {
  font-size: 1.1em;
  margin-top: 12px;
  margin-bottom: 8px;
}

.ai-search-result-content p {
  margin-top: 0;
  margin-bottom: 12px;
}

.ai-search-result-content ul,
.ai-search-result-content ol {
  margin-top: 0;
  margin-bottom: 12px;
  padding-left: 1.5em;
}

.ai-search-result-content li {
  margin: 3px 0;
}

.ai-search-result-content blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 4px solid #1a73e8;
  background: #f5f5f5;
}

.ai-search-result-content table {
  border-collapse: collapse;
  min-width: max-content;
  width: auto;
  margin: 8px 0;
  background: #fff;
}

.ai-search-result-content th, .ai-search-result-content td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
  font-size: 14px;
  word-break: break-all;
  white-space: normal;
  min-width: 100px;
  max-width: 220px;
}

.ai-search-result-content th {
  background: #f5f5f5;
  font-weight: bold;
}

.ai-search-result-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  flex-direction: column;
}

.ai-search-result-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(26, 115, 232, 0.2);
  border-top: 3px solid #1a73e8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.ai-search-result-loading-text {
  margin-top: 15px;
  color: #666;
  font-size: 14px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.ai-search-result-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

.ai-search-result-error-icon {
  font-size: 32px;
  margin-bottom: 16px;
  color: #dc3545;
}

.ai-search-result-error-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #dc3545;
}

.ai-search-result-error-message {
  font-size: 14px;
  color: #666;
  margin-bottom: 16px;
  line-height: 1.5;
}

.ai-search-result-retry-button {
  padding: 8px 16px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
}

.ai-search-result-retry-button:hover {
  background-color: #0056b3;
}

.ai-search-result-buttons {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.ai-search-result-diagnostics {
  margin-top: 24px;
  width: 100%;
  max-width: 400px;
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 16px;
}

.ai-search-result-diagnostic-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 6px;
  background-color: #fff1f0;
  margin-bottom: 12px;
}

.ai-search-result-diagnostic-status {
  margin-right: 12px;
  font-size: 16px;
}

.ai-search-result-diagnostic-text {
  flex: 1;
  font-size: 14px;
  color: #333;
}

.ai-search-result-diagnostic-status.error {
  color: #ea4335;
}

.ai-search-result-online-status {
  font-size: 13px;
  color: #5f6368;
  margin-top: 16px;
  padding: 8px 12px;
  background-color: #fff;
  border-radius: 6px;
  text-align: left;
  border: 1px solid #e8eaed;
}

.ai-search-result-rating-group {
  display: flex;
  gap: 5px;
}

.ai-search-result-action-button.like-btn,
.ai-search-result-action-button.dislike-btn {
  padding: 5px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.ai-search-result-action-button.like-btn:hover {
  background-color: rgba(52, 168, 83, 0.1);
}

.ai-search-result-action-button.dislike-btn:hover {
  background-color: rgba(234, 67, 53, 0.1);
}

.ai-search-result-action-button.like-btn.active {
  background-color: rgba(52, 168, 83, 0.2);
  color: #34a853;
}

.ai-search-result-action-button.dislike-btn.active {
  background-color: rgba(234, 67, 53, 0.2);
  color: #ea4335;
}

.ai-search-result-format-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 10px;
}

/* 基础颜色定义 */
:root {
  --primary-color: #1a73e8;
  --primary-hover: #0d66da;
}

.ai-search-result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  background: #f8f9fa;
  height: 50px;
  box-sizing: border-box;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
}

.ai-search-result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-search-result-format-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-search-result-format-toggle label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #666;
}

.ai-search-result-format-toggle input[type="radio"] {
  margin: 0;
}

.ai-search-result-action-button {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  color: #333;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.ai-search-result-action-button:hover {
  background: #f0f0f0;
}

.ai-search-result-action-button.active {
  background: #e3f2fd;
  border-color: #1a73e8;
  color: #1a73e8;
}

.ai-search-result-rating-group {
  display: flex;
  gap: 8px;
}

.like-btn, .dislike-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.like-btn:hover, .dislike-btn:hover {
  background: #f0f0f0;
}

.like-btn.active {
  background: #e8f5e9;
  border-color: #4caf50;
  color: #4caf50;
}

.dislike-btn.active {
  background: #fbe9e7;
  border-color: #f44336;
  color: #f44336;
}

.ai-translation-options {
  position: absolute;
  z-index: 9999;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  padding: 12px;
  width: 220px;
  animation: fadeIn 0.2s;
}

.ai-translation-options-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
  text-align: center;
}

.ai-translation-options-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-translation-options-buttons button {
  padding: 8px 12px;
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.ai-translation-options-buttons button:hover {
  background-color: #e8e8e8;
}

.ai-search-result-network-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px;
}

.ai-search-result-network-icon {
  font-size: 32px;
  margin-bottom: 10px;
}

.ai-search-result-network-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 15px;
}

.ai-search-result-network-details {
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  width: 100%;
  margin-bottom: 15px;
  font-size: 13px;
  line-height: 1.5;
}

.ai-search-result-network-diag-btn {
  padding: 8px 16px;
  background-color: #1a73e8;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}

.ai-search-result-network-diag-btn:hover {
  background-color: #0d66da;
}

.ai-search-result-network-diag-results {
  margin-top: 15px;
  background-color: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  width: 100%;
  font-size: 13px;
}

.ai-search-result-network-diag-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #eee;
}

.ai-search-result-network-diag-status {
  font-family: monospace;
}

.ai-search-result-network-diag-status.success {
  color: #0f9d58;
}

.ai-search-result-network-diag-status.error {
  color: #d93025;
}

.ai-search-result-network-diag-browser {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #ddd;
  font-size: 12px;
  color: #666;
}

.ai-continue-ask-area {
  padding: 10px 15px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  align-items: center;
  background: #f8f9fa;
  min-height: 36px;
  user-select: text;
  width: 100%;
  box-sizing: border-box;
  position: absolute;
  bottom: 50px;
}