/* ============================================================
   socks_vless 管理台 · Light Glass UI
   ============================================================ */

:root {
  --glass-bg: rgba(255, 255, 255, 0.58);
  --glass-bg-strong: rgba(255, 255, 255, 0.86);
  --glass-bg-soft: rgba(255, 255, 255, 0.40);
  --glass-border: rgba(0, 0, 0, 0.10);
  --glass-border-strong: rgba(0, 0, 0, 0.22);
  --text: #15151a;
  --text-dim: #3b3b44;
  --muted: #74747e;
  --accent: #15151a;
  --accent-2: #3c3c42;
  --green: #1d8a3c;
  --red: #d50015;
  --orange: #c24a00;
  --shadow: 0 14px 44px rgba(0, 0, 0, 0.10);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  background: #ffffff;
  overflow-x: hidden;
}

/* 纯净白底，不再使用蓝紫氛围光 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(65% 48% at 12% 0%, rgba(0, 0, 0, 0.035), transparent 70%),
    radial-gradient(55% 45% at 100% 100%, rgba(0, 0, 0, 0.03), transparent 70%),
    #ffffff;
}

body.embed-mode::before,
body.embed-mode::after { display: none; }

/* —— 通用玻璃元件 —— */
.glass,
.card,
.panel,
.topbar,
.sidebar,
.login-card,
dialog,
.toast {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid var(--glass-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -1px 1px rgba(0, 0, 0, 0.03),
    var(--shadow);
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
p { margin: 0; }

.muted { color: var(--muted); font-size: 12px; }
.mono, code {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

/* —— 侧边栏 —— */
.sidebar {
  position: fixed;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: 218px;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  border-radius: var(--radius-lg);
  z-index: 20;
}
.sidebar .brand {
  font-size: 16px;
  font-weight: 800;
  padding: 6px 12px 16px;
  letter-spacing: -0.02em;
}
.sidebar .brand::first-letter { color: var(--text); }
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  flex: 1;
}
.sidebar .nav-link {
  color: var(--text-dim);
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .18s ease, color .18s ease, transform .12s ease;
}
.sidebar .nav-link:hover {
  background: var(--glass-bg-strong);
  color: var(--text);
  transform: translateX(2px);
}
.sidebar .nav-link.active {
  background: linear-gradient(135deg, #1b1b21, #414149);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}
.sidebar-foot {
  border-top: 1px solid var(--glass-border);
  padding: 12px 6px 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body.with-sidebar main {
  margin-left: 242px;
  padding: 12px 12px 0 0;
}

/* 外壳：菜单切换只切 iframe，不整页刷新 */
.frame-host {
  margin-left: 242px;
  height: calc(100vh - 12px);
  padding: 12px 12px 0 0;
}
.frame-host iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

/* 页面嵌入外壳时的布局覆盖 */
body.embed-mode { background: transparent; }
body.embed-mode .sidebar { display: none; }
body.embed-mode main {
  margin-left: 0;
  padding: 0;
}
body.embed-mode .frame-host { margin-left: 0; }

/* —— 顶栏 —— */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 22px;
  border-radius: var(--radius-lg);
  position: relative;
}
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.top-actions input,
.top-actions select { max-width: 100%; }

/* —— 按钮 · 液态玻璃光环 —— */
@property --angle-1 { syntax: "<angle>"; inherits: false; initial-value: -75deg; }
@property --angle-2 { syntax: "<angle>"; inherits: false; initial-value: -45deg; }

button, .button {
  --border-width: clamp(1px, 0.0625em, 3px);
  appearance: none;
  position: relative;
  isolation: isolate;
  background: linear-gradient(
    -75deg,
    rgba(255, 255, 255, 0.72),
    rgba(255, 255, 255, 0.96),
    rgba(255, 255, 255, 0.72)
  );
  color: var(--text);
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  backdrop-filter: blur(12px) saturate(150%);
  transition: transform .12s ease, background .18s ease, box-shadow .18s ease;
}

button::before, .button::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: calc(var(--border-width) / 2);
  left: calc(var(--border-width) / 2);
  width: calc(100% - var(--border-width));
  height: calc(100% - var(--border-width));
  border-radius: inherit;
  pointer-events: none;
  mix-blend-mode: screen;
  background: linear-gradient(
    var(--angle-2),
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.55) 42% 52%,
    rgba(255, 255, 255, 0) 60%
  );
  background-size: 220% 220%;
  background-position: 0% 50%;
  background-repeat: no-repeat;
  transition: background-position .5s cubic-bezier(0.25, 1, 0.5, 1),
    --angle-2 .5s cubic-bezier(0.25, 1, 0.5, 1);
}

button::after, .button::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: calc(var(--border-width) / -2);
  left: calc(var(--border-width) / -2);
  width: calc(100% + var(--border-width));
  height: calc(100% + var(--border-width));
  border-radius: inherit;
  padding: var(--border-width);
  pointer-events: none;
  background:
    conic-gradient(
      from var(--angle-1) at 50% 50%,
      rgba(0, 0, 0, 0.55),
      rgba(0, 0, 0, 0) 6% 42%,
      rgba(0, 0, 0, 0.75) 50%,
      rgba(0, 0, 0, 0) 58% 94%,
      rgba(0, 0, 0, 0.55)
    ),
    linear-gradient(180deg, rgba(0, 0, 0, 0.26), rgba(0, 0, 0, 0.10));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  transition: --angle-1 .5s ease, opacity .2s ease;
}

button:hover, .button:hover {
  background: linear-gradient(
    -75deg,
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 1),
    rgba(255, 255, 255, 0.9)
  );
  transform: scale(0.975);
}
button:hover::after, .button:hover::after { --angle-1: -125deg; }
button:hover::before, .button:hover::before { background-position: 28% 50%; }
button:active, .button:active { transform: scale(0.95); }
button:active::after, .button:active::after { --angle-1: -75deg; }
button:active::before, .button:active::before {
  --angle-2: -15deg;
  background-position: 50% 18%;
}
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

