/* =========================================================
   BUILDER CSS - All styles scoped to #builderContainer
   ========================================================= */

/* Builder Container - Hidden by default */
#builderContainer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    
    /* Variables scoped to builder */
    --bg: #1e1e2e; 
    --panel: #252535; 
    --node: #333344; 
    --accent: #7aa2f7; 
    --border: #444;
    
    /* Layout */
    background: var(--bg); 
    color: #c0caf5; 
    font-family: 'Segoe UI', monospace;
    gap: 10px; 
    padding: 10px; 
    height: 100vh; 
    overflow: hidden; 
    font-size: 12px;
}

#builderContainer.active {
    display: flex;
}

/* Box-sizing only for builder elements */
#builderContainer *,
#builderContainer *::before,
#builderContainer *::after { 
    box-sizing: border-box; 
}

/* Scrollbars inside builder */
#builderContainer ::-webkit-scrollbar { width: 8px; height: 8px; }
#builderContainer ::-webkit-scrollbar-track { background: #111; }
#builderContainer ::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

/* Panels */
#builderContainer .panel { 
    background: var(--panel); 
    padding: 10px; 
    border-radius: 4px; 
    width: 240px; 
    min-width: 240px; 
    display: flex; 
    flex-direction: column; 
    border: 1px solid var(--border); 
}

#builderContainer .panel h3 { 
    margin: 0 0 10px 0; 
    color: var(--accent); 
    border-bottom: 1px solid var(--border); 
    padding-bottom: 5px; 
    font-size: 14px; 
}

/* Workspace */
#builderContainer .workspace { 
    flex: 1; 
    background: #16161e; 
    border: 1px solid var(--border); 
    border-radius: 4px; 
    padding: 10px; 
    overflow: auto; 
    display: flex; 
    gap: 10px; 
    min-width: 0; 
}

/* Tree Columns */
#builderContainer .tree-column { 
    flex: 1; 
    min-width: 180px; 
    display: flex; 
    flex-direction: column; 
    border-right: 1px dashed #333; 
    padding-right: 5px; 
    padding-bottom: 500px; 
}

#builderContainer .tree-column:last-child { 
    border-right: none; 
}

#builderContainer .tree-column h4 { 
    text-align: center; 
    color: #7dcfff; 
    background: #222; 
    padding: 8px; 
    margin: 0 0 10px 0; 
    border-radius: 3px; 
    font-size: 13px; 
    font-weight: bold; 
}

/* Main Root Drop Zone */
#builderContainer .main-root { 
    flex: 1; 
    min-height: 150px; 
    border: 2px dashed #333; 
    background: rgba(255,255,255,0.02); 
    border-radius: 4px; 
    margin-bottom: 5px; 
    transition: all 0.2s; 
    cursor: pointer; 
}

#builderContainer .main-root:hover { 
    background: rgba(255,255,255,0.05); 
    border-color: #555; 
}

/* Tree Blocks */
#builderContainer .tree-block { 
    padding-left: 12px; 
    min-height: 10px; 
    margin-left: 4px; 
    padding-bottom: 10px; 
}

#builderContainer .tree-block:not(.main-root) { 
    border-left: 1px solid #555; 
}

/* Move Buttons */
#builderContainer .btn-move { 
    cursor: pointer; 
    color: #666; 
    font-size: 11px;
    padding: 2px 4px; 
    border-radius: 3px; 
    background: rgba(0,0,0,0.2); 
    display: inline-block;
}

#builderContainer .btn-move:hover { 
    color: #fff; 
    background: var(--accent); 
}

/* Nodes */
#builderContainer .node { 
    background: var(--node); 
    padding: 4px 8px; 
    border-radius: 3px; 
    margin: 4px 0; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    cursor: pointer; 
    border: 1px solid #444; 
    font-size: 11px; 
    transition: all 0.1s; 
    flex-wrap: wrap; 
}

#builderContainer .node:hover { 
    border-color: var(--accent); 
    background: #3b3b4d; 
}

