/* ── 月舟 shared UI kit ──────────────────────────────────────────────
   One structural component set for ops / admin / portal.
   Colors come from each surface's own palette via --uk-* (mapped below),
   so每端保持各自配色，组件结构与交互统一。No native dialogs/selects/tooltips.
*/
:root {
  --uk-bg: var(--bg, #0a0e17);
  --uk-panel: var(--panel-solid, var(--paper, var(--panel, #121826)));
  --uk-panel2: var(--panel3, var(--acc-soft, var(--panel2, #1a2130)));
  --uk-ink: var(--ink, #e8eefc);
  --uk-ink2: var(--ink2, #9fb0cf);
  --uk-mut: var(--mut, #6a7a95);
  --uk-line: var(--line2, var(--line, #232d40));
  --uk-acc: var(--acc, #8fb4ff);
  --uk-acc-rgb: var(--acc-rgb, 143, 180, 255);
  --uk-danger: var(--danger, var(--err, #f2606a));
  --uk-ok: var(--ok, #5fd6a6);
  --uk-on-acc: var(--on-acc, #0a0e17);
  --uk-radius: var(--r, 6px);
  --uk-font: var(--font, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif);
  --uk-mono: var(--mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
  --uk-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
  --uk-shadow-sm: 0 10px 26px rgba(0, 0, 0, 0.36);
}

/* ── dialog (confirm / prompt / alert) ── */
.uk-dlg-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 7, 14, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: uk-fade 0.16s ease both;
}
.uk-dlg {
  width: min(380px, 94vw);
  background: var(--uk-panel);
  border: 1px solid var(--uk-line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--uk-shadow);
  font-family: var(--uk-font);
  animation: uk-pop 0.2s cubic-bezier(0.22, 1.2, 0.36, 1) both;
}
.uk-dlg h4 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--uk-ink);
}
.uk-dlg p {
  margin: 0;
  font-size: 13px;
  color: var(--uk-ink2);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.uk-dlg-inp {
  width: 100%;
  margin-top: 12px;
  padding: 9px 11px;
  background: var(--uk-bg);
  border: 1px solid var(--uk-line);
  border-radius: var(--uk-radius);
  color: var(--uk-ink);
  font-size: 14px;
  font-family: var(--uk-font);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.uk-dlg-inp:focus {
  border-color: var(--uk-acc);
  box-shadow: 0 0 0 3px rgba(var(--uk-acc-rgb), 0.16);
}
.uk-dlg-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

/* kit buttons (used inside dialogs; safe generic name) */
.uk-btn {
  appearance: none;
  border: 1px solid var(--uk-line);
  background: var(--uk-panel2);
  color: var(--uk-ink);
  font-family: var(--uk-font);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--uk-radius);
  cursor: pointer;
  transition: filter 0.15s, border-color 0.15s, background 0.15s;
}
.uk-btn:hover { border-color: var(--uk-acc); }
.uk-btn.primary {
  background: var(--uk-acc);
  border-color: var(--uk-acc);
  color: var(--uk-on-acc);
  font-weight: 600;
}
.uk-btn.primary:hover { filter: brightness(1.06); }
.uk-btn.danger {
  background: var(--uk-danger);
  border-color: var(--uk-danger);
  color: #fff;
  font-weight: 600;
}
.uk-btn.danger:hover { filter: brightness(1.06); }

/* ── toast ── */
.uk-toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(14px);
  z-index: 1100;
  max-width: min(88vw, 460px);
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--uk-panel);
  border: 1px solid var(--uk-line);
  color: var(--uk-ink);
  font-family: var(--uk-font);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  box-shadow: var(--uk-shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.uk-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.uk-toast.ok { border-color: rgba(var(--uk-acc-rgb), 0.5); }
.uk-toast.err { border-color: var(--uk-danger); }

/* ── custom select ── */
.uk-select { position: relative; display: inline-block; min-width: 96px; }
.uk-select-btn {
  width: 100%;
  text-align: left;
  padding: 6px 26px 6px 10px;
  border: 1px solid var(--uk-line);
  border-radius: var(--uk-radius);
  background: var(--uk-panel2);
  color: var(--uk-ink);
  font-size: 13px;
  font-family: var(--uk-font);
  cursor: pointer;
  transition: border-color 0.15s;
}
.uk-select-btn:hover,
.uk-select.open .uk-select-btn { border-color: var(--uk-acc); }
.uk-select-btn::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border: solid var(--uk-mut);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.15s;
}
.uk-select.open .uk-select-btn::after { transform: translateY(-30%) rotate(225deg); }
/* 允许下拉容器溢出，避免菜单被 .ui-inp overflow:hidden 裁切 */
.ui-inp.ui-inp-select,
.ui-inp:has(.uk-select) { overflow: visible; }
.uk-select-menu {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 10050;
  background: var(--uk-panel);
  border: 1px solid var(--uk-line);
  border-radius: var(--uk-radius);
  box-shadow: var(--uk-shadow-sm);
  padding: 4px;
  display: none;
  max-height: 260px;
  overflow: auto;
}
.uk-select.open .uk-select-menu,
.uk-select-menu.open { display: block; }
.uk-select-opt {
  padding: 7px 10px;
  border-radius: var(--uk-radius);
  font-size: 13px;
  font-family: var(--uk-font);
  color: var(--uk-ink2);
  cursor: pointer;
}
.uk-select-opt:hover { background: rgba(var(--uk-acc-rgb), 0.14); color: var(--uk-ink); }
.uk-select-opt.sel { color: var(--uk-acc); font-weight: 600; }

/* ── switch (checkbox replacement) ── */
.uk-switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  font-family: var(--uk-font);
}
.uk-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.uk-switch-ui {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background: var(--uk-panel2);
  border: 1px solid var(--uk-line);
  transition: background 0.18s, border-color 0.18s;
}
.uk-switch-ui::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--uk-mut);
  transform: translateY(-50%);
  transition: transform 0.18s, background 0.18s;
}
.uk-switch input:checked + .uk-switch-ui {
  background: rgba(var(--uk-acc-rgb), 0.28);
  border-color: var(--uk-acc);
}
.uk-switch input:checked + .uk-switch-ui::after {
  transform: translate(15px, -50%);
  background: var(--uk-acc);
}
.uk-switch input:focus-visible + .uk-switch-ui {
  box-shadow: 0 0 0 3px rgba(var(--uk-acc-rgb), 0.22);
}
.uk-switch:hover .uk-switch-ui { border-color: var(--uk-acc); }
.uk-switch-label { font-size: 13px; color: var(--uk-ink2); }

/* ── tooltip (replaces native title=) ──
   气泡由 ui-kit.js 挂到 <body> 上定位，面板/表格的 overflow:hidden 裁不到它。 */
[data-tip] { position: relative; }
.uk-tip {
  position: fixed;
  left: -9999px;
  top: -9999px;
  z-index: 10060;
  max-width: 260px;
  width: max-content;
  padding: 6px 9px;
  border-radius: var(--uk-radius);
  background: var(--uk-panel);
  border: 1px solid var(--uk-line);
  color: var(--uk-ink);
  font-family: var(--uk-font);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  white-space: pre-line;
  text-align: center;
  box-shadow: var(--uk-shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}
.uk-tip.open { opacity: 1; }
.uk-tip::after {
  content: "";
  position: absolute;
  left: var(--uk-tip-arrow, 50%);
  top: 100%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: var(--uk-line);
}
.uk-tip.below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--uk-line);
}

/* ── autocomplete（替代原生 datalist）── */
.uk-ac-menu {
  position: fixed;
  z-index: 10050;
  background: var(--uk-panel);
  border: 1px solid var(--uk-line);
  border-radius: var(--uk-radius);
  box-shadow: var(--uk-shadow-sm);
  padding: 4px;
  max-height: 240px;
  overflow: auto;
  display: none;
}
.uk-ac-menu.open { display: block; animation: uk-fade 0.12s ease both; }
.uk-ac-opt {
  padding: 6px 9px;
  border-radius: var(--uk-radius);
  font: 12px/1.35 var(--uk-mono);
  color: var(--uk-ink2);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.uk-ac-opt:hover,
.uk-ac-opt.on { background: rgba(var(--uk-acc-rgb), 0.14); color: var(--uk-ink); }

@keyframes uk-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes uk-pop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .uk-dlg-backdrop, .uk-dlg, .uk-toast,
  .uk-tip { animation: none !important; transition: none !important; }
}
