/* AI生图弹窗样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: transparent;
}

/* 遮罩层 */
.ai-generate-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

/* 弹窗主体 */
.ai-generate-modal {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 1100px;
    max-height: 85vh;
    overflow: visible;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    margin: 20px;
}

/* 关闭按钮 */
.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.2s;
    z-index: 100;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #374151;
    transform: scale(1.1);
}

/* 预览区域容器 */
.ai-generate-preview-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 24px;
    padding-top: 50px;
    flex: 1;
    min-height: 0;
    overflow: auto;
}

/* 预览框通用样式 */
.ai-generate-preview-box {
    border-radius: 16px;
    overflow: hidden; /* 保持 hidden 以维持圆角效果 */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    max-height: 450px;
    padding: 4px; /* 添加小量 padding，确保内部按钮不被裁剪 */
    box-sizing: border-box; /* 确保 padding 不影响尺寸计算 */
}

/* 左侧参考图区域 */
.ai-generate-reference-box {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0ff 100%);
    border: 2px dashed #667eea;
}

/* 右侧预览区域 */
.ai-generate-spritesheet-box {
    background: 
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
}

/* 预览图 */
.ai-generate-preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: none;
}

.ai-generate-preview-box img.show {
    display: block;
}

/* 上传区域 */
.reference-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 40px;
    width: 100%;
    height: 100%;
    transition: all 0.3s;
}

.reference-upload-area:hover {
    background: rgba(102, 126, 234, 0.1);
}

.reference-upload-area.hide {
    display: none;
}

.upload-icon {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 12px;
    font-weight: 300;
}

.upload-text {
    color: #667eea;
    font-size: 14px;
    font-weight: 500;
}

/* 参考图容器 */
.reference-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reference-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block !important; /* 覆盖 .ai-generate-preview-box img 的 display: none */
}

/* 删除参考图按钮 */
.reference-remove-btn {
    position: absolute;
    top: 8px; /* 距离顶部足够远，不会被裁剪 */
    right: 8px; /* 距离右边足够远，不会被裁剪 */
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
    z-index: 10; /* 确保按钮在最上层 */
}

.reference-remove-btn:hover {
    background: #ef4444;
    transform: scale(1.1);
}

/* 加载状态 */
.preview-placeholder {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #9ca3af;
}

.preview-placeholder.hide {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 14px;
    color: #6b7280;
}

/* AI生图队列区域 */
.ai-queue-section {
    padding: 0 20px 16px;
}

.ai-queue-title {
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-queue-title::before {
    content: '';
    width: 3px;
    height: 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 2px;
}

.ai-queue-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.ai-queue-list::-webkit-scrollbar {
    height: 6px;
}

.ai-queue-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ai-queue-list::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 3px;
}

.ai-queue-item {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: #f8fafc;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.3s;
}

.ai-queue-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.ai-queue-item.rendering {
    border-color: #667eea;
}

.ai-queue-item.completed {
    border-color: #10b981;
}

.ai-queue-item.failed {
    border-color: #ef4444;
}

.ai-queue-item-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(4px) brightness(0.8);
}

.ai-queue-item.completed .ai-queue-item-preview {
    filter: none;
}

.ai-queue-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
}

.ai-queue-item.completed .ai-queue-item-overlay {
    background: transparent;
    opacity: 0;
    transition: opacity 0.2s;
}

.ai-queue-item.completed:hover .ai-queue-item-overlay {
    opacity: 1;
    background: rgba(0, 0, 0, 0.5);
}

.ai-queue-item-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.ai-queue-item-status {
    font-size: 10px;
    color: white;
    margin-top: 6px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.ai-queue-item-icon {
    font-size: 20px;
}

.ai-queue-item-actions {
    display: flex;
    gap: 4px;
}

.ai-queue-item-action {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: white;
    color: #667eea;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-queue-item-action:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

/* 提示词配置区域 */
.prompt-config-section {
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.config-row {
    display: flex;
    gap: 12px;
}

.config-textarea {
    flex: 1;
    min-height: 80px;
    padding: 14px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.2s;
    font-family: inherit;
}

.config-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.config-textarea::placeholder {
    color: #9ca3af;
}

/* 操作按钮区域 */
.prompt-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.generate-action-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.generate-action-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.generate-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 飞走动画 */
.ai-task-fly-animation {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 图片预览弹窗 */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-preview-modal.show {
    opacity: 1;
}

.image-preview-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.image-preview-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.image-preview-modal.show .image-preview-modal-content {
    transform: scale(1);
}

.image-preview-modal-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-preview-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.image-preview-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.image-preview-modal-download {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.image-preview-modal-download:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ai-generate-preview-container {
        grid-template-columns: 1fr;
    }
    
    .ai-generate-preview-box {
        min-height: 200px;
    }
}

