/**
 * 交互动效层（只加不删，叠加在现有样式之上）
 * 卡片悬停浮起 / 按钮微交互 / 徽章呼吸 / 页面切换 / 表格行高亮
 */

/* ===== 1. 卡片悬停浮起 ===== */
.card {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.25s ease;
  will-change: transform;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.25);
}

/* KPI/统计卡悬停发光 */
.factory-kpi, .group-stat-card, .kpi, .quality-metric, .summary-card {
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.22s ease;
}
.factory-kpi:hover, .group-stat-card:hover, .kpi:hover, .quality-metric:hover, .summary-card:hover {
  transform: translateY(-2px) scale(1.015);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* ===== 2. 按钮微交互 ===== */
.btn {
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.96);
  filter: brightness(0.95);
}
.btn-primary:hover {
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

/* 子Tab按钮 */
.sub-tab-btn, .fac-subtab, .gp-sub-tab {
  transition: all 0.18s ease;
}
.sub-tab-btn:hover, .fac-subtab:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* 导航按钮 */
.tab-nav button {
  transition: all 0.18s ease;
  position: relative;
}
.tab-nav button:hover {
  filter: brightness(1.2);
}
.tab-nav button.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #3b82f6, transparent);
  border-radius: 2px;
}

/* ===== 3. 徽章呼吸（异常/待办提醒） ===== */
.badge-red, .badge.badge-red {
  animation: badge-breathe 2s ease-in-out infinite;
}
@keyframes badge-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50% { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}

/* 智能体异常点呼吸 */
.agent-dot.err {
  animation: dot-pulse 1.6s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); opacity: 1; }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); opacity: 0.7; }
}

/* 智能体等待点闪烁 */
.agent-dot.wait {
  animation: dot-blink 2.2s ease-in-out infinite;
}
@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ===== 4. 表格行悬停高亮 ===== */
.data-table tbody tr {
  transition: background 0.15s ease;
}
.data-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.06);
}

/* ===== 5. 模态框进场动画 ===== */
.modal-overlay.active {
  animation: modal-fade-in 0.2s ease;
}
.modal-overlay.active .modal-container {
  animation: modal-pop-in 0.28s cubic-bezier(0.22, 1.2, 0.36, 1);
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-pop-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== 6. 决策卡片/产线卡进场 ===== */
.decision, .production-line, .timeline-item {
  animation: card-slide-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.decision:nth-child(1) { animation-delay: 0.03s; }
.decision:nth-child(2) { animation-delay: 0.08s; }
.decision:nth-child(3) { animation-delay: 0.13s; }
.decision:nth-child(4) { animation-delay: 0.18s; }
.decision:nth-child(5) { animation-delay: 0.23s; }
.production-line:nth-child(2) { animation-delay: 0.06s; }
.production-line:nth-child(3) { animation-delay: 0.12s; }
.production-line:nth-child(4) { animation-delay: 0.18s; }
@keyframes card-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 7. 数字跳动（配合JS数字滚动） ===== */
.profit-value, .exec-value, .factory-kpi-value {
  transition: color 0.3s ease;
}

/* ===== 8. 知识图谱提示浮层 ===== */
#kgTooltip {
  animation: tooltip-in 0.15s ease;
}
@keyframes tooltip-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 9. Toast/通知进场 ===== */
.toast, .notification-item {
  animation: card-slide-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== 10. 滚动条美化（细节质感） ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.35);
}

/* ===== 11. 减少动画偏好（可访问性） ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
