/* --- 全局变量与重置 --- */
:root {
  --bg-main: #ffffff;
  --bg-sidebar: #f8f9fa;
  --bg-msg-user: #f4f4f7;
  --bg-msg-bot: #ffffff;
  --text-main: #202123;
  --text-muted: #6e6e80;
  --border: #e5e5e5;
  --accent: #10a37f;
  --accent-dark: #0e8c6d;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dark-mode {
  --bg-main: #212121;
  --bg-sidebar: #171717;
  --bg-msg-user: #2f2f2f;
  --bg-msg-bot: #212121;
  --text-main: #ececf1;
  --text-muted: #9a9a9a;
  --border: #3d3d3d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  outline: none;
}

body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto;
  background: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

/* --- 布局结构 --- */
#main-container {
  display: flex;
  height: 100%;
  width: 100%;
}

/* --- 侧边栏 --- */
#sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.collapsed {
  margin-left: -260px;
}

#sidebar-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.brand-text {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--accent);
}

#history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
}

.history-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.dark-mode .history-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.history-item.active {
  background: rgba(16, 163, 127, 0.1);
  color: var(--accent);
  font-weight: 500;
}

.history-item button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 5px;
}

#sidebar-footer {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
}

/* --- 主内容区 --- */
#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
}

#chat-header {
  height: 60px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

#chat-title {
  font-size: 15px;
  font-weight: 600;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- 模型开关 --- */
#model-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-info {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.model-toggle {
  width: 40px;
  height: 20px;
  border-radius: 10px;
  background: var(--accent);
  position: relative;
  border: none;
  cursor: pointer;
  transition: 0.3s;
}

.model-toggle.off {
  background: #b0b0b0;
}

.toggle-slider {
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 3px;
  right: 3px;
  transition: 0.3s;
}

.model-toggle.off .toggle-slider {
  transform: translateX(-20px);
}

/* --- 对话历史 --- */
#chat-history {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 50px;
  scroll-behavior: smooth;
}

.user-msg,
.bot-msg {
  padding: 25px 15%;
  border-bottom: 1px solid var(--border);
  position: relative;
  line-height: 1.7;
  font-size: 15px;
}

.user-msg {
  background: var(--bg-msg-user);
}

.bot-msg {
  background: var(--bg-msg-bot);
}

/* 思维链盒子 */
.reasoning-box {
  background: rgba(0, 0, 0, 0.03);
  border-left: 2px solid var(--accent);
  padding: 12px 16px;
  margin-bottom: 15px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  white-space: pre-wrap;
  border-radius: 0 4px 4px 0;
}

.dark-mode .reasoning-box {
  background: rgba(255, 255, 255, 0.03);
}

/* --- 复制按钮修复 --- */
.copy-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: 0.2s;
}

.bot-msg:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* --- 输入区域 --- */
#input-area {
  padding: 20px 15%;
}

#input-wrapper {
  display: flex;
  align-items: flex-end;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow);
}

#user-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  color: var(--text-main);
  font-size: 15px;
  resize: none;
  max-height: 200px;
}

.drop-area {
  display: none;
  padding: 8px;
  text-align: center;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  background: rgba(16, 163, 127, 0.05);
}

.drop-area.active {
  display: block;
}

/* --- 按钮通用 --- */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: 0.2s;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-main);
}

.primary-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.secondary-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

/* --- 弹窗 --- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--bg-main);
  padding: 30px;
  border-radius: 16px;
  width: 380px;
  box-shadow: var(--shadow);
}

.modal-content h3 {
  margin-bottom: 10px;
}

.modal-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.input-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sidebar);
  color: var(--text-main);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 25px;
}

/* --- 响应式 --- */
@media (max-width: 768px) {

  .user-msg,
  .bot-msg,
  #input-area {
    padding-left: 20px;
    padding-right: 20px;
  }
}