/* ============================================================
 * tools.css - 通用工具页样式
 * 供 image/text/utils/design/more 各工具模块共用
 * 依赖 common.css 中的全局变量与组件
 * ============================================================ */

.tool-page {
  min-height: calc(100vh - var(--header-h));
  background: var(--bg);
  padding-bottom: 80px;
}

/* ---------- 页面头部 ---------- */
.tool-head {
  padding: 38px 0 22px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.tool-head .th-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 28px;
  flex-shrink: 0;
}
.th-blue { background: rgba(108, 140, 255, 0.15); color: #9db4ff; }
.th-green { background: rgba(55, 214, 176, 0.15); color: #6fe3c6; }
.th-purple { background: rgba(160, 108, 255, 0.15); color: #c6a1ff; }
.th-orange { background: rgba(245, 185, 74, 0.15); color: #f7cd82; }
.th-pink { background: rgba(255, 107, 122, 0.15); color: #ff9faa; }
.th-cyan { background: rgba(58, 160, 255, 0.15); color: #8ec8ff; }

.tool-head h1 {
  font-size: 28px;
  margin: 0 0 6px;
  font-weight: 800;
  letter-spacing: -0.4px;
}
.tool-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}
.tool-head .head-tags {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Tab 导航 ---------- */
.tabbar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: 0.18s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn .tb-icon { font-size: 16px; }

/* ---------- Tab 面板 ---------- */
.tab-panel { display: none; animation: fadeIn 0.25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 网格布局 ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}
.tool-grid.even { grid-template-columns: 1fr 1fr; }
.tool-grid.wide-side { grid-template-columns: 1fr 400px; }
@media (max-width: 920px) {
  .tool-grid, .tool-grid.even, .tool-grid.wide-side { grid-template-columns: 1fr; }
}
.settings-card { position: sticky; top: 88px; }
@media (max-width: 920px) { .settings-card { position: static; } }

/* ---------- 面板内标题 ---------- */
.panel-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px;
}
.panel-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 18px;
  line-height: 1.6;
}

/* ---------- 动作条 ---------- */
.action-bar {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.action-bar.center { justify-content: center; }
.action-bar .btn { flex: 0 0 auto; }

/* ---------- 复选框 / 单选 / 开关 ---------- */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 12px;
  user-select: none;
}
.check-row input[type="checkbox"],
.check-row input[type="radio"] { width: auto; accent-color: var(--primary); }
.check-row input[type="range"] { flex: 1; }

input[type="range"] { width: 100%; accent-color: var(--primary); padding: 0; }
.range-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.range-label b { color: var(--text); font-weight: 600; }

/* ---------- 分段控制器 ---------- */
.segment {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  flex-wrap: wrap;
}
.segment button {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  transition: 0.16s;
}
.segment button:hover { color: var(--text); }
.segment button.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- 结果输出区 ---------- */
.result-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.result-head .rh-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.result-head .rh-actions { display: flex; gap: 6px; }
.result-body { padding: 16px; }
textarea.code-area {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  min-height: 260px;
  resize: vertical;
  white-space: pre;
  tab-size: 2;
}
textarea.code-area.small { min-height: 150px; }

/* ---------- Markdown 预览 ---------- */
.md-preview {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  min-height: 300px;
  overflow-wrap: break-word;
  line-height: 1.75;
  font-size: 14px;
}
.md-preview > :first-child { margin-top: 0; }
.md-preview h1, .md-preview h2, .md-preview h3,
.md-preview h4 { margin: 1.4em 0 0.6em; line-height: 1.3; }
.md-preview h1 { font-size: 1.9em; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.md-preview h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.md-preview h3 { font-size: 1.25em; }
.md-preview a { color: var(--primary); text-decoration: underline; }
.md-preview blockquote {
  margin: 1em 0;
  padding: 8px 16px;
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
  color: var(--text-muted);
  border-radius: 0 8px 8px 0;
}
.md-preview code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.9em;
  color: #ffb3c1;
}
.md-preview pre {
  background: #0d1017;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.6;
}
.md-preview pre code { background: none; padding: 0; color: var(--text); }
.md-preview table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.md-preview th, .md-preview td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.md-preview th { background: var(--surface); }
.md-preview img { border-radius: 8px; margin: 8px 0; }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md-preview ul, .md-preview ol { padding-left: 24px; }
.md-preview li { margin: 4px 0; }
/* highlight.js 深色主题微调 */
.md-preview .hljs { background: transparent !important; }

/* ---------- 文件拖拽区 ---------- */
.tool-drop {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  transition: 0.2s;
  cursor: pointer;
  background: var(--bg-elevated);
}
.tool-drop:hover, .tool-drop.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.tool-drop .td-icon { font-size: 38px; margin-bottom: 10px; }
.tool-drop .td-title { font-size: 15px; font-weight: 600; margin-bottom: 5px; }
.tool-drop .td-hint { color: var(--text-muted); font-size: 12px; }

/* ---------- 文件列表 ---------- */
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.file-row .fr-thumb {
  width: 46px; height: 46px; object-fit: cover;
  border-radius: 7px; background: var(--surface-2); flex-shrink: 0;
}
.file-row .fr-info { flex: 1; min-width: 0; }
.file-row .fr-name {
  font-size: 13px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.file-row .fr-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.file-row .fr-del {
  background: none; border: none; color: var(--text-dim);
  font-size: 18px; padding: 4px 8px; cursor: pointer;
}
.file-row .fr-del:hover { color: var(--danger); }

/* ---------- 画布预览 ---------- */
.canvas-wrap {
  background: repeating-conic-gradient(#181c26 0% 25%, #12151d 0% 50%) 50% / 20px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  overflow: auto;
}
.canvas-wrap canvas, .canvas-wrap img {
  max-width: 100%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  border-radius: 4px;
}

/* ---------- 颜色 / 渐变相关 ---------- */
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 64px; height: 64px; border-radius: 12px;
  border: 1px solid var(--border); cursor: pointer;
  position: relative; transition: 0.18s; flex-shrink: 0;
}
.color-swatch:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.color-swatch .sw-label {
  position: absolute; bottom: -20px; left: 0; right: 0;
  text-align: center; font-size: 10px; color: var(--text-dim);
  font-family: var(--mono);
}
.swatch-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.swatch-bar { display: flex; border-radius: 12px; overflow: hidden; height: 90px; border: 1px solid var(--border); }
.swatch-bar > div { flex: 1; cursor: pointer; transition: 0.2s; position: relative; }
.swatch-bar > div:hover { flex-grow: 1.4; }
.gradient-preview {
  height: 180px; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 16px;
}

/* ---------- 键值对表格 ---------- */
.kv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.kv-table td:first-child { color: var(--text-muted); width: 42%; }
.kv-table td:last-child { font-family: var(--mono); word-break: break-all; }

/* ---------- 统计数字 ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.stat-card .sc-num { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-card .sc-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- SVG 图标网格 ---------- */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.icon-cell {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: 0.16s;
}
.icon-cell:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  background: var(--primary-soft);
}
.icon-cell svg { width: 28px; height: 28px; stroke: var(--text); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-cell .ic-name { font-size: 11px; color: var(--text-dim); text-align: center; word-break: break-all; }

/* ---------- 通用提示文本 ---------- */
.inline-hint { font-size: 12px; color: var(--text-dim); margin-top: 8px; line-height: 1.6; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ---------- 徽章状态色 ---------- */
.pill-ok { color: var(--accent); }
.pill-bad { color: var(--danger); }

@media (max-width: 640px) {
  .tool-head { padding-top: 26px; }
  .tool-head h1 { font-size: 23px; }
}
