/* ============================================================
 * 控制台视图样式
 *
 * 各页专属: 总览 / 模型卡 / 自定义模型编辑行 / 应用布局 / 视图过渡 / 响应式 / 日志页.
 * 口径: 纯切分, 选择器与声明逐字节不变. 由 dashboard/index.html 依次加载
 * (base -> loading -> views; 后者依赖前者的主题变量与基础类).
 * ============================================================ */

/* ---------- overview ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: linear-gradient(160deg, rgba(91, 140, 255, .06), transparent), var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: transform .2s var(--ease), border-color .2s, box-shadow .2s;
  animation: cardIn .4s var(--ease) both;
}
.stat:hover { transform: translateY(-2px); border-color: var(--border2); box-shadow: var(--shadow-hover); }
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .value.green { color: var(--green); }
.stat .value.yellow { color: var(--yellow); }
.stat .value.red { color: var(--red); }

.balance-bar {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden;
  margin: 12px 0 4px;
  background: var(--bg3);
  gap: 1px;
}
.balance-bar div { transition: flex .5s var(--ease); min-width: 2px; }

/* 账号状态点 */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.status-dot.ok { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, .7); }
.status-dot.err { background: var(--red); box-shadow: 0 0 8px rgba(248, 113, 113, .7); }
.status-dot.warn { background: var(--yellow); box-shadow: 0 0 8px rgba(251, 191, 36, .7); }
.status-dot.idle { background: var(--muted); }

/* 检测结果行 */
.probe-result {
  animation: rowIn .3s var(--ease) both;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.probe-result:last-child { border-bottom: none; }

/* ---------- model cards ---------- */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.model-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform .2s var(--ease), border-color .2s, box-shadow .2s;
  animation: cardIn .35s var(--ease) both;
}
.model-chip:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--glow-accent); }
.model-chip .mid { font-family: var(--mono); font-size: 11px; word-break: break-all; }
.model-chip .pool { font-size: 11px; }

/* ---------- 自定义模型编辑行（可视化表单，不填 JSON） ---------- */
/* 账号时间轴（导入/更新/调度）：四行短文本，禁止被压缩成竖排单字。
   原来是内联 font-size:11px，宽度被其他列挤没时中文会逐字换行——
   这里给它一个最小宽度 + nowrap，宁可让整表横向滚动。 */
.acct-time {
  min-width: 132px;
  line-height: 1.55;
  white-space: nowrap;
}
.acct-time > div { white-space: nowrap; }

.cm-rows { display: flex; flex-direction: column; gap: 6px; }
.cm-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: rowIn .25s var(--ease) both;
}
.cm-row input, .cm-row select {
  padding: 7px 10px;
  font-size: 12px;
  margin: 0;
}
/* select 行内保留箭头空间（.cm-row 的 padding 覆盖不能吃掉全局 padding-right） */
.cm-row select {
  padding-right: 34px;
  background-position: right 10px center;
}
.cm-row .icon { flex: 0 0 auto; }

/* ---------- app 布局：内容居中 + 四周留白 ----------
   宽度说明：账号表的列比较多（账号/状态/Session/并发/时间轴/额度/Freebucks/请求/
   冷却/操作 = 10 列），1160px 会把「时间轴」那格挤成一行一个字。
   这里放宽到 1560px：宽屏能用满，窄屏照旧靠 .table-wrap 横向滚动兜底。 */
#app {
  max-width: 1560px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}
@media (max-width: 720px) {
  #app { padding: 14px; }
}
/* 表格安全网：极窄屏下允许横向滚动，而不是把单元格压到无法阅读。
   表格用 min-width 保证各列有呼吸空间，overflow-x 已经在 .table-wrap 上。 */
.table-wrap > table { min-width: 1080px; }
@media (max-width: 1080px) {
  .table-wrap > table { min-width: 0; }
}

/* ---------- view transition ---------- */
.view-enter { animation: viewIn .35s var(--ease) both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 局部刷新时给旧内容淡出 */
.refreshing > * { opacity: .5; transition: opacity .25s; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  header { flex-wrap: wrap; }
  header h1 { font-size: 15px; }
  .settings-band { flex-direction: column; align-items: stretch; }
  .model-grid { grid-template-columns: 1fr; }
  th, td { padding: 8px; }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 18px; }
  nav button { padding: 6px 12px; font-size: 12px; }
  .row { gap: 6px; }
  .modal { width: 96vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- logs (控制台「日志」页) ---------- */
.logs-list {
  margin-top: 10px;
  max-height: 62vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
}
.log-row {
  border-bottom: 1px solid var(--border);
}
.log-row:last-child { border-bottom: none; }
.log-row.open { background: var(--bg3); }
.log-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.log-head:hover { background: var(--bg4); }
.log-ts {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.log-msg {
  flex: 1 1 auto;
  word-break: break-word;
  color: var(--text2);
}
.log-row.open .log-msg { color: var(--text); }
.log-body { padding: 0 12px 12px; }
.log-pre {
  margin: 0;
  padding: 10px 12px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text2);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.logs-list select,
.logs-list input,
#logs-q {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font: inherit;
  font-size: 12.5px;
}
#logs-q { flex: 1 1 240px; min-width: 180px; }
#logs-q:focus, .logs-list select:focus {
  outline: none;
  border-color: var(--accent);
}
