/* ============ 佰川星途 · 紫蓝星空 ============ */
:root {
  --bg: #0d0b1e;
  --bg2: #141128;
  --panel: #1a1733;
  --panel2: #211d40;
  --line: #2e2957;
  --line2: #3b3470;
  --txt: #e8e6f7;
  --dim: #9a94c4;
  --purple: #7c6cf0;
  --purple2: #8b7cf7;
  --blue: #4facfe;
  --green: #35d07f;
  --yellow: #f5b942;
  --red: #ff5f6d;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--txt);
}
.hidden { display: none !important; }
.dim { color: var(--dim); }

/* ---------- 登录页 ---------- */
.login-page {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, #1c1740 0%, var(--bg) 60%);
}
.stars {
  position: absolute; inset: 0; pointer-events: none; opacity: .7;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 62%, #cfd6ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 58% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 48%, #b8c6ff 50%, transparent 51%),
    radial-gradient(1px 1px at 86% 78%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 22% 84%, #d9d2ff 50%, transparent 51%),
    radial-gradient(1px 1px at 46% 36%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 22%, #cfd6ff 50%, transparent 51%);
}
.login-card {
  position: relative; width: 360px; background: var(--panel);
  border: 1px solid var(--line2); border-radius: 16px; padding: 36px 32px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(124,108,240,.15);
  text-align: center;
}
.login-logo h1 { font-size: 18px; margin-top: 14px; letter-spacing: .5px; }
.login-logo .sub { color: var(--dim); font-size: 12px; margin: 6px 0 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-card input, .form-row input, .form-row select {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line2); background: var(--bg2); color: var(--txt);
  font-size: 14px; outline: none;
}
.login-card input:focus, .form-row input:focus, .form-row select:focus { border-color: var(--purple); }
.hint { color: var(--yellow); font-size: 13px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line2);
  background: var(--panel2); color: var(--txt); cursor: pointer; font-size: 13px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--purple); }
