/* Left Sidebar: File Explorer */
#file-explorer { width: var(--sidebar-left-width); background: var(--bg-panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; }

/* Pane Resize Handle (shared left + right sidebars) */
.pane-resize-handle {
    height: 5px;
    flex-shrink: 0;
    background: var(--bg-dark);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    cursor: row-resize;
    z-index: 10;
    transition: background 0.15s;
}
.pane-resize-handle:hover,
.pane-resize-handle.is-resizing { background: var(--accent); }
.pane-collapsed + .pane-resize-handle {
    pointer-events: none;
    cursor: default;
    background: var(--bg-dark) !important;
    opacity: 0.4;
}

/* Split Panes (Pages vs Assets) */
.sidebar-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.sidebar-pane.pane-collapsed { flex: 0 0 auto; }
.sidebar-pane.pane-collapsed .pane-content { display: none; }

.sidebar-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--sidebar-header-bg);
}
.sidebar-header h3 {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin: 0;
}
.sidebar-actions {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 2px;
}
.sidebar-actions button {
    background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 2px 4px;
}
.sidebar-actions button:hover { color: var(--text-main); background: var(--hover-bg-strong); border-radius: 3px; }

/* Scripts Add (+) Dropdown */
.scripts-add-container {
    position: relative;
    display: inline-flex;
}
#btn-add-script {
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add-files{
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scripts-add-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 180px;
    background: var(--bg-panel, #2a2a2e);
    border: 1px solid var(--border, #444);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    padding: 4px 0;
    margin-top: 4px;
}
.scripts-add-item {
    position: relative;
    padding: 7px 12px;
    font-size: 12px;
    color: var(--text-muted, #aaa);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: nowrap;
}
.scripts-add-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main, #eee);
}
.scripts-add-arrow {
    font-size: 10px;
    margin-left: 8px;
    opacity: 0.5;
}
.scripts-add-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: -4px;
    min-width: 140px;
    background: var(--bg-panel, #2a2a2e);
    border: 1px solid var(--border, #444);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    padding: 4px 0;
    z-index: 1001;
}
.scripts-add-item:hover > .scripts-add-submenu {
    display: block;
}
.scripts-add-subitem {
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-muted, #aaa);
    cursor: pointer;
    white-space: nowrap;
}
.scripts-add-subitem:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main, #eee);
}

/* Level-3 flyout (font/theme lists) */
.scripts-add-subitem-parent {
    position: relative;
    justify-content: space-between;
}
.scripts-add-level3 {
    display: none;
    position: absolute;
    left: 100%;
    top: -4px;
    min-width: 210px;
    max-height: 360px;
    overflow-y: auto;
    background: var(--bg-panel, #2a2a2e);
    border: 1px solid var(--border, #444);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    padding: 4px 0;
    z-index: 1002;
}
.scripts-add-subitem-parent:hover > .scripts-add-level3 {
    display: block;
}
.scripts-add-level3::-webkit-scrollbar { width: 4px; }
.scripts-add-level3::-webkit-scrollbar-track { background: transparent; }
.scripts-add-level3::-webkit-scrollbar-thumb { background: var(--border, #444); border-radius: 2px; }
.scripts-add-level3-item {
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-muted, #aaa);
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.scripts-add-level3-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main, #eee);
}
.preset-swatches {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}
.preset-swatch {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: inline-block;
    flex-shrink: 0;
}
.preset-font-preview {
    font-size: 15px;
    line-height: 1;
    color: var(--text-main, #eee);
    flex-shrink: 0;
    opacity: 0.85;
    pointer-events: none;
}
.scripts-add-level3-section {
    padding: 4px 12px 2px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted, #888);
    opacity: 0.6;
    user-select: none;
}

.tree-view { flex: 1; overflow-y: auto; padding: 5px 0; }
.tree-item {
    padding: 4px 10px; cursor: pointer; display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    user-select: none;
    border: 1px solid transparent;
}
.tree-item:hover { color: var(--text-main); background: var(--hover-bg); }
.tree-item.active { background: rgba(0,122,204,0.2); color: var(--text-main); border-left: 2px solid var(--accent); }
.tree-indent { width: 15px; display: inline-block; flex-shrink: 0; }
.folder-icon { color: #dcb67a; }
.file-icon { color: #a0a0a0; }
.empty-state { padding: 20px; text-align: center; color: var(--text-muted); font-size: 12px; font-style: italic; }

.tree-view::-webkit-scrollbar { display: none; }
.tree-view { -ms-overflow-style: none; scrollbar-width: none; }

/* Drag & Drop Visuals */
.tree-item.drag-over {
    background: rgba(0, 122, 204, 0.2) !important;
    border: 1px dashed var(--accent);
}
.tree-item.drag-over * { pointer-events: none; }

/* Specific style for the Root Folder */
.root-folder {
    font-weight: 600;
    color: var(--text-main);
    padding: 6px 10px;
}

/* File Explorer: Collapsible Folders */
.folder-item { user-select: none; }
.folder-toggle {
    font-size: 9px;
    color: var(--text-muted);
    display: inline-block;
    width: 12px;
    flex-shrink: 0;
    text-align: center;
}
.folder-children.collapsed { display: none; }

/* File Explorer: Image Thumbnails */
.file-thumb-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 12px 6px;
}

.file-thumb-card {
    min-width: 0;
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 3px;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
    overflow: hidden;
}

.file-thumb-card:hover {
    background: var(--hover-bg);
    border-color: var(--border);
}

#file-tree .file-thumb-card img,
#file-tree .file-thumb-img,
#tree-assets .file-thumb-card img,
#tree-assets .file-thumb-img {
    width: 74px;
    max-width: 84px;
    height: 70px;
    max-height: 80px;
    object-fit: contain;
    border-radius: 3px;
    background: var(--thumb-img-bg);
    display: block;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.file-thumb-name {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 48px;
    width: 100%;
    line-height: 1.3;
}

.file-thumb-actions {
    position: absolute;
    top: 2px;
    right: 2px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 5;
}

.file-thumb-card:hover .file-thumb-actions {
    display: flex;
}

.file-thumb-btn {
    background: var(--thumb-btn-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px;
    width: 16px;
    height: 16px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.file-thumb-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.file-thumb-btn-delete:hover {
    background: #e5534b;
    border-color: #e5534b;
}

/* Global Block Items in Sidebar */
.global-block-item {
    padding: 5px 10px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    border: 1px solid transparent;
    transition: background 0.12s, color 0.12s;
}
.global-block-item:hover {
    color: var(--text-main);
    background: var(--hover-bg);
}
.global-block-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #58a6ff;
}
.global-block-unused .global-block-icon {
    color: var(--text-muted);
    opacity: 0.5;
}
.global-block-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
.global-block-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}
.global-block-drag {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0.5;
}
.global-block-drag svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}
.global-block-item:hover .global-block-drag {
    opacity: 1;
}
.global-block-delete {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    background: none;
    border: none;
    border-radius: 3px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.global-block-item:hover .global-block-delete {
    opacity: 1;
}
.global-block-delete svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}
.global-block-delete:hover {
    background: rgba(229, 83, 75, 0.2);
    color: #e5534b;
}

/* DOM Tree: img drop target */
.dom-tree-img-item {
    cursor: copy;
}

.dom-tree-drop-target {
    background: rgba(46, 160, 67, 0.2) !important;
    border-left: 2px solid #2ea043 !important;
    color: var(--text-main) !important;
    outline: 1px dashed #2ea043;
    border-radius: 2px;
}
