/* ==================== 微交互动画 ==================== */

/* 按钮交互动画 */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 涟漪效果 */
.btn::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;
    pointer-events: none;
}

.btn:active::after {
    width: 300px;
    height: 300px;
    transition: width 0s, height 0s;
}

/* 卡片悬停效果 */
.link-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
}

.link-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.link-item:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

/* 模式按钮动画 */
.mode-btn {
    transition: all 0.3s ease;
    position: relative;
}

.mode-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color, #764ba2) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: inherit;
    z-index: -1;
}

.mode-btn:hover::before {
    opacity: 0.1;
}

.mode-btn.active::before {
    opacity: 1;
}

.mode-btn.active {
    color: white;
    transform: scale(1.05);
}

/* 输入框焦点动画 */
input,
textarea,
select {
    transition: all 0.3s ease;
    position: relative;
}

input:focus,
textarea:focus,
select:focus {
    transform: scale(1.02);
}

/* 复选框动画 */
input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

input[type="checkbox"]:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    color: white;
    font-weight: bold;
    animation: checkbox-pop 0.3s ease forwards;
}

@keyframes checkbox-pop {
    0% {
        transform: translate(-50%, -50%) scale(0);
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Toast通知动画 */
.toast {
    animation: toast-slide-in 0.3s ease, toast-slide-out 0.3s ease 2.7s;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* 侧边栏滑入动画 */
.side-panel {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.side-panel.active {
    transform: translateX(0);
}

/* 模态框动画 */
.modal {
    animation: modal-fade-in 0.3s ease;
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 下拉菜单动画 */
.dropdown-menu {
    animation: dropdown-slide 0.2s ease;
    transform-origin: top;
}

@keyframes dropdown-slide {
    from {
        opacity: 0;
        transform: scaleY(0.8) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scaleY(1) translateY(0);
    }
}

/* 数字滚动动画 */
.counter {
    display: inline-block;
    transition: all 0.5s ease;
}

.counter.updating {
    animation: counter-bounce 0.5s ease;
}

@keyframes counter-bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* 进度条动画 */
.progress-bar {
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 图标旋转动画 */
.icon-spin {
    animation: icon-rotate 1s linear infinite;
}

@keyframes icon-rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* 图标弹跳动画 */
.icon-bounce {
    animation: icon-bounce-anim 0.6s ease;
}

@keyframes icon-bounce-anim {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* 脉冲动画 */
.pulse {
    animation: pulse-anim 2s ease infinite;
}

@keyframes pulse-anim {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* 摇晃动画 */
.shake {
    animation: shake-anim 0.5s ease;
}

@keyframes shake-anim {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

/* 淡入动画 */
.fade-in {
    animation: fade-in-anim 0.5s ease;
}

@keyframes fade-in-anim {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 滑入动画 */
.slide-in-up {
    animation: slide-in-up-anim 0.5s ease;
}

@keyframes slide-in-up-anim {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 缩放动画 */
.scale-in {
    animation: scale-in-anim 0.3s ease;
}

@keyframes scale-in-anim {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 翻转动画 */
.flip {
    animation: flip-anim 0.6s ease;
}

@keyframes flip-anim {
    from {
        transform: rotateY(0deg);
    }

    to {
        transform: rotateY(360deg);
    }
}

/* 悬停发光效果 */
.glow-on-hover {
    position: relative;
}

.glow-on-hover::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #667eea, #764ba2, #667eea);
    background-size: 400%;
    border-radius: inherit;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
    animation: glow-rotate 3s linear infinite;
}

.glow-on-hover:hover::before {
    opacity: 1;
    filter: blur(8px);
}

@keyframes glow-rotate {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* 减少动画 - 尊重用户偏好 */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}