/**
 * 上传拼图通用工具弹窗样式（独立，collage-tool- 前缀，不与其他面板通用）
 * 风格与留言反馈弹窗一致：深色底框、内块浅一层、主按钮紫蓝、圆角
 * 字体：Microsoft YaHei，符合项目字体规范
 */

/* 遮罩：不模糊、不阻挡背后操作，仅作为弹窗定位参考；z-index 高于顶部导航栏(10002)，与图像编辑窗口一致，拖到顶部时可盖住导航与用户信息 */
.collage-tool-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10003;
    pointer-events: none;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 14px;
}

.collage-tool-modal-overlay.collage-tool-modal--show {
    display: block;
}

/* 弹窗主体：可移动、可缩放，尺寸与位置由 JS 设置 */
.collage-tool-modal {
    position: fixed;
    min-width: 800px;
    min-height: 600px;
    background: var(--bg-card, #1e1e1e);
    border-radius: var(--review-radius-lg, 10px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(61, 66, 83, 0.6);
    border: 1px solid var(--border-primary, rgba(61, 66, 83, 0.8));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
}

/* 标题栏：与图像编辑窗口一致，高度 40px、标题 14px，更紧凑 */
.collage-tool-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    padding: 0 14px 0 14px;
    border-bottom: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    flex-shrink: 0;
    cursor: move;
    user-select: none;
}

.collage-tool-modal__title {
    margin: 0;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
    color: var(--text-primary, #fff);
}

.collage-tool-modal__close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
    color: var(--text-secondary, #b0b0b0);
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background 0.2s ease;
}

.collage-tool-modal__close:hover {
    color: var(--text-primary, #fff);
    background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}

.collage-tool-modal__close {
    cursor: pointer;
}

/* 右下角等比例缩放拖拽手柄 */
.collage-tool-modal__resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 1;
}
.collage-tool-modal__resize-handle::after {
    content: "";
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--text-secondary, #b0b0b0);
    border-bottom: 2px solid var(--text-secondary, #b0b0b0);
    border-radius: 0 0 2px 0;
}
.collage-tool-modal__resize-handle:hover::after {
    border-color: var(--text-primary, #fff);
}

.collage-tool-modal__body {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    padding: 20px 24px;
    gap: 16px;
}

/* 左侧：图片列表（拖放区 + 列表） */
.collage-tool-left {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 中间：图片拼合预览区域 */
.collage-tool-center {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* 右侧：设置面板 */
.collage-tool-right {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 12px;
}

.collage-tool-right .collage-tool-options {
    overflow-y: auto;
    min-height: 0;
}

.collage-tool-drop-zone {
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.12));
    border-radius: var(--radius-md, 8px);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-secondary, #2a2a2e);
    transition: border-color 0.2s, background 0.2s;
}

.collage-tool-drop-zone:hover,
.collage-tool-drop-zone.collage-tool-drop-zone--active {
    border-color: rgba(102, 126, 234, 0.35);
    background: var(--bg-hover, #36363b);
}

.collage-tool-file-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.collage-tool-drop-hint {
    margin: 0;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    color: var(--text-secondary, #d0d1d2);
}

.collage-tool-list-wrap {
    flex: 1;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    background: var(--bg-secondary, #2a2a2e);
}

.collage-tool-list-title {
    padding: 10px 14px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #d0d1d2);
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
}

.collage-tool-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    overflow-y: auto;
    flex: 1;
}

.collage-tool-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 8px 10px;
    cursor: grab;
    border-bottom: 1px solid var(--border-primary, rgba(255, 255, 255, 0.06));
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    color: var(--text-primary, #e0e0e0);
    position: relative;
}

.collage-tool-list-item:last-child {
    border-bottom: none;
}

.collage-tool-list-item:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.06));
}

.collage-tool-list-item__remove {
    flex-shrink: 0;
    margin-left: auto;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary, #b0b0b0);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.collage-tool-list-item:hover .collage-tool-list-item__remove {
    opacity: 1;
}

.collage-tool-list-item__remove:hover {
    color: #fff;
    background: rgba(220, 80, 80, 0.5);
}

.collage-tool-list-item__remove:focus {
    outline: none;
    opacity: 1;
}

.collage-tool-list-item.collage-tool-list-item--dragging {
    opacity: 0.6;
    cursor: grabbing;
}

.collage-tool-list-item__index {
    flex-shrink: 0;
    width: 22px;
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary, #b0b0b0);
}

.collage-tool-list-item__thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.collage-tool-list-item__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collage-tool-preview-wrap {
    flex: 1;
    min-height: 200px;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    background: #000;
    position: relative;
}

.collage-tool-preview-wrap.collage-tool-preview-bg--white {
    background: #fff;
}

/* 加载中遮罩（独立，collage-tool- 前缀） */
.collage-tool-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.6);
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 14px;
    color: #fff;
}

.collage-tool-loading-overlay--hide {
    display: none;
}

.collage-tool-loading-overlay:not(.collage-tool-loading-overlay--hide) {
    display: flex;
}

.collage-tool-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: collage-tool-loading-spin 0.8s linear infinite;
}

