/* DeepSeek AI助手样式 */
:root {
  --deepseek-primary: #0066ff;
  --deepseek-hover: #0052cc;
  --deepseek-bg: #1a1a2e;
  --deepseek-card: #16213e;
  --deepseek-input: #0f3460;
  --deepseek-text: #e4e4e4;
  --deepseek-border: #2d3748;
}

/* 主容器 - 左右布局 */
.deepseek-main-container {
  max-width: 1400px;
  margin: 20px auto;
  display: flex;
  gap: 20px;
  min-height: 700px;
}

/* 左侧会话列表 */
.deepseek-sidebar {
  width: 280px;
  background: var(--deepseek-card);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  align-self: stretch;
  display: flex;
  flex-direction: column;
  height: 100%; /* 确保占满父容器高度 */
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--deepseek-border);
}

.sidebar-header h3 {
  margin: 0;
  color: var(--deepseek-text);
  font-size: 15px;
  font-weight: 600;
}

.sidebar-actions {
  display: flex;
  gap: 6px;
  width: 100%;
}

.btn-new-chat, .btn-export-chat, .btn-clear-all {
  background: var(--deepseek-primary);
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s;
  flex: 1;
  white-space: nowrap;
}

.btn-export-chat {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn-clear-all {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.btn-new-chat:hover {
  background: var(--deepseek-hover);
  transform: translateY(-1px);
}

.btn-export-chat:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
}

.btn-clear-all:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 760px; /* 固定高度，不再使用flex自动伸缩 */
  overflow: hidden; /* 隐藏滚动条 */
  flex-shrink: 0; /* 防止被厊缩 */
  /* 计算：8条 × 约70px(padding+内容+边框) + 7个gap(8px) = 640px */
}

.chat-history-item {
  background: var(--deepseek-bg);
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  border: 2px solid transparent;
  position: relative;
  flex-shrink: 0; /* 防止被压缩 */
}

.chat-history-item:hover {
  background: var(--deepseek-input);
  border-color: var(--deepseek-primary);
}

.chat-history-item.active {
  border-color: var(--deepseek-primary);
  background: var(--deepseek-input);
}

.chat-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.chat-item-title {
  color: var(--deepseek-text);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  flex: 1;
  padding-right: 8px;
}

.chat-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chat-item-time {
  color: #718096;
  font-size: 12px;
  flex-shrink: 0;
}

.chat-item-tokens {
  color: #48bb78;
  font-size: 11px;
  background: rgba(72, 187, 120, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.chat-item-delete {
  color: #ff4444;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.3s;
  cursor: pointer;
  padding: 0 4px;
}

.chat-history-item:hover .chat-item-delete {
  opacity: 1;
}

.empty-history {
  text-align: center;
  color: #718096;
  padding: 40px 10px;
  font-size: 14px;
}

/* 翻页按钮容器 */
.pagination-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  margin-top: auto; /* 自动推到底部 */
  border-top: 1px solid var(--deepseek-border);
  flex-shrink: 0; /* 防止被压缩 */
}

/* 翻页按钮 */
.pagination-btn {
  flex: 1;
  background: linear-gradient(135deg, rgba(0, 102, 255, 0.15) 0%, rgba(0, 82, 204, 0.1) 100%);
  color: var(--deepseek-primary);
  border: 1px solid rgba(0, 102, 255, 0.3);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s;
  font-weight: 500;
  white-space: nowrap;
}

.pagination-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(0, 102, 255, 0.25) 0%, rgba(0, 82, 204, 0.2) 100%);
  border-color: var(--deepseek-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 102, 255, 0.3);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #718096;
}