button.primary, .button.primary {
  background: linear-gradient(135deg, #1b1b21, #3c3c42 65%, #54545c);
  color: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}
button.primary:hover {
  filter: brightness(1.08);
  background: linear-gradient(135deg, #1b1b21, #3c3c42 65%, #54545c);
}
button.ghost { background: rgba(255, 255, 255, 0.35); }
button.danger {
  background: linear-gradient(135deg, rgba(213, 0, 21, 0.92), rgba(190, 0, 18, 0.92));
  color: #fff;
  box-shadow: 0 10px 24px rgba(213, 0, 21, 0.22);
}
.danger-text { color: var(--red); }
button.mini { padding: 4px 11px; font-size: 12px; border-radius: 999px; }

/* 分组标签内部的小按钮不套光环，保持干净 */
.group-tabs .tab::before,
.group-tabs .tab::after { display: none; }
.group-tabs .tab { background: transparent; }

/* —— 登录 —— */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 360px;
  border-radius: 34px;
  padding: 34px 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise .5s cubic-bezier(.2, .8, .25, 1) both;
}
.login-card h1 { font-size: 23px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* —— 表单 —— */
label { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; color: var(--text-dim); }
label.check { flex-direction: row; align-items: center; gap: 8px; }

input, select {
  background: rgba(0, 0, 0, 0.035);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus, select:focus {
  border-color: rgba(0, 0, 0, 0.42);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
}
input::placeholder { color: rgba(0, 0, 0, 0.32); }
select option { background: #fff; color: var(--text); }

textarea {
  background: rgba(0, 0, 0, 0.035);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.7;
  outline: none;
  resize: vertical;
  min-height: 180px;
  width: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: border-color .18s ease, box-shadow .18s ease;
}
textarea:focus {
  border-color: rgba(0, 0, 0, 0.42);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
}
textarea::placeholder { color: rgba(0, 0, 0, 0.32); }

/* 添加节点页 */
.add-panel { margin-top: 16px; }
.add-body { padding: 18px 18px 20px; }

/* 设置页 */
.settings-body { padding: 18px 20px 20px; }
.settings-body .form-grid { margin-top: 0; }
.form-grid.one-col { grid-template-columns: 1fr; }

.target-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.035);
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.target-row label.inline { flex-direction: row; align-items: center; gap: 10px; margin: 0; }
.target-row select { min-width: 260px; }
.result-dialog { width: min(680px, 94vw); }
.template-dialog { width: min(760px, 94vw); }
.template-dialog textarea { min-height: 64px; }
.vless-list, .fail-list { max-height: 42vh; overflow: auto; margin-top: 12px; }

/* 每条 VLESS 的二维码卡片 */
.vless-card {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 10px;
}
.qr-box {
  position: relative;
  isolation: isolate;
  flex: 0 0 auto;
  padding: 14px 14px 16px;
  background: #fff;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
/* 液态玻璃窄边白圈（四边） */
.qr-box::before {
  content: "";
  position: absolute;
  inset: -8px;
  z-index: -1;
  border-radius: 28px;
  border: 8px solid rgba(255, 255, 255, 0.82);
  background: transparent;
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  backdrop-filter: blur(14px) saturate(180%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.9),
    0 10px 28px rgba(0, 0, 0, 0.18),
    inset 0 2px 4px rgba(255, 255, 255, 1),
    inset 0 -3px 5px rgba(255, 255, 255, 0.5);
  pointer-events: none;
}
.qr-box img, .qr-box canvas {
  width: 240px;
  height: auto;
  display: block;
  border-radius: 8px;
  cursor: zoom-in;
}

/* 节点数据页二维码预览 */
.qr-dialog { width: min(420px, 92vw); }
.qr-preview {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}
.qr-preview img {
  width: min(320px, 72vw);
  height: auto;
  border-radius: 10px;
}

/* 点击二维码全屏放大，方便扫描 */
.qr-zoom {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: zoom-out;
}
.qr-zoom img {
  width: min(78vmin, 560px);
  height: min(78vmin, 560px);
  background: #fff;
  padding: 18px;
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.vless-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.vless-meta code {
  width: 100%;
  font-size: 12px;
  word-break: break-all;
  color: var(--text-dim);
  max-height: 84px;
  overflow: auto;
}
.vless-output {
  width: 100%;
  margin-top: 12px;
  min-height: 110px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-dim);
  white-space: pre;
  overflow: auto;
}
.list-title { margin: 4px 0 8px; font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.vless-row, .fail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.035);
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 6px;
}
.vless-row code {
  flex: 1;
  font-size: 12px;
  word-break: break-all;
  color: var(--text-dim);
  min-width: 0;
}
.fail-row { color: #b00012; font-size: 12.5px; display: block; }

/* —— 卡片与面板 —— */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  padding: 20px 24px;
}
.card {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: transform .18s ease, box-shadow .18s ease;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -30%;
  width: 90%;
  height: 120%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.05), transparent 62%);
  pointer-events: none;
}
.card:hover { transform: translateY(-2px); }
.card .label { color: var(--muted); font-size: 12px; margin: 0 0 6px; font-weight: 500; }
.card .value { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
.value.ok { color: var(--green); }
.value.bad { color: var(--red); }
.value.warn { color: var(--orange); }

.panel {
  margin: 0 24px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.panel-head > div { display: flex; gap: 10px; }

/* —— 表格 —— */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid rgba(0, 0, 0, 0.07); }
th, td { white-space: nowrap; }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
td { font-size: 13px; color: var(--text-dim); }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(0, 0, 0, 0.04); }
.empty { text-align: center; color: var(--muted); padding: 34px; }

.badge {
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  line-height: 1.5;
}
.badge-ok { background: rgba(29, 138, 60, 0.12); color: #15733a; border: 1px solid rgba(29, 138, 60, 0.25); }
.badge-off { background: rgba(0, 0, 0, 0.05); color: var(--muted); border: 1px solid rgba(0, 0, 0, 0.10); }
.badge-bad { background: rgba(213, 0, 21, 0.08); color: #a30010; border: 1px solid rgba(213, 0, 21, 0.22); }

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--text);
  cursor: pointer;
}
tbody tr.selected-row {
  background: rgba(0, 0, 0, 0.06) !important;
  box-shadow: inset 3px 0 0 var(--text);
}
.selection-bar { display: flex; align-items: center; gap: 10px; }

.group-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.group-tabs .tab { background: transparent; border-color: transparent; color: var(--muted); }
.group-tabs .tab.active {
  background: linear-gradient(135deg, #1b1b21, #414149);
  color: #fff;
  border-color: rgba(0, 0, 0, 0.18);
}

.link-cell { display: flex; align-items: center; gap: 8px; }
.link-cell code {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
  display: block;
}
.ops { white-space: nowrap; }
.ops button + button { margin-left: 6px; }

/* 表格内需要换行展示的少量内容（错误信息）不无限撑宽 */
td.error {
  white-space: normal;
  word-break: break-word;
  max-width: 260px;
}
td > span {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: inline-block;
  vertical-align: bottom;
}

/* —— 对话框 —— */
dialog {
  color: var(--text);
  border-radius: 30px;
  padding: 26px;
  width: min(560px, 92vw);
  animation: rise .28s cubic-bezier(.2, .8, .25, 1) both;
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  backdrop-filter: blur(8px) saturate(120%);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; }

/* —— 状态与提示 —— */
.error { color: #c30010; font-size: 13px; }
.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 600;
  animation: rise .25s ease both;
  z-index: 60;
}

/* —— 版本更新提示 —— */
.update-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--glass-border);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.16);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  font-size: 13px;
  color: var(--text);
}
.update-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(29, 138, 60, 0.15);
}
#update-command {
  width: 100%;
  min-height: 56px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

/* 小屏适配 */
@media (max-width: 860px) {
  .sidebar { width: 64px; padding: 14px 8px; }
  .sidebar .brand, .sidebar .nav-link span, .sidebar-foot .muted {
    display: none;
  }
  .sidebar .nav-link { justify-content: center; }
  body.with-sidebar main { margin-left: 76px; padding-right: 8px; }
  .frame-host { margin-left: 76px; }
  .form-grid { grid-template-columns: 1fr; }
}
