/**
 * 画质增强页面动画和UI增强
 * 为upscale.php添加现代化动画效果
 */

/* ==================== 页面加载动画 ==================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 应用动画到元素 */
.header {
    animation: fadeIn 0.6s ease-out;
}

.sidebar {
    animation: slideInLeft 0.8s ease-out;
}

.main-content {
    animation: slideInRight 0.8s ease-out 0.2s both;
}

.param-group {
    animation: fadeInUp 0.6s ease-out both;
}

.param-group:nth-child(1) { animation-delay: 0.1s; }
.param-group:nth-child(2) { animation-delay: 0.2s; }
.param-group:nth-child(3) { animation-delay: 0.3s; }
.param-group:nth-child(4) { animation-delay: 0.4s; }

/* ==================== 上传区域增强 ==================== */
.upload-area {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 141, 148, 0.1), transparent);
    transition: left 0.6s;
}

.upload-area:hover::before {
    left: 100%;
}

.upload-area:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 141, 148, 0.2);
}

.upload-area.dragover {
    background: rgba(0, 141, 148, 0.05);
    border-color: #008d94;
    border-style: solid;
    transform: scale(1.02);
}

/* 上传图标动画 */
@keyframes uploadPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.upload-area:hover .upload-icon {
    animation: uploadPulse 1.5s ease-in-out infinite;
}

/* ==================== 放大倍数选项动画 ==================== */
.scale-option {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.scale-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 141, 148, 0.1), transparent);
    transition: left 0.6s;
}

.scale-option:hover::before {
    left: 100%;
}

.scale-option:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 141, 148, 0.2);
}

.scale-icon {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.scale-option:hover .scale-icon {
    transform: scale(1.2) rotate(5deg);
}

.scale-option.active .scale-icon {
    animation: iconBounce 0.6s ease-out;
}

@keyframes iconBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

/* 选中标记 */
.scale-option::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: #008d94;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.scale-option.active::after {
    opacity: 1;
    transform: scale(1);
}

/* ==================== 增强级别动画 ==================== */
.enhance-level {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.enhance-level:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 141, 148, 0.2);
}

.enhance-level::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    background: #008d94;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.enhance-level.active::after {
    opacity: 1;
    transform: scale(1);
}

/* ==================== 按钮增强 ==================== */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: scale(0.98);
}

/* ==================== 图片预览增强 ==================== */
.preview-image {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: imageZoomIn 0.6s ease-out;
    cursor: pointer;
}

.preview-image:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 32px rgba(0, 141, 148, 0.3);
}

@keyframes imageZoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==================== 文件信息动画 ==================== */
.file-info {
    animation: fadeInUp 0.6s ease-out;
    transition: all 0.3s;
}

/* ==================== 预览占位符动画 ==================== */
@keyframes placeholderPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.preview-placeholder-icon {
    animation: placeholderPulse 2s ease-in-out infinite;
}

/* ==================== 进度条增强 ==================== */
.progress-bar {
    position: relative;
    overflow: visible;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    bottom: -2px;
    background: linear-gradient(90deg, transparent, rgba(0, 141, 148, 0.3), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.progress-bar.active::after {
    opacity: 1;
    animation: progressGlow 2s ease-in-out infinite;
}

@keyframes progressGlow {
    0%, 100% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(100%);
    }
}

/* ==================== 结果操作按钮动画 ==================== */
.result-actions {
    animation: fadeInUp 0.6s ease-out;
}

.result-actions .btn {
    animation: fadeInUp 0.6s ease-out both;
}

.result-actions .btn:nth-child(1) { animation-delay: 0.1s; }
.result-actions .btn:nth-child(2) { animation-delay: 0.2s; }
.result-actions .btn:nth-child(3) { animation-delay: 0.3s; }

/* ==================== 返回顶部按钮 ==================== */
.back-to-top {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #008d94 0%, #006b70 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 16px rgba(0, 141, 148, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 141, 148, 0.5);
}

/* ==================== 图片缩放预览 ==================== */
.image-zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    cursor: zoom-out;
}

.image-zoom-overlay.active {
    opacity: 1;
    visibility: visible;
}

.image-zoom-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    animation: scaleIn 0.4s ease-out;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ==================== 通知系统 ==================== */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideOutUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-100%);
    }
}

.notification {
    animation: slideInDown 0.5s ease-out;
}

.notification.hiding {
    animation: slideOutUp 0.5s ease-out;
}

/* ==================== 对比视图增强 ==================== */
.compare-container {
    animation: fadeIn 0.5s ease-out;
}

.compare-image-wrapper {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.compare-image-wrapper:hover {
    transform: scale(1.02);
}

/* ==================== 加载状态 ==================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-primary.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

/* ==================== 骨架屏 ==================== */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #2A2D30 25%, #3A3D40 50%, #2A2D30 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
    border-radius: 8px;
}

/* ==================== 响应式动画 ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== 平滑滚动 ==================== */
html {
    scroll-behavior: smooth;
}

/* ==================== 工具提示 ==================== */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #1A1A1A;
    color: white;
    text-align: center;
    border-radius: 8px;
    padding: 8px 12px;
    position: absolute;
    z-index: 1001;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(10px);
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1A1A1A transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* ==================== 信息框增强 ==================== */
.info-box {
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

/* ==================== 章节标题增强 ==================== */
.section-title {
    position: relative;
    overflow: hidden;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, #008d94, transparent);
    animation: titleUnderline 2s ease-in-out infinite;
}

@keyframes titleUnderline {
    0%, 100% {
        transform: translateX(0);
        opacity: 1;
    }
    50% {
        transform: translateX(100px);
        opacity: 0;
    }
}
