/* AI 生图功能样式 - 参考 image-crop.css 深色风格 */

/* 生图按钮样式 - 在上传按钮分割状态中 */
.add-image-btn__generate {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.add-image-btn__generate:hover {
    background-color: rgba(0, 123, 255, 0.08);
    color: #007bff;
}

.add-image-btn__generate svg {
    stroke: currentColor;
    transition: transform 0.2s ease;
}

.add-image-btn__generate:hover svg {
    transform: scale(1.1);
}

.add-image-btn__generate span {
    font-size: 12px;
    font-weight: 500;
}

/* 弹窗遮罩 - 参考 crop-modal */
.jimeng-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.jimeng-modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 弹窗容器 - 浅色模式 */
.jimeng-container {
    position: relative;
    background-color: #ffffff;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    min-height: 600px; /* 改为最小高度，允许自适应 */
    max-height: 90vh; /* 限制最大高度，避免超出屏幕 */
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 标题栏 - 浅色模式 */
.jimeng-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e5;
    background-color: #f8f9fa;
}

.jimeng-title-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jimeng-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.jimeng-badge {
    background-color: #ff8c00;
    color: white;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
}
}

/* 标题栏右侧操作区 */
.jimeng-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px; /* 保证最小高度，避免按钮显示时挤压布局 */
}

/* 标题栏按钮组 */
.jimeng-header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px; /* 预留固定宽度，避免布局变化 */
    min-height: 32px; /* 预留固定高度，确保布局稳定 */
    justify-content: flex-end; /* 按钮靠右对齐 */
}

.jimeng-header-buttons.hidden {
    visibility: hidden; /* 使用visibility而不是display，保持占位空间 */
}

/* 标题栏按钮 - 浅色模式 */
.jimeng-header-btn {
    padding: 6px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: #ffffff;
    color: #666;
}

.jimeng-header-btn:hover {
    background-color: #f8f9fa;
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
}

.jimeng-header-btn--primary {
    background-color: #007bff;
    border-color: #007bff;
    color: white;
}

.jimeng-header-btn--primary:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

.jimeng-header-btn svg {
    stroke: currentColor;
}

/* 关闭按钮 - 浅色模式 */
.jimeng-close-btn {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #666;
}

.jimeng-close-btn:hover {
    background-color: #f5f5f5;
    color: #333;
}

.jimeng-close-btn svg {
    stroke: currentColor;
}

/* 内容区域 - 左右布局 */
.jimeng-content {
    display: flex;
    height: 520px; /* 固定内容区域高度，不受标题栏影响 */
    overflow: hidden;
}

/* 左侧控制面板 - 浅色模式 */
.jimeng-controls {
    width: 280px;
    padding: 24px 24px 30px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background-color: #fafafa;
    border-left: 1px solid #e5e5e5;
}

/* 输入组 */
.jimeng-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.jimeng-prompt-input {
    width: 100%;
    height: 240px !important;
    max-height: 240px !important;
    min-height: 240px !important;
    padding: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    resize: none !important;
    font-family: inherit;
    overflow-y: auto;
    transition: all 0.2s ease;
    background-color: #ffffff;
    color: #333;
    box-sizing: border-box;
}

.jimeng-prompt-input::placeholder {
    color: #999;
}

.jimeng-prompt-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* 尺寸选择组 - 浅色模式 */
.jimeng-size-group {
    padding-top: 12px;
    padding-bottom: 8px;
    border-top: 1px solid #e0e0e0;
}

.jimeng-size-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.jimeng-size-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.jimeng-size-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.jimeng-size-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 2px solid #e0e0e0;
    background-color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.jimeng-size-btn:hover {
    border-color: #007bff;
    background-color: #f8f9fa;
    transform: translateY(-1px);
}

.jimeng-size-btn--active {
    background-color: #007bff !important;
    border-color: #007bff !important;
}

.jimeng-size-btn--active:hover {
    background-color: #0056b3 !important;
    border-color: #0056b3 !important;
}

.jimeng-size-btn--active svg {
    fill: white !important;
}

.jimeng-size-btn svg {
    fill: #666;
    transition: fill 0.2s ease;
}

.jimeng-size-label {
    font-size: 10px;
    color: #666;
    font-weight: 500;
    text-align: center;
    user-select: none;
    line-height: 1;
    transition: color 0.2s ease;
}

.jimeng-size-btn--active + .jimeng-size-label {
    color: #007bff;
    font-weight: 600;
}

/* 生成按钮 - 参考 crop-btn */
.jimeng-btn-generate {
    width: 100%;
    padding: 12px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.jimeng-btn-generate:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.jimeng-btn-generate:disabled {
    background-color: #ccc;
    color: #666;
    cursor: not-allowed;
    transform: none;
}

/* 右侧预览区 - 浅色模式 */
.jimeng-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: #ffffff;
}

