/* 工业风格CSS */

/* 全局变量 - 默认深色主题 */
:root {
  --industrial-blue: #1E3A8A;
  --mechanical-gray: #374151;
  --safety-orange: #F97316;
  --status-green: #10B981;
  --dark-bg: #0F172A;
  --light-bg: #F8FAFC;
  --card-bg: rgba(30, 41, 59, 0.7);
  --light-card-bg: rgba(255, 255, 255, 0.8);
  --text-primary: #F1F5F9;
  --light-text-primary: #1E293B;
  --text-secondary: #94A3B8;
  --light-text-secondary: #64748B;
  --border-color: rgba(148, 163, 184, 0.2);
  --light-border-color: rgba(148, 163, 184, 0.2);
  --glow-blue: rgba(59, 130, 246, 0.3);
  --glow-green: rgba(16, 185, 129, 0.3);
  --glow-orange: rgba(249, 115, 22, 0.3);
  --glow-red: rgba(239, 68, 68, 0.3);
}

/* 浅色主题 */
[data-theme="light"] {
  --dark-bg: var(--light-bg);
  --card-bg: var(--light-card-bg);
  --text-primary: var(--light-text-primary);
  --text-secondary: var(--light-text-secondary);
  --border-color: var(--light-border-color);
}

[data-theme="light"] body {
  background-color: var(--light-bg);
  color: var(--light-text-primary);
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(30, 58, 138, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(16, 185, 129, 0.02) 0%, transparent 50%);
}

[data-theme="light"] .glass-effect {
  background: var(--light-card-bg);
  backdrop-filter: blur-md;
  border: var(--light-border-color);
}

[data-theme="light"] .glass-card {
  background: var(--light-card-bg);
  border: 1px solid var(--light-border-color);
}

[data-theme="light"] .data-table td {
  background-color: rgba(241, 245, 249, 0.5);
}

[data-theme="light"] .data-table tr:hover td {
  background-color: rgba(226, 232, 240, 0.7);
}

[data-theme="light"] .data-table th {
  background-color: rgba(241, 245, 249, 0.9);
}

/* 基础样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--dark-bg);
  color: var(--text-primary);
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(30, 58, 138, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
}

/* 等宽字体 */
.font-mono {
  font-family: 'Roboto Mono', monospace;
}

/* 玻璃态效果 */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 
    0 8px 32px 0 rgba(0, 0, 0, 0.37),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 40px 0 rgba(0, 0, 0, 0.45),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.15);
}

/* 状态指示灯 */
.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  position: relative;
}

.status-running {
  background-color: var(--status-green);
  box-shadow: 0 0 10px var(--glow-green);
  animation: pulse 2s infinite;
}

.status-idle {
  background-color: #3B82F6;
  box-shadow: 0 0 10px var(--glow-blue);
}

.status-maintenance {
  background-color: var(--safety-orange);
  box-shadow: 0 0 10px var(--glow-orange);
  animation: pulse 3s infinite;
}

.status-fault {
  background-color: #EF4444;
  box-shadow: 0 0 10px var(--glow-red);
  animation: pulse 1s infinite;
}

/* 脉冲动画 */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 数据流动画 */
@keyframes flow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.flow-bg {
  background: linear-gradient(
    -45deg,
    rgba(30, 58, 138, 0.1),
    rgba(16, 185, 129, 0.1),
    rgba(249, 115, 22, 0.1),
    rgba(30, 58, 138, 0.1)
  );
  background-size: 400% 400%;
  animation: flow 15s ease infinite;
}

/* 数字滚动动画 */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.number-animate {
  animation: countUp 0.8s ease-out forwards;
}

/* 警告闪烁动画 */
@keyframes warning {
  0%, 100% {
    background-color: var(--safety-orange);
    box-shadow: 0 0 10px var(--glow-orange);
  }
  50% {
    background-color: #F59E0B;
    box-shadow: 0 0 20px var(--glow-orange), 0 0 30px var(--glow-orange);
  }
}

