﻿/* ========== 浮动层弹窗样式 ========== */
.ai-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: aiFadeIn 0.25s ease;
}
@keyframes aiFadeIn { from { opacity: 0; } to { opacity: 1; } }

.ai-popup {
    background: #fff;
    border-radius: 16px;
    width: 92vw;
    max-width: 1100px;
    height: 650px;
    max-height: 90vh;
    overflow-y: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.25);
    animation: aiSlideUp 0.3s ease;
}
@keyframes aiSlideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.ai-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px 16px;
    border-bottom: 1px solid #f0f0f0;
}
.ai-popup-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
}
.ai-popup-close {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: #f5f5f5;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s;
    flex-shrink: 0;
}
.ai-popup-close:hover { background: #e8e8e8; color: #333; }

.ai-popup-body {
    display: flex;
    gap: 24px;
    height:580px;
    padding: 20px 28px 28px;
}

/* 左侧预览区 */
.ai-preview {
    flex: 0 0 40%;
    display: flex;
    gap: 0px;
    align-items: flex-start;
}
.ai-preview .ai-preview-half {
    flex: 1;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 198 / 223;
    max-width: 198px;
}
.ai-preview .ai-preview-half:first-child {
    border-radius: 10px 0 0 10px;
}
.ai-preview .ai-preview-half:last-child {
    border-radius: 0 10px 10px 0;
}
.ai-preview .ai-preview-half img,
.ai-preview .ai-preview-half video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.ai-preview.single .ai-preview-half {
    max-width: 332px;
    aspect-ratio: 332 / 187;
}

/* 右侧操作区 */
.ai-ops {
    flex: 0 0 60%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    min-width: 0;
}

.ai-ops-textarea {
    width: 600px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
    color: #333;
    background: #fafafa;
    transition: border-color 0.2s;
    box-sizing: border-box;
    height: 187px;
    min-height: 120px;
}
.ai-ops-textarea:focus {
    outline: none;
    border-color: #7c5cfc;
    background: #fff;
}

.ai-upload-row {
    display: flex;
    gap: 16px;
    margin-top: 40px;
}

.ai-upload-box {
    width: 145px;
    height: 145px;
    flex-shrink: 0;
    border: 2px dashed #d0d0d0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
    position: relative;
    overflow: hidden;
    text-align: center;
    padding: 12px;
    box-sizing: border-box;
}
.ai-upload-box:hover { border-color: #7c5cfc; background: #f8f6ff; }
.ai-upload-box.has-image { border-style: solid; border-color: #d0d0d0; }
.ai-upload-box img.preview-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    border-radius: 12px;
}
.ai-upload-box .upload-plus {
    font-size: 36px;
    color: #bbb;
    line-height: 1;
    margin-bottom: 8px;
    transition: color 0.2s;
}
.ai-upload-box:hover .upload-plus { color: #7c5cfc; }
.ai-upload-box .upload-label {
    font-size: 12px;
    color: #999;
    line-height: 1.5;
    pointer-events: none;
}

.ai-upload-box .ai-upload-clear {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    z-index: 3;
    padding: 0;
}

.ai-btn-generate {
    width: 600px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #7c5cfc, #5b3cfc);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    letter-spacing: 0.02em;
    position: absolute;
    left: 0;
    bottom: 0;
}
.ai-btn-generate:hover { background: linear-gradient(135deg, #6a4aee, #4a2aee); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,92,252,0.35); }
.ai-btn-generate:active { transform: scale(0.98); }

/* Loading遮罩 */
.ai-loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.85);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.ai-loading-text {
    font-size: 15px;
    color: #555;
    margin-bottom: 16px;
    font-weight: 500;
}
.ai-progress-bar {
    width: 80%;
    max-width: 320px;
    height: 8px;
    background: #e8e8e8;
    border-radius: 4px;
    overflow: hidden;
}
.ai-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #7c5cfc, #5b3cfc);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

/* 生成结果区 */
.ai-result-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.ai-result-area img {
    max-width: 470px;
    max-height: 470px;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.ai-btn-download {
    padding: 12px 32px;
    background: #fff;
    color: #7c5cfc;
    border: 2px solid #7c5cfc;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.ai-btn-download:hover { background: #f8f6ff; }

/* 结果操作按钮行 */
.ai-result-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 响应式 */
@media (max-width: 768px) {
    .ai-popup {
        width: 96vw;
        max-height: 95vh;
        height: auto;
        overflow-y: auto;
    }
    .ai-popup-header { padding: 16px 18px 12px; }
    .ai-popup-body {
        flex-direction: column;
        height: auto;
        padding: 14px 18px 18px;
        gap: 14px;
    }
    .ai-preview {
        flex: 1 1 auto;
        flex-wrap: wrap;
    }
    .ai-preview .ai-preview-half {
        max-width: 50%;
        flex: 1 1 50%;
    }
    .ai-preview.single .ai-preview-half {
        max-width: 100%;
    }
    .ai-ops {
        flex: 1 1 auto;
        gap: 12px;
    }
    .ai-ops-textarea {
        width: 100%;
        height: 120px;
        min-height: 100px;
    }
    .ai-upload-row {
        margin-top: 8px;
        gap: 12px;
    }
    .ai-upload-box {
        width: 48%;
        height: 130px;
        flex-shrink: 1;
        min-width: 0;
    }
    .ai-btn-generate {
        width: 100%;
        position: relative;
        left: auto;
        bottom: auto;
        margin-top: 8px;
    }
    .ai-popup-title { font-size: 18px; }
}