/* =============================================================================
 * base.css —— 设计令牌 / 主题变量 / 基础元素 / 通用组件
 * 风格：科技简约、低饱和、浅色系、圆角卡片、柔和浅阴影、拒绝花哨装饰
 * ========================================================================== */

/* ---------- 1. 设计令牌：浅色主题（默认） ---------- */
:root {
  --bg:            #f4f6f8;
  --bg-grid:       rgba(15, 23, 42, 0.035);
  --surface:       #ffffff;
  --surface-2:     #f8f9fb;
  --surface-3:     #eef1f5;
  --line:          #e8eaee;
  --line-strong:   #d8dce3;

  --text:          #1d2129;
  --text-2:        #5a6472;
  --text-3:        #98a1ad;

  --brand:         #4a68e0;
  --brand-hover:   #3f5bd0;
  --brand-soft:    #eef2ff;
  --brand-line:    #d9e1fb;

  --ok:            #2e9e6b;
  --ok-soft:       #e8f6ef;
  --warn:          #c98014;
  --warn-soft:     #fdf3e3;
  --danger:        #d9534f;
  --danger-soft:   #fdeceb;

  --radius:        14px;
  --radius-sm:     9px;
  --radius-xs:     6px;
  --radius-pill:   999px;

  --shadow-1:      0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-2:      0 2px 6px rgba(16, 24, 40, .06), 0 16px 40px rgba(16, 24, 40, .09);
  --shadow-pop:    0 8px 32px rgba(16, 24, 40, .14);

  --ease:          cubic-bezier(.22, .61, .36, 1);
  --dur:           .22s;

  --topbar-h:      56px;
  --sidebar-w:     248px;
  --rail-w:        8px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- 2. 深色主题（一键切换 data-theme="dark"） ---------- */
[data-theme="dark"] {
  --bg:            #14161a;
  --bg-grid:       rgba(255, 255, 255, 0.035);
  --surface:       #1b1e24;
  --surface-2:     #21252c;
  --surface-3:     #272c34;
  --line:          #2c313a;
  --line-strong:   #3a414c;

  --text:          #e6e9ee;
  --text-2:        #a4adba;
  --text-3:        #737d8b;

  --brand:         #7d93ef;
  --brand-hover:   #8ea2f3;
  --brand-soft:    #232a40;
  --brand-line:    #33406b;

  --ok:            #4cb98a;
  --ok-soft:       #1d2c26;
  --warn:          #d9a04a;
  --warn-soft:     #2e271a;
  --danger:        #e2716d;
  --danger-soft:   #33211f;

  --shadow-1:      0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .28);
  --shadow-2:      0 2px 8px rgba(0, 0, 0, .34), 0 18px 44px rgba(0, 0, 0, .4);
  --shadow-pop:    0 10px 36px rgba(0, 0, 0, .5);
}

/* ---------- 3. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

::selection { background: var(--brand-soft); color: var(--brand); }

/* 细滚动条（克制） */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-3); background-clip: content-box; }

/* ---------- 4. 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), transform .12s var(--ease);
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }

.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; }

.btn--sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: var(--radius-xs); }
.btn--block { width: 100%; height: 38px; font-size: 14px; }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* 锁定按钮：「锁定所有模块 / 已锁定（双击解锁）」文字标签；锁定态仅改文字，外观与普通按钮完全一致，无红框/无特殊底色；窄屏只留图标（hover 提示仍在） */
.lock-label { font-size: 13px; white-space: nowrap; }
@media (max-width: 560px) {
  .lock-label { display: none; }
  #btnRefreshAll { padding: 0 8px; }
}

/* 外链按钮：所有跳转完整业务页的按钮都用 <a target="_blank">，天然是用户手动点击 */
.btn--ext::after {
  content: "";
  width: 9px; height: 9px;
  margin-left: 1px;
  background: currentColor;
  opacity: .55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14 3h7v7M21 3l-9 9M19 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14 3h7v7M21 3l-9 9M19 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* ---------- 5. 表单 ---------- */
.field { display: block; margin-bottom: 14px; }
.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--text-2);
}
.input, .textarea {
  width: 100%;
  max-width: 460px;   /* 输入框/按钮不拉满整卡，松紧适度 */
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.7; }

/* ---------- 6. 通用小组件 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}
.badge--hidden { display: none; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
}
.tag--ok { background: var(--ok-soft); color: var(--ok); }
.tag--warn { background: var(--warn-soft); color: var(--warn); }
.tag--brand { background: var(--brand-soft); color: var(--brand); }

.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none;
        stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 14px; height: 14px; }

/* 刷新按钮的旋转态（顶栏与卡片通用） */
.is-spin svg { animation: wb-spin .8s linear infinite; }
@keyframes wb-spin { to { transform: rotate(360deg); } }

.muted { color: var(--text-3); }
.tiny { font-size: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp3 {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
/* 通用弹性占位：把其后元素推到容器右侧（卡片脚 / 工具条通用） */
.spacer { margin-left: auto; }

/* 空态 / 骨架 */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 26px 12px; color: var(--text-3); font-size: 12.5px; text-align: center;
}
.skeleton {
  height: 12px; border-radius: var(--radius-xs);
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease infinite;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 7. 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(20, 24, 32, .32);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal.is-open { display: flex; animation: fade .18s var(--ease); }
.modal__panel {
  width: 100%; max-width: 420px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: pop .22s var(--ease);
}
.modal__title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.modal__desc { font-size: 12.5px; color: var(--text-3); margin-bottom: 16px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---------- 8. 轻提示 Toast ---------- */
#wb-toast {
  position: fixed; left: 50%; bottom: 34px; z-index: 300;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transform: translateX(-50%); pointer-events: none;
}
.toast {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  animation: toastIn .22s var(--ease);
}
.toast--ok { color: var(--ok); }
.toast--err { color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* 尊重系统「减少动态效果」偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* [PATCH 20260824] 全局气泡提示（WB.tip 挂 body，避开卡片裁切） */
.wb-tip {
  position: fixed; z-index: 9999; max-width: 260px;
  padding: 6px 10px; border-radius: 8px;
  background: rgba(15, 23, 42, .92); color: #f8fafc;
  font-size: 12px; line-height: 1.5; pointer-events: none;
  opacity: 0; transform: translateY(3px);
  transition: opacity .12s ease, transform .12s ease;
}
.wb-tip.on { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .wb-tip { transition: none; } }
