/* 基础样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 主题变量 */
:root {
  --panel-bg: rgba(21, 26, 58, 0.85);
  --text-color: #ffffff;
  --text-secondary: #8b92b3;
  --border-color: #2a3158;
  --primary-color: #00d4ff;
  --success-color: #00ff88;
  --warning-color: #ffaa00;
  --danger-color: #ff4444;
}

body.light {
  --panel-bg: rgba(255, 255, 255, 0.9);
  --text-color: #1a1a2e;
  --text-secondary: #666666;
  --border-color: #d9d9d9;
  --primary-color: #0066cc;
  --success-color: #00aa55;
  --warning-color: #cc8800;
  --danger-color: #cc3333;
}

/* 主容器 */
.dashboard {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
  transition: background-color 0.3s ease;
  position: relative;
}

body.dark .dashboard {
  background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 50%, #0a0e27 100%);
  color: #ffffff;
}

body.light .dashboard {
  background: linear-gradient(135deg, #f0f2f5 0%, #ffffff 50%, #f0f2f5 100%);
  color: #1a1a2e;
}

/* 科技感背景装饰 */
body.dark .dashboard::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(0, 212, 255, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(0, 255, 136, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.dashboard > * {
  position: relative;
  z-index: 1;
}

/* 顶部标题栏 */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-radius: 8px;
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

body.dark .header {
  background: rgba(21, 26, 58, 0.85);
  border: 1px solid rgba(0, 212, 255, 0.3);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.1), inset 0 0 20px rgba(0, 212, 255, 0.05);
}

body.light .header {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d9d9d9;
}

.header-left {
  flex: 1;
}

.title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 2px;
}

body.dark .title {
  color: #00d4ff;
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

body.light .title {
  color: #0066cc;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.screen-size {
  font-size: 12px;
  margin-top: 4px;
  padding-left: 16px;
}

body.dark .screen-size {
  color: #8b92b3;
}

body.light .screen-size {
  color: #666666;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00ff88;
  box-shadow: 0 0 8px #00ff88;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

body.dark .status-text {
  color: #00ff88;
}

body.light .status-text {
  color: #00aa55;
}

.header-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.datetime {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.date {
  font-size: 12px;
}

.time {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

body.dark .datetime {
  color: #8b92b3;
}

body.light .datetime {
  color: #666666;
}

body.dark .time {
  color: #ffffff;
}

body.light .time {
  color: #1a1a2e;
}

/* 主题切换按钮 */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--panel-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

/* 主内容区 */
.main-content {
  flex: 1;
  display: flex;
  gap: 12px;
  min-height: 0;
}

.left-panels,
.right-panels {
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.center-scene {
  flex: 1;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.dark .center-scene {
  background: rgba(21, 26, 58, 0.5);
  border: 1px solid rgba(0, 212, 255, 0.3);
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.1), inset 0 0 30px rgba(0, 212, 255, 0.05);
}

body.light .center-scene {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #d9d9d9;
}

.workshop-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 底部区域 */
.bottom-section {
  display: flex;
  gap: 12px;
  height: 200px;
  flex-shrink: 0;
}

.bottom-left,
.bottom-right {
  width: 260px;
}

.bottom-center {
  flex: 1;
}

/* 数据面板通用样式 */
.data-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

body.dark .data-panel {
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.1), inset 0 0 15px rgba(0, 212, 255, 0.05);
}

/* 科技感边角装饰 */
.data-panel::before,
.data-panel::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary-color);
  opacity: 0.5;
}

.data-panel::before {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
}

.data-panel::after {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-color);
  position: relative;
}

.icon {
  font-size: 16px;
}

.title-text {
  font-weight: 600;
  letter-spacing: 1px;
}

.header-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--primary-color), transparent);
  opacity: 0.5;
}

/* 当前值显示 */
.current-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border-left: 3px solid var(--primary-color);
  margin-bottom: 10px;
}

body.dark .current-value {
  background: rgba(0, 212, 255, 0.05);
}

