/**
 * stats-list.css - List 视图专用样式
 * 从 views/stats/list.html 抽离
 */

/* ========================================
   基础样式
   ======================================== */

.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ========================================
   List 卡片基础样式
   ======================================== */

.list-row-card {
  border: 1px solid var(--border-color) !important;
  background-color: var(--card-surface-bg, var(--card-bg-color));
  box-shadow: var(--card-shadow-base-light, var(--card-shadow));
  transition: background-color var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed), transform var(--transition-speed);
}

:root.dark .list-row-card.theme-border,
.list-row-card.theme-border {
  border: 1px solid var(--border-color) !important;
}

:root.dark .list-row-card {
  background-color: #081429; /* list 页面专用：更暗的卡片背景，增强与容器对比度 */
  box-shadow: var(--card-shadow-base-dark, var(--card-shadow-dark));
}

/* ========================================
   Hover 效果
   ======================================== */

.server-card.list-row-card:hover {
  border-color: var(--light-border-hover-color, var(--border-color)) !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
  transform: translateY(-1px) !important;
}

:root.dark .server-card.list-row-card:hover {
  border-color: var(--dark-border-hover-color, var(--border-color)) !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.25), 0 2px 4px -1px rgba(0, 0, 0, 0.18) !important;
  transform: translateY(-1px) !important;
}


