/**
 * 通用动画样式库
 * 为整个项目提供统一的动画效果
 */

/* ==================== 基础动画关键帧 ==================== */

/* 淡入上升 - 用于表单组动画等 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 淡入左移 - 用于返回按钮动画 */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 旋转动画 - 用于加载图标和 icon-spin-hover */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* 弹入动画 - 统一页面入场动画 */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    60% {
        opacity: 1;
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* 背景渐变动画 - 用于登录/注册页面背景 */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ==================== 动画工具类 ==================== */

/* 淡入上升 - JS 动态添加的默认动画 */
.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* ==================== 成功/失败标记（JS 动态创建）==================== */

.success-mark,
.error-mark {
    position: fixed;
    font-size: 48px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10000;
    transition: all 0.6s ease-out;
    transform: translate(-50%, -50%) scale(0);
}

.success-mark {
    color: #28a745;
}

.error-mark {
    color: #dc3545;
}

/* ==================== 加载动画（JS 动态创建）==================== */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* ==================== 响应式动画禁用 ==================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== 统一返回按钮样式 ==================== */

/**
 * 前台页面统一返回按钮样式
 * 适用于所有前台页面的返回/后退按钮
 * 使用方式：给 <a> 或 <button> 添加 class="back-btn-animated"
 */

.back-btn-animated {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    cursor: pointer;
}

.back-btn-animated:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.45);
    color: white;
    text-decoration: none;
}

.back-btn-animated:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.back-btn-animated:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3), 0 4px 15px rgba(102, 126, 234, 0.3);
}

.back-btn-animated:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.back-btn-animated i {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.back-btn-animated:hover i {
    transform: translateX(-3px);
}

/* 出场动画 - 从左侧淡入 */
.back-btn-animated.animate-enter {
    animation: fadeInLeft 0.6s ease-out;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .back-btn-animated {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}