/**
 * 文生图页面动画和UI增强
 * 为text_to_image.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; }
.param-group:nth-child(5) { animation-delay: 0.5s; }

/* ==================== 输入框增强 ==================== */
.prompt-input {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #FFFFFF;
    color: #1F2937;
    border: 1px solid #E5E7EB;
}

.prompt-input::placeholder {
    color: #9CA3AF;
}

@keyframes inputGlow {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(0, 141, 148, 0.1);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(0, 141, 148, 0.2);
    }
}

.prompt-input:focus {
    animation: inputGlow 2s ease-in-out infinite;
}

/* ==================== 风格选项动画 ==================== */
.style-option {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.style-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;
}

.style-option:hover::before {
    left: 100%;
}

.style-icon {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.style-option:hover .style-icon {
    transform: scale(1.2) rotate(5deg);
}

.style-option.active .style-icon {
    animation: iconBounce 0.6s ease-out;
}

@keyframes iconBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

/* ==================== 尺寸选项动画 ==================== */
.size-option {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.size-option::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background: #008d94;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.size-option.active::after {
    opacity: 1;
    transform: scale(1);
}

/* ==================== 滑块增强 ==================== */
.slider {
    transition: all 0.3s;
}

.slider:hover {
    background: #d0d0d0;
}

/* ==================== 按钮波纹效果 ==================== */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active {
    transform: scale(0.98);
}

/* ==================== 预览区域增强 ==================== */
.preview-area {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.preview-placeholder {
    animation: fadeIn 0.6s ease-out;
}

@keyframes placeholderPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.preview-placeholder-icon {
    animation: placeholderPulse 2s ease-in-out infinite;
}

/* ==================== 加载动画 ==================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading-spinner {
    animation: spin 1s linear infinite;
}

/* ==================== 结果操作按钮动画 ==================== */
.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; }

/* ==================== 成本信息动画 ==================== */
.cost-info {
    animation: fadeInUp 0.6s ease-out 0.6s both;
    transition: all 0.3s;
}

@keyframes costPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.cost-value {
    display: inline-block;
    transition: all 0.3s;
}

.cost-value.updating {
    animation: costPulse 0.5s ease-out;
}

/* ==================== 返回顶部按钮 ==================== */
.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;
}

/* ==================== 提示词建议 ==================== */
.prompt-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    animation: fadeInUp 0.6s ease-out 0.3s both;
}

.prompt-tag {
    background: rgba(0, 141, 148, 0.1);
    border: 1px solid rgba(0, 141, 148, 0.3);
    color: #008d94;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.prompt-tag:hover {
    background: rgba(0, 141, 148, 0.2);
    border-color: #008d94;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 141, 148, 0.2);
}

.prompt-tag:active {
    transform: scale(0.95);
}

/* ==================== 生成历史缩略图 ==================== */
.history-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 15px;
    animation: fadeInUp 0.6s ease-out;
}

.history-thumb {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
}

.history-thumb:hover {
    transform: scale(1.1);
    border-color: #008d94;
    box-shadow: 0 4px 12px rgba(0, 141, 148, 0.3);
    z-index: 10;
}

.history-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==================== 骨架屏 ==================== */
@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: #1F2937;
    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);
}

/* ==================== 进度条增强 ==================== */
.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%);
    }
}

/* ==================== 生成按钮加载状态 ==================== */
.btn-primary.loading {
    pointer-events: none;
}

.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;
}

/* ==================== 参数组悬停效果 ==================== */
.param-group {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.param-group:hover {
    transform: translateX(5px);
}

/* ==================== 章节标题增强 ==================== */
.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;
    }
}
