/* 全局变量 - 亮色主题 */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --bg-hover: #f1f3f4;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-tertiary: #80868b;
  --border-color: #dadce0;
  --accent-color: #1a73e8;
  --accent-hover: #1557b0;
  --success-color: #34a853;
  --warning-color: #fbbc04;
  --error-color: #ea4335;
  --shadow-sm: 0 1px 2px 0 rgba(60, 64, 67, 0.3);
  --shadow-md: 0 1px 3px 0 rgba(60, 64, 67, 0.3);
  --shadow-lg: 0 2px 6px 2px rgba(60, 64, 67, 0.15);
  --gemini-gradient: linear-gradient(135deg, #9fe6ff 0%, #b7b6ff 38%, #f0c7ff 68%, #ffdce8 100%);
  --gemini-gradient-alt: linear-gradient(135deg, #33b1ff 0%, #0f7ae5 100%);
  --user-bubble: #0f7ae5;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-width: 280px;
}

/* 暗色主题 */
[data-theme="dark"] {
  --bg-primary: #1f1f1f;
  --bg-secondary: #2a2a2a;
  --bg-tertiary: #353535;
  --bg-hover: #3a3a3a;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-tertiary: #5f6368;
  --border-color: #3c4043;
  --accent-color: #8ab4f8;
  --accent-hover: #aecbfa;
  --success-color: #81c995;
  --warning-color: #fdd663;
  --error-color: #f28b82;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 2px 6px 2px rgba(0, 0, 0, 0.15);
  --gemini-gradient: linear-gradient(135deg, #7fd2ff 0%, #9b91ff 38%, #d8a8ff 68%, #ffbdd4 100%);
  --gemini-gradient-alt: linear-gradient(135deg, #1a9cff 0%, #2563eb 60%, #3b82f6 100%);
  --user-bubble: #2563eb;
}

/* 基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Google Sans", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  transition: background-color 0.3s, color 0.3s;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar.hidden {
  width: 0;
  min-width: 0;
  max-width: 0;
  border-right: none;
  opacity: 0;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}

.sidebar-header {
  padding: 16px 12px;
}

.new-chat-btn {
  width: 100%;
  padding: 6px 12px;
  font-size: 0.875rem;
  border: none;
  background-color: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
  color: var(--text-primary);
}

.new-chat-btn:hover {
  background-color: color-mix(in srgb, #d3e3fd 80%, transparent);
  color: #0842a0;
  border-radius: var(--radius-lg);
}

.new-chat-btn svg {
  font-size: 0.875rem;
  width: 20px;
  height: 20px;
}

.conversation-list-header {
  padding: 8px 24px;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conversation-item {
  padding: 4px 16px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conversation-item:hover {
  background-color: color-mix(in srgb, #d3e3fd 80%, transparent);
}

.conversation-item.active {
  background-color: #c2e7ff;
  font-weight: 600;
}

.conversation-title {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item:hover .conversation-title {
  color: #0842a0;
}

[data-theme="dark"] .conversation-item.active .conversation-title {
  color: #0842a0;
}

.conversation-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.conversation-item:hover .conversation-actions {
  opacity: 1;
}

.conversation-delete {
  padding: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.conversation-delete:hover {
  background-color: var(--error-color);
  color: white;
}

.conversation-delete svg {
  width: 1rem;
  height: 1rem;
}

.sidebar-footer {
  padding: 16px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-tertiary);
}

.status-indicator.online .status-dot {
  background-color: var(--success-color);
}

.status-indicator.warning .status-dot {
  background-color: var(--warning-color);
}

.status-indicator.error .status-dot {
  background-color: var(--error-color);
}

.version-info {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 4px 8px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

/* 顶部栏 */
.top-bar {
  height: 64px;
  padding: 0 36px;
  display: flex;
  align-items: center;
  gap: 16px;
  background-color: var(--bg-primary);
}

.sidebar-toggle {
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  background-color: var(--bg-hover);
}

.top-bar-title {
  flex: 1;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
}

.top-bar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.theme-toggle .sun-icon {
  display: none;
}

.theme-toggle .moon-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: none;
}

/* 聊天区域 */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 36px;
}

.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

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

.welcome-content h1 {
  font-size: 48px;
  font-weight: 400;
  margin-bottom: 16px;
  background: var(--gemini-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-content p {
  font-size: 18px;
  color: var(--text-secondary);
}

.messages-container {
  width: 100%;
  margin: 0 auto;
  padding: 0 16px;
  overflow-x: hidden;
}

.message {
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

/* 用户消息 - 右对齐 */
.message.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* 助手消息 - 左对齐 */
.message.assistant {
  flex-direction: row;
  justify-content: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 500;
  margin-top: 4px;
}

.message.user .message-avatar {
  background: var(--gemini-gradient-alt);
  color: white;
}

.message.assistant .message-avatar {
  background: var(--gemini-gradient);
  color: white;
}

.message-content {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-bubble {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  box-sizing: border-box;
  min-height: 32px;
  padding: 8px 16px;
  gap: 6px;
}

/* 用户消息气泡 */
.message.user .message-bubble {
  background: var(--user-bubble);
  color: white;
  border-radius: 26px 4px 26px 26px;
  align-self: flex-end;
}

/* 助手消息气泡 */
.message.assistant .message-bubble {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 4px 26px 26px 26px;
  align-self: flex-start;
}

[data-theme="dark"] .message.assistant .message-bubble {
  background: var(--bg-tertiary);
}

/* 用户消息文件信息气泡 - 独立显示在消息下方 */
.message.user .file-info-bubble {
  color: var(--text-primary);
  border-radius: 16px;
  padding: 10px 14px;
}

/* 文件信息气泡内的附件列表不需要额外的上边距 */
.file-info-bubble .message-attachments {
  margin-top: 0;
}

/* 兼容旧格式的文件信息样式 */
.file-info-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-info-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-info-icon {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.file-info-name {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
}

/* 错误消息气泡 */
.error-message-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.error-message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.error-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--error-color);
}

.error-title {
  color: var(--text-primary);
  font-weight: 400;
}

.error-message-detail {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-left: 28px;
  font-style: italic;
}

.message-text {
  font-size: 15px;
  line-height: 1.6;
  /* white-space: pre-wrap; */
  word-wrap: break-word;
}

.message-hint {
  font-size: 13px;
  color: var(--text-secondary);
}

.message.user .message-hint {
  color: rgba(255, 255, 255, 0.85);
}

.message-attachments {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  width: 100%;
}

.attachment-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.attachment-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.attachment-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.attachment-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.message.user .attachment-icon {
  color: rgba(255, 255, 255, 0.85);
}

.message.user .attachment-name {
  color: white;
}

.message.user .attachment-meta {
  color: rgba(255, 255, 255, 0.85);
}

.message-images {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.message-image {
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}

.message-image:hover {
  transform: scale(1.02);
}

.message-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* 消息操作按钮 */
.message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.message-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.message-action-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.message-action-btn.copied {
  color: var(--success-color);
}

.message-action-btn svg {
  width: 16px;
  height: 16px;
}

.message-timestamp {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-tertiary);
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-10px);
  }
}

/* 输入区域 */
.input-area {
  padding: 16px 36px;
  background-color: var(--bg-primary);
}

.input-container {
  max-width: 100%;
  margin: 0 auto;
}

.file-preview {
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-preview-item {
  position: relative;
  padding: 8px 12px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.file-preview-remove {
  padding: 2px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-preview-remove:hover {
  color: var(--error-color);
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.input-wrapper:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.1);
}

.message-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 24px;
  height: 24px;
  min-height: 24px;
  padding: 14px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--text-tertiary) transparent;
  overflow-y: hidden;
}

.message-input::-webkit-scrollbar {
  width: 6px;
}

.message-input::-webkit-scrollbar-track {
  background: transparent;
}

.message-input::-webkit-scrollbar-thumb {
  background-color: var(--text-tertiary);
  border-radius: 3px;
}

.message-input::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-secondary);
}

