/* plugin/assets/widget.css */
/* Komari UnlockTest 首页可拖动浮层样式 — 大字号高对比度终端风 (正文 >= 16px) */

#km-unlock-floating-root {
  --km-ul-bg: rgba(15, 23, 42, 0.96);
  --km-ul-panel: #111827;
  --km-ul-card: #1e293b;
  --km-ul-card-hover: #263449;
  --km-ul-border: #334155;
  --km-ul-text: #f8fafc;
  --km-ul-muted: #94a3b8;
  --km-ul-green: #10b981;
  --km-ul-green-glow: rgba(16, 185, 129, 0.24);
  --km-ul-red: #ef4444;
  --km-ul-red-glow: rgba(239, 68, 68, 0.22);
  --km-ul-cyan: #06b6d4;
  --km-ul-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, Consolas, monospace;
  --km-ul-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  position: fixed;
  right: 24px;
  bottom: 28px;
  width: 440px;
  max-width: calc(100vw - 20px);
  background: var(--km-ul-bg);
  color: var(--km-ul-text);
  border: 1px solid var(--km-ul-border);
  border-radius: 16px;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-family: var(--km-ul-sans);
  font-size: 16px;
  line-height: 1.45;
  z-index: 9990;
  user-select: none;
  overflow: hidden;

  /* 展开状态下必须纵向排列 (flex-direction: column)，绝对不能横排 */
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: flex-start !important;

  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.15s ease,
              box-shadow 0.2s ease,
              border-radius 0.22s ease;
}

#km-unlock-floating-root * {
  box-sizing: border-box;
}

/* 核心优化 1：缩小到 48px 方形 SVG 格式悬浮图标 */
#km-unlock-floating-root.km-ul-minimized {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  border-radius: 12px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: linear-gradient(135deg, #090d16 0%, #1e293b 100%) !important;
  border: 2px solid var(--km-ul-cyan) !important;
  box-shadow: 0 10px 28px rgba(6, 182, 212, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.1) !important;
  cursor: pointer !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
}

#km-unlock-floating-root.km-ul-minimized:hover {
  transform: scale(1.1);
  box-shadow: 0 14px 34px rgba(6, 182, 212, 0.65), 0 0 14px rgba(6, 182, 212, 0.5) !important;
  border-color: #67e8f9 !important;
}

/* 最小化状态下隐藏面板的所有子容器 */
#km-unlock-floating-root.km-ul-minimized .km-ul-header,
#km-unlock-floating-root.km-ul-minimized .km-ul-body,
#km-unlock-floating-root.km-ul-minimized .km-ul-footer {
  display: none !important;
}

/* 48px 方形图标容器与内部 SVG */
.km-ul-minimized-icon-box {
  display: none;
  width: 48px;
  height: 48px;
  position: relative;
  align-items: center;
  justify-content: center;
}

#km-unlock-floating-root.km-ul-minimized .km-ul-minimized-icon-box {
  display: flex;
}

.km-ul-minimized-svg {
  width: 32px;
  height: 32px;
  display: block;
}

.km-ul-minimized-badge-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid #090d16;
  background: var(--km-ul-green);
  box-shadow: 0 0 6px var(--km-ul-green);
}

.km-ul-minimized-badge-dot.probing {
  background: var(--km-ul-cyan);
  box-shadow: 0 0 8px var(--km-ul-cyan);
  animation: km-ul-pulse 1.3s infinite ease-in-out;
}

.km-ul-minimized-badge-dot.error {
  background: var(--km-ul-red);
  box-shadow: 0 0 6px var(--km-ul-red);
}

.km-ul-minimized-badge-dot.empty {
  background: #64748b;
  box-shadow: none;
}

@keyframes km-ul-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.4);
    opacity: 0.5;
  }
}

/* 展开状态面板：必须是完整的垂直结构 */
.km-ul-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(30, 41, 59, 0.92);
  border-bottom: 1px solid var(--km-ul-border);
  cursor: grab;
  flex-shrink: 0;
}

.km-ul-header:active {
  cursor: grabbing;
}

.km-ul-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--km-ul-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--km-ul-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.km-ul-drag-grip {
  color: var(--km-ul-cyan);
  font-size: 18px;
  line-height: 1;
}

.km-ul-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.km-ul-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--km-ul-muted);
  font-family: var(--km-ul-mono);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.km-ul-icon-btn:hover {
  color: var(--km-ul-text);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--km-ul-border);
}

.km-ul-body {
  width: 100%;
  padding: 12px 14px;
  max-height: 410px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.km-ul-toolbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.65);
}

