/* 基础样式和变量 */
:root {
  --primary-color: #00ccff;
  --secondary-color: #0066ff;
  --background-dark: #0a0a1a;
  --background-light: #151530;
  --card-bg: rgba(16, 18, 46, 0.7);
  --text-primary: #e0e0ff;
  --text-secondary: #a0a0ff;
  --success-color: #00ff88;
  --warning-color: #ffaa00;
  --error-color: #ff4444;
  --border-radius: 12px;
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', 'Arial', sans-serif;
}

body {
  background: linear-gradient(135deg, var(--background-dark) 0%, var(--background-light) 50%, var(--background-dark) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* 背景效果 */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 30%, rgba(0, 100, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(0, 200, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

.container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 20px;
}

/* 头部样式 */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid rgba(0, 255, 255, 0.3);
  margin-bottom: 30px;
  position: relative;
}

header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

.logo {
  display: flex;
  align-items: center;
}

.logo-icon {
  font-size: 32px;
  margin-right: 15px;
  color: var(--primary-color);
  filter: drop-shadow(0 0 10px rgba(0, 200, 255, 0.7));
}

.logo h1 {
  font-size: 32px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
  letter-spacing: 1px;
}

/* 状态面板 */
.status-panel {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid rgba(0, 150, 255, 0.3);
}

.status {
  display: flex;
  align-items: center;
  font-size: 16px;
  margin-right: 20px;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--error-color);
  margin-right: 8px;
  box-shadow: 0 0 10px var(--error-color);
  animation: pulse 2s infinite;
}

.status-indicator.connected {
  background-color: var(--success-color);
  box-shadow: 0 0 10px var(--success-color);
}

.sensor-count {
  display: flex;
  align-items: center;
  font-size: 16px;
}

.sensor-count i {
  margin-right: 8px;
  font-size: 20px;
  color: var(--primary-color);
}

/* 动画 */
@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* 仪表板布局 */
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  grid-gap: 20px;
  margin-bottom: 30px;
}

/* 卡片样式 */
.card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: 0 0 20px rgba(0, 150, 255, 0.1);
  border: 1px solid rgba(0, 150, 255, 0.2);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(5px);
  border-left: none; /* 去掉左边框 */
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 30px rgba(0, 150, 255, 0.3);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.sensor-name {
  font-size: 18px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.sensor-name i {
  margin-right: 10px;
  color: var(--primary-color);
}

.location-id {
  font-size: 12px;
  color: #8080cc;
  background: rgba(0, 100, 255, 0.2);
  padding: 3px 8px;
  border-radius: 10px;
}

/* 数据显示 */
.data-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.data-value {
  font-size: 42px;
  font-weight: bold;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.data-unit {
  font-size: 18px;
  color: var(--text-secondary);
  margin-left: 5px;
}

.data-icon {
  font-size: 46px;
  color: rgba(0, 200, 255, 0.7);
  filter: drop-shadow(0 0 5px rgba(0, 200, 255, 0.5));
}

.location-info {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}

.location-info i {
  margin-right: 5px;
}

.last-update {
  font-size: 12px;
  color: #8080cc;
}

/* 图表容器 */
.charts-container {
  margin-top: 20px;
}

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 20px;
  margin-bottom: 20px;
}

.realtime-chart, .week-history, .data-history {
  height: 350px;
}

.realtime-chart canvas {
  height: 280px !important;
}

.history-chart {
  height: 280px;
}

/* 网络信息样式 */
.network-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  position: absolute;
  bottom: 21px;
  right: 25px;
  max-width: 200px;
}

.network-name {
  font-size: 11px;
  color: #8888cc;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  order: 2;
}

.network-name[data-type="4g"] {
  color: #00ccff;
}

.network-signal {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 16px;
  order: 1;
}

.signal-bar {
  width: 3px;
  background-color: #6666aa;
  border-radius: 1px;
  transition: var(--transition);
}

.signal-bar:nth-child(1) { height: 4px; }
.signal-bar:nth-child(2) { height: 6px; }
.signal-bar:nth-child(3) { height: 8px; }
.signal-bar:nth-child(4) { height: 10px; }

/* 信号强度样式 */
.network-signal[data-strength="1"] .signal-bar:nth-child(1) { background-color: var(--success-color); }
.network-signal[data-strength="2"] .signal-bar:nth-child(-n+2) { background-color: var(--success-color); }
.network-signal[data-strength="3"] .signal-bar:nth-child(-n+3) { background-color: var(--success-color); }
.network-signal[data-strength="4"] .signal-bar { background-color: var(--success-color); }

/* 4G信号样式 */
.network-signal[data-type="4g"] .signal-bar {
  border-radius: 2px;
  width: 4px;
}

