/* ── Editor Right Panel — 共享可折叠操作区 ── */

.erp-toggle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 48px;
    border-radius: 6px 0 0 6px;
    background: rgba(20, 16, 36, 0.9);
    border: 1px solid rgba(100, 120, 200, 0.15);
    border-right: none;
    color: rgba(180, 190, 220, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 20;
    transition: all 0.2s ease;
    right: 100%;
}
.erp-toggle:hover {
    background: rgba(100, 70, 200, 0.25);
    color: #c0a8ff;
    border-color: rgba(140, 100, 255, 0.3);
}

.erp-container {
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: rgba(12, 10, 20, 0.92);
    border-left: 1px solid rgba(100, 120, 200, 0.12);
    backdrop-filter: blur(12px);
    overflow: hidden;
    transition: width 0.25s ease;
    z-index: 15;
}
.erp-container.collapsed {
    width: 0 !important;
    border-left-color: transparent;
}

/* ── Tab 栏 ── */
.erp-tabs {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(100, 120, 200, 0.1);
    background: rgba(8, 6, 18, 0.6);
    min-height: 38px;
}

.erp-tab {
    flex: 1;
    padding: 9px 4px;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
    border: none;
    background: transparent;
    color: rgba(180, 190, 220, 0.4);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
}
.erp-tab:hover {
    color: rgba(200, 210, 240, 0.7);
    background: rgba(100, 70, 200, 0.06);
}
.erp-tab.active {
    color: #c0a8ff;
    font-weight: 700;
    border-bottom-color: #9070ff;
    background: rgba(100, 70, 200, 0.08);
}

/* ── 内容区 ── */
.erp-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}
.erp-body::-webkit-scrollbar { width: 4px; }
.erp-body::-webkit-scrollbar-track { background: transparent; }
.erp-body::-webkit-scrollbar-thumb { background: rgba(140, 100, 255, 0.2); border-radius: 2px; }

/* ── 搜索框 ── */
.erp-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid rgba(100, 120, 200, 0.12);
    border-radius: 8px;
    background: rgba(14, 12, 24, 0.8);
    color: #e0e4f8;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 10px;
}
.erp-search:focus { border-color: rgba(140, 100, 255, 0.35); }
.erp-search::placeholder { color: rgba(140, 160, 200, 0.3); }

/* ── 分类标签 ── */
.erp-category-bar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.erp-category-tag {
    padding: 3px 10px;
    font-size: 10px;
    border-radius: 12px;
    border: 1px solid rgba(100, 120, 200, 0.12);
    background: rgba(100, 70, 200, 0.06);
    color: rgba(180, 190, 220, 0.5);
    cursor: pointer;
    transition: all 0.15s;
}
.erp-category-tag:hover { border-color: rgba(140, 100, 255, 0.3); color: rgba(200, 210, 240, 0.7); }
.erp-category-tag.active {
    background: rgba(100, 70, 200, 0.2);
    border-color: rgba(140, 100, 255, 0.4);
    color: #c0a8ff;
    font-weight: 600;
}

/* ── 资产/模板卡片网格 ── */
.erp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.erp-grid.single-col {
    grid-template-columns: 1fr;
}

