/**
 * AI生成 - 参考图区域（图生图模式）
 * 独立样式，命名空间 .ai-generate-ref-image-*，不与其他面板通用
 * 字体：Microsoft YaHei，深色主题
 */

/* ---------- 参考图区域容器（仅图生图显示） ---------- */
.ai-generate-ref-image-wrap {
    width: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 18px;
}

.ai-generate-ref-image-wrap--hidden {
    display: none !important;
}

.ai-generate-ref-image-label {
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 12px;
    line-height: 1.4;
    color: #3b82f6;
    margin: 12px 0 2px 0;
    padding: 0;
}

/* ---------- 一行显示：图片槽 + 添加槽，横向滚动（窄屏） ---------- */
.ai-generate-ref-image-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 10px;
    min-height: 100px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0;
    -webkit-overflow-scrolling: touch;
}

/* 滚动条样式（深色） */
.ai-generate-ref-image-row::-webkit-scrollbar {
    height: 6px;
}
.ai-generate-ref-image-row::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
}
.ai-generate-ref-image-row::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
.ai-generate-ref-image-row::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ---------- 单个槽位：统一宽高比 1:1，固定最小尺寸 ---------- */
.ai-generate-ref-image-slot {
    flex: 0 0 auto;
    width: 100px;
    min-width: 100px;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-sizing: border-box;
}

/* 已添加图片槽：纵向排列缩略图 + 体积（高度由内容决定，不再固定 1:1） */
.ai-generate-ref-image-slot--image {
    cursor: default;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    aspect-ratio: auto;
}

/* 缩略图区域（1:1，内含标签与删除按钮）；双击打开通用 ImageViewer 预览 */
.ai-generate-ref-image-slot__preview {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    min-width: 0;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px 8px 0 0;
    cursor: zoom-in;
}

.ai-generate-ref-image-slot__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    vertical-align: middle;
}

.ai-generate-ref-image-slot__label {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 10px;
    line-height: 1.2;
    color: #fff;
    background: linear-gradient(180deg, rgba(0,0,0,0.88) 0%, rgba(0,0,0,0.5) 45%, transparent 100%);
    padding: 4px 6px;
    box-sizing: border-box;
    z-index: 1;
}

/* 图片体积：缩略图下方，深色底、白字粗体（参考截图） */
.ai-generate-ref-image-slot__size {
    flex: 0 0 auto;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 11px;
    font-weight: bold;
    line-height: 1.3;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    padding: 4px 6px;
    text-align: center;
    border-radius: 0 0 8px 8px;
    box-sizing: border-box;
}

.ai-generate-ref-image-slot__remove {
    position: absolute;
    right: 4px;
    top: 4px;
    z-index: 1;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    transition: background 0.2s;
    z-index: 1;
    -webkit-appearance: none;
    appearance: none;
}

.ai-generate-ref-image-slot__remove:hover {
    background: rgba(220, 38, 38, 0.9);
}

.ai-generate-ref-image-slot__remove:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

/* ---------- 添加槽（+ 号）：字体略小、内容居中、与边缘保持间距 ---------- */
.ai-generate-ref-image-slot--add {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 8px;
    box-sizing: border-box;
    transition: background 0.2s, border-color 0.2s;
}

.ai-generate-ref-image-slot--add:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(59, 130, 246, 0.5);
}

/* 拖放悬停高亮（可发现性，使用 outline 避免布局抖动） */
.ai-generate-ref-image-slot--add.ai-generate-ref-image-slot--drag-over {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
    outline: 2px solid #3b82f6;
    outline-offset: -1px;
}

/* 个人文件拉取原图期间：添加槽显示「加载中...」，禁止重复操作 */
.ai-generate-ref-image-slot--add.ai-generate-ref-image-slot--loading {
    pointer-events: none;
    cursor: wait;
}
.ai-generate-ref-image-slot--add.ai-generate-ref-image-slot--loading::after {
    content: '加载中...';
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 8px;
    z-index: 10;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.3;
}

/* 满 6 张时添加槽冻结：不可点击、视觉禁用 */
.ai-generate-ref-image-slot--add.ai-generate-ref-image-slot--disabled {
    pointer-events: none;
    cursor: not-allowed;
    opacity: 0.5;
}

.ai-generate-ref-image-slot--add.ai-generate-ref-image-slot--disabled:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.ai-generate-ref-image-slot--add:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.ai-generate-ref-image-slot__plus {
    font-size: 22px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 300;
}

.ai-generate-ref-image-slot__hint {
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 10px;
    line-height: 1.3;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
}

.ai-generate-ref-image-slot__imports {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: 0;
}

/* 导入入口：无底框无包边，点击文字即可触发（链接式） */
.ai-generate-ref-image-import-btn {
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 10px;
    line-height: 1.3;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: color 0.2s;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}

.ai-generate-ref-image-import-btn:hover {
    color: #3b82f6;
}

.ai-generate-ref-image-import-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

/* 点击添加槽本身不触发两个按钮时，阻止冒泡由 JS 处理；此处仅样式 */
.ai-generate-ref-image-slot--add .ai-generate-ref-image-import-btn {
    pointer-events: auto;
}

.ai-generate-ref-image-slot--add:focus-within .ai-generate-ref-image-slot__plus {
    color: rgba(255, 255, 255, 0.85);
}