/* 4G卡片特殊样式 */
.card[data-device-type="4G"]::before {
  background: linear-gradient(90deg, #39FF14, #00cc00); /* 绿色 */
}

.card[data-device-type="4G"] {
  border-left: none; /* 去掉左边框 */
}

/* WiFi卡片特殊样式 */
.card[data-device-type="WiFi"]::before {
  background: linear-gradient(90deg, #00ccff, #0066ff); /* 蓝色 */
}

.card[data-device-type="WiFi"] {
  border-left: none; /* 去掉左边框 */
}

/* 同时移除之前为设备类型设置的左边框样式 */
.card[data-device-type] {
  border-left: none;
}

/* 警告样式 */
.card.data-timeout-warning {
  border: 3px solid var(--error-color) !important;
  box-shadow: 0 0 15px rgba(255, 68, 68, 0.6) !important;
  animation: pulse-warning 0.5s ease-in-out;
}

.card.connection-warning {
  border: 2px solid var(--warning-color) !important;
  box-shadow: 0 0 10px rgba(255, 170, 0, 0.4) !important;
}

.card.server-warning {
  border: 2px solid var(--error-color) !important;
  box-shadow: 0 0 10px rgba(255, 68, 68, 0.4) !important;
}

.card.fault-warning {
  border: 2px solid var(--warning-color) !important;
  animation: fault-pulse 1s infinite alternate !important;
  box-shadow: 0 0 15px rgba(255, 170, 0, 0.6) !important;
}

@keyframes pulse-warning {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes fault-pulse {
  0% {
    box-shadow: 0 0 5px rgba(255, 170, 0, 0.4);
    border-color: var(--warning-color);
  }
  100% {
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.8);
    border-color: #ffcc00;
  }
}

/* 消息通知 */
.message {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 15px 20px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 400px;
  transform: translateX(400px);
  opacity: 0;
  transition: var(--transition);
  border-left: 4px solid;
}

.message.show {
  transform: translateX(0);
  opacity: 1;
}

.message-success { border-left-color: var(--success-color); }
.message-error { border-left-color: var(--error-color); }
.message-warning { border-left-color: var(--warning-color); }
.message-info { border-left-color: var(--primary-color); }
.message-loading { border-left-color: #aa00ff; }

.message-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.message-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
}

.message-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.message-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

/* 页脚和控件 */
.footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid rgba(0, 255, 255, 0.3);
  color: var(--text-secondary);
  font-size: 14px;
  position: relative;
}

.footer::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

.controls {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.control-btn {
  background: var(--card-bg);
  border: 1px solid rgba(0, 150, 255, 0.3);
  color: var(--text-secondary);
  padding: 8px 16px;
  margin: 0 5px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.control-btn:hover {
  background: rgba(0, 100, 255, 0.3);
  color: var(--primary-color);
}

.control-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 网格线背景 */
.grid-lines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(0, 150, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 150, 255, 0.05) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: -1;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .dashboard {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
  
  .chart-row {
    grid-template-columns: 1fr;
  }
  
  .realtime-chart, .week-history, .data-history {
    height: 300px;
  }
  
  .realtime-chart canvas,
  .history-chart {
    height: 230px !important;
  }
}

@media (max-width: 768px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  
  .chart-row {
    grid-template-columns: 1fr;
  }
  
  .realtime-chart, .week-history, .data-history {
    height: 280px;
  }
  
  .realtime-chart canvas,
  .history-chart {
    height: 210px !important;
  }
  
  header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .status-panel {
    margin-top: 15px;
    width: 100%;
    justify-content: space-between;
  }
  
  .data-value {
    font-size: 36px;
  }
}

/* 模态框样式 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 1200px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(0, 150, 255, 0.3);
  border: 1px solid rgba(0, 150, 255, 0.3);
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.modal.show .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid rgba(0, 150, 255, 0.3);
  background: rgba(16, 18, 46, 0.9);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-header h2 {
  color: var(--text-primary);
  font-size: 24px;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(255, 68, 68, 0.2);
  color: var(--error-color);
}

.modal-body {
  padding: 20px;
}

.sensor-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.info-section {
  background: rgba(0, 20, 40, 0.6);
  border-radius: 8px;
  padding: 15px;
  border: 1px solid rgba(0, 150, 255, 0.2);
}

.info-section h3 {
  color: var(--primary-color);
  font-size: 16px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-row:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.info-label {
  color: var(--text-secondary);
  font-size: 14px;
}

.info-value {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

.info-value small {
  color: var(--text-secondary);
  font-size: 12px;
}

.modal-chart {
  margin-top: 30px;
  background: rgba(0, 20, 40, 0.6);
  border-radius: 8px;
  padding: 15px;
  border: 1px solid rgba(0, 150, 255, 0.2);
}

.modal-chart h3 {
  color: var(--primary-color);
  font-size: 16px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-chart-container {
  height: 200px;
  position: relative;
}

/* 卡片点击效果 */
.card {
  cursor: pointer;
  user-select: none;
}

.card:active {
  transform: translateY(-2px) scale(0.98);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-height: 95vh;
  }
  
  .sensor-info-grid {
    grid-template-columns: 1fr;
  }
  
  .info-row {
    flex-direction: column;
    gap: 4px;
  }
  
  .info-value {
    max-width: 100%;
    text-align: left;
  }
}

/* 在原有样式后添加 */
#modal-system-status,
#modal-uptime {
  font-size: 14px;
  color: var(--text-primary);
}

/* 内存信息样式 */
#modal-free-memory small {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: 4px;
}

