/* ==================== 全局变量 ==================== */
:root {
  /* 统一字体 */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, monospace;
  
  /* 字号系统 */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 20px;
  --text-3xl: 24px;
  
  /* 间距系统 (8px基准) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  
  /* 颜色 */
  --color-primary: #5369f8;
  --color-bg: #f5f6f8;
  --color-card: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #1f2937;
  --color-text-light: #6b7280;
  --color-text-muted: #9ca3af;
  
  /* 告警颜色 */
  --color-critical: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;
  --color-success: #10b981;
}

/* ==================== 基础重置 ==================== */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==================== 布局框架 ==================== */
#page {
  min-height: 100vh;
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
}

#header {
  width: 100%;
  height: 60px;
  line-height: 60px;
  background-color: var(--color-card);
  padding: 0 var(--space-6);
  position: fixed;
  top: 0;
  right: 0;
  border-bottom: 1px solid var(--color-border);
  z-index: 1000;
}

.logo {
  display: inline-block;
  height: 44px;  /* 从 28px 增加到 44px */
  line-height: 44px;
  margin: 8px 0;  /* 调整上下边距保持居中 */
}

.logo img {
  height: 100%;
  max-width: 280px;  /* 为长方形 logo 设置最大宽度 */
  object-fit: contain;
  vertical-align: middle;
}

.logo .system_name {
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
  font-family: var(--font-family);
  color: var(--color-text);
  font-weight: 600;
  vertical-align: middle;
  margin-left: var(--space-2);
}

.top-menu {
  display: flex;
  float: right;
  color: var(--color-text-light);
  font-size: var(--text-base);
}

.top-menu .menu {
  margin-right: var(--space-6);
  cursor: pointer;
}

.top-menu .menu:last-child {
  margin-right: 0;
}

#core-container {
  width: 100%;
  margin-top: 60px;
  display: flex;
}

/* ==================== 左侧导航 ==================== */
#left-side {
  width: 220px;
  height: calc(100vh - 60px);
  background-color: var(--color-card);
  padding: var(--space-4) 0;
  position: fixed;
  left: 0;
  top: 60px;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
}

#left-side .nav-link {
  display: flex;
  align-items: center;
  width: 100%;
  color: var(--color-text);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  font-size: var(--text-base);
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

#left-side .nav-link .iconfont {
  margin-right: var(--space-3);
  font-size: var(--text-lg);
  opacity: 0.7;
}

#left-side .nav-link:hover {
  color: var(--color-primary);
  background-color: #f8f9fd;
}

#left-side .active {
  color: var(--color-primary);
  background-color: #f8f9fd;
  border-left-color: var(--color-primary);
  font-weight: 500;
}

.menu-section-title {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: var(--space-3);
}

.menu-section-title:first-child {
  margin-top: 0;
}

/* ==================== 右侧主内容 ==================== */
#right-side {
  width: calc(100% - 220px);
  height: 100%;
  margin-left: 220px;
  position: relative;
  padding-bottom: 60px;
  background-color: var(--color-bg);
}

#main {
  padding: var(--space-4);
  min-height: calc(100vh - 60px);
}

/* ==================== 卡片系统 ==================== */
.card, .layui-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.card-header, .layui-card-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--color-text);
}

.card-body, .layui-card-body {
  padding: var(--space-4);
}

.card h6, .card h5 {
  margin: 0 0 var(--space-3) 0;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
}

/* ==================== KPI卡片 ==================== */
.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.kpi {
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-card);
}

.kpi .label {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  margin-bottom: var(--space-1);
}

.kpi .value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-text);
  margin-top: var(--space-1);
}

/* ==================== 表格 ==================== */
.table {
  width: 100%;
  font-size: var(--text-base);
  color: var(--color-text);
  border-collapse: collapse;
}

.table thead {
  background-color: #f9fafb;
  border-bottom: 2px solid var(--color-border);
}

.table thead th {
  padding: var(--space-3) var(--space-3);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text-light);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.table tbody td {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-base);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background-color: #f9fafb;
}

/* ==================== 按钮 ==================== */
.btn {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-base);
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-family);
}

