/* ============================================
   water.css —— 小红书去水印
   ============================================ */

.wm-layout {
    display: grid;
    grid-template-columns: 302px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    max-width: 1560px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 2.5rem;
}

/* ===== 控制面板 ===== */
.control-panel {
    position: sticky;
    top: calc(var(--topbar-h) + 1rem);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--topbar-h) - 2rem);
}

.control-panel .panel-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.wm-actions {
    display: flex;
    gap: 0.5rem;
}

.wm-actions:not(:last-child) {
    margin-bottom: 0.6rem;
}

.wm-actions .btn {
    flex: 1;
    justify-content: center;
}

.divider {
    height: 1px;
    margin: 0.9rem 0;
    background: var(--border-color);
}

/* ===== 表单 ===== */
.form-stack {
    margin-bottom: 0.9rem;
}

.form-stack .form-label {
    display: block;
    margin-bottom: 0.45rem;
}

.seg-tabs-full {
    display: flex;
    width: 100%;
}

.seg-tabs-full .seg-tab {
    flex: 1;
    text-align: center;
}

.form-row-inline {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.form-row-inline input[type="range"] {
    flex: 1;
    min-width: 0;
}

.form-row-inline .form-value {
    flex: 0 0 auto;
    min-width: 74px;
}

.w-45 {
    width: 45%;
}

/* ===== 警告 / 提示 ===== */
.wm-warn {
    margin-top: 0.7rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid rgba(234, 88, 12, 0.28);
    border-radius: var(--radius-sm);
    background: rgba(234, 88, 12, 0.07);
    color: var(--accent-orange);
    font-size: 0.75rem;
    line-height: 1.55;
}

.wm-tip {
    margin-top: 0.7rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    line-height: 1.65;
}

/* ===== 批量区（仅批量模式显示） ===== */
.batch-block {
    display: none;
}

body[data-mode="batch"] .batch-block {
    display: block;
}

.batch-title {
    margin-bottom: 0.55rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.progress-track {
    height: 5px;
    border-radius: 3px;
    background: var(--border-color);
    overflow: hidden;
}

.progress-bar {
    width: 0;
    height: 100%;
    border-radius: 3px;
    background: var(--accent-solid);
    transition: width 0.2s ease;
}

.progress-text {
    margin-top: 0.4rem;
    color: var(--text-muted);
    font-size: 0.72rem;
}

/* ===== 画布区 ===== */
.stage-panel {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--topbar-h) - 4rem);
}

.stage-panel .panel-title {
    min-width: 0;
}

#fileInfo {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.canvas-body {
    display: flex;
    flex: 1;
    min-height: 0;
    padding: 1rem;
}

.drop-zone {
    position: relative;
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-height: 380px;
    padding: 1.5rem;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.drop-zone.dragover {
    border-color: var(--accent-primary);
    background: var(--accent-tint);
}

.drop-zone.has-image {
    padding: 0;
    border-color: transparent;
    background: transparent;
}

.drop-zone.has-image .drop-inner,
.drop-zone:not(.has-image) .stage-wrap {
    display: none;
}

.drop-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.drop-inner h3 {
    color: var(--text-primary);
    font-size: 0.98rem;
    font-weight: 600;
}

.drop-inner p {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.drop-icon {
    color: var(--accent-primary);
    opacity: 0.85;
}

/* ===== 舞台 ===== */
.stage-wrap {
    display: flex;
    width: 100%;
    justify-content: center;
}

/* 不能让 flex 压缩舞台：canvas 与框按 JS 算出的尺寸绝对定位，
   舞台一旦被压缩两者就会错位 */
.stage {
    position: relative;
    flex: 0 0 auto;
    max-width: 100%;
    background: var(--bg-subtle);
    box-shadow: var(--shadow-sm);
    line-height: 0;
    touch-action: none;
}

.stage-canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
}

.stage-panel.processing .stage::after {
    content: '处理中…';
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 9;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.68);
    color: #fff;
    font-size: 11px;
    line-height: 18px;
}

.stage-panel.busy {
    pointer-events: none;
    opacity: 0.7;
}

/* ===== 水印框 ===== */
.wm-overlay {
    position: absolute;
    inset: 0;
    touch-action: none;
}

.wm-overlay.dragging {
    cursor: move;
}

.wm-box {
    position: absolute;
    border: 1.5px solid var(--accent-solid);
    border-radius: 3px;
    background: rgba(37, 99, 235, 0.09);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.72);
    cursor: move;
}

.wm-box-label {
    position: absolute;
    top: -20px;
    left: -1.5px;
    padding: 0 6px;
    border-radius: 3px 3px 0 0;
    background: var(--accent-solid);
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    white-space: nowrap;
    pointer-events: none;
}

.wm-handle {
    position: absolute;
    width: 11px;
    height: 11px;
    margin: -6px 0 0 -6px;
    border: 1.5px solid var(--accent-solid);
    border-radius: 2px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
}

.wm-handle-nw { left: 0;    top: 0;    cursor: nwse-resize; }
.wm-handle-ne { left: 100%; top: 0;    cursor: nesw-resize; }
.wm-handle-sw { left: 0;    top: 100%; cursor: nesw-resize; }
.wm-handle-se { left: 100%; top: 100%; cursor: nwse-resize; }

.wm-del {
    position: absolute;
    top: -9px;
    right: -9px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1.5px solid #fff;
    border-radius: 50%;
    background: var(--accent-red);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

/* ===== 对比滑杆 ===== */
.compare-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 6;
    width: 2px;
    margin-left: -1px;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.28);
    cursor: ew-resize;
}

.compare-handle span {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
    border: 1px solid rgba(15, 23, 42, 0.18);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.22);
}

/* ===== 批量队列 ===== */
.queue-strip {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.queue-list {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
}

.queue-item {
    position: relative;
    flex: 0 0 auto;
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    line-height: 0;
    overflow: hidden;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.queue-item:hover {
    border-color: var(--border-hover);
}

.queue-item.active {
    border-color: var(--accent-solid);
}

.queue-item canvas {
    display: block;
}

.queue-badge {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.62);
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
    .wm-layout {
        grid-template-columns: 258px minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    .wm-layout {
        grid-template-columns: minmax(0, 1fr);
        padding: 1rem;
    }

    /* 窄屏以看图为主：画布提到参数面板之前 */
    .stage-panel {
        order: -1;
        min-height: 0;
    }

    .control-panel {
        position: static;
        max-height: none;
    }

    .control-panel .panel-body {
        overflow: visible;
    }

    .drop-zone {
        min-height: 280px;
    }
}
