/**
 * NodeTrafficStatus Premium UI Styles (v1.0.4)
 * 极致现代、灵动优雅的实时探针带宽节点卡片设计系统
 * 全面适配 Scarlet、HeroRui、HeroXboard、Xboard 原生等多款主题
 */

/* 1. 彻底隐藏原有简单节点网格（杜绝任何闪烁） */
html.nts-node-page .node-grid:not(.nts-custom-grid),
body.nts-node-page .node-grid:not(.nts-custom-grid),
.nts-active .node-grid:not(.nts-custom-grid) {
  display: none !important;
}

/* 2. 自定义节点网格容器 */
.nts-custom-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)) !important;
  gap: 1.35rem !important;
  width: 100% !important;
  margin-top: 1.25rem !important;
  box-sizing: border-box !important;
  animation: ntsEntrance 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes ntsEntrance {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 3. 现代玻璃拟态节点卡片 */
.nts-card {
  position: relative;
  background: var(--card-bg, rgba(255, 255, 255, 0.92));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.06));
  border-radius: 1.25rem;
  padding: 1.35rem;
  box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.03), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  box-sizing: border-box;
}

/* 顶部微光装饰线 */
.nts-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.25), rgba(16, 185, 129, 0.25), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nts-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -4px rgba(0, 0, 0, 0.08), 0 6px 14px -2px rgba(0, 0, 0, 0.03);
  border-color: rgba(59, 130, 246, 0.28);
}

.nts-card:hover::before {
  opacity: 1;
}

/* 深色模式适配（兼容 Scarlet 的 html.dark 与标准 data-theme='dark'） */
html.dark .nts-card,
html[data-theme='dark'] .nts-card,
body.dark .nts-card,
.dark .nts-card {
  background: var(--card-bg, rgba(28, 28, 33, 0.92)) !important;
  border-color: var(--card-border, rgba(255, 255, 255, 0.08)) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.45) !important;
}

html.dark .nts-card:hover,
html[data-theme='dark'] .nts-card:hover,
body.dark .nts-card:hover,
.dark .nts-card:hover {
  border-color: rgba(96, 165, 250, 0.35) !important;
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.6) !important;
}

/* 4. 卡片顶部行：国旗徽章 + 在线状态 */
.nts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

/* 国旗徽章容器 */
.nts-flag-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--flag-bg, rgba(0, 0, 0, 0.03));
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.nts-card:hover .nts-flag-wrap {
  transform: scale(1.05);
}

