/* Fancytree - force original app's exact layout and spacing */

#tree, #fancytree, 
#tree *, #fancytree *,
#tree ul.fancytree-container,
#tree ul.fancytree-container *,
#fancytree ul.fancytree-container,
#fancytree ul.fancytree-container * {
    font-family: 'Calibri', 'Google Sans', 'Product Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
    font-size: 1.2rem !important;
    font-weight: 400 !important;
    line-height: 1.4rem !important;
    -webkit-font-smoothing: antialiased;
}

/* Remove ALL Fancytree default spacing/borders */
ul.fancytree-container {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    font-family: 'Calibri', 'Google Sans', 'Product Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
}

ul.fancytree-container ul {
    padding: 0 !important;
    margin: 0 !important;
}

ul.fancytree-container li {
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
}

/* CRITICAL: Make the node span a flex row so expander + title are inline */
span.fancytree-node {
    display: flex !important;
    align-items: center !important;
    padding: 2px 0 2px 8px !important;
    margin-bottom: 0.0625rem !important;
    min-height: 0 !important;
    line-height: 1.4rem !important;
    background: white;
    transition: background 0.15s ease;
}

span.fancytree-node:hover {
    background: #f0f0f0;
}

/* Selected: default (regular doc) – green; overridden below for sticky (yellow) and shared (blue) */
span.fancytree-active > span.fancytree-node {
    background: #D4EDDA !important;
}

/* Title: remove all default padding/margins - the node span handles row layout */
span.fancytree-title {
    display: inline-flex !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: none !important;
    font-family: 'Calibri', 'Google Sans', 'Product Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
    font-size: 1.2rem !important;
    font-weight: 400 !important;
    line-height: 1.4rem !important;
    color: #1f1f1f;
    cursor: pointer;
    flex: 1 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    -webkit-font-smoothing: antialiased;
}

/* Truncate long folder/doc names with ellipsis (like original) */
span.fancytree-title .fancytree-title-text {
    flex: 1 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* 6-dot grab icon on the right – show on hover (matches original topic list DD icon) */
#fancytree span.fancytree-node .fancytree-drag-handle {
    flex-shrink: 0;
    margin-left: auto;
    margin-right: 0;
    min-width: 14px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    color: #666;
    cursor: grab;
    user-select: none;
}
#fancytree span.fancytree-node .fancytree-drag-handle svg {
    display: block;
}
#fancytree span.fancytree-node:hover .fancytree-drag-handle {
    opacity: 1;
    pointer-events: auto;
}

/* Sticky doc in tree: yellow doc icon + yellow left border */
#fancytree span.fancytree-node.sticky-doc-node {
    border-left: 3px solid #FF8F00;
    padding-left: 5px !important; /* Reduce by 3px to compensate for border */
}
#fancytree span.fancytree-node.sticky-doc-node .doc-icon rect {
    fill: #FFECB3 !important;
    stroke: #FF8F00 !important;
}
#fancytree span.fancytree-node.sticky-doc-node .doc-icon line {
    stroke: #FF8F00 !important;
}

/* Shared doc in tree: blue doc icon + blue left border */
#fancytree span.fancytree-node.shared-doc-node {
    border-left: 3px solid #0D47A1;
    padding-left: 5px !important; /* Reduce by 3px to compensate for border */
}
#fancytree span.fancytree-node.shared-doc-node .doc-icon rect {
    fill: #BBDEFB !important;
    stroke: #0D47A1 !important;
}
#fancytree span.fancytree-node.shared-doc-node .doc-icon line {
    stroke: #0D47A1 !important;
}

/* Admin-shared doc in tree: purple doc icon + purple left border */
#fancytree span.fancytree-node.admin-shared-doc-node {
    border-left: 3px solid #7B1FA2;
    padding-left: 5px !important; /* Reduce by 3px to compensate for border */
}
#fancytree span.fancytree-node.admin-shared-doc-node .doc-icon rect {
    fill: #E1BEE7 !important;
    stroke: #7B1FA2 !important;
}
#fancytree span.fancytree-node.admin-shared-doc-node .doc-icon line {
    stroke: #7B1FA2 !important;
}

/* Remove indent from sticky/shared doc titles (so icons align) */
#fancytree span.fancytree-node.sticky-doc-node span.fancytree-title,
#fancytree span.fancytree-node.shared-doc-node span.fancytree-title,
#fancytree span.fancytree-node.admin-shared-doc-node span.fancytree-title {
    margin-left: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-radius: 0 !important;
}

