.loc-tree-picker {
    position: relative;
}

.loc-tree-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: #fff;
}

.loc-tree-chevron {
    font-size: 12px;
    color: #6c757d;
    margin-left: 8px;
}

.loc-tree-panel {
    display: none;
    flex-direction: column;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    max-height: 360px;
}

.loc-tree-panel.open {
    display: flex;
}

.loc-tree-tabs {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
    padding: 0 10px;
    border-bottom: 1px solid #dee2e6;
    overflow-x: auto;
}

.loc-tree-tab {
    background: none;
    border: none;
    padding: 8px 10px;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    color: #6c757d;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.loc-tree-tab.active {
    color: #0d6efd;
    border-bottom-color: #0d6efd;
}

.loc-tree-search-wrap {
    flex: 0 0 auto;
    padding: 8px 10px;
}

.loc-tree-search {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.875rem;
}

.loc-tree-search:focus {
    outline: none;
    border-color: #0d6efd;
}

.loc-tree-list {
    flex: 1 1 auto;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.loc-tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.loc-tree-row {
    display: flex;
    align-items: center;
    padding: 6px 12px;
}

.loc-tree-toggle {
    width: 18px;
    flex: 0 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6c757d;
    font-size: 11px;
}

/* Self-contained CSS chevron (border trick) so the toggle renders regardless of
   whether the host page loads Font Awesome, Remix Icon, or any other icon font. */
.loc-tree-toggle:not(.loc-tree-toggle-empty)::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}

.loc-tree-node.expanded > .loc-tree-row > .loc-tree-toggle::before {
    transform: rotate(45deg);
}

.loc-tree-toggle-empty {
    cursor: default;
}

.loc-tree-label {
    margin-left: 4px;
    flex: 1 1 auto;
}

.loc-tree-label.selectable {
    cursor: pointer;
}

.loc-tree-label.selectable:hover {
    color: #0d6efd;
    text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
    .loc-tree-input {
        background: inherit;
    }

    .loc-tree-panel {
        background: #212529;
        border-color: #495057;
    }

    .loc-tree-tabs {
        border-bottom-color: #495057;
    }

    .loc-tree-search {
        background: #212529;
        border-color: #495057;
        color: #f8f9fa;
    }
}