.warning-flash {
  animation: warning 1.5s infinite;
}

/* 页面切换过渡 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-transition {
  animation: fadeIn 0.5s ease-out forwards;
}

/* 生产线条流动画 */
.production-line {
  position: relative;
  overflow: hidden;
}

.production-line::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--status-green), transparent);
  animation: lineFlow 3s linear infinite;
}

@keyframes lineFlow {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* 玻璃态按钮 */
.glass-btn {
  background: rgba(59, 130, 246, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #3B82F6;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.glass-btn:hover {
  background: rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 15px var(--glow-blue);
  transform: translateY(-1px);
}

/* 仪表盘样式 */
.dashboard-gauge {
  position: relative;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.dashboard-gauge::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--status-green), var(--safety-orange), #EF4444);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .glass-card {
    backdrop-filter: blur(8px);
    margin-bottom: 1rem;
  }
  
  .status-indicator {
    width: 10px;
    height: 10px;
  }
  
  /* 修复移动端点击问题 */
  a, button, [role="button"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  
  /* 确保可点击元素在移动端有足够的点击区域 */
  button, a {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  /* 修复固定定位元素的问题 */
  header {
    position: sticky;
    top: 0;
    z-index: 50;
  }
  
  /* 确保移动端导航菜单在最上层显示 */
  #mobile-nav {
    position: fixed !important;
    z-index: 70 !important;
    height: 100vh !important;
  }
  
  #mobile-nav-overlay {
    position: fixed !important;
    z-index: 60 !important;
  }
  
  /* 调整移动端内容边距 */
  main {
    padding-top: 16rem !important;
    padding-bottom: 8rem !important;
  }
  
  /* 调整表格在移动端的显示 */
  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  /* 调整KPI卡片在移动端的布局 */
  .kpi-card {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  
  /* 调整时间筛选按钮在移动端的布局 */
  .time-filter {
    margin: 0.25rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
  
  /* 调整导航菜单项在移动端的样式 */
  nav a {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
  
  /* 确保模态框在移动端正常显示 */
  #custom-date-modal .glass-effect {
    margin: 1rem;
    width: calc(100% - 2rem);
    max-width: none;
  }
  
  /* 调整玻璃态按钮在移动端的样式 */
  .glass-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
  }
  
  /* 修复移动端滚动问题 */
  body {
    -webkit-overflow-scrolling: touch;
  }
  
  /* 调整页脚在移动端的布局 */
  footer {
    padding: 2rem 1rem;
  }
  
  /* 调整工厂结构树在移动端的样式 */
  .factory-tree-node {
    padding: 0.75rem 1rem;
  }
  
  /* 调整数据卡片在移动端的样式 */
  .glass-card {
    padding: 1rem;
  }
  
  /* 调整状态指示器在移动端的位置 */
  .status-indicator {
    margin-right: 0.5rem;
  }
}

/* 大屏模式 */
@media (min-width: 1920px) {
  .glass-card {
    padding: 24px;
  }
  
  h1 {
    font-size: 2.5rem;
  }
  
  .status-indicator {
    width: 16px;
    height: 16px;
  }
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--dark-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--mechanical-gray);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4B5563;
}

/* 加载动画 */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--status-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* 数据卡片高亮 */
.card-highlight {
  border: 1px solid rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 20px var(--glow-blue);
}

/* 表格样式 */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background-color: rgba(30, 41, 59, 0.9);
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(15, 23, 42, 0.5);
}

.data-table tr:hover td {
  background-color: rgba(30, 41, 59, 0.7);
}

/* 打印样式 */
@media print {
  body {
    background: white;
    color: black;
  }
  
  .glass-card {
    background: white;
    border: 1px solid #ddd;
    box-shadow: none;
  }
  
  .status-indicator {
    box-shadow: none;
  }
  
  .no-print {
    display: none;
  }
}

/* 工具提示 */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  text-align: center;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}