/* ============================================
   Media Factory - 结果查看器样式
   优雅展示图片、视频、音频结果
   ============================================ */

/* ==================== 灯箱组件 ==================== */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(20px);
}

.lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

/* 关闭按钮 */
.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* 导航按钮 */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

@media (max-width: 768px) {
    .lightbox-nav {
        width: 44px;
        height: 44px;
    }
    
    .lightbox-prev { left: 0.5rem; }
    .lightbox-next { right: 0.5rem; }
}

/* 主内容区 */
.lightbox-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 4rem;
    overflow: hidden;
}

@media (max-width: 768px) {
    .lightbox-content {
        padding: 1.5rem;
    }
}

.lightbox-media-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 加载动画 */
.lightbox-loading {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: rgba(255, 255, 255, 0.7);
}

.lightbox-loading.hidden {
    display: none;
}

.loading-ring {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* 图片 */
.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: lightbox-fade-in 0.3s ease;
}

.lightbox-image.hidden {
    display: none;
}

/* 视频 */
.lightbox-video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: lightbox-fade-in 0.3s ease;
}

.lightbox-video.hidden {
    display: none;
}

/* 音频容器 */
.lightbox-audio-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 3rem;
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.1), rgba(167, 139, 250, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    min-width: 400px;
    max-width: 500px;
    animation: lightbox-fade-in 0.3s ease;
}

.lightbox-audio-container.hidden {
    display: none;
}

.audio-visualizer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.audio-icon {
    color: var(--accent-primary);
    animation: pulse-glow 2s ease-in-out infinite;
}

.audio-waves {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 40px;
}

.audio-waves span {
    width: 4px;
    height: 100%;
    background: linear-gradient(to top, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
    animation: audio-wave 1s ease-in-out infinite;
}

.audio-waves span:nth-child(1) { animation-delay: 0s; height: 40%; }
.audio-waves span:nth-child(2) { animation-delay: 0.1s; height: 60%; }
.audio-waves span:nth-child(3) { animation-delay: 0.2s; height: 100%; }
.audio-waves span:nth-child(4) { animation-delay: 0.3s; height: 70%; }
.audio-waves span:nth-child(5) { animation-delay: 0.4s; height: 50%; }
.audio-waves span:nth-child(6) { animation-delay: 0.5s; height: 80%; }
.audio-waves span:nth-child(7) { animation-delay: 0.6s; height: 60%; }
.audio-waves span:nth-child(8) { animation-delay: 0.7s; height: 90%; }
.audio-waves span:nth-child(9) { animation-delay: 0.8s; height: 50%; }
.audio-waves span:nth-child(10) { animation-delay: 0.9s; height: 30%; }

@keyframes audio-wave {
    0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
    50% { transform: scaleY(1); opacity: 1; }
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(34, 211, 238, 0.3)); }
    50% { filter: drop-shadow(0 0 20px rgba(34, 211, 238, 0.6)); }
}

.lightbox-audio {
    width: 100%;
    height: 48px;
    accent-color: var(--accent-primary);
}

.audio-info {
    text-align: center;
}

.audio-title {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    font-weight: 500;
}

/* 底部工具栏 */
.lightbox-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-lg);
    margin: 0 auto;
    max-width: 600px;
    width: 100%;
}

.lightbox-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lightbox-counter {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    font-size: 0.9rem;
}

.lightbox-type {
    padding: 0.25rem 0.75rem;
    background: rgba(34, 211, 238, 0.2);
    border-radius: var(--radius-full);
    color: var(--accent-primary);
    font-size: 0.75rem;
    font-weight: 500;
}

.lightbox-actions {
    display: flex;
    gap: 0.5rem;
}

.lightbox-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: white;
    text-decoration: none;
    transition: all 0.2s ease;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

@keyframes lightbox-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==================== 结果卡片 ==================== */
.result-card-new {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-card-new:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(34, 211, 238, 0.15);
}

.result-card-new.animate-in {
    animation: card-appear 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes card-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 卡片尺寸 */
.result-card-new.small .card-media { height: 120px; }
.result-card-new.medium .card-media { height: 180px; }
.result-card-new.large .card-media { height: 280px; }

/* 卡片媒体区 */
.card-media {
    position: relative;
    height: 200px;
    background: var(--bg-base);
    overflow: hidden;
}

.card-media img,
.card-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.result-card-new:hover .card-media img,
.result-card-new:hover .card-media video {
    transform: scale(1.05);
}

/* 卡片遮罩 */
.card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.result-card-new:hover .card-overlay {
    opacity: 1;
}

.card-play-hint {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.result-card-new:hover .card-play-hint {
    transform: scale(1);
}

.video-hint {
    background: rgba(34, 211, 238, 0.3);
    border-color: rgba(34, 211, 238, 0.5);
}

/* 类型标签 */
.card-type-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border-radius: var(--radius-full);
    color: white;
    font-size: 0.7rem;
    font-weight: 500;
}

.video-badge {
    background: rgba(34, 211, 238, 0.8);
}

.audio-badge {
    background: rgba(167, 139, 250, 0.8);
}

/* 音频卡片 */
.audio-media {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.15), rgba(244, 114, 182, 0.15));
}

