/*
 * Canonical MNZL hierarchical department picker.
 * Visual and interaction reference: com_ec&view=main.
 */
.mnzl-department-picker {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.mnzl-department-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #21262d;
    color: #f0f6fc;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    box-sizing: border-box;
}

.mnzl-department-trigger:hover,
.mnzl-department-trigger:focus-visible,
.mnzl-department-picker.is-open .mnzl-department-trigger {
    border-color: #8b949e;
    background: #2b3139;
    outline: none;
}

.mnzl-department-trigger__text {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mnzl-department-trigger__caret {
    flex: 0 0 auto;
    color: #8b949e;
    transition: transform .15s ease;
}

.mnzl-department-picker.is-open .mnzl-department-trigger__caret {
    transform: rotate(180deg);
}

.mnzl-department-dropdown {
    /* Coordinates and available height are calculated by departmentpicker.js.
       Fixed positioning keeps the dropdown outside modal scroll geometry. */
    position: fixed;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: 10050;
    width: auto;
    min-width: 0;
    max-width: calc(100vw - 16px);
    border: 1px solid #30363d;
    border-radius: 8px;
    background: #1a1f27;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
    overflow: hidden;
}

.mnzl-department-dropdown__head {
    padding: 10px 12px;
    border-bottom: 1px solid #30363d;
    color: #f0f6fc;
    font-size: 13px;
    font-weight: 700;
    background: #161b22;
}

.mnzl-department-tree {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 6px 0;
}

.mnzl-department-tree__item,
.mnzl-department-tree__children {
    min-width: 0;
}

.mnzl-department-tree__row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 30px;
    padding-right: 8px;
    padding-left: calc(8px + (var(--mnzl-department-tree-depth, 0) * 18px));
}

.mnzl-department-tree__row:hover {
    background: rgba(56, 139, 253, .08);
}

.mnzl-department-tree__row.is-active {
    background: rgba(46, 160, 67, .16);
}

.mnzl-department-tree__toggle,
.mnzl-department-tree__select {
    border: 0;
    background: transparent;
}

.mnzl-department-tree__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    padding: 0;
    color: #8b949e;
    cursor: pointer;
    transition: transform .15s ease, color .15s ease;
}

.mnzl-department-tree__toggle:hover {
    color: #f0f6fc;
}

.mnzl-department-tree__toggle.is-expanded {
    transform: rotate(90deg);
}

.mnzl-department-tree__spacer {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
}

.mnzl-department-tree__select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
    padding: 5px 0;
    color: #c9d1d9;
    font-size: 13px;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
}

.mnzl-department-tree__marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    color: transparent;
    font-size: 11px;
    font-weight: 700;
}

.mnzl-department-tree__row.is-active .mnzl-department-tree__marker {
    background: rgba(46, 160, 67, .28);
    color: #9be9a8;
}

.mnzl-department-tree__title {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: normal;
}

.mnzl-department-tree__empty {
    padding: 12px;
    color: #8b949e;
    font-size: 13px;
}

/* While the picker is open inside a modal, the tree is the only active
   scroll area. This prevents the modal and picker from showing two vertical
   scrollbars at the same time. */
.mf-modal__body.mnzl-department-picker-host-open,
.modal-body.mnzl-department-picker-host-open {
    overflow: hidden !important;
}

@media (max-width: 760px) {
    .mnzl-department-tree {
        max-height: 55vh;
    }
}

/* 1.0.77: у режимі перегляду дерево можна відкривати й розгортати,
   але вибір іншого підрозділу не змінює картку. */
.mnzl-department-picker.is-readonly .mnzl-department-tree__select {
    cursor: default;
}

.mnzl-department-picker.is-readonly .mnzl-department-tree__select:not(.is-readonly) {
    cursor: default;
}
