/**
 * AI创作坊面板 · 基础布局样式
 * 面板根、桌布、侧栏容器（含拖拽、头部、标题、收起状态）、画布与网格、占位文案、左下角展开按钮
 * 独立命名空间 ai-workshop-*，不与其他面板共用，保证面板独立性
 * 字体：Microsoft YaHei，符合项目字体规范
 */

/* 与个人文件面板一致：面板根 100% 填满，无内边距 */
.ai-workshop-panel {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    color: #f5f5f5;
}

/* 桌布背景容器：与个人文件 .personal-files-layout 布局一致
 * 填满面板（无 padding）、统一圆角/边框/阴影，消除底部缝隙 */
.ai-workshop-desktop {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-card, #1a1a1a);
    border-radius: var(--radius-lg, 8px);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.1));
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.15));
}

/* 左侧竖向弹窗容器（位于左侧轨道内容区内，宽度可由拖动手柄调整 450~1000px）
 * 修饰边框：细而柔和的浅灰描边，与主内容区区分又不抢眼 */
.ai-workshop-sidebar {
    width: 100%;
    background-color: #1f1f21;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

/* 右侧拖动手柄：调整侧栏宽度 */
.ai-workshop-sidebar-resize {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 5;
    flex-shrink: 0;
}

.ai-workshop-sidebar-resize:hover,
.ai-workshop-sidebar-resize:active {
    background: rgba(107, 140, 255, 0.15);
}

.ai-workshop-sidebar-resize::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 2px;
    transform: translateY(-50%);
    width: 2px;
    height: 40px;
    border-radius: 1px;
    background: rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

.ai-workshop-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-workshop-title {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
}

/* 画布区域：视口容器，占满剩余空间；外框由 .ai-workshop-desktop 统一提供，此处仅保留与左侧栏分隔 */
.ai-workshop-canvas {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 100%;
    border-radius: 0;
    background-color: var(--bg-card, #1a1a1a);
    border: none;
    border-left: 1px solid var(--border-primary, rgba(255, 255, 255, 0.1));
    box-shadow: none;
    overflow: hidden;
    cursor: default;
    user-select: none;
}

.ai-workshop-canvas:active {
    cursor: default;
}

/* 左键框选时的矩形框（由 JS 动态创建，坐标相对视口） */
.ai-workshop-canvas-selection-box {
    position: absolute;
    pointer-events: none;
    border: 1px solid rgba(107, 140, 255, 0.7);
    background: rgba(107, 140, 255, 0.12);
    box-sizing: border-box;
}

/* 可平移缩放的桌布内层：zoom 控制缩放（目标分辨率重新光栅化，文字清晰），left/top 控制平移 */
.ai-workshop-canvas-inner {
    position: absolute;
    left: 0;
    top: 0;
    width: 10000px;
    height: 10000px;
    border-radius: var(--radius-lg, 8px);
    background-color: var(--bg-card, #1a1a1a);
}

/* 节点连线层：在网格之上、节点之下，拖拽连线与已连接线 */
.ai-workshop-node-connections {
    position: absolute;
    left: 0;
    top: 0;
    width: 10000px;
    height: 10000px;
    pointer-events: none;
    z-index: 1;
}

/* Alt 切线模式：按住 Alt 时 SVG 开启指针事件，可点击连线断开 */
.ai-workshop-node-connections.alt-cut-mode {
    pointer-events: auto;
}

/* 连线透明点击区（宽描边，便于精准点击细线），正常模式默认光标
 * pointer-events 由 JS setAttribute 直接写在元素属性上（优先级更高、更可靠） */
.ai-workshop-connection-hitbox {
    fill: none;
    stroke-width: 14;
    pointer-events: stroke;
    cursor: default;
}

/* Alt 切线模式下，悬停连线显示十字准星光标 */
.ai-workshop-node-connections.alt-cut-mode .ai-workshop-connection-hitbox {
    cursor: crosshair;
}

/* 连线悬停高亮（Alt 模式下鼠标移过时变红，表示将断开） */
.ai-workshop-connection-line.alt-hover {
    stroke: rgba(255, 80, 80, 0.9) !important;
    stroke-width: 3 !important;
}

/* 画布右上角操作区：置于内层之上，避免被 canvas-inner 遮挡 */
.ai-workshop-canvas-corner-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

.ai-workshop-canvas-corner-actions > button {
    pointer-events: auto;
}

/* Debug聊天 临时按钮：默认隐藏，仅当调试开关打开时由 JS 为面板添加 .ai-workshop-debug-enabled 后显示 */
.ai-workshop-debug-chat-btn {
    display: none;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 12px;
}
.ai-workshop-panel.ai-workshop-debug-enabled .ai-workshop-debug-chat-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: var(--radius-md, 6px);
    border: 1px solid var(--border-secondary, rgba(255, 255, 255, 0.08));
    outline: none;
    background-color: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    color: var(--text-secondary, #aaa);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ai-workshop-panel.ai-workshop-debug-enabled .ai-workshop-debug-chat-btn:hover {
    background-color: rgba(107, 140, 255, 0.16);
    border-color: rgba(107, 140, 255, 0.35);
    color: var(--text-accent, #6b8cff);
}
.ai-workshop-panel.ai-workshop-debug-enabled .ai-workshop-debug-chat-btn:active {
    transform: scale(0.96);
}

/* 画布标签栏：与画布一体，贴顶贴边，不单独浮起 */
.ai-workshop-canvas-tabs {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: stretch;
    gap: 0;
    pointer-events: none;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 12px;
    background: var(--bg-secondary, rgba(255, 255, 255, 0.03));
    padding: 6px 10px 0 10px;
    border-bottom: 1px solid var(--border-primary, rgba(255, 255, 255, 0.1));
    min-height: 36px;
    box-sizing: border-box;
}

.ai-workshop-canvas-tabs-list,
.ai-workshop-canvas-tabs > .ai-workshop-canvas-tab-add {
    pointer-events: auto;
}

.ai-workshop-canvas-tabs-list {
    display: flex;
    align-items: stretch;
    flex-wrap: nowrap;
    max-width: 320px;
    overflow: hidden;
}

.ai-workshop-canvas-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 8px 12px;
    margin-right: 2px;
    border-radius: 4px 4px 0 0;
    background-color: rgba(255, 255, 255, 0.06);
    color: #b0b0b0;
    cursor: pointer;
    border: none;
    outline: none;
    border-bottom: 2px solid transparent;
    max-width: 140px;
    min-width: 60px;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ai-workshop-canvas-tab:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

.ai-workshop-canvas-tab.is-active {
    background-color: rgba(107, 140, 255, 0.12);
    color: #ffffff;
    border-bottom-color: var(--text-accent, #6b8cff);
}

.ai-workshop-canvas-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 关闭按钮：始终显示（单标签时为清空画布，多标签时为关闭画布） */
.ai-workshop-canvas-tab-close {
    display: inline-flex;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 2px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    align-items: center;
    justify-content: center;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.ai-workshop-canvas-tab-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.ai-workshop-canvas-tab-add {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    margin-left: 6px;
    padding: 0;
    border-radius: 4px;
    border: none;
    outline: none;
    background-color: rgba(255, 255, 255, 0.08);
    color: #c0c0c0;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-workshop-canvas-tab-add:hover {
    background-color: rgba(107, 140, 255, 0.25);
    color: #ffffff;
}

/* 适配窗口按钮 */
.ai-workshop-fit-view-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: var(--radius-md, 6px);
    border: 1px solid var(--border-secondary, rgba(255, 255, 255, 0.08));
    outline: none;
    background-color: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    color: var(--text-secondary, #aaa);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}

.ai-workshop-fit-view-btn:hover {
    background-color: rgba(107, 140, 255, 0.16);
    border-color: rgba(107, 140, 255, 0.35);
    color: var(--text-accent, #6b8cff);
}

.ai-workshop-fit-view-btn:active {
    transform: scale(0.96);
}

.ai-workshop-fit-view-icon {
    width: 14px;
    height: 14px;
    display: block;
}

.ai-workshop-fit-view-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* 画布占位文案（SVG 矢量文字，位于桌布内层，随缩放平移且缩放不模糊） */
.ai-workshop-canvas-placeholder {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
}

.ai-workshop-canvas-placeholder-svg {
    display: block;
    width: 320px;
    height: 36px;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
}

.ai-workshop-canvas-placeholder-svg .ai-workshop-canvas-text-main {
    font-size: 13px;
    font-weight: 500;
    fill: #d0d0d0;
}

.ai-workshop-canvas-placeholder-svg .ai-workshop-canvas-text-sub {
    font-size: 11px;
    font-weight: normal;
    fill: #a6a6a6;
}

/* 保存工程 / 打开工程 按钮（与适配窗口同区，位于其左侧） */
.ai-workshop-project-save-btn,
.ai-workshop-project-open-btn {
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 12px;
    height: 24px;
    padding: 0 8px;
    border-radius: var(--radius-md, 6px);
    border: 1px solid var(--border-secondary, rgba(255, 255, 255, 0.08));
    outline: none;
    background-color: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    color: var(--text-secondary, #aaa);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease, border-color 0.15s ease;
}
.ai-workshop-project-save-btn:hover,
.ai-workshop-project-open-btn:hover {
    background-color: rgba(107, 140, 255, 0.16);
    border-color: rgba(107, 140, 255, 0.35);
    color: var(--text-accent, #6b8cff);
}
.ai-workshop-project-save-btn:active,
.ai-workshop-project-open-btn:active {
    transform: scale(0.96);
}

/* 保存工程：首次保存弹窗 */
.ai-workshop-project-save-mask,
.ai-workshop-project-open-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.ai-workshop-project-save-mask.is-visible,
.ai-workshop-project-open-mask.is-visible {
    opacity: 1;
    visibility: visible;
}
.ai-workshop-project-save-dialog,
.ai-workshop-project-open-dialog {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    background: #2d2d30;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    padding: 20px 24px;
    min-width: 320px;
    max-width: 90vw;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    font-family: "Microsoft YaHei", "微软雅黑", "SimSun", "宋体", "Arial", sans-serif;
    font-size: 13px;
    color: #e0e0e0;
}
.ai-workshop-project-save-dialog.is-visible,
.ai-workshop-project-open-dialog.is-visible {
    opacity: 1;
    visibility: visible;
}
.ai-workshop-project-save-title,
.ai-workshop-project-open-title {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
}
.ai-workshop-project-save-form label {
    display: block;
    margin-bottom: 4px;
    color: #b0b0b0;
    font-size: 12px;
}
.ai-workshop-project-save-form label + input {
    margin-bottom: 12px;
}
.ai-workshop-project-save-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: #1e1e1e;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 13px;
}
.ai-workshop-project-save-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
}
.ai-workshop-project-save-actions,
.ai-workshop-project-open-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.ai-workshop-project-save-cancel,
.ai-workshop-project-save-ok,
.ai-workshop-project-open-cancel {
    padding: 6px 14px;
    border-radius: 4px;
    border: none;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}
.ai-workshop-project-save-cancel,
.ai-workshop-project-open-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #b0b0b0;
}
.ai-workshop-project-save-ok {
    background: #0e639c;
    color: #ffffff;
}
.ai-workshop-project-save-ok:hover {
    background: #1177bb;
}
.ai-workshop-project-open-list {
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 12px;
}
.ai-workshop-project-open-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.ai-workshop-project-open-item:hover {
    background: rgba(255, 255, 255, 0.08);
}
.ai-workshop-project-open-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-workshop-project-open-item-time {
    flex-shrink: 0;
    margin-left: 12px;
    font-size: 11px;
    color: #888;
}
.ai-workshop-project-open-empty {
    display: none;
    padding: 24px;
    text-align: center;
    color: #888;
    font-size: 13px;
}
.ai-workshop-project-open-empty.is-visible {
    display: block;
}

