/* 现代化动画效果库 */

/* 基础动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    transform: translate3d(0,0,0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -8px, 0);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0,-1px,0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 动画类 */
.fade-in {
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-up {
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.slide-in-left {
  animation: slideInLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.scale-in {
  animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bounce {
  animation: bounce 1s infinite;
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary-500);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
}

/* 进度条 */
.progress {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-600));
  border-radius: inherit;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton.text {
  height: 16px;
  margin: 4px 0;
}

.skeleton.title {
  height: 24px;
  width: 60%;
  margin: 8px 0;
}

.skeleton.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton.card {
  height: 120px;
  margin: 8px 0;
}

/* 交互动画 */
.hover-lift {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
  transform: translateY(-2px);
}

.hover-scale {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-scale:hover {
  transform: scale(1.02);
}

.press-scale {
  transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.press-scale:active {
  transform: scale(0.98);
}

/* 延迟动画 */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }

/* 状态指示器动画 */
.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-indicator.online {
  background: var(--success);
  animation: pulse-green 2s infinite;
}

.status-indicator.offline {
  background: var(--danger);
}

.status-indicator.warning {
  background: var(--warning);
  animation: pulse-yellow 2s infinite;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulse-yellow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* 扫描线动画 */
.scan-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  --box-w: 70%;
  --box-h: 60%;
  --box-l: 50%;
  --box-t: 50%;
}

.scan-overlay::before {
  content: "";
  position: absolute;
  width: var(--box-w);
  height: var(--box-h);
  left: calc(var(--box-l) - var(--box-w)/2);
  top: calc(var(--box-t) - var(--box-h)/2);
  border: 2px solid #fff;
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5) inset, 0 0 20px rgba(0,0,0,0.3);
}

.scan-overlay::after {
  content: "";
  position: absolute;
  width: calc(var(--box-w) - 10px);
  height: 2px;
  left: calc(var(--box-l) - var(--box-w)/2 + 5px);
  top: calc(var(--box-t) - var(--box-h)/2 + 10px);
  background: var(--primary);
  border-radius: 2px;
  animation: scanline 2.2s linear infinite;
}

@keyframes scanline {
  0% { transform: translateY(0); }
  100% { transform: translateY(calc(var(--box-h) - 20px)); }
}

/* 通知动画 */
.notification {
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 模态框动画 */
.modal {
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content {
  animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s both;
}

/* 列表项交错动画 */
.stagger-animation .list-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation .list-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation .list-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation .list-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation .list-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-animation .list-item:nth-child(6) { animation-delay: 0.6s; }
.stagger-animation .list-item:nth-child(7) { animation-delay: 0.7s; }
.stagger-animation .list-item:nth-child(8) { animation-delay: 0.8s; }

/* 减少动画（用户偏好） */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}