.btn.primary { background: linear-gradient(135deg, var(--purple), #5a8dee); border: none; color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { background: #3a1522; border-color: #6e2436; color: #ff9aa5; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn.block { width: 100%; padding: 11px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 主布局 ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.main-body { flex: 1; display: flex; min-height: 0; }
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- 左侧服务器列表 ---------- */
.sidebar {
  width: 250px; flex: none; display: flex; flex-direction: column;
  background: var(--bg2); border-right: 1px solid var(--line);
  -webkit-user-select: none; user-select: none;
}
.main-body.sb-off .sidebar { display: none; }
.sb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 10px; font-weight: 600; font-size: 13.5px;
}
.sb-count {
  font-size: 11px; font-weight: 400; color: var(--dim);
  background: var(--panel2); border: 1px solid var(--line2);
  padding: 1px 8px; border-radius: 20px;
}
.sb-search {
  margin: 0 12px 10px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--line2); background: var(--bg); color: var(--txt);
  font-size: 12.5px; outline: none;
}
.sb-search:focus { border-color: var(--purple); }
.sb-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.sb-empty { color: var(--dim); font-size: 12.5px; text-align: center; padding: 30px 10px; line-height: 1.8; }
.sb-item {
  padding: 10px 10px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; margin-bottom: 4px; transition: .12s;
  position: relative;
}
.sb-item:hover { background: var(--panel); border-color: var(--line); }
.sb-item.active { background: var(--panel2); border-color: var(--line2); }
.sb-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 3px; background: linear-gradient(180deg, var(--purple), var(--blue));
}
.sb-row { display: flex; align-items: center; gap: 7px; }
.sb-row .sb-name {
  font-size: 13px; font-weight: 600; flex: 1; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.sb-dot { width: 8px; height: 8px; border-radius: 50%; background: #555; flex: none; }
.sb-dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.sb-dot.off { background: var(--red); box-shadow: 0 0 6px var(--red); }
.sb-dot.checking { background: var(--yellow); animation: pulse 1s infinite; }
.sb-dot.port { background: transparent; border: 2px solid var(--green); opacity: .55; }
.sb-edit {
  width: 20px; height: 20px; border-radius: 5px; border: none; background: transparent;
  color: var(--dim); font-size: 11px; cursor: pointer; flex: none;
  display: none; align-items: center; justify-content: center;
}
.sb-item:hover .sb-edit { display: flex; }
.sb-edit:hover { background: var(--line); color: #fff; }
.sb-note {
  font-size: 12px; color: #b8b2e8; margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-note.empty { color: #5d5786; font-style: italic; }
.sb-host {
  font-size: 11px; color: var(--dim); margin-top: 3px; font-family: Consolas, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-foot {
  padding: 8px 14px; font-size: 11px; border-top: 1px solid var(--line);
  text-align: center; color: var(--dim);
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--bg2); border-bottom: 1px solid var(--line);
  -webkit-user-select: none; user-select: none;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand .ver { font-size: 11px; font-weight: 400; color: var(--dim); margin-left: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.stat-text { color: var(--dim); font-size: 12px; margin-right: 6px; }

/* ---------- 标签栏 ---------- */
.tabbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 8px 0 4px;
}
.tabs { display: flex; overflow-x: auto; scrollbar-width: thin; }
.tab {
  display: flex; align-items: center; gap: 6px; padding: 9px 14px; cursor: pointer;
  border-right: 1px solid var(--line); color: var(--dim); font-size: 13px;
  white-space: nowrap; position: relative; -webkit-user-select: none; user-select: none;
}
.tab:hover { color: var(--txt); background: var(--panel2); }
.tab.active { color: var(--txt); background: var(--bg); }
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--purple), var(--blue));
}
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: #555; flex: none; }
.tab .dot.checking { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); animation: pulse 1s infinite; }
.tab .dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.tab .dot.off { background: var(--red); box-shadow: 0 0 6px var(--red); }
@keyframes pulse { 50% { opacity: .35; } }
.tab .close {
  width: 18px; height: 18px; border-radius: 4px; display: flex; align-items: center;
  justify-content: center; font-size: 11px; color: var(--dim); border: none; background: transparent; cursor: pointer;
}
.tab .close:hover { background: #443c6e; color: #fff; }
.tabbar-right { display: flex; gap: 8px; padding: 6px 4px; }

/* ---------- 内容区 ---------- */
.panes { flex: 1; position: relative; overflow: hidden; }
.pane { position: absolute; inset: 0; display: none; flex-direction: column; }
.pane.active { display: flex; }

/* 服务器卡片首页 */
.server-grid {
  flex: 1; overflow-y: auto; padding: 22px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; align-content: start;
}
.empty-tip { grid-column: 1/-1; text-align: center; color: var(--dim); padding: 60px 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; transition: .15s; position: relative;
}
.card:hover { border-color: var(--line2); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
/* 卡片实时桌面缩略图 */
.c-thumb {
  position: relative; width: 100%; aspect-ratio: 16/9; margin-bottom: 12px;
  background: #060512; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; cursor: pointer; display: block;
}
.c-thumb canvas { width: 100%; height: 100%; display: block; object-fit: contain; }
.c-thumb .thumb-ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 12px; background:
    repeating-linear-gradient(45deg, #0a0819 0 12px, #0d0b22 12px 24px);
}
.c-thumb .thumb-play {
  position: absolute; right: 10px; bottom: 8px; width: 26px; height: 26px;
  border-radius: 50%; background: rgba(124,108,240,.85); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
  padding-left: 2px; box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.c-thumb .live-flag {
  position: absolute; left: 8px; top: 6px; font-size: 10px; letter-spacing: 1px;
  color: #ff8f98; background: rgba(20,6,14,.75); border: 1px solid #6e2436;
  padding: 1px 7px; border-radius: 20px; animation: pulse 1.6s infinite;
}
.c-thumb.live { border-color: #2c5e38; }
.c-thumb:hover { border-color: var(--purple); }

.card .c-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; padding-right: 64px; }
.card .c-host { color: var(--dim); font-size: 12.5px; font-family: Consolas, monospace; }
.card .c-note { color: var(--dim); font-size: 12px; margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .c-tags { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--line2); color: var(--dim); }
.badge.win { color: #7fc3ff; border-color: #274b6e; }
.badge.linux { color: #9fe6a8; border-color: #2c5e38; }
.card .c-actions { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
/* 卡片底部操作条（不再压在缩略图上，避免误点删除） */
.card .c-foot {
  display: flex; align-items: center; gap: 6px; margin-top: 12px;
  padding-top: 10px; border-top: 1px solid var(--line);
}
.card .c-foot .grow { flex: 1; }
.card .c-foot .btn { padding: 4px 10px; font-size: 12px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line2);
  background: var(--bg2); color: var(--txt); cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: .15s;
}
.icon-btn:hover { border-color: var(--purple); background: var(--panel2); }
.icon-btn.del:hover { border-color: var(--red); color: var(--red); }
.st-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); }
.st-line .dot { width: 8px; height: 8px; border-radius: 50%; background: #555; }
.st-line.up .dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.st-line.up { color: var(--green); }
.st-line.down .dot { background: var(--red); }
.st-line.down { color: var(--red); }
.st-line.checking .dot { background: var(--yellow); animation: pulse 1s infinite; }

/* 远程桌面页 */
.rdp-head {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line); font-size: 13px;
}
.rdp-head .name { font-weight: 600; }
.rdp-head .host { color: var(--dim); font-family: Consolas, monospace; font-size: 12px; }
.rdp-head .grow { flex: 1; }
.rdp-head .state { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.rdp-head .state .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }
.rdp-head .state.on .dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.rdp-head .state.on { color: var(--green); }
.rdp-head .state.off .dot { background: var(--red); box-shadow: 0 0 6px var(--red); }
.rdp-head .state.off { color: var(--red); }
.rdp-canvas-wrap {
  flex: 1; position: relative; overflow: auto; background: #060512;
  display: flex; align-items: center; justify-content: center;
  /* 关键：guacamole 的画布层用 z-index:-1，若本容器不建立层叠上下文，
     画布会被这里的背景色盖住 → 表现为「已连接但一片黑」 */
  isolation: isolate;
}
.rdp-canvas-wrap .guac-display { outline: none; }
.rdp-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; background: rgba(8,6,20,.92);
  z-index: 5; text-align: center; padding: 30px;
}
.rdp-overlay .spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line2); border-top-color: var(--purple); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.rdp-overlay .msg { color: var(--dim); font-size: 14px; max-width: 480px; }
.rdp-overlay.error .spinner { display: none; }
.rdp-overlay.error .msg { color: var(--red); }
.rdp-overlay .hint {
  max-width: 520px; font-size: 12.5px; line-height: 1.7;
  color: var(--dim); background: rgba(255,255,255,.04);
  border: 1px solid var(--line2); border-radius: 8px; padding: 10px 14px;
}

/* ---------- 远程桌面全屏模式（画面铺满窗口） ---------- */
body.rdp-full .topbar,
body.rdp-full .tabbar,
body.rdp-full .sidebar,
body.rdp-full .rdp-head { display: none !important; }
body.rdp-full { cursor: auto; }
.fs-exit {
  position: fixed; top: 14px; right: 16px; z-index: 300;
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line2);
  background: rgba(26, 23, 51, .82); color: var(--txt); font-size: 13px; cursor: pointer;
  backdrop-filter: blur(4px); opacity: .4; transition: .15s; white-space: nowrap;
}
.fs-exit:hover { opacity: 1; border-color: var(--purple); }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(5,3,16,.66); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-box {
  width: 440px; max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal-box.wide { width: 780px; }
.modal-box.small { width: 380px; }
.cf-msg { font-size: 13.5px; line-height: 1.7; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.modal-head .x { background: none; border: none; color: var(--dim); font-size: 15px; cursor: pointer; }
.modal-head .x:hover { color: #fff; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-body.no-pad { padding: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 12.5px; color: var(--dim); }
.form-row label em { color: var(--yellow); font-style: normal; font-size: 11.5px; }
.form-row.three { flex-direction: row; gap: 10px; }
.form-row.three > div { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.form-row.three label { font-size: 12.5px; color: var(--dim); }

/* 日志表 */
.log-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.log-table th {
  text-align: left; padding: 9px 14px; color: var(--dim); font-weight: 500;
  background: var(--bg2); position: sticky; top: 0; border-bottom: 1px solid var(--line);
}
.log-table td { padding: 8px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log-table td.t { color: var(--dim); font-family: Consolas, monospace; font-size: 12px; }
.log-table .a-ok { color: var(--green); }
.log-table .a-fail { color: var(--red); }
.log-table .a-warn { color: var(--yellow); }
.log-table .a-info { color: var(--blue); }

/* Toast */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--panel2); border: 1px solid var(--line2); color: var(--txt);
  padding: 10px 22px; border-radius: 10px; font-size: 13px; z-index: 200;
  transition: .25s; pointer-events: none; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--red); color: #ffb3ba; }
.toast.ok { border-color: var(--green); }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
