/* 页面切换动画效果 */

/* 淡入动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* 从下方滑入 */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 从上方滑入 */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 从左侧滑入 */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 从右侧滑入 */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 缩放淡入 */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 旋转淡入 */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.9);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* 应用动画的类 */
.page-transition {
    animation: fadeIn 0.4s ease-out;
}

.slide-in-up {
    animation: slideInUp 0.5s ease-out;
}

.slide-in-down {
    animation: slideInDown 0.5s ease-out;
}

.slide-in-left {
    animation: slideInLeft 0.5s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

.zoom-in {
    animation: zoomIn 0.4s ease-out;
}

.rotate-in {
    animation: rotateIn 0.5s ease-out;
}

/* 主内容区域默认应用淡入动画 */
.main-content {
    animation: fadeIn 0.4s ease-out;
}

/* 卡片依次淡入动画 */
.card-stagger {
    animation: slideInUp 0.5s ease-out;
}

.card-stagger:nth-child(1) {
    animation-delay: 0.1s;
}

.card-stagger:nth-child(2) {
    animation-delay: 0.2s;
}

.card-stagger:nth-child(3) {
    animation-delay: 0.3s;
}

.card-stagger:nth-child(4) {
    animation-delay: 0.4s;
}

/* 悬浮效果增强 */
.hover-lift {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* 按钮点击波纹效果 */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* 表单元素聚焦动画 */
.form-control,
.form-select {
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    transform: scale(1.02);
}

/* 导航项悬浮动画 */
.nav-link,
.dropdown-item {
    position: relative;
    transition: all 0.3s ease;
}

.nav-link::before,
.dropdown-item::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::before,
.dropdown-item:hover::before {
    width: 80%;
}

/* 卡片翻转效果 */
.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    backface-visibility: hidden;
}

.card-flip-back {
    transform: rotateY(180deg);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* 加载占位符动画 */
.skeleton {
    background: linear-gradient(90deg,
        rgba(212, 175, 55, 0.1) 25%,
        rgba(212, 175, 55, 0.2) 50%,
        rgba(212, 175, 55, 0.1) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* 暗黑模式下的骨架屏 */
body.dark-mode .skeleton {
    background: linear-gradient(90deg,
        rgba(129, 199, 132, 0.1) 25%,
        rgba(129, 199, 132, 0.2) 50%,
        rgba(129, 199, 132, 0.1) 75%
    );
    background-size: 200% 100%;
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 页面进入/退出动画 */
.page-enter {
    animation: fadeIn 0.3s ease-out;
}

.page-exit {
    animation: fadeOut 0.3s ease-in;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* 响应式动画调整 */
@media (max-width: 768px) {
    .slide-in-up,
    .slide-in-down,
    .slide-in-left,
    .slide-in-right {
        animation-duration: 0.3s;
    }

    .hover-lift:hover {
        transform: translateY(-4px);
    }
}

/* 减少动画偏好设置 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