/* 页码信息 */
.pagination-info {
  color: var(--deepseek-text);
  font-size: 13px;
  font-weight: 500;
  padding: 0 8px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 导出菜单 */
.export-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.export-menu {
  background: linear-gradient(135deg, #1a1f3a 0%, #0f1419 100%);
  border-radius: 20px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.export-menu-header {
  text-align: center;
  margin-bottom: 25px;
}

.export-menu-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.export-menu-title {
  color: white;
  font-size: 24px;
  font-weight: 600;
  margin: 0;
}

.export-menu-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-option {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 15px;
}

.export-option:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--deepseek-primary);
  transform: translateY(-2px);
}

.export-option-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.export-option-info {
  flex: 1;
}

.export-option-title {
  color: white;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.export-option-desc {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.export-menu-footer {
  margin-top: 20px;
  text-align: center;
}

.export-cancel-btn {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.export-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* 右侧主体 */
.deepseek-main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.deepseek-container {
  max-width: 1200px;
  margin: 0;
  background: var(--deepseek-bg);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 900px; /* 锁定高度为900px，与左侧对齐 */
  flex-shrink: 0; /* 防止被压缩 */
}

.deepseek-header {
  background: linear-gradient(135deg, var(--deepseek-primary) 0%, #0052cc 100%);
  padding: 25px 30px;
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.deepseek-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: white;
}

.deepseek-stats {
  display: flex;
  gap: 20px;
}

/* 公告滚动区域 */
.deepseek-notice {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.12);
  padding: 8px 16px;
  border-radius: 20px;
  max-width: 500px;
  margin: 0 20px;
  overflow: hidden;
}

.notice-icon {
  font-size: 18px;
  flex-shrink: 0;
  animation: pulse-notice 2s infinite;
}

@keyframes pulse-notice {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.notice-content {
  flex: 1;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 500;
}

.notice-content marquee {
  color: white;
  font-weight: 500;
}

.stat-item {
  background: rgba(255,255,255,0.15);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat-label {
  opacity: 0.9;
}

.stat-value {
  font-weight: 600;
  font-size: 16px;
}

.deepseek-role-selector {
  background: var(--deepseek-card);
  padding: 20px 30px;
  border-bottom: 1px solid var(--deepseek-border);
}

.deepseek-role-selector label {
  color: var(--deepseek-text);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  display: block;
  letter-spacing: 0.3px;
}

.deepseek-role-select {
  width: 100%;
  padding: 14px 40px 14px 18px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  border: 2px solid transparent;
  border-radius: 12px;
  color: var(--deepseek-text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.deepseek-role-select:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.12) 100%);
  border-color: rgba(102, 126, 234, 0.3);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
  transform: translateY(-1px);
}

.deepseek-role-select:focus {
  outline: none;
  border-color: var(--deepseek-primary);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15), 0 4px 16px rgba(102, 126, 234, 0.25);
  transform: translateY(-1px);
}

.deepseek-role-select option {
  background: var(--deepseek-card);
  color: var(--deepseek-text);
  padding: 12px;
  font-weight: 500;
}

/* option中的简介部分样式 */
.deepseek-role-select option[data-short-name] {
  padding: 12px 16px;
  line-height: 1.6;
}

/* 为带简介的option添加更好的间距 */
.deepseek-role-select option:not(:first-child) {
  border-top: 1px solid rgba(102, 126, 234, 0.1);
}

.deepseek-chat-area {
  flex: 1; /* 自动填满剩余空间 */
  overflow-y: auto; /* 显示垂直滚动条 */
  padding: 20px 30px;
  background: var(--deepseek-bg);
  min-height: 0; /* 允许flex子项正常缩小 */
}

.deepseek-chat-area::-webkit-scrollbar {
  width: 8px;
}

.deepseek-chat-area::-webkit-scrollbar-track {
  background: var(--deepseek-card);
}

.deepseek-chat-area::-webkit-scrollbar-thumb {
  background: var(--deepseek-border);
  border-radius: 4px;
}

.deepseek-chat-area::-webkit-scrollbar-thumb:hover {
  background: #4a5568;
}

.chat-message {
  margin-bottom: 20px;
  display: flex;
  gap: 15px;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--deepseek-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  flex-shrink: 0;
}

.chat-message.assistant .message-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message-content {
  max-width: 70%;
  background: var(--deepseek-card);
  padding: 15px 18px;
  border-radius: 12px;
  color: var(--deepseek-text);
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-message.user .message-content {
  background: var(--deepseek-primary);
  color: white;
}

.message-image {
  max-width: 200px;
  border-radius: 8px;
  margin-top: 10px;
}

.message-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  margin-top: 8px;
  font-size: 13px;
}

/* TTS朗读按钮样式 */
.tts-button {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  z-index: 10;
}

.tts-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.tts-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tts-button.speaking {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(245, 87, 108, 0.3);
  }
  50% {
    box-shadow: 0 4px 16px rgba(245, 87, 108, 0.6);
  }
}

/* 调整聊天消息容器以适应按钮 */
.chat-message.assistant {
  position: relative;
  padding-bottom: 40px;
}

/* AI消息后广告位样式 */
.ai-message-ad {
  width: 100%;
  margin: 15px 0;
  padding: 15px;
  background: var(--deepseek-card);
  border-radius: 12px;
  border: 1px solid var(--deepseek-border);
  text-align: center;
  animation: fadeIn 0.3s ease-in;
}

.ai-message-ad img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.ai-message-ad a {
  color: var(--deepseek-primary);
  text-decoration: none;
  transition: opacity 0.3s;
}

.ai-message-ad a:hover {
  opacity: 0.8;
}

/* AI消息内嵌广告样式（在对话框内部） */
.message-ad-inline {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
}

.message-ad-inline img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin-top: 8px;
}

.message-ad-inline a {
  color: #667eea;
  text-decoration: none;
  transition: opacity 0.3s;
  font-weight: 500;
}

.message-ad-inline a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.deepseek-input-area {
  background: var(--deepseek-card);
  padding: 20px 30px;
  border-top: 1px solid var(--deepseek-border);
  flex-shrink: 0; /* 防止被压缩，固定在底部 */
}

.deepseek-upload-preview {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.upload-item {
  position: relative;
  display: inline-block;
}

.upload-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--deepseek-border);
}

.upload-item-file {
  padding: 10px 15px;
  background: var(--deepseek-input);
  border-radius: 8px;
  border: 2px solid var(--deepseek-border);
  color: var(--deepseek-text);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  background: #ff4444;
  border-radius: 50%;
  border: 2px solid var(--deepseek-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  transition: all 0.2s;
}

.upload-remove:hover {
  background: #cc0000;
  transform: scale(1.1);
}

.deepseek-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.deepseek-textarea {
  flex: 1;
  background: var(--deepseek-input);
  border: 1px solid var(--deepseek-border);
  border-radius: 12px;
  padding: 12px 15px;
  color: var(--deepseek-text);
  font-size: 14px;
  resize: none;
  min-height: 50px;
  max-height: 150px;
  transition: all 0.3s;
}

.deepseek-textarea:focus {
  outline: none;
  border-color: var(--deepseek-primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.deepseek-toolbar {
  display: flex;
  gap: 10px;
}

.deepseek-btn {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.deepseek-btn-upload {
  background: var(--deepseek-input);
  color: var(--deepseek-text);
  border: 1px solid var(--deepseek-border);
}

.deepseek-btn-upload:hover {
  background: var(--deepseek-border);
}

.deepseek-btn-search {
  background: var(--deepseek-input);
  color: var(--deepseek-text);
  border: 1px solid var(--deepseek-border);
  transition: all 0.3s;
}

.deepseek-btn-search:hover {
  background: var(--deepseek-border);
}

.deepseek-btn-search.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.deepseek-btn-search.active:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.deepseek-btn-send {
  background: var(--deepseek-primary);
  color: white;
  min-width: 100px;
}

.deepseek-btn-send:hover:not(:disabled) {
  background: var(--deepseek-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

.deepseek-btn-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.deepseek-btn-clear {
  background: #ff4444;
  color: white;
}

.deepseek-btn-clear:hover {
  background: #cc0000;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #718096;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.empty-state-text {
  font-size: 16px;
  margin-bottom: 10px;
}

.empty-state-hint {
  font-size: 14px;
  opacity: 0.7;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--deepseek-primary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-10px); }
}

@media (max-width: 768px) {
  .deepseek-main-container {
    flex-direction: column;
    margin: 10px;
  }
  
  .deepseek-sidebar {
    width: 100%;
    max-height: 200px;
  }
  
  .deepseek-container {
    border-radius: 12px;
  }
  
  .deepseek-header {
    padding: 20px;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
  
  .deepseek-stats {
    width: 100%;
    justify-content: space-between;
  }
  
  .deepseek-role-selector,
  .deepseek-chat-area,
  .deepseek-input-area {
    padding: 15px 20px;
  }
  
  .deepseek-chat-area {
    height: 400px;
  }
  
  .message-content {
    max-width: 85%;
  }
  
  .deepseek-input-wrapper {
    flex-direction: column;
  }
  
  .deepseek-toolbar {
    width: 100%;
    justify-content: space-between;
  }
}
