/* ============================================================
   Wos UI · 组件层
   Modal 弹窗 / Toast 提示 / Tabs 标签页 / Switch 开关
   Checkbox 复选 / Pagination 分页 / Progress 进度
   Metrics 指标条 / Avatar 头像 / Tag 标签 / Tooltip 提示
   依赖：tokens.css、base.css
   ============================================================ */

/* ---------------- Modal 弹窗 ---------------- */
.mask {
  position: fixed;
  inset: 0;
  background: oklch(0.2 0.02 var(--hue) / 0.45);
  display: grid;
  place-items: center;
  z-index: 60;
  animation: wos-fade-in 180ms var(--ease);
}
.mask[hidden] { display: none; }
.modal {
  width: 400px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s-5) 22px;
  box-shadow: 0 18px 50px oklch(0.2 0.03 var(--hue) / 0.25);
  animation: wos-pop 200ms var(--ease-expo);
}
.modal-title { display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.modal-sub { font-size: 12px; color: var(--text-3); margin: 0 0 14px; }
.modal-err { font-size: 12.5px; color: var(--danger); margin: 2px 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: var(--s-5); }
@keyframes wos-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes wos-pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------------- Toast 轻提示 ---------------- */
.toast-host {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border-radius: 9px;
  background: oklch(0.24 0.012 var(--hue));
  color: #fff;
  font-size: 13.2px;
  box-shadow: 0 10px 30px -8px oklch(0.2 0.03 var(--hue) / 0.42),
              0 3px 10px -3px oklch(0.2 0.02 var(--hue) / 0.24);
  max-width: min(90vw, 440px);
  animation: wos-toast-in 200ms var(--ease-expo);
}
.toast-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand-2);
  flex-shrink: 0;
}
.toast--ok .toast-dot { background: #34d399; }
.toast--error .toast-dot { background: #f87171; }
.toast--info .toast-dot { background: var(--gold); }
.toast--leave { opacity: 0; transform: translateY(-10px) scale(0.97); transition: all 200ms var(--ease); }
@keyframes wos-toast-in { from { opacity: 0; transform: translateY(-10px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ---------------- Tabs 标签页 ---------------- */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-sunken);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
}
.tab {
  height: 30px;
  padding: 0 16px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
.tab--active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* 下划线式 Tabs（备选风格） */
.tabs--line {
  display: flex;
  gap: var(--s-5);
  padding: 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.tabs--line .tab {
  height: 38px;
  padding: 0 2px;
  border-radius: 0;
  background: none;
  box-shadow: none;
  position: relative;
}
.tabs--line .tab--active { background: none; box-shadow: none; color: var(--brand); }
.tabs--line .tab--active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--brand);
  border-radius: 2px;
}

/* ---------------- Switch 开关 ---------------- */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: var(--r-full);
  background: oklch(0.80 0.008 var(--hue));
  transition: background var(--dur) var(--ease);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px oklch(0.2 0.02 var(--hue) / 0.3);
  transition: transform var(--dur) var(--ease-expo);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--shadow-glow); }
.switch input:disabled + .switch-track { opacity: 0.45; cursor: not-allowed; }
.switch-sm { width: 32px; height: 18px; }
.switch-sm .switch-track::after { width: 14px; height: 14px; }
.switch-sm input:checked + .switch-track::after { transform: translateX(14px); }

/* ---------------- Checkbox 复选框 ---------------- */
.ck {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-2);
  user-select: none;
}
.ck input { position: absolute; opacity: 0; pointer-events: none; }
.ck-box {
  width: 17px; height: 17px;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  flex-shrink: 0;
}
.ck-box svg {
  width: 11px; height: 11px;
  stroke: #fff;
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-expo);
}
.ck input:checked + .ck-box { background: var(--brand); border-color: var(--brand); }
.ck input:checked + .ck-box svg { opacity: 1; transform: scale(1); }
.ck input:focus-visible + .ck-box { box-shadow: var(--shadow-glow); }
.ck input:disabled + .ck-box { opacity: 0.45; }
.ck:hover .ck-box { border-color: var(--line-hover); }
.ck input:checked:hover + .ck-box { border-color: var(--brand); }

