/* 页面头部 */
.header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1001;
}

.header h1 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

.history-toggle-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.history-toggle-btn:hover {
    background: #0056b3;
}

/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 主要内容区域 */
.main-content {
    display: flex;
    gap: 30px;
    margin-bottom: 30px;
}

/* 左侧生成器面板 */
.generator-panel {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border: 2px solid #e74c3c;
}

.generator-panel h2 {
    font-size: 24px;
    margin-bottom: 24px;
    color: #333;
}

/* 图片上传区域 */
.upload-section {
    margin-bottom: 1.5rem;
}

.upload-section label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
    position: relative;
}

.upload-area:hover {
    border-color: #007bff;
    background: #f0f8ff;
}

.upload-area.dragover {
    border-color: #007bff;
    background: #e3f2fd;
    transform: scale(1.02);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.upload-icon {
    font-size: 2rem;
    color: #666;
}

.upload-placeholder p {
    margin: 0;
    color: #666;
}

.upload-hint {
    font-size: 0.9rem;
    color: #999;
}

.image-preview {
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-image:hover {
    background: #cc0000;
}

.image-preview {
    position: relative;
    max-width: 100%;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    object-fit: contain;
}

.remove-image {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

/* 参数选择区域 */
.params-section {
    margin-bottom: 24px;
}

.param-group {
    margin-bottom: 20px;
}

.param-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.button-group {
    display: flex;
    gap: 8px;
}

.param-btn {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 44px;
}

.param-btn:hover {
    border-color: #e74c3c;
}

.param-btn.active {
    background: #2c3e50;
    color: white;
    border-color: #2c3e50;
}

/* 提示词输入区域 */
.prompt-section {
    margin-bottom: 24px;
}

#promptInput {
    width: 100%;
    padding: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

#promptInput:focus {
    outline: none;
    border-color: #e74c3c;
}

/* 生成按钮 */
.generate-btn {
    width: 100%;
    padding: 16px;
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 56px;
}

.generate-btn:hover {
    background: #34495e;
}

.generate-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* 右侧预览面板 */
.preview-panel {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border: 2px solid #f39c12;
}

.preview-panel h2 {
    font-size: 24px;
    margin-bottom: 24px;
    color: #333;
}

/* 视频区域 */
.video-section {
    margin-bottom: 24px;
}

/* 视频容器样式 */
.video-wrapper {
    position: relative;
    width: 100%;
    min-height: 200px;
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    /* 让容器自适应内容高度 */
}

/* 视频加载状态 */
.video-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #666;
    background: #1a1a1a;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.video-loading p {
    margin: 0;
    font-size: 14px;
}

/* 视频错误状态 */
.video-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    padding: 20px;
    text-align: center;
    background: #2a1f1f;
    color: #ff6b6b;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-message {
    font-size: 18px;
    font-weight: bold;
    margin: 0 0 8px 0;
}

.error-details {
    font-size: 14px;
    color: #ff9999;
    margin: 0 0 20px 0;
    word-break: break-word;
}

.retry-btn, .open-link-btn {
    padding: 8px 16px;
    margin: 4px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.retry-btn {
    background: #007bff;
    color: white;
}

.retry-btn:hover:not(:disabled) {
    background: #0056b3;
}

.retry-btn:disabled {
    background: #666;
    cursor: not-allowed;
}

.open-link-btn {
    background: #28a745;
    color: white;
}

.open-link-btn:hover {
    background: #1e7e34;
}

/* 视频播放器 */
#mainVideo {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    background: #000;
    display: block;
}

/* 视频信息 */
.video-info {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.video-info p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: #666;
}

.video-info a {
    color: #007bff;
    text-decoration: none;
}

.video-info a:hover {
    text-decoration: underline;
}

.video-container {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    min-height: 200px;
    width: 100%;
    /* 移除固定的aspect-ratio，让视频自适应 */
}

.generated-video {
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    background: #000;
    display: block;
}

/* 确保视频控制器样式 */
.generated-video::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.8);
}

.generated-video::-webkit-media-controls-play-button,
.generated-video::-webkit-media-controls-volume-slider,
.generated-video::-webkit-media-controls-timeline,
.generated-video::-webkit-media-controls-current-time-display,
.generated-video::-webkit-media-controls-time-remaining-display,
.generated-video::-webkit-media-controls-mute-button,
.generated-video::-webkit-media-controls-fullscreen-button {
    display: block !important;
    opacity: 1 !important;
}