.btn-primary {
  background-color: var(--color-primary) !important;
  color: white;
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background-color: #4357e6 !important;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: #6b7280;
  color: white;
  border-color: #6b7280;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

.btn-sm {
  padding: 4px var(--space-3);
  font-size: var(--text-sm);
}

.btn-outline-primary {
  background-color: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-outline-primary:hover {
  background-color: var(--color-primary);
  color: white;
}

/* ==================== 表单 ==================== */
.form-select, .form-control, input[type="text"], input[type="number"], select {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  font-family: var(--font-family);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background-color: var(--color-card);
  transition: all 0.15s ease;
}

.form-select:focus, .form-control:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(83, 105, 248, 0.1);
}

/* ==================== 告警样式 ==================== */
.alert-critical {
  color: var(--color-critical);
  background-color: #fef2f2;
  border-left: 3px solid var(--color-critical);
}

.alert-warning {
  color: #d97706;
  background-color: #fffbeb;
  border-left: 3px solid var(--color-warning);
}

.alert-info {
  color: var(--color-info);
  background-color: #eff6ff;
  border-left: 3px solid var(--color-info);
}

/* 告警级别徽章 */
.badge-critical {
  background-color: var(--color-critical);
  color: white;
  padding: 2px var(--space-2);
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
}

.badge-warning {
  background-color: var(--color-warning);
  color: white;
  padding: 2px var(--space-2);
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
}

.badge-info {
  background-color: var(--color-info);
  color: white;
  padding: 2px var(--space-2);
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
}

/* ==================== 通知消息 ==================== */
.message {
  min-width: 380px;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid;
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translate(-50%, 0);
  transition: opacity 0.3s, transform 0.4s, top 0.4s;
  overflow: hidden;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  font-size: var(--text-base);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.message-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.message-success {
  background-color: #f0fdf4;
  border-color: #bbf7d0;
  color: #16a34a;
}

.message_content {
  margin-left: var(--space-2);
  margin-bottom: 0 !important;
}

.message-hide {
  transform: translate(-50%, -100px);
  opacity: 0;
}

/* ==================== 工具类 ==================== */
.text-muted {
  color: var(--color-text-muted);
}

.text-center {
  text-align: center;
}

.d-flex {
  display: flex;
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.mb-2 {
  margin-bottom: var(--space-2);
}

.mb-3 {
  margin-bottom: var(--space-3);
}

.mt-1 {
  margin-top: var(--space-2);
}

.p-3 {
  padding: var(--space-4);
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
  #left-side {
    width: 60px;
  }
  
  #right-side {
    width: calc(100% - 60px);
    margin-left: 60px;
  }
  
  #left-side .nav-link span {
    display: none;
  }
  
  .menu-section-title {
    display: none;
  }
}

/* ==================== 加载动画 ==================== */
.spinner-border {
  width: 3rem;
  height: 3rem;
  color: var(--color-primary);
}

.loading {
  opacity: 0.2;
}

/* ==================== 其他优化 ==================== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: #4357e6;
}

.pointer {
  cursor: pointer;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
/* ====== AI Analytics Styles ====== */