#builderContainer .node span.del { 
    color: #f7768e; 
    font-weight: bold; 
    cursor: pointer; 
    padding: 0 6px; 
    font-size: 14px; 
}

#builderContainer .node span.label { 
    font-weight: 700; 
    pointer-events: none; 
    letter-spacing: 0.5px; 
}

#builderContainer .node[data-cat="struct"] { 
    border-left: 3px solid #bb9af7; 
}

#builderContainer .node[data-cat="cond"] { 
    border-left: 3px solid #e0af68; 
}

#builderContainer .node[data-cat="act"] { 
    border-left: 3px solid #9ece6a; 
}

/* Buttons */
#builderContainer button.btn { 
    background: #3b4261; 
    color: white; 
    border: none; 
    padding: 6px; 
    margin-bottom: 3px; 
    width: 100%; 
    text-align: left; 
    cursor: pointer; 
    border-radius: 3px; 
    font-size: 11px; 
}

#builderContainer button.btn:hover { 
    background: var(--accent); 
    color: #111; 
}

#builderContainer button.btn:disabled { 
    background: #1a1a20; 
    color: #444; 
    cursor: not-allowed; 
    border-left: 3px solid #332222; 
    opacity: 0.6; 
}

#builderContainer button.btn-warn { 
    background: #e0af68; 
    color: #111; 
}

/* Palette */
#builderContainer .palette-header { 
    color: #666; 
    font-size: 10px; 
    margin-top: 10px; 
    margin-bottom: 4px; 
    font-weight: bold; 
}

/* Inspector */
#builderContainer #inspectorFields label { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 5px; 
}

#builderContainer #inspectorFields input { 
    background: #111; 
    border: 1px solid #555; 
    color: #fff; 
    width: 60px; 
    padding: 2px 5px; 
    border-radius: 3px; 
    text-align: right; 
}

/* Export Area */
#builderContainer .export-area { 
    width: 100%; 
    flex: 1; 
    background: #111; 
    color: #73daca; 
    border: 1px solid var(--border); 
    padding: 10px; 
    font-family: monospace; 
    resize: none; 
    font-size: 10px; 
    border-radius: 4px; 
    margin-top: 5px; 
}

/* Active Drop Zone */
#builderContainer .active-drop { 
    background: rgba(122,162,247,0.15); 
    border-color: var(--accent); 
}

/* --- UNIFORM EDITOR MODAL --- */
#builderContainer #uniModal { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.85); 
    z-index: 9999; 
    justify-content: center; 
    align-items: center; 
}

#builderContainer .modal-content { 
    background: var(--panel); 
    width: 700px; 
    height: 650px; 
    border: 1px solid var(--accent); 
    border-radius: 8px; 
    display: flex; 
    overflow: hidden; 
    box-shadow: 0 0 30px rgba(0,0,0,0.8); 
}

/* Modal Left Side: Controls */
#builderContainer .config-pane { 
    width: 320px; 
    padding: 15px; 
    border-right: 1px solid #444; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden;
}

#builderContainer .uni-tabs { 
    display: flex; 
    gap: 2px; 
    margin-bottom: 15px; 
    border-bottom: 1px solid #444; 
    padding-bottom: 5px; 
}

#builderContainer .uni-tab { 
    flex: 1; 
    background: #333; 
    border: none; 
    color: #888; 
    padding: 8px; 
    cursor: pointer; 
    font-weight: bold; 
    transition: 0.2s; 
}

#builderContainer .uni-tab.active { 
    background: var(--accent); 
    color: #111; 
}

#builderContainer .uni-tab:hover { 
    color: #fff; 
}

/* Modal Right Side: Preview */
#builderContainer .preview-pane { 
    flex: 1; 
    background: #16161e; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    position: relative; 
}

/* Uniform Controls Area */
#builderContainer #uniControlsArea { 
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
    display: flex; 
    flex-direction: column; 
    gap: 4px; 
}