/**
 * 动画和过渡效果
 */

/* ========== 淡入淡出 ========== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

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

.fade-out {
  animation: fadeOut 0.3s ease-out;
}

/* ========== 滑动 ========== */

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

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideLeft {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideRight {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

.slide-down {
  animation: slideDown 0.3s ease-out;
}

.slide-left {
  animation: slideLeft 0.3s ease-out;
}

.slide-right {
  animation: slideRight 0.3s ease-out;
}

/* ========== 缩放 ========== */

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes scaleOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.95);
    opacity: 0;
  }
}

.scale-in {
  animation: scaleIn 0.3s ease-out;
}

.scale-out {
  animation: scaleOut 0.3s ease-out;
}

/* ========== 加载动画 ========== */

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

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

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.spin {
  animation: spin 1s linear infinite;
}

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

.shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-hover) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

/* ========== 抖动 ========== */

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-5px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(5px);
  }
}

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

/* ========== 弹跳 ========== */

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.bounce {
  animation: bounce 1s ease-in-out infinite;
}

/* ========== 高亮闪烁 ========== */

@keyframes highlight {
  0% {
    background-color: transparent;
  }
  50% {
    background-color: rgba(245, 158, 11, 0.2);
  }
  100% {
    background-color: transparent;
  }
}

.highlight {
  animation: highlight 1s ease-in-out;
}

/* ========== 模态框动画 ========== */

@keyframes modalBackdropIn {
  from {
    background-color: rgba(0, 0, 0, 0);
  }
  to {
    background-color: rgba(0, 0, 0, 0.5);
  }
}

@keyframes modalBackdropOut {
  from {
    background-color: rgba(0, 0, 0, 0.5);
  }
  to {
    background-color: rgba(0, 0, 0, 0);
  }
}

@keyframes modalIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes modalOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.95);
    opacity: 0;
  }
}

.modal-backdrop.show {
  animation: modalBackdropIn 0.3s ease-out;
}

.modal-backdrop.hide {
  animation: modalBackdropOut 0.3s ease-out;
}

.modal.show {
  animation: modalIn 0.3s ease-out;
}

.modal.hide {
  animation: modalOut 0.3s ease-out;
}

/* ========== 抽屉动画 ========== */

@keyframes drawerSlideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes drawerSlideOut {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

.drawer.show {
  animation: drawerSlideIn 0.3s ease-out;
}

.drawer.hide {
  animation: drawerSlideOut 0.3s ease-out;
}

/* ========== 下拉菜单动画 ========== */

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

.dropdown.show {
  animation: dropdownIn 0.2s ease-out;
}

/* ========== Toast 通知动画 ========== */

@keyframes toastIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

.toast.show {
  animation: toastIn 0.3s ease-out;
}

.toast.hide {
  animation: toastOut 0.3s ease-out;
}

/* ========== 工具类 ========== */

.animate-none {
  animation: none !important;
}

.transition-none {
  transition: none !important;
}

.duration-fast {
  animation-duration: 0.15s !important;
}

.duration-normal {
  animation-duration: 0.3s !important;
}

.duration-slow {
  animation-duration: 0.5s !important;
}
