﻿:root {
    --border: #c8c8c8;
    --row-hover: #eaf9ff;
    --bg: #fff;
    --tag-bg: #eef2f5;
    --tag-border: #cdd5df;
}

/* RESET */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ROOT (STACK ABOVE OTHER FORM CONTROLS) */
.treeselect {
    position: relative;
    width: 100%;
    font-size: 14px;
    z-index: 9999; /* 🔥 critical */
}

/* AUTO-INJECTED SHELL */
.treeselect-shell {
    position: relative;
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* SEARCH / INPUT BAR */
.treeselect-search-input {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 5px;
    min-height: 35px;
    background: transparent;
}

/* TAG CONTAINER */
.treeselect-tags-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* TAG */
.treeselect-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    font-size: 13px;
    background: var(--tag-bg);
    border: 1px solid var(--tag-border);
    border-radius: 12px;
    white-space: nowrap;
}

.tag-x {
    cursor: pointer;
    font-weight: bold;
    line-height: 1;
}

/* SEARCH INPUT */
.treeselect-search-input input {
    flex: 1;
    min-width: 60px;
    max-width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
}
/* CLEAR BUTTON */
.treeselect-clear-input {
    width: 22px;
    height: 22px;
    border: 1px solid #ccc;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    background: #fff;
    flex-shrink: 0;
}

/* DROPDOWN LIST (ALWAYS ON TOP) */
.treeselect-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 340px;
    overflow-y: auto;
    background: #fff;
    border-top: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    z-index: 9999; /* 🔥 above inputs, selects, datepickers */
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

/* TREE ROW */
.treeselect-node {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
}

    .treeselect-node:hover {
        background: var(--row-hover);
    }

    /* KEYBOARD FOCUS */
    .treeselect-node.focused {
        background: #e2f9ed;
        outline: 2px solid #b8f3d1;
    }

/* INDENT */
.node-indent {
    width: 18px;
    flex-shrink: 0;
}

/* TOGGLE ARROW */
.node-toggle {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

/* CHECKBOX */
.treeselect-node input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #445;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
    position: relative;
    flex-shrink: 0;
}

    /* CHECKED */
    .treeselect-node input[type="checkbox"]:checked {
        background: #1e90ff;
        border-color: #1e90ff;
    }

        .treeselect-node input[type="checkbox"]:checked::after {
            content: "";
            width: 12px;
            height: 12px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            mask: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20 6L9 17l-5-5" stroke="white" stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>');
            background: #fff;
        }

    /* PARTIAL */
    .treeselect-node input[type="checkbox"]:indeterminate {
        background: #1e90ff;
        border-color: #1e90ff;
    }

        .treeselect-node input[type="checkbox"]:indeterminate::after {
            content: "";
            width: 12px;
            height: 3px;
            background: #fff;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            border-radius: 2px;
        }

/* SEARCH HIGHLIGHT */
.treeselect-node mark {
    background: #ffe58f;
    color: #000;
    padding: 2px 3px;
    border-radius: 3px;
}

/* Parent nodes bold */
.treeselect-node.is-parent div:last-child {
    font-weight: 600;
}

/* Leaf nodes normal */
.treeselect-node:not(.is-parent) div:last-child {
    font-weight: 400;
}

/* ============================================================
   FORCE TREE LABELS TO SINGLE LINE + HORIZONTAL SCROLL
   ============================================================ */
.treeselect-node {
    white-space: nowrap;
}

.treeselect-list {
    overflow-x: auto;
}

.treeselect-node > div > div:last-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.treeselect-list::-webkit-scrollbar {
    height: 6px;
}

.treeselect-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.treeselect-tag-more {
    position: relative;
    cursor: pointer;
    font-size: 12px;
    color: #555;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}

.treeselect-more-popup {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 8px;
    z-index: 99999;
    min-width: 220px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.treeselect-popup-item {
    padding: 4px 6px;
    font-size: 13px;
    white-space: nowrap;
    gap: 8px;
}

.treeselect-tag span:first-child {
    max-width: 200px; 
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}
.treeselect-search-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    padding: 5px;
    min-height: 35px;
}

    .treeselect-search-input input {
        flex: 1;
        min-width: 160px; 
        border: none;
        outline: none;
        background: transparent;
        font-size: 14px;
    }