/* ===== 统一工具页样式 ===== */

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

/* 主题变量 */
[data-theme="modern"], :root {
  --primary: #1677ff; --primary-light: #e6f4ff; --primary-dark: #0958d9;
  --accent: #722ed1; --bg: #f5f7fa; --bg-card: #ffffff; --bg-nav: rgba(255,255,255,0.92);
  --text: #1a1a2e; --text-secondary: #555; --text-muted: #999;
  --border: #e8e8e8; --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --radius: 12px; --radius-sm: 8px;
  --font: -apple-system,"Microsoft YaHei","PingFang SC","Helvetica Neue",sans-serif;
  --font-heading: var(--font);
}
[data-theme="ancient"] {
  --primary: #2c2c2c; --primary-light: #f0ebe3; --accent: #c43a31;
  --bg: #f5f0e8; --bg-card: #faf6ee; --bg-nav: rgba(245,240,232,0.95);
  --text: #1a1a1a; --text-secondary: #4a4a4a; --text-muted: #7a7a7a;
  --border: #c8c0b5; --radius: 2px; --radius-sm: 2px;
  --font: "STKaiti","KaiTi","楷体","FangSong",serif;
}
[data-theme="retro"] {
  --primary: #2b4c7e; --primary-light: #eef3f9; --accent: #c9a84c;
  --bg: #eee9e0; --bg-card: #f6f2eb; --bg-nav: rgba(238,233,224,0.94);
  --text: #1e1e2a; --text-secondary: #4a4a5a; --text-muted: #8a8a9a;
  --border: #cbc4b8; --radius: 2px; --radius-sm: 1px;
  --font: "STSong","SimSun","宋体","FangSong",serif;
}
[data-theme="western"] {
  --primary: #2c5282; --primary-light: #ebf4ff; --accent: #c53030;
  --bg: #f7f5f0; --bg-card: #fcfaf5; --bg-nav: rgba(247,245,240,0.94);
  --text: #1a202c; --text-secondary: #4a5568; --text-muted: #a0aec0;
  --border: #e2dcd0; --radius: 4px; --radius-sm: 2px;
  --font: Georgia, "Times New Roman", serif;
}

body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.7; font-size: 15px; min-height: 100vh;
}

/* ===== 顶部导航 ===== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-nav); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; height: 60px;
  gap: 12px;
}
.topbar-back {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: 14px; transition: all .2s;
}
.topbar-back:hover { background: var(--primary-light); color: var(--primary); }
.topbar-title {
  font-size: 20px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.topbar-icon { font-size: 24px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-status { font-size: 12px; color: var(--text-muted); padding: 4px 10px; background: var(--bg); border-radius: 20px; }

/* ===== 页面主体 ===== */
.tool-page {
  max-width: 960px; margin: 0 auto; padding: 32px 24px 60px;
}
.tool-page-wide {
  max-width: 1200px;
}
.tool-header {
  margin-bottom: 28px;
}
.tool-header h1 { font-size: 26px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.tool-header p { font-size: 15px; color: var(--text-secondary); }

/* ===== 卡片容器 ===== */
.tool-card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 28px; margin-bottom: 20px;
}

/* ===== 输入区域 ===== */
.input-section { margin-bottom: 20px; }
.input-section textarea {
  width: 100%; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.6;
  resize: vertical; min-height: 120px; transition: border-color .2s;
}
.input-section textarea:focus { outline: none; border-color: var(--primary); }

/* ===== 工具栏行 ===== */
.toolbar-row {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin: 14px 0;
}

/* ===== 标签选择器 ===== */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--bg-card); color: var(--text-secondary); cursor: pointer;
  font-size: 13px; font-family: var(--font); transition: all .2s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 引擎选择 ===== */
.engine-select { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.engine-select select {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text); font-size: 13px; font-family: var(--font);
}

/* ===== 按钮 ===== */
.btn-primary {
  display: inline-block; padding: 12px 32px;
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius-sm); font-size: 15px; font-weight: 600;
  font-family: var(--font); cursor: pointer; transition: opacity .2s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.btn-block { width: 100%; text-align: center; }

/* ===== 加载状态 ===== */
.loading {
  text-align: center; padding: 24px; color: var(--text-muted); font-size: 14px;
}

/* ===== 结果卡片 ===== */
.result-section { margin-top: 20px; }
.result-card {
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.result-item {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.result-item:last-child { border-bottom: none; }
.result-lang { font-size: 13px; font-weight: 600; color: var(--primary); margin-bottom: 4px; }
.result-text { font-size: 15px; line-height: 1.7; color: var(--text); }
.result-source {
  padding: 10px 20px; background: var(--bg); font-size: 13px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.result-footer {
  padding: 10px 20px; background: var(--bg); font-size: 12px; color: var(--text-muted);
  text-align: right; border-top: 1px solid var(--border);
}

/* ===== 数据表格 ===== */
.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  padding: 12px 14px; text-align: left; background: var(--bg);
  border-bottom: 2px solid var(--border); font-weight: 600; color: var(--text-secondary);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table tr:nth-child(even) { background: var(--bg); }

/* ===== 聊天 ===== */
.chat-box {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); height: 460px; overflow-y: auto; padding: 20px;
  margin-bottom: 14px; display: flex; flex-direction: column; gap: 14px;
}
.chat-msg { display: flex; flex-direction: column; }
.chat-msg.user { align-items: flex-end; }
.chat-msg.bot { align-items: flex-start; }
.msg-role { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
.msg-bubble {
  max-width: 75%; padding: 12px 16px; border-radius: 12px;
  font-size: 14px; line-height: 1.6;
}
.chat-msg.user .msg-bubble { background: var(--primary); color: #fff; border-radius: 12px 12px 4px 12px; }
.chat-msg.bot .msg-bubble { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; }
.chat-msg.bot .msg-extra { margin-top: 6px; display: flex; gap: 6px; }
.chat-input-row {
  display: flex; gap: 10px;
}
.chat-input-row input {
  flex: 1; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text); font-size: 15px; font-family: var(--font);
  transition: border-color .2s;
}
.chat-input-row input:focus { outline: none; border-color: var(--primary); }
.chat-send-btn {
  padding: 12px 28px; background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius-sm); font-size: 15px; font-weight: 600;
  font-family: var(--font); cursor: pointer; transition: opacity .2s;
}
.chat-send-btn:hover { opacity: 0.85; }
.chat-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-top: 10px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .tool-page { padding: 20px 16px 40px; }
  .tool-card { padding: 20px; }
  .topbar { padding: 0 12px; }
  .topbar-title { font-size: 17px; }
  .chat-box { height: 350px; }
}

/* ===== 主题切换 ===== */
.theme-switcher { position: relative; }
.theme-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); cursor: pointer; font-size: 18px; transition: all .2s;
}
.theme-btn:hover { border-color: var(--primary); }
.theme-dropdown {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); z-index: 200; min-width: 130px; overflow: hidden;
}
.theme-option {
  display: block; width: 100%; padding: 8px 14px; text-align: left;
  border: none; background: none; cursor: pointer; font-size: 13px;
  font-family: var(--font); color: var(--text); transition: background .15s;
}
.theme-option:hover { background: var(--primary-light); }
.theme-option.active { color: var(--primary); font-weight: 600; }
