/* ======================================================
   TREE PANEL
====================================================== */

.tree-panel {
    position: relative;
}

.tree-panel-toolbar {
    position: sticky;
    top: 72px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0 12px 0;
    margin-bottom: 10px;
    background: linear-gradient( to bottom, rgba(255,255,255,0.96), rgba(255,255,255,0.86) );
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #edf2f7;
}

.tree-header-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-header-title {
    font-size: 20px;
    font-weight: 800;
    color: #16243f;
    letter-spacing: -0.02em;
}

.tree-header-subtitle {
    font-size: 12px;
    color: #64748b;
}

.tree-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tree-count {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

/* ======================================================
   TREE STRUCTURE
====================================================== */

.tree-wrap {
    overflow: auto;
    padding-top: 4px;
    padding-right: 4px;
}

.tree-root,
.tree-children {
    list-style: none;
    margin: 0;
    padding-left: 0;
}

.tree-children {
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid #d9e2ec;
    overflow: hidden;
    transition: max-height 0.22s ease, opacity 0.18s ease;
    opacity: 1;
}

    .tree-children.is-collapsed {
        max-height: 0 !important;
        opacity: 0.25;
        overflow: hidden;
    }

.tree-node {
    margin: 2px 0;
}

/* ======================================================
   TREE ROW
====================================================== */

.tree-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 26px;
    padding: 4px 8px;
    border-radius: 14px;
    transition: background 0.14s ease, box-shadow 0.14s ease, transform 0.10s ease, border-color 0.14s ease;
    cursor: default;
    position: relative;
    border: 1px solid transparent;
}

    .tree-row.is-toggleable {
        cursor: pointer;
    }

    .tree-row:hover {
        background: #f3f6fb;
    }

    .tree-row.is-selected {
        background: #e9f1ff;
        border-color: #cfe0ff;
        box-shadow: inset 3px 0 0 #3b82f6;
    }

/* ======================================================
   EXPANDER
====================================================== */

.tree-expander {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
    color: #94a3b8;
    user-select: none;
    border-radius: 999px;
    opacity: 0.7;
    transition: background 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}

.tree-row:hover .tree-expander {
    background: rgba(148, 163, 184, 0.10);
    color: #2563eb;
    opacity: 1;
}

.tree-expander.is-hidden {
    visibility: hidden;
}

.tree-expander-icon {
    font-size: 10px;
    line-height: 1;
    opacity: 0.7;
    transition: transform 0.18s ease, color 0.14s ease, opacity 0.14s ease;
    transform-origin: center;
}

.tree-node.is-open > .tree-row .tree-expander-icon {
    transform: rotate(90deg);
}

/* ======================================================
   CONTENT
====================================================== */

.tree-icon {
    width: 20px;
    flex: 0 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    color: #5b6b82;
    font-size: 14px;
}

.tree-label {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.tree-title-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

.tree-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    color: #172033;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-subtitle {
    font-size: 12px;
    color: #64748b;
    line-height: 1.25;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ======================================================
   BASE LEVEL TYPOGRAPHY
====================================================== */

.tree-node[data-level="0"] > .tree-row {
    margin-bottom: 4px;
}

    .tree-node[data-level="0"] > .tree-row .tree-title {
        font-size: 15px;
        font-weight: 800;
        color: #122443;
    }

.tree-node[data-level="1"] > .tree-row .tree-title {
    font-size: 14px;
    font-weight: 750;
}

.tree-node[data-level="2"] > .tree-row .tree-title {
    font-size: 14px;
    font-weight: 700;
}

.tree-node[data-level="3"] > .tree-row .tree-title,
.tree-node[data-level="4"] > .tree-row .tree-title,
.tree-node[data-level="5"] > .tree-row .tree-title {
    font-size: 13px;
    font-weight: 650;
}

/* ======================================================
   SCROLLBAR
====================================================== */

.tree-wrap::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.tree-wrap::-webkit-scrollbar-thumb {
    background: #d8e1ed;
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.tree-wrap::-webkit-scrollbar-track {
    background: transparent;
}

/* ======================================================
   RESPONSIVE
====================================================== */

@media (max-width: 900px) {
    .tree-panel-toolbar {
        top: 58px;
    }
}
