/* =====================================================================
   base.css — siri 自动化云日志系统 · 共享样式（白蓝主题 v2.0）
   参考 DESIGN.md。所有页面通用：变量、reset、按钮、卡片、表单、表格、
   badge、modal、nav、scrollbar、动效。
   ===================================================================== */

/* ---------- 1. 设计令牌（CSS 变量） ---------- */
:root {
  /* 背景与表面 */
  --bg: #f4f7fb;            /* 画布主背景：极浅蓝灰 */
  --bg-soft: #eef2f7;       /* 次级背景 */
  --surface: #ffffff;       /* 卡片/面板白底 */
  --surface-2: #f8fafc;     /* 次级表面：输入框底、表头 */
  --log-bg: #0f172a;        /* 日志/代码区深色底（护眼惯例） */
  --log-text: #e2e8f0;      /* 日志区文字 */

  /* 边框 */
  --border: #e2e8f0;       /* 浅边框 */
  --border-strong: #cbd5e1; /* 强边框（hover） */
  --border-soft: rgba(15, 23, 42, 0.06);

  /* 文字 */
  --text: #0f172a;         /* 主文字：深墨 */
  --text-dim: #64748b;     /* 次要文字 */
  --text-faint: #94a3b8;   /* 微弱文字 */

  /* 主色（钴蓝） */
  --accent: #0064e0;
  --accent-hover: #0457cb;
  --accent-light: #0091ff;
  --accent-soft: rgba(0, 100, 224, 0.10);

  /* 语义色 */
  --green: #31a24c;
  --green-soft: rgba(49, 162, 76, 0.12);
  --red: #e41e3f;
  --red-soft: rgba(228, 30, 63, 0.10);
  --yellow: #f2a918;
  --yellow-soft: rgba(242, 169, 24, 0.14);
  --purple: #a121ce;
  --purple-soft: rgba(161, 33, 206, 0.10);

  /* 阴影 */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 8px 24px -8px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 12px 32px -8px rgba(0, 100, 224, 0.18);
  --shadow-glow: 0 0 0 1px var(--border), 0 12px 40px -12px rgba(0, 100, 224, 0.18);
  --shadow-btn: 0 6px 16px -6px rgba(0, 100, 224, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  --shadow-modal: 0 24px 60px -16px rgba(15, 23, 42, 0.25);

  /* 圆角 */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 20px;
  --r-pill: 100px;
}

/* ---------- 2. Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Montserrat", -apple-system, "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* 画布背景光晕（浅蓝点缀） */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 600px 400px at 10% 0%, rgba(0, 100, 224, 0.06), transparent 60%),
    radial-gradient(ellipse 500px 400px at 95% 100%, rgba(161, 33, 206, 0.04), transparent 60%);
}

/* ---------- 3. 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------- 4. 顶栏 header ---------- */
header {
  position: relative;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px -4px rgba(0, 100, 224, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; color: #fff; }
header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
header h1 .tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--purple-soft);
  color: var(--purple);
  margin-left: 8px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
header .user-info {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
}
header .user-info .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}
header .status-bar {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
}
header .status-bar .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---------- 5. 按钮（全部胶囊形） ---------- */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--r-pill);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.43;
}
.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn svg { width: 14px; height: 14px; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -6px rgba(0, 100, 224, 0.55);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c41530; }
.btn-outline {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- 6. 卡片 / 面板 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.panel h2 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.panel h2 .h-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.panel h2 .h-icon svg { width: 14px; height: 14px; }
.panel h3 {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* 统计卡 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: linear-gradient(135deg, var(--surface-2) 0%, rgba(0, 100, 224, 0.03) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}
.stat-card:hover {
  border-color: rgba(0, 100, 224, 0.25);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.stat-card::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 70%);
  opacity: 0.7;
}
.stat-card .label { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; font-weight: 500; }
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  position: relative;
  z-index: 1;
}
.stat-card.green .value { color: var(--green); }
.stat-card.green::after { background: radial-gradient(circle, var(--green-soft) 0%, transparent 70%); }
.stat-card.purple .value { color: var(--purple); }
.stat-card.purple::after { background: radial-gradient(circle, var(--purple-soft) 0%, transparent 70%); }
.stat-card.yellow .value { color: var(--yellow); }
.stat-card.yellow::after { background: radial-gradient(circle, var(--yellow-soft) 0%, transparent 70%); }

/* ---------- 7. 表单 ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s;
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-faint); }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.checkbox-row { display: flex; flex-direction: column; gap: 8px; }
.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- 8. 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table th:first-child { border-radius: var(--r-sm) 0 0 0; }
.table th:last-child { border-radius: 0 var(--r-sm) 0 0; }
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}
.table tr:hover td { background: rgba(0, 100, 224, 0.03); }
.table tr:last-child td { border-bottom: none; }

/* ---------- 9. Badge / Dot / 状态 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge.open { background: var(--yellow-soft); color: var(--yellow); }
.badge.open::before { background: var(--yellow); }
.badge.replied { background: var(--accent-soft); color: var(--accent); }
.badge.replied::before { background: var(--accent); }
.badge.completed { background: var(--green-soft); color: var(--green); }
.badge.completed::before { background: var(--green); }
.badge.pending { background: var(--yellow-soft); color: var(--yellow); }
.badge.pending::before { background: var(--yellow); }
.badge.running { background: var(--accent-soft); color: var(--accent); }
.badge.running::before { background: var(--accent); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.done::before { background: var(--green); }
.badge.failed { background: var(--red-soft, #fdecea); color: var(--red, #d93026); }
.badge.failed::before { background: var(--red, #d93026); }
.url-hint { font-size: 12px; color: var(--text-dim); word-break: break-all; padding: 6px 0; }
.log-table td { font-size: 12px; word-break: break-all; vertical-align: top; }
.log-table td:nth-child(4) { text-align: left; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.offline { background: var(--red); opacity: 0.6; }

/* ---------- 10. 消息提示 ---------- */
.msg {
  font-size: 12px;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  display: none;
  font-weight: 500;
}
.msg.error { color: var(--red); background: var(--red-soft); border: 1px solid rgba(228, 30, 63, 0.2); display: block; }
.msg.success { color: var(--green); background: var(--green-soft); border: 1px solid rgba(49, 162, 76, 0.2); display: block; }
.msg.info { color: var(--text-dim); background: var(--bg-soft); border: 1px solid var(--border); display: block; }
.empty {
  padding: 32px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- 11. 主容器 + 侧边栏 ---------- */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px 10px;
  gap: 2px;
}
.sidebar-header {
  padding: 8px 12px 12px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font-size: 13px;
  border-radius: var(--r-lg);
  transition: all 0.18s ease;
  color: var(--text-dim);
  font-weight: 500;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, var(--accent-soft) 0%, rgba(0, 100, 224, 0.03) 100%);
  color: var(--text);
  border-color: rgba(0, 100, 224, 0.25);
}
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; transition: color 0.18s; color: var(--text-faint); }
.main-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ---------- 12. 面板切换 ---------- */
.pane { display: none; animation: paneIn 0.3s ease; }
.pane.active { display: block; }
@keyframes paneIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- 13. 弹层（玻璃拟态） ---------- */
.modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-mask.show { display: flex; animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-modal);
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h2 { font-size: 16px; margin-bottom: 16px; font-weight: 700; color: var(--text); }

/* ---------- 14. 工具栏 ---------- */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar input,
.toolbar select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s;
}
.toolbar input:focus,
.toolbar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- 15. 通用布局 ---------- */
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.btn-row { display: flex; gap: 8px; }
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
