/**
 * 渲染页面动画和UI增强
 * 为render_optimized.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;
}

.module-card {
    animation: fadeInUp 0.6s ease-out both;
}

.module-card:nth-child(1) { animation-delay: 0.1s; }
.module-card:nth-child(2) { animation-delay: 0.2s; }
.module-card:nth-child(3) { animation-delay: 0.3s; }
.module-card:nth-child(4) { animation-delay: 0.4s; }
.module-card:nth-child(5) { animation-delay: 0.5s; }

/* ==================== 上传区域增强 ==================== */
.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);
    border-color: #008d94;
}

.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;
}

/* ==================== 图片预览增强 ==================== */
.preview-image {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    animation: scaleIn 0.5s ease-out;
}

.preview-image:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

/* ==================== 按钮增强 ==================== */
.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);
    box-shadow: 0 8px 24px rgba(0, 141, 148, 0.4);
}

.btn:active {
    transform: translateY(0);
}

/* ==================== 进度条动画 ==================== */
@keyframes progressFlow {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}

.progress-fill {
    background: linear-gradient(90deg, #008d94, #00a3ab, #008d94);
    background-size: 200% 100%;
    animation: progressFlow 2s linear infinite;
}

/* ==================== 结果卡片动画 ==================== */
.result-card {
    animation: scaleIn 0.6s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 48px rgba(0, 141, 148, 0.2);
}

/* ==================== 模块折叠动画 ==================== */
.module-content {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top;
}

.module-card.collapsed .module-content {
    max-height: 0;
    opacity: 0;
    transform: scaleY(0);
    padding: 0;
    margin: 0;
}

.module-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.module-card.collapsed .module-arrow {
    transform: rotate(-90deg);
}

/* ==================== 加载动画 ==================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading-spinner {
    animation: spin 1s linear infinite;
}

.loading-text {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ==================== 工具提示 ==================== */
.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);
}

/* ==================== 标签动画 ==================== */
.tag {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tag:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 141, 148, 0.3);
}

.tag.selected {
    animation: scaleIn 0.3s ease-out;
}

/* ==================== 图片对比滑块 ==================== */
.image-compare-slider {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-compare-slider:hover {
    transform: scale(1.02);
}

/* ==================== 通知动画 ==================== */
@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;
}

/* ==================== 骨架屏 ==================== */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ==================== 响应式动画 ==================== */
@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;
}

/* ==================== 返回顶部按钮 ==================== */
.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;
    animation: fadeInUp 0.5s ease-out;
}

.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.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.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;
}

/* ==================== 拖拽提示 ==================== */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.drag-hint {
    animation: bounce 2s ease-in-out infinite;
}