/* 背景色变化：仅在禁用毛玻璃时应用 */
body.no-glassmorphism .server-card.list-row-card:hover {
  background-color: var(--light-hover-bg-color, #f1f5f9) !important;
}

:root.dark body.no-glassmorphism .server-card.list-row-card:hover {
  background-color: #0a182d !important;
}

/* ========================================
   列表行布局
   ======================================== */

.list-row-layout {
  gap: 0;
}

.list-region {
  padding: 0 1rem;
  position: relative;
}

.list-row-layout .list-region-info {
  padding-right: 0.5rem;
}

/* ========================================
   区域1：服务器信息
   ======================================== */

.list-region-info {
  padding-left: 0.25rem;
  flex: 0 0 220px;
  min-width: 160px;
  max-width: 300px;
}

/* ========================================
   区域2：性能指标
   ======================================== */

.list-region-metrics {
  flex: 2 1 300px;
  min-width: 280px;
  max-width: none;
}

.list-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

.list-metric {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 0;
  gap: 0.35rem;
}

.list-metric-head {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
  max-width: 100%;
}

.list-metric-head .metric-value {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.list-metric-track {
  height: 6px;
  border-radius: 9999px;
  background: rgba(var(--light-border-color-rgb, 100, 116, 139), 0.35);
  overflow: hidden;
  max-width: 100%;
}

:root.dark .list-metric-track {
  background: rgba(var(--dark-border-color-rgb, 71, 85, 105), 0.45);
}

.list-metric-bar {
  display: block;
  height: 100%;
  border-radius: 9999px;
  width: var(--metric-value, 0%);
  background: var(--status-online-color);
  transition: width 0.25s ease, background-color var(--transition-speed);
}

.list-metric-bar.warn {
  background: var(--status-warning-color);
}

.list-metric-bar.danger {
  background: var(--status-error-color);
}

/* ========================================
   区域3a1：实时带宽
   ======================================== */

.list-region-bandwidth {
  flex: 1 1 120px;
  min-width: 100px;
  max-width: 160px;
  padding: 0 0.5rem;
  font-family: ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.4;
}

/* ========================================
   区域3a2：总流量（复用带宽样式）
   ======================================== */

.list-region-traffic-total {
  flex: 1 1 120px;
  min-width: 100px;
  max-width: 160px;
  padding: 0 0.5rem;
  font-family: ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.4;
}

/* ========================================
   区域3b：延迟
   ======================================== */

.list-region-latency {
  flex: 1 1 100px;
  min-width: 100px;
  max-width: 140px;
  padding: 0 0.5rem;
  font-family: ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.4;
}

/* ========================================
   区域3c：月流量
   ======================================== */

.list-region-traffic {
  flex: 1 1 110px;
  min-width: 100px;
  max-width: 120px;
  padding: 0 0.5rem;
  font-family: ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.4;
}

/* ========================================
   区域4：操作按钮
   ======================================== */

.list-region-actions {
  padding-right: 0.25rem;
  flex: 0 0 32px;
  width: 32px;
}

/* ========================================
   带宽/延迟通用样式
   ======================================== */

.list-bandwidth-col,
.list-latency-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.list-bandwidth-row,
.list-latency-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.list-network-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  min-width: 48px;
}

.list-network-label-text {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.list-network-value {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 9ch;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1;
}

.list-network-value .metric-unit {
  font-size: 0.85em;
  margin-left: 0.15em;
  line-height: 1;
}

.list-network-value.warn {
  color: var(--status-warning-color, #f59e0b) !important;
}

.list-network-value.danger {
  color: var(--status-error-color, #ef4444) !important;
}

/* ========================================
   Mini 饼状图
   ======================================== */

.list-traffic-mini-chart {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.list-traffic-pie {
  width: 100%;
  height: 100%;
}

.list-traffic-pie-bg {
  fill: none;
  stroke: rgba(var(--light-border-color-rgb, 148, 163, 184), 0.3);
  stroke-width: 3;
}

:root.dark .list-traffic-pie-bg {
  stroke: rgba(var(--dark-border-color-rgb, 71, 85, 105), 0.4);
}

.list-traffic-pie-fill {
  fill: none;
  stroke: #06b6d4;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dasharray 0.3s ease;
}

.list-traffic-pie-fill.warn {
  stroke: #f59e0b;
}

.list-traffic-pie-fill.danger {
  stroke: #ef4444;
}

/* ========================================
   其他辅助样式
   ======================================== */

.list-bandwidth-values {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.list-bandwidth-sep {
  font-size: 0.65rem;
  flex-shrink: 0;
}

.list-total-value {
  font-size: 0.65rem;
  opacity: 0.8;
  min-width: auto !important;
  width: auto;
  flex-shrink: 0;
}

.list-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
  flex: 1 1 85px;
  min-width: 85px;
  max-width: 140px;
}

.list-meta-icon {
  font-size: 13px;
  line-height: 1;
}

.list-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.list-value {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 52px;
  text-align: left;
}

/* ========================================
   响应式：窄屏隐藏区域2-3的文字描述
   ======================================== */

@media (max-width: 1300px) {
  .list-metric-head > span:not(.metric-value) {
    display: none;
  }
  .list-metric-head {
    gap: 4px;
  }
  .list-region-metrics {
    min-width: 200px;
  }
  .list-metrics-grid {
    gap: 8px;
  }
  .list-network-label-text {
    display: none;
  }
  .list-network-label {
    min-width: auto;
  }
}

/* ========================================
   移动端边框颜色调整
   ======================================== */

@media (max-width: 1023px) {
  :root:not(.dark) #server-view-container {
    --light-border-color: #cbd5e1;
  }
}

/* ========================================
   List 页面单位样式覆盖
   ======================================== */

#server-view-container .metric-unit {
  font-size: 0.75em;
  width: auto;
  display: inline;
  color: inherit;
  vertical-align: baseline;
}

#server-view-container .pill-metric-unit {
  margin-left: 0;
}


/* ========================================
   拖拽手柄样式 - 绝对定位不占用布局空间
   ======================================== */

/* List 视图：拖拽手柄绝对定位 */
.list-row-card .drag-handle {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}

/* 确保卡片有定位上下文 */
.list-row-card {
  position: relative;
}


/* ========================================
   月流量容器查询：基于父容器宽度折叠总量部分
   ======================================== */

/* 设置移动端第二行容器为查询上下文，检测可用空间 */
/* 选择器：list-row-card > 移动端容器（包含 lg:hidden 类）> 第二行容器 */
.list-row-card > [class*="lg:hidden"] > .flex.items-center.justify-between.gap-2 {
  container-type: inline-size;
  container-name: mobile-second-row;
}

/* 当第二行容器宽度不足时，隐藏月流量总量部分 */
/* 断点基于实际布局：CPU/MEM/HDD(3*44px) + 总流量(72px) + 实时速度(88px) + gap ≈ 320px */
/* 当容器宽度 < 320px 时，说明空间紧张，隐藏总量部分 */
@container mobile-second-row (max-width: 320px) {
  .traffic-limit-part {
    display: none;
  }
}

/* 降级方案：不支持容器查询的浏览器，使用媒体查询 */
@supports not (container-type: inline-size) {
  @media (max-width: 374px) {
    .traffic-limit-part {
      display: none;
    }
  }
}


/* ========================================
   移动端自适应字体大小
   ======================================== */

@media (max-width: 1023px) {
  /* 第一行：标题区域 */
  .list-row-card .lg\:hidden h3 {
    font-size: clamp(10px, 2.8vw, 13px);
  }
  
  /* 第一行：U/E 标签 */
  .list-row-card .lg\:hidden .text-\[9px\] {
    font-size: clamp(8px, 2.3vw, 11px);
  }
  
  /* 第一行：标签内文字 */
  .list-row-card .lg\:hidden .text-\[8px\] {
    font-size: clamp(7px, 2vw, 10px);
  }
  
  /* 第二行：数值文字 */
  .list-row-card .lg\:hidden .text-\[10px\] {
    font-size: clamp(9px, 2.5vw, 12px);
  }
}
