/* Tree View */

.tree-node { user-select: none; }

.tree-node-row {
    display: flex;
    align-items: center;
    gap: 8px;
    /* padding: 8px 12px; */
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s;
}

.tree-node-row:hover { background: var(--bg-hover); }

.tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: transform 0.2s, color 0.15s;
}

.tree-toggle:hover { color: var(--text); background: var(--bg-hover); }
.tree-toggle.expanded { transform: rotate(90deg); }

.tree-toggle svg { width: 14px; height: 14px; }

.tree-toggle.leaf { visibility: hidden; }

.tree-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--primary);
}

.tree-icon svg { width: 22px; height: 22px; }

.tree-name {
    font-size: 13.5px;
    color: var(--text);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-meta {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.tree-closed-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 6px;
}
.tree-closed-icon svg {
    width: 16px;
    height: 16px;
}

.tree-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.tree-node-row:hover .tree-actions { opacity: 1; }

.tree-children {
    margin-left: 28px;
    border-left: 1px solid var(--border);
    padding-left: 4px;
}

.tree-children.collapsed { display: none; }

.tree-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.tree-empty svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.3; }

/* Sync modal */
.sync-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 400;
    align-items: center;
    justify-content: center;
}

.sync-modal-overlay.show { display: flex; }

.sync-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.sync-modal h3 {
    font-size: 17px;
    color: var(--text);
    margin-bottom: 8px;
}

.sync-modal p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.sync-modal .sync-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sync-modal .btn { justify-content: center; width: 100%; }

.sync-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: var(--primary);
    font-size: 13px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.tree-node-row.highlight {
    background: rgba(250, 204, 21, 0.08) !important;
    border-radius: 6px;
}

.tree-node-row.highlight .tree-name {
    font-weight: 600;
}

.tree-name mark {
    background: rgba(250, 204, 21, 0.25);
    color: #facc15;
    border-radius: 2px;
    padding: 0 2px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

#treeSearch:focus {
    border-color: var(--primary) !important;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed !important;
}

.tree-index-icon {
    width: 16px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.tree-index-icon svg { width: 16px; height: 16px; }

.tree-file-node .tree-node-row { cursor: default; }

.tree-index-child {
    margin-left: 28px;
    border-left: 1px solid rgba(34,197,94,0.3);
    padding-left: 4px;
}

/* XML Modal */
.xml-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.xml-modal-overlay.show { display: flex; }

.xml-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.xml-code {
    font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #d4d4d4;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
    background: #1e1e2e;
    padding: 16px;
    border-radius: 8px;
}

.xml-tag { color: #569cd6; }
.xml-tag-closing { color: #569cd6; }
.xml-attr { color: #9cdcfe; }
.xml-val { color: #ce9178; }
.xml-comment { color: #6a9955; font-style: italic; }
.xml-decl { color: #808080; }
.xml-cdata { color: #ce9178; }
.xml-val { color: #005086; }

[data-theme="dark"] .xml-val { color: rgb(112,160,182); }

/* Index Options Modal */
.index-options-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.index-options-modal-overlay.show { display: flex; }

.index-options-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.index-option-cards {
    display: flex;
    gap: 12px;
}

.index-option-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    text-align: center;
}

.index-option-card:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
}