.metric-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.metric-card .label {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.metric-card .value {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0.5rem 0;
}

.metric-card .note {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.5rem;
}

/* ====== Prediction Cards ====== */

.prediction-card {
  border-left: 4px solid #10b981;
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: white;
  border-radius: 0 8px 8px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.prediction-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.prediction-card.severity-high {
  border-left-color: #ef4444;
  background: #fef2f2;
}

.prediction-card.severity-medium {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.pred-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.pred-header .equipment {
  font-size: 1.1rem;
  color: #1e293b;
}

.pred-header .health-badge {
  background: #10b981;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
}

.pred-body {
  margin-bottom: 1rem;
}

.timeline-bar {
  position: relative;
  height: 28px;
  background: #e5e7eb;
  border-radius: 14px;
  margin: 1rem 0;
  overflow: hidden;
}

.timeline-bar .progress {
  position: absolute;
  height: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 100%);
  
  border-radius: 14px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-bar .days-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 600;
  font-size: 0.875rem;
  color: #1e293b;
  z-index: 1;
}

.pred-details {
  background: rgba(0,0,0,0.02);
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  line-height: 1.6;
}

.pred-details div {
  margin-bottom: 0.25rem;
}

.pred-footer {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

.pred-footer button {
  flex: 1;
}

/* ====== Equipment Module Cards ====== */

.module-card {
  display: inline-block;
  width: 100px;
  padding: 0.75rem;
  margin: 0.5rem;
  border: 2px solid #10b981;
  border-radius: 8px;
  text-align: center;
  background: white;
  transition: all 0.2s ease;
}

.module-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.module-card.warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.module-card.normal {
  border-color: #10b981;
  background: #f0fdf4;
}

.module-id {
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.module-load {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0.25rem 0;
}

.module-status {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.5rem;
}

/* ====== CRAH Equipment Grid ====== */

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.crah-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
  transition: all 0.2s ease;
}

.crah-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.crah-card .id {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.crah-card .rpm,
.crah-card .comp {
  font-size: 0.875rem;
  color: #64748b;
  margin: 0.25rem 0;
}

/* ====== Optimization Gain Card ====== */

.gain-card {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(16, 185, 129, 0.3);
  margin: 2rem 0;
}

.gain-card .current,
.gain-card .target {
  font-size: 1.15rem;
  margin: 0.75rem 0;
}

.gain-card .current strong,
.gain-card .target strong {
  font-size: 1.5rem;
  font-weight: 700;
}

.gain-card .arrow {
  font-size: 2.5rem;
  margin: 1.5rem 0;
  opacity: 0.9;
}

.gain-card .improvement {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.3);
}

/* ====== Badge Styles ====== */

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-critical,
.badge-major {
  background: #fee2e2;
  color: #991b1b;
}

.badge-minor,
.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

/* ====== Table Styles ====== */

.table-control,
.table-anomaly {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-top: 1rem;
}

.table-control th,
.table-control td,
.table-anomaly th,
.table-anomaly td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.table-control th,
.table-anomaly th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-control tbody tr:hover,
.table-anomaly tbody tr:hover {
  background: #f8fafc;
}

.table-anomaly tr.warning {
  background: #fffbeb;
}

.table-anomaly tr.warning:hover {
  background: #fef3c7;
}

/* ====== Button Styles ====== */

.button-group {
  display: flex;
  gap: 1rem;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-success {
  background: #10b981;
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-outline-secondary {
  background: white;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.btn-outline-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

/* ====== Section Title Enhancement ====== */

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 1.5rem 0;
  color: #1e293b;
  border-bottom: 3px solid #3b82f6;
  padding-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 1.5rem;
  background: #3b82f6;
  border-radius: 2px;
}

/* ====== Chart Container Enhancement ====== */

.chart-container {
  width: 100%;
  height: 400px;
  margin-bottom: 2rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 1rem;
  transition: box-shadow 0.2s ease;
}

.chart-container:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* ====== Responsive Design ====== */

@media (max-width: 768px) {
  .metrics-row {
    grid-template-columns: 1fr;
  }
  
  .equipment-grid {
    grid-template-columns: 1fr;
  }
  
  .module-card {
    width: 100%;
    margin: 0.5rem 0;
  }
  
  .button-group {
    flex-direction: column;
  }
  
  .button-group button {
    width: 100%;
  }
  
  .pred-footer {
    flex-direction: column;
  }
  
  .chart-container {
    height: 300px;
  }
}

/* ====== Animation Utilities ====== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

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

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ====== Loading States ====== */

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(59, 130, 246, 0.3);
  border-radius: 50%;
  border-top-color: #3b82f6;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ====== Alert Banner ====== */

.alert-banner {
  padding: 1rem 1.5rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.alert-banner.info {
  background: #dbeafe;
  color: #1e40af;
  border-left: 4px solid #3b82f6;
}

.alert-banner.warning {
  background: #fef3c7;
  color: #92400e;
  border-left: 4px solid #f59e0b;
}

.alert-banner.success {
  background: #d1fae5;
  color: #065f46;
  border-left: 4px solid #10b981;
}

.alert-banner.error {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid #ef4444;
}