/* ============================================
   图片合成工具样式
   ============================================ */

.image-merge-page {
    max-width: 1400px;
    margin: 24px auto;
    padding: 0 20px 40px;
}

/* 顶部 */
.merge-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.merge-header h1 {
    margin: 0 0 6px;
    color: #333;
    font-size: 26px;
}
.merge-header p {
    margin: 0;
    color: #888;
    font-size: 14px;
}
.back-btn {
    padding: 8px 18px;
    background: #f0f0f0;
    border-radius: 8px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
    white-space: nowrap;
}
.back-btn:hover { background: #e0e0e0; }

/* 主布局 */
.merge-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    align-items: start;
}

/* 侧边栏 */
.merge-sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* 面板 */
.panel {
    background: #fff;
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.panel-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.layer-count {
    background: #667eea;
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

/* 上传区 */
.upload-area {
    border: 2px dashed #d0d7e0;
    border-radius: 10px;
    padding: 24px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafbfc;
}
.upload-area:hover,
.upload-area.dragover {
    border-color: #667eea;
    background: #f0f3ff;
}
.upload-icon {
    font-size: 32px;
    color: #667eea;
    line-height: 1;
    margin-bottom: 8px;
}
.upload-hint > div:nth-child(2) {
    color: #333;
    font-size: 14px;
    margin-bottom: 4px;
}
.upload-sub {
    color: #999;
    font-size: 12px;
    line-height: 1.5;
}

/* 图层列表 */
.layer-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 8px;
}
.layer-list::-webkit-scrollbar { width: 6px; }
.layer-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f8f9fa;
    border: 1px solid #e8ecf1;
    border-radius: 8px;
    cursor: move;
    transition: all 0.15s;
    user-select: none;
}
.layer-item:hover {
    background: #f0f4f8;
    border-color: #c8d4e0;
}
.layer-item.dragging {
    opacity: 0.4;
}
.layer-item.drag-over {
    border-color: #667eea;
    background: #f0f3ff;
}

.layer-thumb {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background: 
        repeating-conic-gradient(#f0f0f0 0 25%, #fff 0 50%) 
        50% / 12px 12px;
    border-radius: 6px;
    border: 1px solid #e8ecf1;
    flex-shrink: 0;
}

.layer-info {
    flex: 1;
    min-width: 0;
}
.layer-name {
    font-size: 12px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.layer-meta {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}

.layer-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.layer-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: all 0.15s;
}
.layer-btn:hover {
    background: #e8ecf1;
    color: #333;
}
.layer-btn.remove:hover {
    background: #fdedec;
    color: #e74c3c;
}

.empty-hint {
    text-align: center;
    color: #bbb;
    font-size: 13px;
    padding: 20px 0;
}

.layer-tip {
    font-size: 11px;
    color: #999;
    text-align: center;
    padding-top: 4px;
}

/* 表单 */
.form-row {
    margin-bottom: 12px;
}
.form-row:last-child { margin-bottom: 0; }
.form-row > label {
    display: block;
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
    font-weight: 500;
}
.form-row input[type="number"],
.form-row select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    font-size: 13px;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: #667eea;
}

.radio-group {
    display: flex;
    gap: 8px;
}
.radio-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
    transition: all 0.15s;
}
.radio-item:hover {
    border-color: #a8d4f0;
    background: #f8fcff;
}
.radio-item input[type="radio"] {
    margin: 0;
    cursor: pointer;
    accent-color: #667eea;
}
.radio-item input[type="radio"]:checked ~ span {
    color: #667eea;
    font-weight: 500;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    user-select: none;
}
.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: #667eea;
}

.form-row input[type="range"] {
    width: calc(100% - 50px);
    vertical-align: middle;
}
.quality-value {
    display: inline-block;
    width: 40px;
    text-align: right;
    font-size: 12px;
    color: #666;
    font-weight: 500;
    vertical-align: middle;
}

/* 按钮 */
.btn-block {
    width: 100%;
    justify-content: center;
    margin-bottom: 8px;
}
.btn-block:last-child { margin-bottom: 0; }

.actions-panel {
    padding: 12px;
}

/* 主区域 */
.merge-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* 预览面板 */
.preview-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid #f0f0f0;
}
.preview-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}
.preview-info {
    font-size: 12px;
    color: #999;
}

.preview-body {
    padding: 20px;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 棋盘格透明背景 */
    background: 
        repeating-conic-gradient(#f0f0f0 0 25%, #fff 0 50%) 
        50% / 20px 20px;
    overflow: auto;
    max-height: 60vh;
}

.preview-empty {
    text-align: center;
    color: #bbb;
    font-size: 14px;
    pointer-events: none;
}
.preview-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

#previewCanvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    background: transparent;
}

/* 结果面板 */
.result-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-bottom: 1px solid #f0f0f0;
    background: #f0fff4;
}
.result-title {
    font-size: 14px;
    font-weight: 600;
    color: #27ae60;
}
.result-info {
    font-size: 12px;
    color: #666;
}
.result-body {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
}
#resultImage {
    max-width: 100%;
    max-height: 500px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
.result-actions {
    padding: 16px 18px;
    text-align: center;
    border-top: 1px solid #f0f0f0;
}
.result-actions .btn {
    padding: 10px 32px;
    font-size: 15px;
}

/* ============================================
   移动端
   ============================================ */
@media (max-width: 900px) {
    .merge-layout {
        grid-template-columns: 1fr;
    }
    .merge-sidebar {
        order: 2;
    }
    .merge-main {
        order: 1;
    }
}

@media (max-width: 768px) {
    .image-merge-page {
        margin: 16px auto;
        padding: 0 12px 24px;
    }
    .merge-header h1 {
        font-size: 20px;
    }
    .merge-header p {
        font-size: 12px;
    }
    .panel {
        padding: 14px;
    }
    .preview-body {
        min-height: 260px;
        padding: 12px;
    }
    .radio-group {
        flex-wrap: wrap;
    }
    .radio-item {
        flex: 1;
        min-width: 70px;
        padding: 6px 8px;
        font-size: 12px;
    }
    .result-actions .btn {
        width: 100%;
        padding: 12px;
    }
}