/* WiFi信号强度显示优化 */
#modal-wifi-strength small {
  color: var(--text-secondary);
  font-size: 12px;
}

/* 在原有样式后添加网络位置相关样式 */
#modal-network-location {
  font-size: 14px;
  color: var(--text-primary);
}

/* 网络信息部分样式调整 */
.info-section:nth-child(4) .info-row:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* 设备状态部分样式调整 */
.info-section:nth-child(5) .info-row:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* 芯片温度样式 */
#modal-chip-temperature,
#modal-chip-temperature-status {
  font-size: 14px;
  color: var(--text-primary);
}

/* 主界面芯片温度标签样式 */
.data-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 5px;
  font-weight: normal;
}

/* 芯片温度警告样式 */
.data-value[style*="error"] {
  text-shadow: 0 0 5px var(--error-color);
  animation: pulse 1s infinite;
}

.data-value[style*="warning"] {
  text-shadow: 0 0 5px var(--warning-color);
}

/* 报警模态框样式 */
.alarm-modal {
  display: none;
  position: fixed;
  top: 20px;
  right: 20px;
  width: 400px;
  z-index: 10001;
  background: rgba(255, 50, 50, 0.1);
  border-radius: var(--border-radius);
  backdrop-filter: blur(10px);
  border: 2px solid var(--error-color);
  box-shadow: 0 0 30px rgba(255, 68, 68, 0.5);
  animation: alarm-pulse 1s infinite alternate;
}

.alarm-modal.show {
  display: block;
}

@keyframes alarm-pulse {
  0% {
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.5);
    border-color: var(--error-color);
  }
  100% {
    box-shadow: 0 0 30px rgba(255, 68, 68, 0.8);
    border-color: #ff3333;
  }
}

.alarm-content {
  background: linear-gradient(135deg, #2a0a0a 0%, #1a0505 100%);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.alarm-header {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  background: linear-gradient(90deg, #ff3333 0%, #cc0000 100%);
  color: white;
}

.alarm-icon {
  font-size: 32px;
  margin-right: 15px;
  animation: alarm-shake 0.5s infinite alternate;
}

@keyframes alarm-shake {
  0% { transform: rotate(-5deg); }
  100% { transform: rotate(5deg); }
}

.alarm-header h2 {
  flex: 1;
  font-size: 24px;
  font-weight: bold;
  margin: 0;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.alarm-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
}

.alarm-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.alarm-body {
  padding: 20px;
}

.alarm-info {
  margin-bottom: 20px;
}

.alarm-item {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  border-left: 3px solid var(--error-color);
}

.alarm-item i {
  font-size: 20px;
  margin-right: 12px;
  color: var(--error-color);
  width: 30px;
  text-align: center;
}

.alarm-text {
  flex: 1;
}

.alarm-label {
  display: block;
  font-size: 12px;
  color: #ff9999;
  margin-bottom: 2px;
}

.alarm-value {
  display: block;
  font-size: 16px;
  font-weight: bold;
  color: white;
}

.alarm-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.alarm-silence {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.alarm-silence:hover {
  background: rgba(255, 255, 255, 0.2);
}

.alarm-acknowledge {
  flex: 2;
  background: linear-gradient(90deg, var(--error-color) 0%, #cc0000 100%);
  color: white;
  font-weight: bold;
  border: none;
}

.alarm-acknowledge:hover {
  background: linear-gradient(90deg, #ff5555 0%, #dd0000 100%);
  box-shadow: 0 0 15px rgba(255, 68, 68, 0.5);
}

.alarm-footer {
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.5);
  text-align: center;
  border-top: 1px solid rgba(255, 68, 68, 0.3);
}

.alarm-footer small {
  color: #ff9999;
  font-size: 12px;
}

/* 传感器卡片报警样式 */
.card.smoke-alarm {
  animation: card-alarm 0.5s infinite alternate !important;
  border-color: var(--error-color) !important;
  box-shadow: 0 0 20px rgba(255, 68, 68, 0.6) !important;
  position: relative;
  overflow: hidden;
}

.card.smoke-alarm::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 68, 68, 0.1), transparent);
  z-index: 1;
  pointer-events: none;
}

.card.smoke-alarm::after {
  content: '🔥';
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 24px;
  z-index: 2;
  animation: alarm-icon-pulse 1s infinite alternate;
}

@keyframes card-alarm {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.6);
  }
  100% {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 0 30px rgba(255, 68, 68, 0.8);
  }
}

@keyframes alarm-icon-pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* 响应式调整 */
@media (max-width: 768px) {
  .alarm-modal {
    width: calc(100% - 40px);
    left: 20px;
    right: 20px;
    top: 10px;
  }
}

.status-panel {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 20px;
}

.user-info-centered .user-name {
    font-size: 16px;
    font-weight: 500;
}

.user-info-centered .user-role {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 12px;
}