.video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
}

.placeholder-content {
    text-align: center;
    color: #666;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* 进度显示 */
.progress-container {
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #666;
}

/* 错误显示 */
.error-container {
    margin: 1rem 0;
    padding: 1rem;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-radius: 8px;
    color: #c53030;
}

.error-message {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.clear-error-btn {
    background: none;
    border: none;
    color: #c53030;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    min-width: 20px;
}

.clear-error-btn:hover {
    color: #9b2c2c;
}

/* 操作按钮区域 */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* 刷新按钮 */
.refresh-btn {
    flex: 1;
    padding: 12px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
}

.refresh-btn:hover {
    background: #0056b3;
}

.refresh-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* 下载按钮 */
.download-btn {
    flex: 1;
    padding: 12px 16px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
}

.download-btn:hover {
    background: #2ecc71;
}

/* 历史记录面板 */
.history-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: white;
    border-left: 1px solid #e0e0e0;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}

.history-panel::-webkit-scrollbar {
    width: 8px;
}

.history-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.history-panel::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.history-panel::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.history-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1002;
    flex-shrink: 0;
}

.history-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
}

.history-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.refresh-history-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.3s;
    position: relative;
    z-index: 1003;
    flex-shrink: 0;
}

.refresh-history-btn:hover {
    background: #0056b3;
}

.refresh-history-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.history-collapse-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.3s;
    position: relative;
    z-index: 1003;
    flex-shrink: 0;
}

.history-collapse-btn:hover {
    background: #5a6268;
}

.history-container {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 1rem;
    max-height: calc(100vh - 120px) !important; /* 增加!important确保优先级 */
    min-height: 200px; /* 添加最小高度 */
    position: relative;
    /* 确保滚动条可见 */
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.history-container::-webkit-scrollbar {
    width: 8px;
}

.history-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.history-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.history-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.no-history {
    text-align: center;
    color: #999;
    padding: 2rem;
    font-style: italic;
}

.history-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.3s;
}

.history-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.history-header-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-date {
    font-size: 0.8rem;
    color: #666;
}

.history-status {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.history-status.success {
    background: #d4edda;
    color: #155724;
}

.history-status.error {
    background: #f8d7da;
    color: #721c24;
}

.history-status.pending {
    background: #fff3cd;
    color: #856404;
}

.history-prompt {
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    max-height: 3em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    border: 1px solid #007bff;
    background: white;
    color: #007bff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-small:hover {
    background: #007bff;
    color: white;
}

.btn-small.delete-history-btn {
    border-color: #dc3545;
    color: #dc3545;
}

.btn-small.delete-history-btn:hover {
    background: #dc3545;
    color: white;
}

.history-error {
    font-size: 0.8rem;
    color: #c53030;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #fff5f5;
    border-radius: 4px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .main-content {
        flex-direction: column;
        gap: 20px;
    }
    
    .generator-panel,
    .preview-panel {
        padding: 20px;
    }
    
    .generator-panel h2,
    .preview-panel h2 {
        font-size: 20px;
        margin-bottom: 20px;
    }
    
    .upload-area {
        padding: 30px 15px;
        min-height: 150px;
    }
    
    .upload-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }
    
    .param-btn {
        font-size: 16px;
        min-height: 44px;
    }
    
    #promptInput {
        font-size: 16px;
    }
    
    .generate-btn,
    .download-btn {
        font-size: 16px;
        min-height: 50px;
    }
    
    .video-container {
        aspect-ratio: 9/16;
    }
    
    .placeholder-icon {
        font-size: 36px;
        margin-bottom: 12px;
    }
    
    .history-panel {
        padding: 20px;
    }
    
    .history-panel h3 {
        font-size: 18px;
    }
/* 下载通知样式 */
.download-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification-icon {
    font-size: 18px;
    font-weight: bold;
}

.notification-text {
    font-size: 14px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    .generator-panel,
    .preview-panel,
    .history-panel {
        padding: 16px;
    }
    
    .button-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .param-btn {
        width: 100%;
    }
    
    .progress-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}
}