@keyframes collage-tool-loading-spin {
    to { transform: rotate(360deg); }
}

.collage-tool-loading-text {
    font-weight: 500;
}

.collage-tool-resolution-display {
    position: absolute;
    right: 10px;
    bottom: 10px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 10px;
    border-radius: 4px;
    pointer-events: none;
}

.collage-tool-preview-wrap.collage-tool-preview-bg--white .collage-tool-resolution-display {
    color: rgba(0, 0, 0, 0.75);
    background: rgba(255, 255, 255, 0.85);
}

.collage-tool-preview-inner {
    width: 100%;
    height: 100%;
    min-height: 280px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.collage-tool-preview-img {
    max-width: none;
    max-height: none;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center center;
}

.collage-tool-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0;
}

.collage-tool-options-section {
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-md, 8px);
    background: var(--bg-secondary, #2a2a2e);
    overflow: hidden;
}

.collage-tool-options-section__title {
    margin: 0;
    padding: 10px 14px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #d0d1d2);
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
}

.collage-tool-options-section__body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.collage-tool-option-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.collage-tool-option-hint {
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 11px;
    color: var(--text-secondary, #b0b0b0);
}

.collage-tool-option-label {
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #e0e0e0);
}

.collage-tool-radio {
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary, #e0e0e0);
}

.collage-tool-radio input[type="radio"] {
    accent-color: #667eea;
}

.collage-tool-gap-input {
    width: 64px;
    padding: 6px 10px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.15));
    border-radius: var(--radius-md, 6px);
    background: var(--bg-secondary, #2a2a2e);
    color: var(--text-primary, #e0e0e0);
    outline: none;
}

.collage-tool-gap-input:focus {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* 宫格拼图区域（独立块，collage-tool- 前缀） */
.collage-tool-grid-section .collage-tool-grid-preset-select {
    min-width: 100px;
    padding: 6px 10px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.15));
    border-radius: var(--radius-md, 6px);
    background: var(--bg-secondary, #2a2a2e);
    color: var(--text-primary, #e0e0e0);
    outline: none;
    cursor: pointer;
}

.collage-tool-grid-section .collage-tool-grid-preset-select:focus {
    border-color: rgba(102, 126, 234, 0.5);
}

.collage-tool-grid-section .collage-tool-grid-input {
    width: 48px;
    padding: 6px 8px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.15));
    border-radius: var(--radius-md, 6px);
    background: var(--bg-secondary, #2a2a2e);
    color: var(--text-primary, #e0e0e0);
    outline: none;
}

.collage-tool-grid-section .collage-tool-grid-input:focus {
    border-color: rgba(102, 126, 234, 0.5);
}

.collage-tool-res-select {
    min-width: 120px;
    padding: 6px 10px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.15));
    border-radius: var(--radius-md, 6px);
    background: var(--bg-secondary, #2a2a2e);
    color: var(--text-primary, #e0e0e0);
    outline: none;
    cursor: pointer;
}

.collage-tool-res-select:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.collage-tool-res-select:focus {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.collage-tool-res-custom-input {
    width: 72px;
    padding: 6px 10px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.15));
    border-radius: var(--radius-md, 6px);
    background: var(--bg-secondary, #2a2a2e);
    color: var(--text-primary, #e0e0e0);
    outline: none;
}

.collage-tool-res-custom-input:focus {
    border-color: rgba(102, 126, 234, 0.5);
}

.collage-tool-upload-filename-input {
    flex: 1;
    min-width: 120px;
    padding: 6px 10px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.15));
    border-radius: var(--radius-md, 6px);
    background: var(--bg-secondary, #2a2a2e);
    color: var(--text-primary, #e0e0e0);
    outline: none;
}

.collage-tool-upload-filename-input::placeholder {
    color: var(--text-muted, #888);
}

.collage-tool-upload-filename-input:focus {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.collage-tool-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.collage-tool-btn {
    padding: 10px 20px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", Arial, sans-serif;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md, 8px);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* 主按钮与上传按钮：同色紫蓝渐变，无发光保证文字清晰 */
.collage-tool-btn--primary {
    background: linear-gradient(135deg, #4f6cf6 0%, #667eea 50%, #5a67d8 100%);
    color: #fff;
}

.collage-tool-btn--primary:hover {
    background: linear-gradient(135deg, #5a6ff7 0%, #7688f0 50%, #667eea 100%);
}

.collage-tool-btn--secondary {
    background: linear-gradient(135deg, #4f6cf6 0%, #667eea 50%, #5a67d8 100%);
    color: #fff;
}

.collage-tool-btn--secondary:hover {
    background: linear-gradient(135deg, #5a6ff7 0%, #7688f0 50%, #667eea 100%);
}

.collage-tool-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
