/* 30s 盾构机掘进参数实时预测系统样式 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: clamp(14px, 1vw + 0.5rem, 18px);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'SimSun', '宋体', sans-serif;
  background: radial-gradient(circle at top, #1f2937 0%, #020617 55%, #000000 100%);
  color: #e5e7eb;
  height: 100vh;
  overflow: hidden;
}

.container {
  width: 100%;
  height: 100vh;
  padding: 0.625rem; /* 10px */
  display: flex;
  flex-direction: column;
}

.header {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 0.625rem;
  padding: 0.5rem 0.9375rem; /* 8px 15px */
  margin-bottom: 0.5rem; /* 8px */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.625rem; /* 10px */
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.header-title-block {
  display: flex;
  flex-direction: column;
  gap: 0.125rem; /* 2px */
}

.header h1 {
  font-size: clamp(1.15rem, 1.2vw + 1rem, 1.7rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #e5e7eb;
  font-weight: 600;
}

.header h1 i {
  color: #38bdf8;
}

.header-subtitle {
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.95);
  letter-spacing: 0.02em;
  margin: 0;
}

/* 3D 模型左上角：当前盾构机 + 拨动开关 */
.tbm-switch-overlay {
  position: absolute;
  top: 0.625rem;
  left: 0.625rem;
  z-index: 2;
  padding: 0.5rem 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  border-radius: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.tbm-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(0.8rem, 0.5vw + 0.6rem, 0.95rem);
}

.tbm-switch-overlay .tbm-switch {
  font-size: clamp(1rem, 1.2vw + 0.6rem, 1.35rem);
  gap: 0.625rem;
}

.tbm-current-label {
  color: rgba(148, 163, 184, 0.95);
  white-space: nowrap;
}

.tbm-current-value {
  font-weight: 600;
  color: #38bdf8;
  min-width: 6ch;
}

.tbm-switch-overlay .tbm-current-value {
  font-size: 0.9em;
}

/* 拨动开关：滑轨 + 滑块 */
.tbm-toggle-track {
  width: 2.5rem;
  height: 1.25rem;
  border-radius: 999px;
  background: rgba(30, 64, 175, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.4);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.tbm-switch-overlay .tbm-toggle-track {
  width: 3.25rem;
  height: 1.6rem;
}

.tbm-switch-overlay .tbm-toggle-thumb {
  width: calc(1.6rem - 0.25rem);
  height: calc(1.6rem - 0.25rem);
  top: 0.125rem;
  left: 0.125rem;
}

.tbm-switch-overlay .tbm-toggle-track.tbm-toggle-right .tbm-toggle-thumb {
  transform: translateX(1.65rem);
}

.tbm-toggle-track:hover {
  background: rgba(30, 64, 175, 0.7);
}

.tbm-toggle-thumb {
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: calc(1.25rem - 0.25rem);
  height: calc(1.25rem - 0.25rem);
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
  box-shadow: 0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease;
}

.tbm-toggle-track.tbm-toggle-right .tbm-toggle-thumb {
  transform: translateX(1.25rem);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.625rem; /* 10px */
  font-size: clamp(0.8rem, 0.5vw + 0.6rem, 0.95rem);
}

.status-dot {
  width: 0.625rem;  /* 10px */
  height: 0.625rem; /* 10px */
  border-radius: 50%;
  background: #f97316;
  box-shadow: 0 0 10px #f97316;
}

.status-dot.connected {
  background: #22c55e;
  box-shadow: 0 0 10px #22c55e;
}

.status-dot.connecting {
  background: #facc15;
  box-shadow: 0 0 10px #facc15;
}

.time-info {
  background: rgba(15, 23, 42, 0.8);
  padding: 0.1875rem 0.5rem; /* 3px 8px */
  border-radius: 0.25rem; /* 4px */
  font-size: 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  white-space: nowrap;
}

.main-content {
  display: grid;
  grid-template-columns: 1.6fr 1.4fr;
  gap: 0.625rem; /* 10px */
  flex: 1;
  min-height: 0;
}

.left-panel,
.right-panel {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 0.625rem; /* 10px */
  padding: 0.625rem; /* 10px */
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(30, 64, 175, 0.6);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.image-container {
  position: relative;
  flex: 1;
  border-radius: 0.625rem; /* 10px */
  overflow: hidden;
  border: 1px solid rgba(30, 64, 175, 0.8);
}

/* 三维模型局部加载遮罩，仅覆盖 TBM 区域 */
.model-loading-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.95));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.image-container.status-active {
  border: 1px solid rgba(34, 197, 94, 0.75);
}

.image-container.status-rest {
  border: 1px solid rgba(202, 138, 4, 0.75);
}

model-viewer {
  width: 100%;
  height: 100%;
  background-color: #020617;
  opacity: 0.92;
}

.image-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.625rem; /* 8px 10px */
  background: linear-gradient(to top, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.1));
}

.overlay-stats {
  position: absolute;
  right: 0.625rem;  /* 10px */
  bottom: 0.625rem; /* 10px */
  display: flex;
  flex-direction: column;
  gap: 0.375rem; /* 6px */
}