.erp-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(100, 120, 200, 0.1);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}
.erp-card:hover {
    border-color: rgba(140, 100, 255, 0.35);
    transform: translateY(-1px);
    background: rgba(100, 70, 200, 0.06);
}
.erp-card-thumb {
    width: 100%;
    aspect-ratio: 16 / 10;
    background: rgba(10, 12, 20, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: rgba(140, 100, 255, 0.4);
    overflow: hidden;
}
.erp-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.erp-card-info {
    padding: 6px 8px;
}
.erp-card-name {
    font-size: 11px;
    font-weight: 600;
    color: rgba(220, 225, 248, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.erp-card-desc {
    font-size: 9px;
    color: rgba(180, 190, 220, 0.4);
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── 角色资产卡（横向） ── */
.erp-char-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(100, 120, 200, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.erp-char-card:hover {
    border-color: rgba(140, 100, 255, 0.35);
    background: rgba(100, 70, 200, 0.06);
}
.erp-char-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(100, 70, 200, 0.2);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.erp-char-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}
.erp-char-name {
    font-size: 12px;
    font-weight: 600;
    color: rgba(220, 225, 248, 0.85);
}
.erp-char-tag {
    font-size: 9px;
    color: rgba(140, 100, 255, 0.5);
    margin-top: 1px;
}

/* ── 智能体列表 ── */
.erp-agent-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(100, 120, 200, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 6px;
}
.erp-agent-card:hover {
    border-color: rgba(140, 100, 255, 0.35);
    background: rgba(100, 70, 200, 0.08);
}
.erp-agent-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.erp-agent-info { flex: 1; min-width: 0; }
.erp-agent-name {
    font-size: 12px;
    font-weight: 700;
    color: rgba(220, 225, 248, 0.9);
}
.erp-agent-role {
    font-size: 10px;
    color: rgba(180, 190, 220, 0.45);
    margin-top: 1px;
}
.erp-agent-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.erp-agent-status.online { background: #50c878; box-shadow: 0 0 6px rgba(80, 200, 120, 0.4); }
.erp-agent-status.offline { background: rgba(140, 160, 200, 0.25); }

/* ── 预制资产标签栏 ── */
.erp-prefab-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    padding: 2px;
}
.erp-prefab-tab {
    flex: 1;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(180, 190, 220, 0.45);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}
.erp-prefab-tab:hover { color: rgba(200, 210, 240, 0.7); }
.erp-prefab-tab.active {
    background: rgba(100, 70, 200, 0.2);
    color: #b090ff;
}

/* ── 横向滚动容器 ── */
.erp-prefab-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(140, 100, 255, 0.15) transparent;
    margin-bottom: 8px;
    padding-bottom: 4px;
}
.erp-prefab-scroll::-webkit-scrollbar { height: 4px; }
.erp-prefab-scroll::-webkit-scrollbar-track { background: transparent; }
.erp-prefab-scroll::-webkit-scrollbar-thumb { background: rgba(140, 100, 255, 0.2); border-radius: 2px; }

.erp-prefab-grid {
    display: grid;
    grid-template-rows: repeat(2, 1fr);
    grid-auto-flow: column;
    grid-auto-columns: 72px;
    gap: 6px;
    min-width: min-content;
}

/* ── 基础形状网格（旧兼容） ── */
.erp-shape-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}
.erp-shape-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(100, 120, 200, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.erp-shape-cell:hover {
    border-color: rgba(140, 100, 255, 0.35);
    background: rgba(100, 70, 200, 0.08);
    transform: translateY(-1px);
}
.erp-shape-cell.active {
    border-color: rgba(140, 100, 255, 0.5);
    background: rgba(100, 70, 200, 0.15);
    box-shadow: 0 0 8px rgba(140, 100, 255, 0.15);
}
.erp-shape-cell.active .erp-shape-label { color: #b090ff; }
.erp-shape-icon { font-size: 22px; line-height: 1.2; display: flex; align-items: center; justify-content: center; text-align: center; min-height: 26px; }
.erp-char-avatar-icon svg { width: 28px; height: 36px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }
.erp-shape-label { font-size: 9px; color: rgba(180, 190, 220, 0.5); }
.erp-lego-cell:hover { border-color: rgba(200, 160, 100, 0.4); background: rgba(200, 160, 100, 0.08); }

/* ── Agent 对话框 ── */
.erp-agent-active { border-color: rgba(140, 100, 255, 0.5) !important; background: rgba(100, 70, 200, 0.12) !important; }

.erp-chat-box {
    margin-top: 10px;
    border: 1px solid rgba(100, 120, 200, 0.15);
    border-radius: 10px;
    background: rgba(8, 6, 18, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 160px;
}
.erp-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(220, 225, 248, 0.8);
    border-bottom: 1px solid rgba(100, 120, 200, 0.1);
    flex-shrink: 0;
}
.erp-chat-close {
    background: none;
    border: none;
    color: rgba(180, 190, 220, 0.4);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
}
.erp-chat-close:hover { color: rgba(220, 100, 100, 0.8); }

.erp-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    min-height: 80px;
    max-height: 200px;
}
.erp-chat-messages::-webkit-scrollbar { width: 3px; }
.erp-chat-messages::-webkit-scrollbar-thumb { background: rgba(140, 100, 255, 0.2); border-radius: 2px; }

.erp-chat-empty {
    text-align: center;
    padding: 20px 8px;
    font-size: 10px;
    color: rgba(140, 160, 200, 0.3);
}
.erp-chat-bubble {
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.5;
    margin-bottom: 6px;
    max-width: 90%;
    word-break: break-word;
}
.erp-chat-user {
    background: rgba(100, 70, 200, 0.2);
    color: rgba(220, 225, 248, 0.9);
    margin-left: auto;
    border-bottom-right-radius: 3px;
}
.erp-chat-agent {
    background: rgba(60, 80, 120, 0.2);
    color: rgba(200, 210, 240, 0.8);
    margin-right: auto;
    border-bottom-left-radius: 3px;
}

.erp-chat-input-row {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid rgba(100, 120, 200, 0.1);
    flex-shrink: 0;
}
.erp-chat-input {
    flex: 1;
    padding: 6px 10px;
    font-size: 11px;
    border: 1px solid rgba(100, 120, 200, 0.12);
    border-radius: 6px;
    background: rgba(14, 12, 24, 0.8);
    color: #e0e4f8;
    outline: none;
    box-sizing: border-box;
}
.erp-chat-input:focus { border-color: rgba(140, 100, 255, 0.35); }
.erp-chat-input::placeholder { color: rgba(140, 160, 200, 0.3); }
.erp-chat-send {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: rgba(100, 70, 200, 0.3);
    color: #c0a8ff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.erp-chat-send:hover { background: rgba(100, 70, 200, 0.5); }

/* ── 代码文件树（Studio） ── */
.erp-code-tree {
    margin-bottom: 10px;
}
.erp-code-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
    margin-bottom: 2px;
}
.erp-code-file:hover { background: rgba(100, 70, 200, 0.06); }
.erp-code-file.active {
    background: rgba(100, 70, 200, 0.12);
    border-left: 2px solid #9070ff;
}
.erp-code-file-icon { font-size: 14px; flex-shrink: 0; }
.erp-code-file-name {
    flex: 1;
    font-size: 11px;
    font-weight: 500;
    color: rgba(220, 225, 248, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.erp-code-file-type {
    font-size: 9px;
    color: rgba(140, 160, 200, 0.35);
    flex-shrink: 0;
}

.erp-code-preview {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(100, 120, 200, 0.1);
    border-radius: 8px;
    background: rgba(10, 12, 20, 0.5);
    overflow: hidden;
}
.erp-code-preview-name {
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(180, 190, 220, 0.6);
    border-bottom: 1px solid rgba(100, 120, 200, 0.08);
    flex-shrink: 0;
}
.erp-code-block {
    flex: 1;
    margin: 0;
    padding: 8px 10px;
    font-size: 10px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    line-height: 1.5;
    color: rgba(200, 210, 230, 0.7);
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.erp-code-block::-webkit-scrollbar { width: 3px; }
.erp-code-block::-webkit-scrollbar-thumb { background: rgba(140, 100, 255, 0.15); border-radius: 2px; }

.erp-code-actions {
    padding: 6px 8px;
    border-top: 1px solid rgba(100, 120, 200, 0.08);
    flex-shrink: 0;
}
.erp-code-send-btn {
    width: 100%;
    padding: 6px 10px;
    font-size: 10px;
    border: 1px solid rgba(140, 100, 255, 0.2);
    border-radius: 6px;
    background: rgba(100, 70, 200, 0.1);
    color: #c0a8ff;
    cursor: pointer;
    transition: all 0.15s;
}
.erp-code-send-btn:hover {
    background: rgba(100, 70, 200, 0.2);
    border-color: rgba(140, 100, 255, 0.4);
}

/* ── 空状态 ── */
.erp-empty {
    text-align: center;
    padding: 32px 16px;
    color: rgba(140, 160, 200, 0.3);
    font-size: 12px;
}
.erp-empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.4;
}

/* ── Section 标题 ── */
.erp-section-title {
    font-size: 10px;
    font-weight: 700;
    color: rgba(140, 160, 200, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 14px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(100, 120, 200, 0.06);
}
.erp-section-title:first-child { margin-top: 0; }

/* ── Studio 适配 ── */
.studio-main .erp-container {
    background: #161822;
    border-left-color: #2a2e40;
    backdrop-filter: none;
}
.studio-main .erp-tabs {
    background: #1a1e2a;
    border-bottom-color: #2a2e40;
}
.studio-main .erp-tab {
    color: #666;
}
.studio-main .erp-tab.active {
    color: #a0c0ff;
    border-bottom-color: #6080ff;
}
.studio-main .erp-toggle {
    background: #1a1e2a;
    border-color: #2a2e40;
    color: #666;
}
.studio-main .erp-toggle:hover {
    background: rgba(100, 140, 255, 0.15);
    color: #a0c0ff;
}

/* ── Agent Dock（底部固定） ── */
.erp-agent-dock {
    flex-shrink: 0;
    border-top: 1px solid rgba(100, 120, 200, 0.15);
    background: rgba(10, 8, 18, 0.95);
    padding: 8px 12px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(140, 100, 255, 0.15) transparent;
}
.erp-agent-dock::-webkit-scrollbar { width: 3px; }
.erp-agent-dock::-webkit-scrollbar-thumb { background: rgba(140, 100, 255, 0.2); border-radius: 2px; }

/* ── Script Template Chips ── */
.erp-script-tpl-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    font-size: 10px;
    background: rgba(100, 140, 255, 0.08);
    border: 1px solid rgba(100, 140, 255, 0.2);
    border-radius: 12px;
    color: rgba(180, 190, 220, 0.7);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.erp-script-tpl-chip:hover {
    background: rgba(100, 140, 255, 0.2);
    border-color: rgba(100, 140, 255, 0.4);
    color: #c0d0ff;
}
.erp-script-tpl-chip span {
    font-size: 11px;
}
