/* Larktun 云雀通 - 网络架构可视化 */
:root {
  --bg: #0b1020;
  --panel: #131a2e;
  --panel-2: #1a2238;
  --border: #2a3350;
  --text: #e6eaf5;
  --muted: #8a93ad;
  --primary: #3b6bff;
  --primary-2: #5b8bff;
  --hs: #22c55e;
  --derp: #ef4444;
  --client: #f59e0b;
  --saas: #3b82f6;
  --direct: #22c55e;
  --relay: #ef4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(160deg, #070b1a 0%, #0c1226 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.header-left h1 {
  font-size: 18px;
  margin: 0 0 6px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.subtitle {
  font-size: 12px;
  color: var(--muted);
}
.metrics {
  display: flex;
  gap: 28px;
}
.metric { text-align: right; }
.metric-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.metric-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.metric-value .sep { color: var(--muted); margin: 0 4px; }

/* Visualization */
.viz {
  padding: 14px;
  background: #0a0f1e;
  border-radius: 14px;
  overflow: hidden;
}
#topology {
  width: 100%;
  height: auto;
  display: block;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(59, 107, 255, 0.10), transparent 60%),
    #0a0f1e;
  border-radius: 10px;
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.control-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.control-row.dual,
.control-row.sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.control-row.login-row .btn-primary {
  margin-left: auto;
  min-width: 220px;
  padding: 11px 36px;
}

/* 一组 "标签 + 滑块 + 数值" 的字段 */
.field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.field .slider-wrap {
  flex: 1;
  min-width: 0;
}

.control-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.seg-toggle {
  display: inline-flex;
  background: #1e263f;
  border-radius: 8px;
  padding: 3px;
}
.seg {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 7px 22px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.seg.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 107, 255, 0.4);
}

.slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
}


input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #2a3350;
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-2);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(91, 139, 255, 0.18);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--primary-2);
  cursor: pointer;
}
.count-box {
  width: 52px;
  height: 34px;
  line-height: 34px;
  text-align: center;
  background: #1e263f;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
}

.btn {
  background: #1e263f;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.18s;
}
.btn:hover:not(:disabled) {
  background: #27304f;
  border-color: #3a456a;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.attention {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
  animation: btnPulseWarn 0.6s ease-in-out 2;
}
.btn.wide { width: 100%; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-2);
  border-color: var(--primary-2);
}
@keyframes btnPulseWarn {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 14px);
  min-width: 240px;
  max-width: min(86vw, 520px);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(245, 158, 11, 0.5);
  background: rgba(15, 20, 35, 0.95);
  color: #f8d188;
  font-size: 13px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 99;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* SVG node styles */
.node-label {
  font-size: 11px;
  font-weight: 600;
  fill: var(--text);
  text-anchor: middle;
  dominant-baseline: middle;
  letter-spacing: 0.3px;
}
.node-pill {
  fill: transparent;
  stroke-width: 1.5;
}
.node-pill.hs { stroke: var(--hs); }
.node-pill.derp { stroke: var(--derp); }
.node-pill.client { stroke: var(--client); }
.node-pill.saas { stroke: var(--saas); fill: rgba(59, 130, 246, 0.12); }
.node-pill.gateway { stroke: #a78bfa; fill: rgba(167, 139, 250, 0.1); }

/* Headscale 集群边框 */
.cluster-frame {
  fill: rgba(34, 197, 94, 0.03);
  stroke: rgba(34, 197, 94, 0.38);
  stroke-width: 1.2;
  stroke-dasharray: 6 5;
}
.cluster-title {
  font-size: 11px;
  font-weight: 600;
  fill: #22c55e;
  letter-spacing: 0.6px;
  text-anchor: middle;
}

/* 信令包上的小标签 */
.packet-label {
  font-size: 10px;
  font-weight: 600;
  fill: #e6eaf5;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #0a0f1e;
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.status-text {
  font-size: 10px;
  text-anchor: middle;
  dominant-baseline: middle;
  letter-spacing: 0.4px;
}
.status-text.off { fill: var(--muted); }
.status-text.on { fill: var(--hs); }

/* Edges */
.edge {
  fill: none;
  stroke: #3a456a;
  stroke-width: 1;
  stroke-dasharray: 4 5;
  opacity: 0.55;
}
.edge.active-login {
  stroke: var(--primary-2);
  stroke-width: 2;
  stroke-dasharray: none;
  opacity: 0.95;
  filter: url(#glow);
}
.edge.active-direct {
  stroke: var(--direct);
  stroke-width: 2.2;
  stroke-dasharray: none;
  opacity: 0.95;
  filter: url(#glow);
}
.edge.active-relay {
  stroke: var(--relay);
  stroke-width: 2;
  stroke-dasharray: 6 6;
  opacity: 0.9;
  animation: dashmove 0.8s linear infinite;
}
@keyframes dashmove {
  to { stroke-dashoffset: -24; }
}

.packet {
  filter: drop-shadow(0 0 4px currentColor);
}