/* Indent via left padding on the node span (not title) */
li > span.fancytree-node {
    padding-left: 8px !important;
}

li > ul > li > span.fancytree-node {
    padding-left: 28px !important; /* 8 + 20 */
}
li > ul > li > span.fancytree-node.sticky-doc-node,
li > ul > li > span.fancytree-node.shared-doc-node,
li > ul > li > span.fancytree-node.admin-shared-doc-node {
    padding-left: 25px !important; /* 28 - 3 for border */
}

li > ul > li > ul > li > span.fancytree-node {
    padding-left: 48px !important; /* 8 + 40 */
}
li > ul > li > ul > li > span.fancytree-node.sticky-doc-node,
li > ul > li > ul > li > span.fancytree-node.shared-doc-node,
li > ul > li > ul > li > span.fancytree-node.admin-shared-doc-node {
    padding-left: 45px !important; /* 48 - 3 for border */
}

li > ul > li > ul > li > ul > li > span.fancytree-node {
    padding-left: 68px !important; /* 8 + 60 */
}
li > ul > li > ul > li > ul > li > span.fancytree-node.sticky-doc-node,
li > ul > li > ul > li > ul > li > span.fancytree-node.shared-doc-node,
li > ul > li > ul > li > ul > li > span.fancytree-node.admin-shared-doc-node {
    padding-left: 65px !important; /* 68 - 3 for border */
}

/* Hide Fancytree default icon and checkbox */
span.fancytree-icon,
span.fancytree-checkbox {
    display: none !important;
}

/* Expander: 16x16 circle with +/- - inline in the row */
span.fancytree-expander {
    width: 16px !important;
    height: 16px !important;
    margin-right: 4px !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
    display: inline-block !important;
    position: relative !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
}

span.fancytree-expander:before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="none" stroke="%23666" stroke-width="1.5"/><line x1="5" y1="8" x2="11" y2="8" stroke="%23666" stroke-width="1.5"/><line x1="8" y1="5" x2="8" y2="11" stroke="%23666" stroke-width="1.5"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
}

span.fancytree-expanded > span.fancytree-expander:before {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="none" stroke="%23666" stroke-width="1.5"/><line x1="5" y1="8" x2="11" y2="8" stroke="%23666" stroke-width="1.5"/></svg>');
}

/* For docs without expander, make it 20px spacer like original */
span.fancytree-node:not(.fancytree-folder) > span.fancytree-expander {
    visibility: hidden;
    pointer-events: none;
    width: 20px !important;
    margin-right: 0 !important;
}

/* For empty folders - hide the + icon but keep spacing */
span.fancytree-expander[data-empty="true"]:before {
    content: none !important;
    background: none !important;
    background-image: none !important;
}

/* Custom icons - ensure proper sizing and spacing */
.custom-icon.folder-icon,
.custom-icon.doc-icon {
    flex-shrink: 0;
    display: block;
}

/* Drag helper */
div.fancytree-drag-helper {
    background: white;
    border: 2px solid #0B57D0;
    border-radius: 4px;
    padding: 8px 12px;
    box-shadow: 0 4px 12px rgba(11, 87, 208, 0.2);
    opacity: 0.95;
    font-size: 14px;
    font-weight: 500;
}

/* Drop indicators - professional highlight (no ugly lines) */
/* Before/after: highlight the target row with subtle blue glow */
#tree span.fancytree-drop-before > span.fancytree-node,
#tree span.fancytree-drop-after > span.fancytree-node {
    background: rgba(11, 87, 208, 0.08) !important;
    box-shadow: inset 0 0 0 1px rgba(11, 87, 208, 0.3) !important;
    border-radius: 4px;
}

/* Drop over (into folder): stronger highlight */
#tree span.fancytree-drop-over > span.fancytree-node {
    background: rgba(11, 87, 208, 0.12) !important;
    box-shadow: inset 0 0 0 2px #0B57D0 !important;
    border-radius: 4px;
}

/* Drag source */
span.fancytree-drag-source > span.fancytree-node {
    opacity: 0.5;
    background: #f5f5f5;
}

/* Remove expand animation that causes spacing issues */
ul.fancytree-container ul {
    animation: none !important;
}

/* Scrollbar */
#tree::-webkit-scrollbar {
    width: 8px;
}
#tree::-webkit-scrollbar-track {
    background: #f5f5f5;
}
#tree::-webkit-scrollbar-thumb {
    background: #bdbdbd;
    border-radius: 4px;
}