html.dark .nts-flag-wrap,
html[data-theme='dark'] .nts-flag-wrap,
body.dark .nts-flag-wrap,
.dark .nts-flag-wrap {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* 国旗 SVG 图片 */
.nts-flag-img {
  width: 28px;
  height: 20px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* 5. 状态徽章 (在线/离线) */
.nts-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.72rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.25s ease;
}

/* 在线徽标 (清新翡翠绿 + 呼吸灯) */
.nts-status.online {
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

html.dark .nts-status.online,
html[data-theme='dark'] .nts-status.online,
body.dark .nts-status.online,
.dark .nts-status.online {
  color: #34d399 !important;
  background: rgba(16, 185, 129, 0.16) !important;
  border-color: rgba(16, 185, 129, 0.35) !important;
}

/* 离线徽标 (静谧质感灰) */
.nts-status.offline {
  color: #6b7280;
  background: rgba(156, 163, 175, 0.12);
  border: 1px solid rgba(156, 163, 175, 0.2);
}

html.dark .nts-status.offline,
html[data-theme='dark'] .nts-status.offline,
body.dark .nts-status.offline,
.dark .nts-status.offline {
  color: #9ca3af !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* 状态圆点 */
.nts-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nts-status.online .nts-status-dot {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: ntsPulseGlow 2s infinite ease-in-out;
}

.nts-status.offline .nts-status-dot {
  background-color: #9ca3af;
}

@keyframes ntsPulseGlow {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* 6. 节点名称区域 */
.nts-body {
  margin-bottom: 1.15rem;
}

.nts-node-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-color, #111827);
  letter-spacing: -0.015em;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.dark .nts-node-name,
html[data-theme='dark'] .nts-node-name,
body.dark .nts-node-name,
.dark .nts-node-name {
  color: #f9fafb !important;
}

/* 7. 实时带宽分栏卡片组 (双模块并列设计) */
.nts-bandwidth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

/* 单个带宽计量小槽 */
.nts-speed-card {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.85rem;
  transition: all 0.2s ease;
}

/* 上行卡槽（微青绿渐变） */
.nts-speed-up {
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.12);
}

html.dark .nts-speed-up,
html[data-theme='dark'] .nts-speed-up,
body.dark .nts-speed-up,
.dark .nts-speed-up {
  background: rgba(16, 185, 129, 0.08) !important;
  border-color: rgba(16, 185, 129, 0.2) !important;
}

/* 下行卡槽（科技蓝微渐变） */
.nts-speed-down {
  background: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.12);
}

html.dark .nts-speed-down,
html[data-theme='dark'] .nts-speed-down,
body.dark .nts-speed-down,
.dark .nts-speed-down {
  background: rgba(59, 130, 246, 0.08) !important;
  border-color: rgba(59, 130, 246, 0.2) !important;
}

/* 上下行指示徽标 */
.nts-speed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 800;
  flex-shrink: 0;
}

.nts-speed-up .nts-speed-badge {
  background: rgba(16, 185, 129, 0.16);
  color: #059669;
}

html.dark .nts-speed-up .nts-speed-badge,
html[data-theme='dark'] .nts-speed-up .nts-speed-badge,
body.dark .nts-speed-up .nts-speed-badge,
.dark .nts-speed-up .nts-speed-badge {
  color: #34d399 !important;
  background: rgba(16, 185, 129, 0.25) !important;
}

.nts-speed-down .nts-speed-badge {
  background: rgba(59, 130, 246, 0.16);
  color: #2563eb;
}

html.dark .nts-speed-down .nts-speed-badge,
html[data-theme='dark'] .nts-speed-down .nts-speed-badge,
body.dark .nts-speed-down .nts-speed-badge,
.dark .nts-speed-down .nts-speed-badge {
  color: #60a5fa !important;
  background: rgba(59, 130, 246, 0.25) !important;
}

/* 速率详情内容 */
.nts-speed-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.nts-speed-title {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #9ca3af;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 0.22rem;
}

html.dark .nts-speed-title,
html[data-theme='dark'] .nts-speed-title,
body.dark .nts-speed-title,
.dark .nts-speed-title {
  color: #6b7280 !important;
}

/* 速率数字 (等宽字体展示) */
.nts-speed-number {
  font-size: 0.88rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', 'SF Mono', ui-monospace, Menlo, Monaco, Consolas, monospace;
  color: var(--text-color, #1f2937);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.25s ease;
}

html.dark .nts-speed-number,
html[data-theme='dark'] .nts-speed-number,
body.dark .nts-speed-number,
.dark .nts-speed-number {
  color: #f3f4f6 !important;
}

/* 速率变化时轻微动效 */
.nts-rate-flash {
  animation: ntsFlashGlow 0.4s ease;
}

@keyframes ntsFlashGlow {
  0% {
    filter: brightness(1.25);
    transform: scale(1.02);
  }
  100% {
    filter: brightness(1);
    transform: scale(1);
  }
}

/* 8. 空状态与提示 */
.nts-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1.5rem;
  color: #9ca3af;
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 1.25rem;
  border: 1px dashed rgba(0, 0, 0, 0.08);
}

html.dark .nts-empty,
html[data-theme='dark'] .nts-empty,
body.dark .nts-empty,
.dark .nts-empty {
  background: rgba(255, 255, 255, 0.02) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #9ca3af !important;
}

/* 9. “管理员已经关闭显示” 专属现代磨砂玻璃卡片 */
.nts-disabled-notice {
  width: 100% !important;
  box-sizing: border-box !important;
  margin-top: 1.5rem !important;
  margin-bottom: 2rem !important;
  padding: 3.5rem 2rem !important;
  text-align: center !important;
  background: var(--card-bg, rgba(255, 255, 255, 0.88)) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid var(--card-border, rgba(0, 0, 0, 0.06)) !important;
  border-radius: 1.5rem !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.04), 0 8px 10px -6px rgba(0, 0, 0, 0.02) !important;
  animation: ntsEntrance 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards !important;
}

html.dark .nts-disabled-notice,
html[data-theme='dark'] .nts-disabled-notice,
body.dark .nts-disabled-notice,
.dark .nts-disabled-notice {
  background: rgba(28, 28, 33, 0.88) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5) !important;
}

.nts-disabled-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 1.25rem;
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.12);
}

html.dark .nts-disabled-icon-wrap,
html[data-theme='dark'] .nts-disabled-icon-wrap,
body.dark .nts-disabled-icon-wrap,
.dark .nts-disabled-icon-wrap {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
}

.nts-disabled-title {
  margin: 0 0 0.5rem 0 !important;
  font-size: 1.35rem !important;
  font-weight: 700 !important;
  color: var(--text-color, #111827) !important;
  letter-spacing: -0.015em !important;
}

html.dark .nts-disabled-title,
html[data-theme='dark'] .nts-disabled-title,
body.dark .nts-disabled-title,
.dark .nts-disabled-title {
  color: #f9fafb !important;
}

.nts-disabled-desc {
  margin: 0 !important;
  font-size: 0.95rem !important;
  color: #6b7280 !important;
  line-height: 1.6 !important;
}

html.dark .nts-disabled-desc,
html[data-theme='dark'] .nts-disabled-desc,
body.dark .nts-disabled-desc,
.dark .nts-disabled-desc {
  color: #9ca3af !important;
}