.overlay-stats .stat-card {
  display: flex;
  align-items: center;
  gap: 0.375rem; /* 6px */
  padding: 0.3125rem 0.625rem; /* 5px 10px */
  min-width: 6.25rem; /* 100px */
  background: rgba(15, 23, 42, 0.9);
  border-radius: 0.375rem; /* 6px */
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.overlay-stats .stat-card i {
  font-size: 0.95rem;
  color: #38bdf8;
}

/* 缺失数据非零时，“缺失数据”卡片红色高亮 */
.overlay-stats .stat-card.stat-card--alert {
  border-color: rgba(248, 113, 113, 0.85);
  background: rgba(248, 113, 113, 0.12);
}
.overlay-stats .stat-card.stat-card--alert i {
  color: #f87171;
}

.overlay-stats .stat-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.overlay-stats .stat-value {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

.overlay-stats .stat-label {
  font-size: 0.72rem;
  color: rgba(148, 163, 184, 0.95);
  line-height: 1.2;
}

.machine-status {
  font-size: clamp(1.05rem, 0.9vw + 0.7rem, 1.4rem);
}

.machine-status .status-item {
  display: flex;
  align-items: center;
  gap: 0.375rem; /* 6px */
}

.machine-status i {
  color: #38bdf8;
}

.image-container.status-active .machine-status,
.image-container.status-active .machine-status i {
  color: rgba(34, 197, 94, 0.95);
}

.image-container.status-rest .machine-status,
.image-container.status-rest .machine-status i {
  color: rgba(202, 138, 4, 0.95);
}

/* 有效数据为 0 时：盾构机实时状态显示“无数据”并红色高亮 */
.machine-status .status-item.status-item--no-data,
.machine-status .status-item.status-item--no-data i {
  color: #f87171;
}

.data-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem; /* 8px */
}

.data-header h2 {
  font-size: clamp(1rem, 0.8vw + 0.7rem, 1.3rem);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.data-controls {
  display: flex;
  gap: 0.375rem; /* 6px */
}

.btn {
  border: none;
  border-radius: 0.25rem; /* 4px */
  padding: 0.25rem 0.625rem; /* 4px 10px */
  font-size: clamp(0.78rem, 0.4vw + 0.6rem, 0.9rem);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #0ea5e9);
  color: #f9fafb;
}

.btn-secondary {
  background: rgba(30, 64, 175, 0.7);
  color: #e5e7eb;
}

.btn:hover {
  filter: brightness(1.05);
}

.data-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.data-table-wrapper {
  height: 100%;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  /* 表格字体：在小屏上明显缩小一些，避免列挤在一起 */
  font-size: clamp(0.7rem, 0.35vw + 0.55rem, 0.9rem);
  table-layout: fixed;
}

.data-table thead {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.95);
  z-index: 1;
}

.data-table th,
.data-table td {
  padding: 0.3rem 0.375rem;
  border-bottom: 1px solid rgba(30, 64, 175, 0.4);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 表头列宽可拖动的握柄 */
.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 0.25rem;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}

.col-resize-handle::after {
  content: "";
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: rgba(148, 163, 184, 0.6);
}

th:hover .col-resize-handle::after {
  background: rgba(248, 250, 252, 0.85);
}

.data-table th:nth-child(1),
.data-table td:nth-child(1),
.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  text-align: left;
}

.data-table th:nth-child(1),
.data-table td:nth-child(1) {
  width: 7%;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  width: 25%;
}

/* 后 4 列等宽：当前时刻预测值、当前时刻值、预测误差、下一时刻预测值 */
.data-table th:nth-child(3),
.data-table th:nth-child(4),
.data-table th:nth-child(5),
.data-table th:nth-child(6),
.data-table td:nth-child(3),
.data-table td:nth-child(4),
.data-table td:nth-child(5),
.data-table td:nth-child(6) {
  width: 17.25%;
}

.data-value {
  font-variant-numeric: tabular-nums;
}

.change-value {
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.7rem, 0.35vw + 0.6rem, 0.95rem);
}

.row-high-error td {
  background: rgba(248, 113, 113, 0.16);
}

.change-value.increase {
  color: #4ade80;
}

.change-value.decrease {
  color: #f97373;
}

.change-value.no-change {
  color: #94a3b8;
}

.data-stats {
  display: flex;
  gap: 0.5rem;        /* 8px */
  margin-top: 0.375rem; /* 6px */
}

.stat-card {
  flex: 1;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 0.375rem; /* 6px */
  padding: 0.375rem 0.5rem; /* 6px 8px */
  display: flex;
  align-items: center;
  gap: 0.5rem; /* 8px */
  border: 1px solid rgba(30, 64, 175, 0.6);
}

.stat-card i {
  font-size: 1.1rem;
  color: #38bdf8;
}

.stat-content {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 600;
}

.stat-label {
  font-size: 0.8rem;
  color: #9ca3af;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.loading-spinner {
  background: rgba(15, 23, 42, 0.95);
  padding: 0.75rem 1.125rem; /* 12px 18px */
  border-radius: 0.5rem; /* 8px */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9);
  text-align: center;
}

.loading-spinner p {
  margin-top: 0.375rem;
  font-size: 0.85rem;
}

.loading-spinner i {
  color: #38bdf8;
  font-size: 1.4rem;
}

.loading-progress {
  margin-top: 0.625rem;
  width: clamp(12rem, 18vw, 14rem);
  height: 0.375rem;
  border-radius: 999px;
  background: rgba(31, 41, 55, 0.9);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.loading-progress-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #facc15, #f97316);
  background-size: 200% 100%;
  animation: loading-bar-stripes 1.2s linear infinite;
}

@keyframes loading-bar-stripes {
  0% {
    transform: translateX(-50%);
  }
  100% {
    transform: translateX(50%);
  }
}

@media (max-width: 60rem) {
  html {
    font-size: clamp(13px, 2vw, 15px);
  }
  /* 小屏下进一步压缩右侧表格字体，并允许水平滚动代替换行 */
  .data-table {
    font-size: 0.62rem;
  }
  .data-table th,
  .data-table td {
    white-space: nowrap;
  }
  .change-value {
    font-size: 0.62rem;
  }
  .data-table-wrapper {
    overflow-x: auto;
  }
  .main-content {
    grid-template-columns: 1fr;
  }
}

