/* ===== 图片去底色/背景处理工具 - 可视化弹窗 UI 规范 ===== */

.image-backdrop-page {
    background-color: var(--page-bg, #f8fafc);
}

/* 主页图片网格卡片容器 (Step 2) */
.bd-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

/* 单个图片卡片 */
.bd-image-card {
    background: #ffffff;
    border: 1px solid var(--border-main, #cbd5e1);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.bd-image-card:hover {
    border-color: #2563eb;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
    transform: translateY(-2px);
}

.bd-image-card.active {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* 卡片顶部 index 序号 Badge */
.bd-image-card .card-idx-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    z-index: 2;
}

/* 卡片缩略图 Viewport Wrapper (棋盘格背景) */
.bd-image-card .card-thumb-wrap {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8fafc;
    background-image: 
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%), 
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%), 
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
    cursor: pointer;
    border: 1px solid #e2e8f0;
}

.bd-image-card .card-thumb-wrap canvas,
.bd-image-card .card-thumb-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* 悬浮 hover 编辑遮罩层 */
.bd-image-card .card-thumb-wrap .card-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: 8px;
}

.bd-image-card .card-thumb-wrap:hover .card-hover-overlay {
    opacity: 1;
}

.bd-image-card .card-hover-overlay i {
    font-size: 22px;
}

/* 卡片信息 */
.bd-image-card .card-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
}

.bd-image-card .card-filename {
    font-weight: 700;
    color: var(--text-main, #0f172a);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 140px;
}

.bd-image-card .card-meta {
    font-size: 11px;
    color: var(--text-sub, #64748b);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.bd-image-card .card-mode-badge {
    font-size: 10.5px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.bd-image-card .card-mode-badge.badge-transparent {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.bd-image-card .card-mode-badge.badge-solid {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.bd-image-card .card-actions {
    display: flex;
    gap: 6px;
    margin-top: auto;
}

.bd-image-card .card-actions .btn {
    flex: 1;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 8px;
}

/* ZIP 批量导入 Tag */
.backdrop-badge-zip {
    background: #fef3c7;
    color: #92400e;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    margin-right: 4px;
}

/* ===== 可视化去底色弹窗编辑器 ===== */
.bd-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.bd-modal-dialog {
    background: #ffffff;
    border-radius: 14px;
    width: 96%;
    max-width: 1240px;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.bd-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-main, #e2e8f0);
    flex-shrink: 0;
}

.bd-modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main, #0f172a);
    display: flex;
    align-items: center;
    gap: 8px;
}

.bd-modal-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bd-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #e2e8f0;
}

/* 左侧 Canvas 可视化舞台 (Scrollable, Center Aligned) */
.bd-modal-canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: auto;
    position: relative;
    user-select: none;
    background-color: #cbd5e1;
    background-image: 
        linear-gradient(45deg, #94a3b8 25%, transparent 25%), 
        linear-gradient(-45deg, #94a3b8 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #94a3b8 75%), 
        linear-gradient(-45deg, transparent 75%, #94a3b8 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.bd-modal-canvas-stage {
    position: relative;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    overflow: hidden;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
}

#bdModalPreviewCanvas {
    display: block;
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    border-radius: 6px;
    transition: cursor 0.2s ease;
}

#bdModalPreviewCanvas.is-pipette-active {
    cursor: crosshair !important;
}

/* 底部分辨率信息条 */
.bd-modal-canvas-info {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(6px);
    color: #ffffff;
    font-size: 11.5px;
    padding: 4px 14px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.bd-modal-canvas-info strong {
    color: #60a5fa;
}

/* 吸管激活提示 */
.bd-pipette-toast {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(220, 38, 38, 0.92);
    backdrop-filter: blur(6px);
    color: #ffffff;
    padding: 7px 18px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 6px;
    animation: bdPulse 2s infinite;
}

@keyframes bdPulse {
    0%, 100% { opacity: 0.95; }
    50% { opacity: 0.75; }
}

/* 右侧参数控制面板 */
.bd-modal-sidebar {
    width: 320px;
    flex-shrink: 0;
    background: #ffffff;
    border-left: 1px solid var(--border-main, #e2e8f0);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bd-modal-sidebar .sidebar-header {
    margin-bottom: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-sub, #f1f5f9);
}

.bd-modal-sidebar .sidebar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main, #0f172a);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 侧边栏卡片容器 */
.bd-modal-sidebar .sidebar-card {
    background: #f8fafc;
    border: 1px solid var(--border-main, #e2e8f0);
    border-radius: 8px;
    padding: 12px;
}

.bd-modal-sidebar .sidebar-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.bd-modal-sidebar .card-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-main, #0f172a);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 模式 Radio 切换 Pill */
.bd-mode-pill-sidebar {
    display: flex;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 8px;
    gap: 4px;
}

.bd-mode-pill-sidebar .bd-mode-item {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.bd-mode-pill-sidebar .bd-mode-item input {
    display: none;
}

.bd-mode-pill-sidebar .bd-mode-item.active {
    background: #ffffff;
    color: #2563eb;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* 预设颜色按钮网格 */
.bd-presets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.bd-preset-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bd-preset-btn:hover {
    border-color: #2563eb;
    color: #2563eb;
}

.bd-preset-btn.active {
    border-color: #2563eb;
    background: #eff6ff;
    color: #2563eb;
    box-shadow: 0 0 0 1px #2563eb;
}

.bd-preset-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* 自定义颜色拾取输入组 */
.bd-color-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bd-color-picker {
    width: 32px;
    height: 30px;
    padding: 1px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    cursor: pointer;
    background: #ffffff;
}

.bd-hex-input {
    height: 30px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    font-family: monospace;
    flex: 1;
    border-radius: 5px;
}

.bd-pipette-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #2563eb;
    padding: 0 8px;
    height: 30px;
    border-radius: 5px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.bd-pipette-btn:hover,
.bd-pipette-btn.active {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

/* Sliders Section */
.bd-modal-sidebar .sidebar-section {
    background: #f8fafc;
    border: 1px solid var(--border-main, #e2e8f0);
    border-radius: 8px;
    padding: 12px;
}

.bd-modal-sidebar .sidebar-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main, #0f172a);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.bd-modal-sidebar .sidebar-form-group {
    margin-bottom: 10px;
}

.bd-modal-sidebar .sidebar-form-group:last-child {
    margin-bottom: 0;
}

.bd-modal-sidebar .slider-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.bd-modal-sidebar .slider-val-badge {
    background: #eff6ff;
    color: #2563eb;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.bd-modal-sidebar .sidebar-range {
    height: 6px;
    background: #cbd5e1;
    border-radius: 3px;
    outline: none;
    margin-top: 4px;
}

.bd-modal-sidebar .sidebar-tip-box {
    background: #fffbebfb;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: 11px;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    gap: 6px;
    line-height: 1.4;
}

/* Footer Control Bar */
.bd-modal-footer {
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border-main, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

/* 响应式支持 */
@media (max-width: 768px) {
    .bd-modal-dialog {
        width: 98%;
        height: 96vh;
        max-height: 96vh;
    }
    .bd-modal-body {
        flex-direction: column;
    }
    .bd-modal-sidebar {
        width: 100%;
        height: 45vh;
        border-left: none;
        border-top: 1px solid var(--border-main);
    }
}
