/* ==========================================================================
   图片编辑工具（/tools/photo-editor）
   仅服务 public/assets/js/photo-editor.js 生成的界面，命名统一带 jx-pe 前缀，
   避免影响站点其他板块。
   ========================================================================== */

.jx-pe {
    padding-bottom: 3rem;
}

.jx-pe__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1.25rem;
    align-items: start;
}

/* ---------- 画布区 ---------- */

.jx-pe__stage {
    min-width: 0;
}

.jx-pe__canvas-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background-color: var(--surface-secondary);
    background-image:
        linear-gradient(45deg, var(--surface-tertiary) 25%, transparent 25%, transparent 75%, var(--surface-tertiary) 75%),
        linear-gradient(45deg, var(--surface-tertiary) 25%, transparent 25%, transparent 75%, var(--surface-tertiary) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    overflow: hidden;
}

.jx-pe__canvas-wrap.is-dropping {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent-soft);
}

.jx-pe__canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    touch-action: none;
    cursor: grab;
}

.jx-pe__canvas.is-empty {
    display: none;
}

.jx-pe__canvas.is-dragging {
    cursor: grabbing;
}

.jx-pe__canvas.is-locked {
    cursor: default;
}

.jx-pe__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 2.5rem 1rem;
    text-align: center;
    pointer-events: none;
}

.jx-pe__empty.is-hidden {
    display: none;
}

.jx-pe__empty-icon {
    display: block;
    width: 42px;
    height: 42px;
    color: var(--text-muted);
}

.jx-pe__empty-icon svg {
    width: 100%;
    height: 100%;
}

.jx-pe__empty-title {
    margin: 0.25rem 0 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
}

.jx-pe__empty-desc {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.jx-pe__stagebar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.jx-pe__stagebar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.jx-pe__status {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.jx-pe__hint {
    margin: 0.5rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.jx-pe__file {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- 控制面板 ---------- */

.jx-pe__panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--bg-elevated);
    overflow: hidden;
}

.jx-pe__tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-bottom: 1px solid var(--border);
}

.jx-pe__tab {
    padding: 0.7rem 0.25rem;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--duration-fast) var(--ease-default), background var(--duration-fast) var(--ease-default);
}

.jx-pe__tab:hover {
    background: var(--fill-secondary);
    color: var(--text);
}

.jx-pe__tab.is-active {
    color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.jx-pe__panes {
    padding: 1rem;
}

.jx-pe__pane {
    display: none;
    flex-direction: column;
    gap: 0.9rem;
}

.jx-pe__pane.is-active {
    display: flex;
}

.jx-pe__pane-hint {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.jx-pe__actions {
    display: flex;
    justify-content: stretch;
}

/* ---------- 字段行 ---------- */

.jx-pe-field {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.jx-pe-field__icon {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.jx-pe-field__icon svg {
    width: 100%;
    height: 100%;
}

.jx-pe-field__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.jx-pe-field__label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.jx-pe-field__input {
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
}

.jx-pe-field__clear {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: var(--radius-full);
    background: var(--fill-secondary);
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: color var(--duration-fast) var(--ease-default), background var(--duration-fast) var(--ease-default);
}

.jx-pe-field__clear:hover {
    background: var(--hot-soft);
    color: var(--hot);
}

/* ---------- 区块与控件 ---------- */

.jx-pe-block {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.jx-pe-block.is-hidden {
    display: none;
}

.jx-pe-block__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
}

.jx-pe-block__value {
    font-style: normal;
    font-weight: 500;
    color: var(--text-muted);
}

.jx-pe-textarea {
    resize: vertical;
    min-height: 84px;
    font-family: inherit;
    line-height: 1.5;
}

.jx-pe-select {
    cursor: pointer;
}

.jx-pe-range {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

.jx-pe-seg {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2px;
    padding: 2px;
    border-radius: var(--radius);
    background: var(--fill-secondary);
}

.jx-pe-seg--4 {
    grid-template-columns: repeat(4, 1fr);
}

.jx-pe-seg__item {
    padding: 0.4rem 0.3rem;
    border: 0;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-default), color var(--duration-fast) var(--ease-default);
}

.jx-pe-seg__item:hover {
    color: var(--text);
}

.jx-pe-seg__item.is-active {
    background: var(--bg-elevated);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-md);
}

/* 九宫格落点（固定位置水印） */

.jx-pe-pos {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
    border-radius: var(--radius);
    background: var(--fill-secondary);
}

.jx-pe-pos__item {
    position: relative;
    padding: 0;
    aspect-ratio: 3 / 2;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-default), border-color var(--duration-fast) var(--ease-default);
}

.jx-pe-pos__item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 22%;
    height: 22%;
    min-width: 6px;
    min-height: 6px;
    transform: translate(-50%, -50%);
    border-radius: 2px;
    background: var(--text-muted);
    transition: background var(--duration-fast) var(--ease-default);
}

.jx-pe-pos__item:hover {
    background: var(--fill-secondary);
    border-color: var(--border);
}

.jx-pe-pos__item.is-active {
    background: var(--bg-elevated);
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.jx-pe-pos__item.is-active::after {
    background: var(--accent);
}

/* ---------- 开关 ---------- */

.jx-pe__switch-row {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.jx-pe-switch {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}

.jx-pe-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.jx-pe-switch__track {
    position: relative;
    flex: 0 0 auto;
    width: 40px;
    height: 22px;
    border-radius: var(--radius-full);
    background: var(--surface-tertiary);
    transition: background var(--duration-fast) var(--ease-default);
}

.jx-pe-switch__dot {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform var(--duration-fast) var(--ease-default);
}

.jx-pe-switch input:checked + .jx-pe-switch__track {
    background: var(--color-emerald);
}

.jx-pe-switch input:checked + .jx-pe-switch__track .jx-pe-switch__dot {
    transform: translateX(18px);
}

.jx-pe-switch input:focus-visible + .jx-pe-switch__track {
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.jx-pe-switch__text {
    font-size: 0.8125rem;
    color: var(--text);
}

/* ---------- 页脚说明 ---------- */

.jx-pe__note {
    margin: 1.25rem 0 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ---------- 响应式 ---------- */

@media (max-width: 980px) {
    .jx-pe__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .jx-pe__panel {
        order: 2;
    }

    .jx-pe__canvas-wrap {
        min-height: 240px;
    }
}
