/**
 * 侧边栏样式
 */

/* 推文翻译按钮样式 */
.fluentx-translate-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  margin: 8px 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.fluentx-translate-button:hover {
  background: linear-gradient(135deg, #5568d3 0%, #6a3d8f 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.fluentx-translate-button:active {
  transform: translateY(0);
}

.fluentx-translate-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 推文翻译结果显示区域 */
.fluentx-translation-result {
  margin-top: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: 12px;
  border: 1px solid #fbbf24;
  font-size: 15px;
  line-height: 1.6;
  color: #1f2937;
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(251, 191, 36, 0.15);
}

.fluentx-translation-result.loading {
  color: #536471;
  font-style: italic;
}

.fluentx-translation-result.error {
  border-left-color: #f4212e;
  color: #f4212e;
}

:root {
  /* 由脚本计算：= 主内容区域的右边界像素值 */
  --x-helper-left: auto;
  /* 统一的背景灰色 */
  --bg-gray: #f5f5f5;
}

.x-tweet-helper-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--x-helper-left);
  width: auto; /* 占据从 left 到 viewport 右侧的全部空间 */
  height: 100vh;
  background: white;
  border-left: 1px solid rgb(239, 243, 244);
  z-index: 1; /* 设置为 1，高于主内容(z-index: 0)，但低于 Messages 等弹窗 */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: left 0.3s ease, width 0.3s ease;
  pointer-events: auto;
}

/* 不再通过 margin 推页面，改为动态计算 left，因此无需设置 html/body margin */

.x-tweet-helper-sidebar.minimized {
  left: auto;
  width: 60px;
}

.x-tweet-helper-sidebar.minimized .sidebar-content {
  display: none;
}

.x-tweet-helper-sidebar.minimized .sidebar-title span:last-child {
  display: none;
}

/* 头部 */
.sidebar-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

/* 更新通知 */
.update-notification {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.update-text {
  font-weight: 500;
}

.update-link {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 12px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  text-decoration: none;
}

.update-link:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
}

.sidebar-title-clickable {
  cursor: pointer;
  transition: opacity 0.2s;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 6px;
}

.sidebar-title-clickable:hover {
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.version-badge {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.9;
  margin-left: 4px;
}

.sidebar-icon {
  font-size: 20px;
}

.sidebar-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 内容区域 */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: var(--bg-gray);
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* 欢迎消息 */
/* 核心功能卡片：突出显示 */
.main-feature-card {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
  border: 2px solid #667eea;
  border-radius: 12px;
  padding: 24px 20px;
  margin: 20px 16px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.welcome-message {
  text-align: center;
}

.welcome-title-main {
  font-size: 18px;
  font-weight: 700;
  color: #667eea;
  margin: 0 0 12px 0;
  line-height: 1.4;
}

.welcome-text-main {
  font-size: 14px;
  color: #4b5563;
  margin: 0;
  line-height: 1.6;
}

/* 分隔线 */
.feature-divider {
  display: flex;
  align-items: center;
  margin: 24px 16px;
  position: relative;
}

.feature-divider::before,
.feature-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.divider-text {
  padding: 0 12px;
  color: #9ca3af;
  font-size: 13px;
  background: white;
}

/* 加载状态 */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #6b7280;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-gray);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 错误状态 */
.error-container {
  text-align: center;
  padding: 40px 20px;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-message {
  color: #ef4444;
  margin-bottom: 20px;
  line-height: 1.6;
}

.retry-button {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.retry-button:hover {
  background: #5568d3;
}

/* 结果容器 */
.result-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 章节标题 */
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 翻译区域 */
/* 摘要区域 */
.summary-section {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-left: 3px solid #0ea5e9;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.summary-content {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #0c4a6e;
  line-height: 1.6;
  font-size: 14px;
}

.summary-icon {
  flex-shrink: 0;
  font-size: 16px;
  margin-top: 2px;
}

.summary-text {
  flex: 1;
  font-weight: 500;
}

/* 翻译区域 */
.translation-section {
  background: var(--bg-gray);
  padding: 16px;
  border-radius: 8px;
}

.translation-content {
  color: #374151;
  line-height: 1.6;
  font-size: 14px;
}

/* 加载回复区域 */
.loading-replies-section {
  margin-top: 20px;
}

.loading-replies-section .loading-container {
  padding: 40px 20px;
}

/* 回复建议区域 */
.suggestions-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 带按钮的标题区域 */
.section-header-with-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header-with-button .section-title {
  margin: 0;
}

/* 换一批按钮 */
.refresh-replies-button {
  padding: 6px 14px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
  white-space: nowrap;
}

.refresh-replies-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.refresh-replies-button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
}

.refresh-replies-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.suggestions-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

.suggestion-card {
  background: var(--bg-gray);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
  transition: border-color 0.2s, transform 0.2s;
  animation: fadeInSlide 0.4s ease-out forwards;
  opacity: 0; /* 初始隐藏 */
}

.suggestion-card:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

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

.suggestion-label {
  font-size: 13px;
  font-weight: 600;
  color: #667eea;
}

.copy-button {
  background: #667eea;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.2s;
}

.copy-button:hover {
  background: #5568d3;
}

.suggestion-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion-original {
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  font-weight: 500;
}

.suggestion-translation {
  color: #6b7280;
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  margin-top: 4px;
}

/* 自定义回复区域 */
.custom-reply-section {
  background: var(--bg-gray);
  padding: 16px;
  border-radius: 8px;
}

.custom-reply-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.custom-reply-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 自定义回复按钮容器 */
.custom-reply-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.translate-button,
.chat-button {
  flex: 1;
  background: #667eea;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.translate-button:hover:not(:disabled),
.chat-button:hover:not(:disabled) {
  background: #5568d3;
}

.translate-button:disabled,
.chat-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* 聊天按钮特殊样式 */
.chat-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.chat-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
}

.custom-reply-result {
  margin-top: 12px;
  padding: 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

/* 默认翻译区域 */
/* 辅助功能区域：视觉上弱化 */
.default-translation-section {
  margin: 0 16px 20px 16px;
  background: #f9fafb;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.section-title-secondary {
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  margin: 0 0 12px 0;
}

.default-translation-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.default-translation-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.default-translation-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.default-translate-button {
  flex: 1;
  background: #667eea;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.default-translate-button:hover:not(:disabled) {
  background: #5568d3;
}

.default-translate-button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.default-translation-result {
  margin-top: 12px;
  padding: 12px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.default-translation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.default-translation-label {
  font-weight: 500;
  color: #374151;
  font-size: 13px;
}

.default-translation-text {
  color: #374151;
  line-height: 1.6;
  font-size: 14px;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.custom-reply-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.custom-reply-text {
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
}

/* 响应式调整 */
/* 宽度由 left 自动决定，无需响应式 margin 规则 */

/* 小屏幕时，侧边栏可以完全隐藏 */
@media (max-width: 768px) {
  .x-tweet-helper-sidebar.minimized {
    width: 0;
    border: none;
  }
}

/* 
 * 确保 X 的 Messages 抽屉等弹窗始终在侧边栏之上
 * 侧边栏是 z-index: 1，所以这些弹窗需要更高的层级
 */
.r-173mn98.css-175oi2r[data-testid="DMDrawer"],
div[data-testid="DMDrawer"],
[role="dialog"],
[aria-modal="true"],
div[data-testid*="Drawer"],
div[data-testid*="Modal"] {
  z-index: 1000 !important;
}