.audio-card-visual {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
}

.audio-card-icon {
    color: var(--accent-secondary);
    opacity: 0.8;
    transition: all 0.3s ease;
}

.result-card-new:hover .audio-card-icon {
    opacity: 1;
    transform: scale(1.1);
}

.audio-card-waves {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
}

.audio-card-waves span {
    width: 3px;
    background: var(--accent-secondary);
    border-radius: 2px;
    animation: audio-wave 1s ease-in-out infinite;
    opacity: 0.6;
}

.audio-card-waves span:nth-child(1) { height: 30%; animation-delay: 0s; }
.audio-card-waves span:nth-child(2) { height: 60%; animation-delay: 0.1s; }
.audio-card-waves span:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.audio-card-waves span:nth-child(4) { height: 50%; animation-delay: 0.3s; }
.audio-card-waves span:nth-child(5) { height: 80%; animation-delay: 0.4s; }

.audio-card-title {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* 卡片操作按钮 */
.card-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.result-card-new:hover .card-actions {
    opacity: 1;
    transform: translateY(0);
}

.card-action {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: white;
    text-decoration: none;
    transition: all 0.2s ease;
}

.card-action:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

/* ==================== 任务卡片增强 ==================== */
.task-card-enhanced {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1rem;
    transition: all 0.3s ease;
}

.task-card-enhanced:hover {
    border-color: var(--border-strong);
}

.task-card-enhanced.completed-animation {
    animation: task-complete 0.5s ease;
}

@keyframes task-complete {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); border-color: var(--success); }
    100% { transform: scale(1); }
}

.task-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.task-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.task-card-icon.pending {
    background: rgba(167, 139, 250, 0.15);
    color: var(--accent-secondary);
}

.task-card-icon.processing {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

.task-card-icon.completed {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
}

.task-card-icon.failed {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
}

.task-card-info {
    flex: 1;
    min-width: 0;
}

.task-card-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-card-model {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.task-card-status {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
    min-width: max-content;
}

.task-card-status.pending {
    background: rgba(167, 139, 250, 0.15);
    color: var(--accent-secondary);
}

.task-card-status.processing {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

.task-card-status.completed {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
}

.task-card-status.failed {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
}

/* 任务进度条 */
.task-card-progress {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.task-card-progress.hidden {
    display: none;
}

.task-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    overflow: hidden;
}

.task-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

.task-progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* 任务结果预览 */
.task-card-result {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.task-card-result.hidden {
    display: none;
}

.task-result-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.task-result-item {
    aspect-ratio: 1;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.task-result-item:hover {
    transform: scale(1.05);
}

.task-result-item img,
.task-result-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.task-result-item.video-item .result-type-icon,
.task-result-item.audio-item .audio-mini-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    color: white;
}

.task-result-item.audio-item {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.2), rgba(244, 114, 182, 0.2));
}

.task-result-item.audio-item .audio-mini-icon {
    background: transparent;
    color: var(--accent-secondary);
}

.task-result-more {
    aspect-ratio: 1;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.task-error {
    padding: 0.75rem;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.85rem;
}

/* ==================== 结果网格增强 ==================== */
.result-grid-enhanced {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

@media (max-width: 640px) {
    .result-grid-enhanced {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

/* ==================== 历史详情模态框 ==================== */
.history-detail-modal {
    max-width: 800px;
    width: 95vw;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.history-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.history-detail-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.history-detail-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.history-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

.history-detail-results {
    margin-bottom: 1.5rem;
}

.history-detail-results h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.history-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.history-result-item {
    aspect-ratio: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-result-item:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.history-result-item img,
.history-result-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-result-audio {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.15), rgba(244, 114, 182, 0.15));
    color: var(--accent-secondary);
}

.history-detail-params {
    margin-bottom: 1.5rem;
}

.history-detail-params h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.param-item {
    padding: 0.75rem;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
}

.param-key {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.param-value {
    font-size: 0.85rem;
    color: var(--text-primary);
    word-break: break-word;
}

/* ==================== 响应式调整 ==================== */
@media (max-width: 768px) {
    .lightbox-audio-container {
        min-width: 300px;
        padding: 2rem 1.5rem;
    }
    
    .lightbox-toolbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .task-result-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ==================== 动画工具类 ==================== */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

@keyframes progress-indeterminate {
    0% {
        width: 0%;
        margin-left: 0;
    }
    50% {
        width: 50%;
        margin-left: 25%;
    }
    100% {
        width: 0%;
        margin-left: 100%;
    }
}

/* 隐藏类 */
.hidden {
    display: none !important;
}