/* 预览区域 */
.jimeng-preview-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: auto;
}

/* 占位符 - 浅色模式 */
.jimeng-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    text-align: center;
}

.jimeng-preview-placeholder svg {
    stroke: #ddd;
    margin-bottom: 16px;
}

.jimeng-preview-placeholder p {
    font-size: 14px;
    margin: 0;
    color: #999;
}

/* 生成的图片容器 */
.jimeng-preview-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: block;
    margin: auto;
}


/* 加载状态 - 浅色模式 */
.jimeng-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

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

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

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

.jimeng-loading p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .jimeng-container {
        width: 95%;
        min-height: 85vh; /* 改为最小高度 */
        max-height: 95vh; /* 限制最大高度 */
        border-radius: 8px;
    }
    
    .jimeng-content {
        flex-direction: column;
        height: auto; /* 移动端允许自适应高度 */
        min-height: 400px; /* 设置最小高度 */
    }
    
    .jimeng-controls {
        width: 100%;
        padding: 20px 20px 24px 20px;
        border-left: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .jimeng-prompt-input {
        height: 180px !important;
        max-height: 180px !important;
        min-height: 180px !important;
    }
    
    .jimeng-preview {
        height: 300px;
    }
    
    .jimeng-header-buttons {
        flex-direction: column;
        gap: 4px;
        min-height: 60px; /* 固定最小高度，防止布局变化 */
    }
    
    .jimeng-header-btn {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .jimeng-size-btn {
        width: 36px;
        height: 36px;
    }
    
    .jimeng-size-options {
        gap: 6px;
    }
    
    .jimeng-size-row {
        gap: 10px;
    }
    
    .jimeng-size-item {
        gap: 3px;
    }
    
    .jimeng-size-label {
        font-size: 9px;
    }
    
    /* 移动端清空按钮调整 */
    .jimeng-clear-text-btn {
        width: 24px; /* 移动端稍微小一点 */
        height: 24px;
        bottom: 14px; /* 移动端也增加呼吸感 */
        right: 14px; /* 移动端增加右侧间距 */
    }
    
    .jimeng-clear-text-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .jimeng-optimize-btn {
        width: 24px;
        height: 24px;
        bottom: 14px; /* 与清空按钮保持相同的底部距离，增加呼吸感 */
        right: 44px; /* 在清空按钮左边，调整移动端间距 */
    }
    
    .jimeng-optimize-btn svg {
        width: 14px;
        height: 14px;
    }
    
    /* 移动端标签调整 */
    .jimeng-title-wrapper {
        gap: 8px;
    }
    
    .jimeng-badge {
        font-size: 10px;
        padding: 3px 6px;
    }
}

/* 深色模式支持 */
body.dark-mode .jimeng-container {
    background-color: #0f0f0f; /* 更深的黑色 */
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

body.dark-mode .jimeng-header {
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .jimeng-title {
    color: white;
}

body.dark-mode .jimeng-badge {
    background-color: #ff8c00;
    color: white;
}

body.dark-mode .jimeng-header-btn {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

body.dark-mode .jimeng-header-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: #007bff;
    color: white;
}

body.dark-mode .jimeng-close-btn {
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .jimeng-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

body.dark-mode .jimeng-controls {
    background-color: rgba(255, 255, 255, 0.03);
    border-left-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .jimeng-prompt-input {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

body.dark-mode .jimeng-prompt-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .jimeng-prompt-input:focus {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

body.dark-mode .jimeng-size-group {
    border-top-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .jimeng-size-btn {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .jimeng-size-btn:hover {
    background-color: rgba(0, 123, 255, 0.1);
    border-color: #007bff;
}

body.dark-mode .jimeng-size-btn--active {
    background-color: #007bff !important;
    border-color: #007bff !important;
}

body.dark-mode .jimeng-size-btn--active:hover {
    background-color: #0056b3 !important;
    border-color: #0056b3 !important;
}

body.dark-mode .jimeng-size-btn--active svg {
    fill: white !important;
}

body.dark-mode .jimeng-size-btn svg {
    fill: rgba(255, 255, 255, 0.7);
}

body.dark-mode .jimeng-size-label {
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .jimeng-size-btn--active + .jimeng-size-label {
    color: #007bff;
}

body.dark-mode .jimeng-btn-generate:disabled {
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .jimeng-preview {
    background-color: #0f0f0f; /* 更深的黑色 */
}

body.dark-mode .jimeng-preview-placeholder {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .jimeng-preview-placeholder svg {
    stroke: rgba(255, 255, 255, 0.3);
}

body.dark-mode .jimeng-preview-placeholder p {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .jimeng-loading {
    background-color: rgba(26, 26, 26, 0.95);
}

body.dark-mode .jimeng-spinner {
    border-color: rgba(255, 255, 255, 0.2);
    border-top-color: #007bff;
}

body.dark-mode .jimeng-loading p {
    color: rgba(255, 255, 255, 0.7);
}

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

/* 快捷提示 - 参考 crop-tips */
.jimeng-tips {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    text-align: center;
    margin-top: 8px;
}

/* 新增：参考图弹窗输入框容器样式 */
.jimeng-input-wrapper {
    position: relative; /* 作为清空按钮绝对定位的基准 */
    flex: 1; /* 占据剩余空间 */
}

/* 参考图弹窗清空按钮样式 - 与主页输入框清空按钮保持一致 */
.jimeng-clear-text-btn {
    position: absolute; /* 绝对定位 */
    bottom: 18px; /* 增加底部距离，提供更好的视觉呼吸感 */
    right: 18px; /* 增加右侧距离，与文本框保持更好的间距 */
    padding: 5px; /* 按钮内边距 - 与主页清空按钮保持一致 */
    background-color: rgba(0, 0, 0, 0.1); /* 浅灰色背景 */
    border: 1px solid rgba(0, 0, 0, 0.1); /* 添加边框与主页清空按钮一致 */
    border-radius: 5px; /* 方形圆角 - 与主页清空按钮一致 */
    cursor: pointer;
    line-height: 0; /* 防止 SVG 底部有空隙 */
    opacity: 0.7; /* 默认轻微透明 */
    transition: opacity 0.2s ease, background-color 0.2s ease; /* 平滑过渡 */
    width: 26px; /* 固定宽度 - 与主页清空按钮一致 */
    height: 26px; /* 固定高度 - 与主页清空按钮一致 */
    display: flex; /* 使用flex布局 */
    align-items: center; /* 垂直居中 */
    justify-content: center; /* 水平居中 */
    z-index: 10; /* 确保按钮在输入框之上 */
}

.jimeng-clear-text-btn svg {
    display: block; /* 确保 SVG 是块级元素 */
    color: #666; /* 图标颜色 */
}

.jimeng-clear-text-btn:hover {
    opacity: 1; /* 悬停时不透明 */
    background-color: rgba(0, 0, 0, 0.15); /* 悬停时背景稍深 */
}

/* 通过 JS 控制显示/隐藏 */
.jimeng-clear-text-btn.hidden {
    display: none;
}

/* 提示词优化按钮样式 */
.jimeng-optimize-btn {
    position: absolute;
    bottom: 18px; /* 与清空按钮保持相同的底部距离，增加呼吸感 */
    right: 56px; /* 在清空按钮左边，增加间距提供更好的视觉层次 */
    padding: 5px;
    background-color: rgba(33, 150, 243, 0.1); /* 蓝色背景 */
    border: 1px solid rgba(33, 150, 243, 0.2);
    border-radius: 5px;
    cursor: pointer;
    line-height: 0;
    opacity: 0.8;
    transition: all 0.2s ease;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jimeng-optimize-btn svg {
    display: block;
    color: #2196f3; /* 蓝色图标 */
}

.jimeng-optimize-btn:hover {
    opacity: 1;
    background-color: rgba(33, 150, 243, 0.15);
    transform: translateY(-1px);
}

.jimeng-optimize-btn.hidden {
    display: none;
}

.jimeng-optimize-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* 深色模式下的清空按钮样式 */
body.dark-mode .jimeng-clear-text-btn {
    background-color: rgba(255, 255, 255, 0.1); /* 深色模式下的背景 */
    border: 1px solid rgba(255, 255, 255, 0.1); /* 深色模式下的边框 */
}

body.dark-mode .jimeng-clear-text-btn svg {
    color: #ccc; /* 深色模式下的图标颜色 */
}

body.dark-mode .jimeng-clear-text-btn:hover {
    background-color: rgba(255, 255, 255, 0.15); /* 深色模式下悬停时的背景 */
}

/* 深色模式下的优化按钮样式 */
body.dark-mode .jimeng-optimize-btn {
    background-color: rgba(33, 150, 243, 0.15);
    border: 1px solid rgba(33, 150, 243, 0.3);
}

body.dark-mode .jimeng-optimize-btn svg {
    color: #64b5f6;
}

body.dark-mode .jimeng-optimize-btn:hover {
    background-color: rgba(33, 150, 243, 0.2);
}

/* 优化按钮加载状态 */
.jimeng-optimize-btn.loading {
    cursor: wait;
    opacity: 0.8;
}

.jimeng-optimize-btn.loading svg {
    display: none;
}

.jimeng-optimize-btn .loading-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(33, 150, 243, 0.3);
    border-top: 2px solid #2196f3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.jimeng-optimize-btn.loading .loading-spinner {
    display: block;
}

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

/* 移动端加载状态调整 */
@media (max-width: 768px) {
    .jimeng-optimize-btn .loading-spinner {
        width: 14px;
        height: 14px;
        border-width: 1.5px;
    }
}