/* ---------------- Pagination 分页 ---------------- */
/* 用法：<div class="pager"><button class="pager-btn">‹</button><button class="pager-btn pager-btn--on">1</button>…<span class="pager-info">共 n 条</span></div>
   当前页类名 pager-btn--on；历史别名 pager-btn--active / pager-ellipsis / pager-gap 均兼容 */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.pager-btn:hover:not(:disabled):not(.pager-btn--on):not(.pager-btn--active) {
  border-color: var(--brand);
  color: var(--brand);
}
.pager-btn--on,
.pager-btn--active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}
.pager-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pager-ellipsis,
.pager-gap {
  min-width: 18px;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  user-select: none;
}
.pager-info {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------------- Progress 进度条 ---------------- */
.prog {
  height: 7px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  border: 1px solid var(--line-2);
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  transition: width var(--dur-slow) var(--ease-expo);
}
.prog-fill--ok { background: oklch(0.62 0.14 155); }
.prog-fill--warn { background: oklch(0.72 0.14 75); }
.prog-fill--danger { background: oklch(0.60 0.19 27); }

/* ---------------- Metrics 指标条 ---------------- */
.metrics {
  display: grid;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.metric {
  padding: var(--s-5) var(--s-6);
  border-left: 1px solid var(--line-2);
  min-width: 0;
}
.metric:first-child { border-left: 0; }
.m-label {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.m-value {
  font-size: clamp(24px, 2.3vw, 32px);
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.18;
  margin-top: var(--s-2);
  font-variant-numeric: tabular-nums;
}
.m-value .m-unit { font-size: 14px; font-weight: 400; color: var(--text-3); margin-left: 2px; letter-spacing: 0; }
.metric--brand .m-value { color: var(--brand); }
.metric--gold .m-value { color: var(--gold-deep); }
.m-foot { margin-top: 5px; min-height: 17px; font-size: 12px; color: var(--text-3); }
.m-foot .up { color: oklch(0.55 0.14 155); font-weight: 500; }
.m-foot .down { color: oklch(0.55 0.18 27); font-weight: 500; }

/* ---------------- Avatar 头像 ---------------- */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 1px 4px oklch(0.55 0.18 var(--hue) / 0.3);
  flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }
.avatar-lg { width: 44px; height: 44px; font-size: 17px; }
.avatar-group { display: flex; }
.avatar-group .avatar {
  border: 2px solid var(--surface);
  margin-left: -8px;
}
.avatar-group .avatar:first-child { margin-left: 0; }

/* ---------------- Tag 标签（可点击/可删除） ---------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: default;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
  user-select: none;
}
.tag--click { cursor: pointer; }
.tag--click:hover { border-color: var(--brand-line); background: var(--brand-soft); color: oklch(0.47 0.17 var(--hue)); }
.tag--on { border-color: var(--brand); background: var(--brand-soft); color: oklch(0.47 0.17 var(--hue)); font-weight: 500; }
.tag-x {
  display: inline-grid;
  place-items: center;
  width: 14px; height: 14px;
  margin-right: -3px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1;
}
.tag-x:hover { background: oklch(0.24 0.02 var(--hue) / 0.1); color: var(--text); }

/* ---------------- Tooltip（纯 CSS，data-tip） ---------------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  background: oklch(0.24 0.012 var(--hue));
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  z-index: 80;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tip--bottom]::after { bottom: auto; top: calc(100% + 7px); }

/* ---------------- Notice 通告条 ---------------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--brand-line);
  background: var(--brand-soft);
  color: var(--text);
}
.notice--ok { border-color: oklch(0.88 0.06 155); background: var(--ok-soft); }
.notice--warn { border-color: oklch(0.88 0.07 75); background: var(--warn-soft); }
.notice--danger { border-color: var(--danger-line); background: var(--danger-soft); }

/* ---------------- Kbd 键位 ---------------- */
.kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-sunken);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-2);
}

/* ---------------- Drawer 抽屉 ---------------- */
.scrim {
  position: fixed;
  inset: 0;
  background: oklch(0.2 0.02 var(--hue) / 0.42);
  z-index: 25;
  animation: wos-fade-in 180ms var(--ease);
}
.drawer {
  position: fixed;
  top: 0; bottom: 0;
  width: 320px;
  max-width: 86vw;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 26;
  transition: transform var(--dur-slow) var(--ease-expo);
}
.drawer--left { left: 0; transform: translateX(-100%); }
.drawer--right { right: 0; transform: translateX(100%); }
.drawer--open.drawer--left, .drawer--open.drawer--right { transform: none; }

