/**
 * AI创作坊 · 节点窗口基础样式
 * 所有节点共用：窗口框、标题栏、锁、连接点、精简/详细布局
 * 独立命名空间 ai-workshop-node-*，不与其他面板共用
 * 字体：Microsoft YaHei
 */

/* 节点挂载容器：覆盖画布，用于绝对定位节点 */
.ai-workshop-nodes-container {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.ai-workshop-nodes-container > * {
    pointer-events: auto;
}

/* 有节点时隐藏画布占位文案 */
.ai-workshop-canvas-inner:has(.ai-workshop-nodes-container:not(:empty)) .ai-workshop-canvas-placeholder {
    display: none;
}

/* ---------- 单节点窗口通用 ---------- */
.ai-workshop-node {
    position: absolute;
    min-width: 180px;
    border-radius: 8px;
    overflow: visible; /* 允许下方输出口（箭头小尾巴）伸出显示，不裁剪 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 12px;
    color: #e0e0e0;
    background: #2d2d30;
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    user-select: none;
}

/* 右下角拖拽调整宽度手柄 */
.ai-workshop-node-resize-handle {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.15s ease;
    border-radius: 0 0 8px 0;
}

.ai-workshop-node:hover .ai-workshop-node-resize-handle,
.ai-workshop-node.is-selected .ai-workshop-node-resize-handle {
    opacity: 1;
}

.ai-workshop-node-resize-handle::after {
    content: '';
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 7px;
    height: 7px;
    border-right: 2px solid rgba(255, 255, 255, 0.45);
    border-bottom: 2px solid rgba(255, 255, 255, 0.45);
    border-radius: 0 0 2px 0;
}

.ai-workshop-node-resize-handle:hover::after {
    border-right-color: rgba(255, 255, 255, 0.8);
    border-bottom-color: rgba(255, 255, 255, 0.8);
}

/* 锁定状态下隐藏调整大小手柄 */
.ai-workshop-node.is-locked .ai-workshop-node-resize-handle {
    display: none;
}

.ai-workshop-node.is-selected {
    outline: 2px solid rgba(107, 140, 255, 0.8);
    outline-offset: 1px;
    z-index: 2;
}

.ai-workshop-node.is-locked .ai-workshop-node-body,
.ai-workshop-node.is-locked .ai-workshop-node-body input,
.ai-workshop-node.is-locked .ai-workshop-node-body textarea {
    pointer-events: none;
    cursor: default;
}

/* 节点禁用状态：整体降低不透明度 */
.ai-workshop-node.is-disabled {
    opacity: 0.62;
}

/* 禁用遮罩层：绝对定位铺满节点，暗色半透明背景 */
.ai-workshop-node-disable-overlay {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.38);
    display: none;
    pointer-events: none;
    z-index: 20;
    overflow: hidden;
}

/* 居中 X 图案：通过 background-size + background-position 缩小绘图区，留出边距 */
.ai-workshop-node-disable-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(
            to bottom right,
            transparent calc(50% - 2px),
            rgba(0, 0, 0, 0.62) calc(50% - 2px),
            rgba(0, 0, 0, 0.62) calc(50% + 2px),
            transparent calc(50% + 2px)
        ) center / calc(100% - 36px) calc(100% - 36px) no-repeat,
        linear-gradient(
            to bottom left,
            transparent calc(50% - 2px),
            rgba(0, 0, 0, 0.62) calc(50% - 2px),
            rgba(0, 0, 0, 0.62) calc(50% + 2px),
            transparent calc(50% + 2px)
        ) center / calc(100% - 36px) calc(100% - 36px) no-repeat;
}

.ai-workshop-node.is-disabled .ai-workshop-node-disable-overlay {
    display: block;
}

/* 标题栏：可拖拽移动节点、显示锁、名称（居中）、支持自定义背景色；顶部圆角与节点一致（节点 overflow:visible 时不被裁切） */
.ai-workshop-node-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 6px 10px;
    min-height: 28px;
    background: var(--ai-workshop-node-titlebar-bg, #3c3c3e);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: grab;
    flex-shrink: 0;
    border-radius: 8px 8px 0 0;
}

.ai-workshop-node-header:active {
    cursor: grabbing;
}

/* 简单单色锁图标，非彩色；开锁/关锁造型区分明显 */
.ai-workshop-node-lock {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #a0a0a0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
    padding: 0;
}

.ai-workshop-node-lock:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #e8e8e8;
}

/* 点击时明显反馈：缩小 + 背景高亮 */
.ai-workshop-node-lock:active {
    transform: scale(0.88);
    background: rgba(255, 255, 255, 0.22);
}

.ai-workshop-node-lock.is-locked {
    color: #e0e0e0;
}

/* 锁按钮置于标题文字之上，保证可点击 */
.ai-workshop-node-lock {
    z-index: 1;
}

.ai-workshop-node-lock-svg {
    display: block;
    pointer-events: none;
}

/* 窗口标题名字：整栏居中显示，不阻挡锁按钮点击 */
.ai-workshop-node-name {
    position: absolute;
    left: 0;
    right: 0;
    font-size: 12px;
    font-weight: 600;
    color: #f0f0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    pointer-events: none;
    z-index: 0;
}

/* 内容区（类型专属内容 + 详细模式设置） */
.ai-workshop-node-body {
    padding: 10px 12px 8px;
    min-height: 36px;
    background: #252527;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 输出连接点：箭头在窗口外，像小尾巴 */
.ai-workshop-node-footer {
    position: relative;
    height: 4px;
    flex-shrink: 0;
}

.ai-workshop-node-port-out {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    width: 28px;
    height: 18px;
    margin-top: 2px;
    border: none;
    background: transparent;
    cursor: crosshair;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 10px;
    transition: color 0.15s ease;
    z-index: 1;
}

.ai-workshop-node-port-out:hover {
    color: #b0b0b0;
}

.ai-workshop-node-port-out::after {
    content: '▼';
}

/* 详细模式下的设置区占位 */
.ai-workshop-node-detail {
    display: none;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 4px;
}

.ai-workshop-node.view-detail .ai-workshop-node-detail {
    display: block;
}

/* 无标题栏节点（如信息球）：不显示 resize 手柄，禁用遮罩与选中态沿用通用样式 */
.ai-workshop-node.ai-workshop-node-no-header .ai-workshop-node-resize-handle {
    display: none;
}