.value {
  font-size: 28px;
  font-weight: bold;
  color: var(--primary-color);
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.unit {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 传感器列表 */
.sensor-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sensor-item {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
  transition: all 0.3s ease;
}

body.dark .sensor-item {
  background: rgba(0, 212, 255, 0.03);
}

.sensor-item:hover {
  background: rgba(0, 212, 255, 0.1);
  transform: translateX(2px);
}

.sensor-name {
  color: var(--text-secondary);
}

.sensor-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sensor-value.normal {
  color: var(--primary-color);
}

.sensor-value.warning {
  color: var(--warning-color);
  text-shadow: 0 0 8px rgba(255, 170, 0, 0.5);
}

.sensor-value.danger {
  color: var(--danger-color);
  text-shadow: 0 0 8px rgba(255, 68, 68, 0.5);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* 洁净度面板 */
.pm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  margin-bottom: 8px;
}

body.dark .pm-item {
  background: rgba(0, 212, 255, 0.03);
}

.pm-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.pm-value {
  font-size: 24px;
  font-weight: bold;
  color: var(--success-color);
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

.pm-unit {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 4px;
}

.quality-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  border-left: 3px solid var(--success-color);
}

body.dark .quality-indicator {
  background: rgba(0, 255, 136, 0.05);
}

.quality-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.quality-level {
  font-size: 20px;
  font-weight: bold;
  color: var(--success-color);
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

/* 换气系统面板 */
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  margin-bottom: 8px;
}

body.dark .metric-row {
  background: rgba(0, 212, 255, 0.03);
}

.metric-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.metric-value {
  font-size: 18px;
  font-weight: bold;
  color: var(--primary-color);
}

.metric-unit {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 4px;
}

.progress-bar {
  width: 100%;
  height: 20px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--success-color));
  border-radius: 10px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot-small {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
  animation: pulse 2s infinite;
}

/* 风扇状态面板 */
.fan-summary {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.summary-card {
  flex: 1;
  padding: 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  text-align: center;
}

body.dark .summary-card {
  background: rgba(0, 212, 255, 0.03);
}

.summary-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.summary-value {
  font-size: 20px;
  font-weight: bold;
}

.summary-value.running {
  color: var(--success-color);
}

.summary-value.stopped {
  color: var(--text-secondary);
}

.summary-value.fault {
  color: var(--danger-color);
}

.fan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 120px;
  overflow-y: auto;
}

.fan-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  transition: all 0.3s ease;
}

body.dark .fan-item {
  background: rgba(0, 212, 255, 0.03);
}

.fan-item:hover {
  background: rgba(0, 212, 255, 0.1);
}

.fan-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fan-name {
  font-size: 12px;
  color: var(--text-color);
}

.fan-status-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
}

.fan-status-badge.running {
  background: rgba(0, 255, 136, 0.2);
  color: var(--success-color);
}

.fan-status-badge.stopped {
  background: rgba(139, 146, 179, 0.2);
  color: var(--text-secondary);
}

.fan-status-badge.fault {
  background: rgba(255, 68, 68, 0.2);
  color: var(--danger-color);
}

.fan-data {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.fan-speed {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-color);
}

.fan-current {
  font-size: 10px;
  color: var(--text-secondary);
}

/* 报警面板 */
.alarm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.alarm-count {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--danger-color);
  color: white;
  border-radius: 10px;
  font-weight: 600;
}

.alarm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 140px;
  overflow-y: auto;
}

.alarm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  border-left: 3px solid var(--warning-color);
}

body.dark .alarm-item {
  background: rgba(0, 212, 255, 0.03);
}

.alarm-item.danger {
  border-left-color: var(--danger-color);
  animation: borderPulse 2s infinite;
}

@keyframes borderPulse {
  0%, 100% { border-left-color: var(--danger-color); }
  50% { border-left-color: transparent; }
}

.alarm-time {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 60px;
}

.alarm-message {
  flex: 1;
  font-size: 12px;
  color: var(--text-color);
}

.alarm-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
}

.alarm-status.resolved {
  background: rgba(0, 255, 136, 0.2);
  color: var(--success-color);
}

.alarm-status.unresolved {
  background: rgba(255, 68, 68, 0.2);
  color: var(--danger-color);
}

/* 趋势图表面板 */
.trend-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chart-container {
  flex: 1;
  min-height: 0;
}

#trend-chart {
  width: 100%;
  height: 100%;
}

/* 滚动条样式 */
.left-panels::-webkit-scrollbar,
.right-panels::-webkit-scrollbar,
.fan-list::-webkit-scrollbar,
.alarm-list::-webkit-scrollbar {
  width: 4px;
}

.left-panels::-webkit-scrollbar-thumb,
.right-panels::-webkit-scrollbar-thumb,
.fan-list::-webkit-scrollbar-thumb,
.alarm-list::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 255, 0.3);
  border-radius: 2px;
}

body.light .left-panels::-webkit-scrollbar-thumb,
body.light .right-panels::-webkit-scrollbar-thumb,
body.light .fan-list::-webkit-scrollbar-thumb,
body.light .alarm-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}
