/* 在线工具页样式：与首页保持一致的配色与结构 */

.tools-main {
  background: #f8f8f8;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 280px 1fr; /* 左侧列表 + 右侧内容 */
  gap: 20px;
}

.tools-sidebar {
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.tools-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 12px;
}

.tools-list {
  list-style: none;
}

.tools-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.tools-item:hover {
  background: #f3f4f6;
}

.tools-item.active {
  background: #eff6ff;
  border: 1px solid #c7d2fe;
  color: #4f46e5;
}

/* 当前配置标记 */
.ai-chat-page .current-badge {
  display: inline-block;
  font-size: 12px;
  color: #4f46e5;
  background: #eff6ff;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 2px 6px;
  margin-left: 8px;
}

.tool-icon {
  width: 22px;
  text-align: center;
  font-size: 18px;
}

.tool-name {
  flex: 1;
  font-size: 14px;
}

/* 会话项省略号与弹出菜单 */
.item-ellipsis {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 18px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ai-chat-page .tools-item:hover .item-ellipsis { opacity: 1; }
.ai-chat-page .item-menu {
  position: absolute;
  right: 8px;
  top: 8px;
  transform: none;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  min-width: 120px;
}
.ai-chat-page .menu-close {
  align-self: flex-end;
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.ai-chat-page .menu-item {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #374151;
  font-size: 13px;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
.ai-chat-page .menu-item:hover { background: #f3f4f6; }
.ai-chat-page .menu-item.danger { color: #ef4444; border-color: #fca5a5; }

/* 右侧聊天列布局与底部固定 */
.ai-chat-page .chat-column { display: flex; flex-direction: column; max-height: calc(100vh - 66px); position: relative; padding: 16px 16px 160px; }
.ai-chat-page .chat-scroll { flex: 1; overflow: auto; }
.ai-chat-page .chat-input-floating {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 30px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  padding: 12px 16px;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  box-shadow: 0 -6px 18px rgba(0,0,0,0.08);
}
.ai-chat-page .chat-input-floating .input-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

.ai-chat-page .tools-content {
  background: #ffffff;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  height: 100%;
}

/* 通用两列布局容器（左侧栏 + 右侧主体） */
.tool-layout-two-cols {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  height: 100%;
}

/* 侧栏：新建会话采用与首页添加分类一致的风格 */
.ai-chat-page .tools-item.add-conv {
  border: 2px dashed var(--border-color, #e5e7eb);
  background: transparent;
  color: var(--text-secondary, #4b5563);
  justify-content: center;
  margin: 8px 8px 6px;
}
.ai-chat-page .tools-item.add-conv:hover {
  border-color: var(--primary-color, #4a90e2);
  color: var(--primary-color, #4a90e2);
  background: rgba(74, 144, 226, 0.05);
}

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

.content-title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}

.tool-panel {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
}

.placeholder {
  color: #6b7280;
  font-size: 14px;
}

/* 工具表单与交互样式 */
.tool-form { display: flex; flex-direction: column; gap: 12px; }
.tool-row { display: flex; align-items: center; gap: 10px; }
.tool-row.column { flex-direction: column; align-items: stretch; }
.tool-label { color: #374151; font-size: 13px; min-width: 72px; }
.tool-input, .tool-select {
  height: 34px;
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}
.tool-input { flex: 1; min-width: 220px; }
.tool-select { min-width: 90px; }
.tool-input:focus, .tool-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.tool-textarea {
  width: 100%;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: #374151;
  font-size: 13px;
  outline: none;
}
.tool-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.tool-editor {
  width: 100%;
  min-height: 44px;  
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 50px;
  color: #374151;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 200px;
  -webkit-overflow-scrolling: touch;
  line-height: 1.6;
  white-space: pre-wrap;
}
.tool-editor:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.tool-editor:empty:before {
  content: attr(data-placeholder);
  color: #9ca3af;
}

/* Markdown 内容样式 */
.md-code {
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  overflow: auto;
}
.md-code code { font-family: Consolas, Menlo, monospace; font-size: 12px; }
.md-inline { background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 4px; padding: 0 4px; }
.md-ul { margin: 6px 0; padding-left: 18px; }
.md-ul li { line-height: 1.7; }

/* 代码块复制工具栏 */
.md-code-block { position: relative; }
.code-toolbar { position: absolute; top: 6px; right: 6px; }
.code-copy-btn {
  background: rgba(255,255,255,0.85);
  border: 1px solid #e5e7eb;
  color: #374151;
  font-size: 12px;
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
}
.code-copy-btn:hover { background: rgba(255,255,255,1); }

/* 扩展 Markdown 元素样式 */
.md-ol { margin: 6px 0; padding-left: 18px; }
.md-ol li { line-height: 1.7; }
.md-img { max-width: 100%; border-radius: 6px; }
.md-quote { border-left: 4px solid #e5e7eb; padding-left: 10px; color: #6b7280; }
.md-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.md-table th, .md-table td { border: 1px solid #e5e7eb; padding: 6px 8px; }
.md-h1 { font-size: 1.6rem; margin: 10px 0; }
.md-h2 { font-size: 1.45rem; margin: 10px 0; }
.md-h3 { font-size: 1.3rem; margin: 8px 0; }
.md-h4 { font-size: 1.2rem; margin: 6px 0; }
.md-h5 { font-size: 1.1rem; margin: 6px 0; }
.md-h6 { font-size: 1rem; margin: 6px 0; }
.md-hr { border: none; border-top: 1px solid #e5e7eb; margin: 8px 0; }

/* 连接状态指示点 */
.conn-status { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.conn-status.connecting { background: #f59e0b; }
.conn-status.streaming { background: #22c55e; }
.conn-status.done { background: #3b82f6; }
.conn-status.stopped { background: #6b7280; }
.conn-status.error { background: #ef4444; }
.tool-actions { display: flex; gap: 10px; }
.tool-btn {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #374151;
  font-size: 14px;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tool-btn:hover { background: #e5e7eb; }
.tool-btn.primary { background: #4f46e5; border-color: #4f46e5; color: #ffffff; }
.tool-btn.primary:hover { background: #4338ca; border-color: #4338ca; }
.tool-btn.ghost { background: transparent; border-color: #d1d5db; }
.tool-output {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px dashed #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
}
.output-label { color: #6b7280; font-size: 13px; }
.output-value { color: #111827; font-size: 14px; word-break: break-all; }
.tool-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

/* 作用域覆盖：工具页不使用首页左侧站点侧栏，移除主内容左侧留白 */
.tools-page .main-content {
  margin-left: 0;
  overflow-x: hidden; /* 防止移动端横向滚动 */
}

/* 保证工具页顶栏贴边显示（与首页一致） */
.tools-page .top-bar {
  left: 0;
}

/* 移动端适配（工具页） */
@media (max-width: 768px) {
  .tools-page .tools-main {
    grid-template-columns: 1fr; /* 两列改为单列 */
    gap: 16px;
    padding: 16px;
    overflow-x: hidden;
  }
  .tools-page .tools-sidebar {
    border-right: none;
    border-bottom: 1px solid #e5e7eb; /* 侧栏在下方分隔 */
  }
  .tools-page .tools-content {
    padding: 16px 0 0 0; /* 右侧内容不再需要右间距 */
  }
  .tools-page .content-header-row {
    flex-wrap: wrap; /* 标题和操作在小屏换行 */
    gap: 8px;
  }
  .tools-page .tool-row {
    flex-wrap: wrap; /* 表单控件自动换行 */
  }
  .tools-page .tool-actions {
    flex-wrap: wrap; /* 操作按钮换行，避免溢出 */
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .tools-page .tool-input { min-width: 0; width: 100%; }
  .tools-page .tool-select { min-width: 0; width: 100%; }
}

/* 顶部日期下拉触发与日历样式 */
.date-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.weather-icon {
  font-size: 18px;
}
.date-text {
  user-select: none;
}
.date-dropdown {
  position: absolute;
  top: 28px;
  right: 0;
  width: 480px;
  max-width: 90vw;
  max-height: 70vh;
  overflow: auto;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  z-index: 30;
}
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-left: 12px;
  padding-right: 12px;
}
.ym-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}
.ym-picker select {
  height: 32px;
  min-width: 110px;
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}
.ym-picker select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
#ymYearSelect { min-width: 130px; }
#ymMonthSelect { min-width: 100px; }
.ym-picker .cal-btn {
  padding: 6px 12px;
}
.ym-picker .cal-btn:hover {
  background: #e5e7eb;
  color: #1f2937;
}
.calendar-footer {
	padding-bottom: 12px;
	padding-top: 12px;
	background-color: #f8f8f8;
	border-bottom: 1px solid #e5e7eb;
	text-align: center;
	margin-bottom: 12px;
}
.cal-btn {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #374151;
  font-size: 14px;
  border-radius: 6px;
  padding: 2px 8px;
}

.cal-title { font-weight: 600; color: #1f2937; }
.calendar-grid {
   padding: 12px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-weekday { text-align: center; color: #6b7280; font-size: 12px; }
.cal-day {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 6px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  min-height: 42px;
  cursor: pointer;
}
.cal-day.out-month { opacity: 0.45; }
.cal-day.today { border-color: #93c5fd; }
.cal-day.selected { background: #eff6ff; border-color: #93c5fd; }
.day-num { font-size: 14px; color: #1f2937; }
.day-lunar { font-size: 11px; color: #6b7280; }

/* 天气详情下拉 */
.weather-dropdown {
  position: absolute;
  top: 28px;
  right: 0;
  width: 320px;
  max-width: 90vw;
  max-height: 70vh;
  overflow: auto;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  padding: 12px;
  z-index: 30;
}
.weather-title {
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 8px;
}
.weather-row { color: #374151; font-size: 14px; line-height: 22px; }
.weather-tip { color: #6b7280; font-size: 12px; margin-top: 6px; }
.content-narrow {
  max-width: 900px;
  margin: 0 auto;
}

/* 聊天消息列表与气泡样式 */
.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-bubble {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  background: #f9fafb;
  line-height: 1.7;
  white-space: pre-wrap;
}
.chat-bubble.user {
  align-self: flex-end;
  background: #eff6ff;
  border-color: #c7d2fe;
}
.chat-bubble.ai {
  align-self: flex-start;
  background: #ffffff;
}
.chat-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.chat-meta .role {
  color: #6b7280;
  font-size: 12px;
}
.chat-meta .time {
  color: #9ca3af;
  font-size: 12px;
}

/* 仅作用于聊天页面：强制换行与限制溢出，避免代码块撑开页面 */
.ai-chat-page .chat-column { overflow: hidden; }
.ai-chat-page .chat-list { word-break: break-word; overflow-wrap: anywhere; }
.ai-chat-page .chat-list pre,
.ai-chat-page .chat-list code {
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
}
.ai-chat-page .chat-list table { max-width: 100%; display: block; overflow-x: auto; }
.ai-chat-page .chat-list img { max-width: 100%; height: auto; }
.ai-chat-page .conn-status.streaming { cursor: pointer; }

/* 移动端适配（不影响PC端） */
@media (max-width: 768px) {
  /* 两列改为单列栈叠 */
  .ai-chat-page .tool-layout-two-cols { grid-template-columns: 1fr; }
  .ai-chat-page .tools-sidebar { border-right: none; border-bottom: 1px solid #e5e7eb; }
  .ai-chat-page .tools-item { padding: 10px 12px; }

  /* 聊天区域与输入栏 */
  .ai-chat-page .chat-column { max-height: none; padding: 12px 12px 220px; }
  .ai-chat-page .chat-scroll { max-height: calc(100vh - 220px); }
  .ai-chat-page .chat-input-floating {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    border-top-left-radius: 0; border-top-right-radius: 0;
    padding: 12px;
    z-index: 1000;
  }
  .ai-chat-page .chat-input-floating .input-actions { flex-wrap: wrap; }

  /* 顶栏操作区在小屏换行，避免溢出 */
  .ai-chat-page .top-actions { flex-wrap: wrap; gap: 8px; }
}