.message-input::placeholder {
  color: var(--text-tertiary);
}

/* 输入工具栏 */
.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
}

.input-toolbar .input-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-toolbar .input-hint kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 5px;
  font-size: 11px;
  font-family: inherit;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--border-color);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 模型选择器 */
.model-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background-color: transparent;
  border: none;
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.model-selector:hover {
  background-color: var(--bg-hover);
}

.model-selector .model-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.model-selector .model-name {
  font-size: 13px;
  color: var(--text-primary);
}

.model-selector .model-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
  transition: transform 0.2s;
}

.model-selector.open .model-chevron {
  transform: rotate(180deg);
}

/* 模型下拉浮窗 */
.model-dropdown {
  position: fixed;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  max-width: 90vw;
  max-height: 400px;
  overflow-y: auto;
  z-index: 10000;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.model-dropdown.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.model-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.model-dropdown-item:hover {
  background-color: var(--bg-hover);
}

.model-dropdown-item.active {
  background-color: color-mix(in srgb, var(--accent-color) 10%, transparent);
}

.model-dropdown-item .model-item-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.model-dropdown-item .model-item-info {
  flex: 1;
  min-width: 0;
}

.model-dropdown-item .model-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.model-dropdown-item .model-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-dropdown-item .model-item-check {
  width: 18px;
  height: 18px;
  color: var(--accent-color);
  opacity: 0;
}

.model-dropdown-item.active .model-item-check {
  opacity: 1;
}

.send-btn {
  color: var(--accent-color);
}

.send-btn:hover:not(:disabled) {
  background-color: var(--accent-color);
  color: white;
}

/* AI 声明 */
.ai-disclaimer {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 8px 0 0;
}

/* 思考链样式 */
.thinking-block {
  margin-bottom: 12px;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s;
  user-select: none;
}

.thinking-header:hover {
  background-color: var(--bg-hover);
}

.thinking-icon {
  width: 16px;
  height: 16px;
  color: var(--accent-color);
}

.thinking-icon.spinning {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.thinking-title {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
}

.thinking-title.thinking-active {
  background: linear-gradient(90deg, var(--accent-color), #a190ff, var(--accent-color));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -100% 0;
  }
}

.thinking-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  transition: transform 0.2s;
}

.thinking-block.expanded .thinking-chevron {
  transform: rotate(180deg);
}

.thinking-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.thinking-block.expanded .thinking-content {
  max-height: 500px;
  overflow-y: auto;
}

.thinking-text {
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  margin-top: -4px;
  word-wrap: break-word;
}

.thinking-hint {
  padding: 8px 12px;
  padding-top: 0;
  font-size: 12px;
  color: var(--text-tertiary);
  background-color: var(--bg-secondary);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* 思考中指示器 */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

/* 模态框 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background-color: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  overflow: hidden;
}

.modal-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 500;
}

.modal-body {
  padding: 24px;
}

.modal-body p {
  margin-bottom: 12px;
  line-height: 1.6;
}

.modal-body .hint {
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.modal-body code {
  padding: 2px 6px;
  background-color: var(--bg-tertiary);
  border-radius: 4px;
  font-family: "Consolas", "Monaco", monospace;
  font-size: 13px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--accent-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

/* 大模态框 */
.modal-large {
  max-width: 900px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-large .modal-body {
  flex: 1;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* 登录标签页 */
.login-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.tab-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.tab-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.tab-btn.active {
  background-color: var(--accent-color);
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* 远程浏览器 */
.browser-status {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.browser-container {
  position: relative;
  width: 100%;
  background-color: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.browser-screen {
  width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
}

.browser-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.browser-toolbar {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.browser-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
}

.browser-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

/* 手动输入表单 */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  font-family: "Consolas", "Monaco", monospace;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-color);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

/* 状态指示器可点击 */
.status-indicator {
  cursor: pointer;
  transition: background-color 0.2s;
  padding: 8px;
  border-radius: var(--radius-lg);
}

.status-indicator:hover {
  background-color: color-mix(in srgb, #d3e3fd 80%, transparent);
}

[data-theme="dark"] .status-indicator:hover {
  color: #0842a0;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Markdown 内容样式 */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
  margin-top: 1em;
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.3;
}

.message-text h1 {
  font-size: 1.5em;
}

.message-text h2 {
  font-size: 1.3em;
}

.message-text h3 {
  font-size: 1.15em;
}

.message-text h4 {
  font-size: 1em;
}

.message-text p {
  margin-bottom: 0.75em;
  line-height: 1.6;
}

.message-text p:last-child {
  margin-bottom: 0;
}

.message-text ul,
.message-text ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.message-text li {
  margin: 0.25em 0;
  line-height: 1.5;
}

.message-text blockquote {
  margin: 0.75em 0;
  padding: 0.5em 1em;
  border-left: 4px solid var(--accent-color);
  background-color: var(--bg-hover);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message-text a {
  color: var(--accent-color);
  text-decoration: none;
}

.message-text a:hover {
  text-decoration: underline;
}

.message-text table {
  border-collapse: collapse;
  margin: 0.75em 0;
  width: 100%;
  overflow-x: auto;
  display: block;
}

.message-text th,
.message-text td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.message-text th {
  background-color: var(--bg-hover);
  font-weight: 600;
}

.message-text hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1em 0;
}

/* 行内代码 */
.message-text code {
  background-color: var(--bg-hover);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-size: 0.9em;
}

/* 代码块容器 */
.code-block-wrapper {
  position: relative;
  margin: 0.75em 0;
}

.message-text pre {
  margin: 0;
  padding: 1em;
  background-color: #1e1e1e;
  border-radius: var(--radius-md);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
}

.message-text pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.5;
  color: #d4d4d4;
}

/* 代码复制按钮 */
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background-color: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--radius-sm);
  color: #aaa;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
}

.code-block-wrapper:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* 图片样式 */
.message-text img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 0.5em 0;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    transition: transform 0.25s ease, opacity 0.25s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .sidebar.hidden {
    /* 在移动端隐藏类不生效，交给 transform 控制 */
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    opacity: 1;
  }

  .top-bar {
    gap: 8px;
    padding: 0 12px;
  }

  .main-content {
    margin-left: 0;
  }

  .messages-container {
    padding: 0 12px;
  }

  .message-bubble {
    max-width: 90%;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
  }

  .sidebar.hidden {
    transform: translateX(-100%);
  }

  .top-bar {
    padding: 0 16px;
  }

  /* 移动端隐藏快捷键提示 */
  .input-hint {
    display: none !important;
  }

  .chat-container {
    padding: 16px;
  }

  .messages-container {
    padding: 0 8px;
  }

  .message {
    gap: 10px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 13px;
    margin-top: 2px;
  }

  .message-content {
    max-width: 100%;
  }

  .message-bubble {
    padding: 10px 12px;
    max-width: 100%;
  }

  .input-toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }

  .toolbar-left,
  .toolbar-right {
    justify-content: flex-start;
    gap: 8px;
  }

  .model-dropdown {
    min-width: 220px;
    max-width: 92vw;
  }

  .input-area {
    padding: 12px 16px 16px;
  }

  .welcome-content h1 {
    font-size: 32px;
  }
}

/* Toast 通知样式 */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease-out;
}

.toast.toast-hiding {
  animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.toast-message {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.toast-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-tertiary);
  border-radius: 4px;
  transition: background-color 0.2s, color 0.2s;
}

.toast-close:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

/* Toast 类型样式 */
.toast.toast-success {
  border-left: 4px solid var(--success-color);
}

.toast.toast-success .toast-icon {
  color: var(--success-color);
}

.toast.toast-error {
  border-left: 4px solid var(--error-color);
}

.toast.toast-error .toast-icon {
  color: var(--error-color);
}

.toast.toast-warning {
  border-left: 4px solid var(--warning-color);
}

.toast.toast-warning .toast-icon {
  color: var(--warning-color);
}

.toast.toast-info {
  border-left: 4px solid var(--accent-color);
}

.toast.toast-info .toast-icon {
  color: var(--accent-color);
}

/* 表单必填标记 */
.form-group label .required {
  color: var(--error-color);
  margin-left: 2px;
}

/* 表单提示文字 */
.form-group .hint {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.form-group .hint b {
  color: var(--accent-color);
}

/* 高级选项折叠面板 */
.advanced-options {
  margin: 16px 0;
  padding: 12px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.advanced-options summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}

.advanced-options summary:hover {
  color: var(--accent-color);
}

.advanced-options[open] summary {
  margin-bottom: 12px;
}

.advanced-options .form-group {
  margin-bottom: 0;
}

/* ==================== 确认对话框样式 ==================== */
.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.confirm-overlay.show {
  opacity: 1;
}

.confirm-dialog {
  background-color: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 320px;
  max-width: 420px;
  transform: scale(0.9);
  transition: transform 0.2s ease;
}

.confirm-overlay.show .confirm-dialog {
  transform: scale(1);
}

.confirm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 0;
}

.confirm-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.confirm-warning .confirm-icon {
  color: var(--warning-color);
}

.confirm-danger .confirm-icon {
  color: var(--error-color);
}

.confirm-info .confirm-icon {
  color: var(--accent-color);
}

.confirm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.confirm-body {
  padding: 16px 20px;
}

.confirm-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-input {
  width: 100%;
  padding: 10px 12px;
  margin-top: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s;
}

.confirm-input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.confirm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 20px;
}

.confirm-footer .btn {
  min-width: 72px;
}

/* 危险操作的确认按钮 */
.confirm-danger .confirm-ok {
  background-color: var(--error-color);
  border-color: var(--error-color);
}

.confirm-danger .confirm-ok:hover {
  background-color: #d32f2f;
  border-color: #d32f2f;
}