.km-ul-node-select {
  flex: 1;
  min-width: 0;
  background: var(--km-ul-card);
  color: var(--km-ul-text);
  border: 1px solid var(--km-ul-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
  font-family: var(--km-ul-mono);
  outline: none;
  cursor: pointer;
}

.km-ul-node-select:focus {
  border-color: var(--km-ul-cyan);
}

.km-ul-ip-pills {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.km-ul-ip-pill {
  padding: 5px 9px;
  border-radius: 6px;
  font-family: var(--km-ul-mono);
  font-size: 13px;
  font-weight: 600;
  background: var(--km-ul-card);
  color: var(--km-ul-muted);
  border: 1px solid var(--km-ul-border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.km-ul-ip-pill.active {
  background: rgba(6, 182, 212, 0.2);
  color: #67e8f9;
  border-color: var(--km-ul-cyan);
}

.km-ul-logo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.km-ul-service-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 6px;
  border-radius: 12px;
  background: var(--km-ul-card);
  border: 2px solid var(--km-ul-border);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.km-ul-service-card:hover {
  transform: translateY(-2px);
  background: var(--km-ul-card-hover);
}

/* 可解锁服务：绿色边框 */
.km-ul-service-card.unlocked {
  border-color: var(--km-ul-green);
  box-shadow: 0 0 10px var(--km-ul-green-glow);
}

/* 无法解锁服务：红色边框 */
.km-ul-service-card.locked {
  border-color: var(--km-ul-red);
  box-shadow: 0 0 8px var(--km-ul-red-glow);
  opacity: 0.9;
}

.km-ul-logo-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 13, 22, 0.72);
  margin-bottom: 4px;
}

.km-ul-logo-box svg {
  width: 24px;
  height: 24px;
}

.km-ul-service-name {
  font-size: 16px;
  color: var(--km-ul-text);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* Logo 底部区域缩写小字 */
.km-ul-region-sub {
  margin-top: 3px;
  font-family: var(--km-ul-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.25;
}

.km-ul-service-card.unlocked .km-ul-region-sub {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
}

.km-ul-service-card.locked .km-ul-region-sub {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}

.km-ul-empty-state {
  padding: 20px 12px;
  text-align: center;
  color: var(--km-ul-muted);
  font-size: 16px;
  line-height: 1.6;
}

.km-ul-footer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  border-top: 1px solid rgba(51, 65, 85, 0.65);
  background: rgba(9, 13, 22, 0.88);
  font-family: var(--km-ul-mono);
  font-size: 13px;
  color: var(--km-ul-muted);
  flex-shrink: 0;
}

.km-ul-footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.km-ul-link-btn {
  background: none;
  border: none;
  color: #67e8f9;
  font-family: var(--km-ul-mono);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.km-ul-link-btn:hover {
  color: #a5f3fc;
}

/* 诊断/调试与关于弹窗样式 */
.km-ul-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10005;
  padding: 18px;
}

.km-ul-modal-backdrop.open {
  display: flex;
}

.km-ul-modal-card {
  background: #111827;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 14px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px;
  font-family: var(--km-ul-sans);
  font-size: 16px;
  line-height: 1.55;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
}

.km-ul-modal-card h3 {
  margin: 0 0 12px 0;
  font-size: 20px;
}

.km-ul-modal-card p {
  margin: 0 0 10px 0;
  color: #cbd5e1;
  font-size: 16px;
}

.km-ul-modal-card code {
  font-family: var(--km-ul-mono);
  color: #67e8f9;
  font-size: 14px;
  background: rgba(15, 23, 42, 0.6);
  padding: 2px 6px;
  border-radius: 4px;
}

.km-ul-debug-terminal {
  background: #050811;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px;
  font-family: var(--km-ul-mono);
  font-size: 13px;
  color: #34d399;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 10px 0;
}

/* One combined result per service; V6 successes remain green with a clear badge. */
#km-unlock-floating-root .km-ul-service-card.via-v6 .km-ul-region-sub {
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.5);
  white-space: nowrap;
}
#km-unlock-floating-root .km-ul-node-select { width: 100%; min-width: 0; }
@media (max-width: 420px) {
  #km-unlock-floating-root .km-ul-logo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* --- 探测中流线型动效与状态 (Probing Animation) --- */
.km-ul-probing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 16px;
  text-align: center;
}

.km-ul-probing-radar-box {
  width: 68px;
  height: 68px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.km-ul-probing-wave {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid #06b6d4;
  opacity: 0.8;
  animation: km-ul-wave-expand 2s infinite cubic-bezier(0.25, 1, 0.5, 1);
}
.km-ul-probing-wave.delay1 {
  animation-delay: 0.6s;
}
.km-ul-probing-wave.delay2 {
  animation-delay: 1.2s;
}

.km-ul-probing-radar-core {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #06b6d4, #0284c7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  z-index: 2;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.7);
}

@keyframes km-ul-wave-expand {
  0% { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(1.6); opacity: 0; }
}

.km-ul-probing-title {
  font-size: 16px;
  font-weight: 600;
  color: #67e8f9;
  margin-bottom: 6px;
}

.km-ul-probing-sub {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 16px;
}

.km-ul-probing-bar {
  width: 220px;
  height: 4px;
  background: rgba(51, 65, 85, 0.6);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.km-ul-probing-bar-fill {
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, #06b6d4, #10b981);
  border-radius: 999px;
  animation: km-ul-bar-slide 1.5s infinite ease-in-out;
}

@keyframes km-ul-bar-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.km-ul-stat-dot-probing {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #06b6d4;
  box-shadow: 0 0 8px #06b6d4;
  margin-right: 6px;
  animation: km-ul-pulse 1.2s infinite ease-in-out;
}

/* 警告提示横幅（如 Web SSH 禁用） */
.km-ul-warn-banner {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
