/* The structure tree (Shared/NetworkStructure): picking a place in a network, viewing a network's structure,
   building it. Mockup 005 variant A (docs/superpowers/specs/2026-10-23-network-structure-tree/mockup-005.jpg).

   Every selector starts with .vn-structure, the element the host wraps the tree in. It is a size container,
   so the tree and the picker narrow by their own width, not the window's. Colours are theme.css's --vn-*
   tokens; the few literals are the mockup's tints that have no token.

   A plain stylesheet rather than scoped .razor.css: a scoped stylesheet of a new component reaches the bundle
   only on a full rebuild. Linked in Pages/_Layout.cshtml before theme.css. */

.vn-structure {
    container-type: inline-size;
    color: var(--vn-text);
    font-size: 13px;
    line-height: 1.4;
}
.vn-structure *, .vn-structure *::before, .vn-structure *::after { box-sizing: border-box; }
.vn-structure .st-ic { flex-shrink: 0; display: block; }
/* The tree's own buttons only: a host's button in ToolbarEnd or RowEnd keeps its own (Bootstrap) colours. */
.vn-structure :is(.st-chev, .st-clear, .st-btn-q, .st-btn-s, .st-ibtn) { font: inherit; color: inherit; }
/* The panel's purple, not --vn-focus: the pink #E46BE0 is 2.8:1 on white, below the 3:1 a focus indicator needs
   (WCAG 2.1, 1.4.11); #7A4DB0 is 6.0:1 (mockup 010). */
.vn-structure :focus-visible { outline: 2px solid var(--vn-ring); outline-offset: 2px; }
.vn-structure mark { background: #FBE0F7; color: inherit; padding: 0 1px; border-radius: 3px; font-weight: 700; }

.vn-structure .st-loading,
.vn-structure .st-empty { padding: 26px 12px; text-align: center; color: var(--vn-label); font-size: 13px; }
.vn-structure .st-empty-note { padding: 8px 12px 10px calc(8px + 24px + 10px); color: var(--vn-label); font-size: 12.5px; }
.vn-structure .st-quiet { font-size: 12.5px; color: var(--vn-label); padding: 0 2px; }

/* ─── Picker layout (mockup 010 C): the search field with the choice as its footer, then the tree ─── */

.vn-structure.st-picker { display: flex; flex-direction: column; gap: 12px; }

/* ─── Toolbar: search field, expand and collapse ───────────────────────────────────────────────── */

.vn-structure .st-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vn-structure .st-search {
    height: 40px; min-width: 0; border-radius: 999px; background: var(--vn-field); padding: 0 8px 0 16px;
    display: flex; align-items: center; gap: 10px; flex: 1 1 220px;
}
.vn-structure .st-search:focus-within { background: #fff; box-shadow: 0 0 0 2px var(--vn-ring); }
.vn-structure .st-search .st-ic { color: var(--vn-purple); }
/* theme.css styles every input in main with a selector of six :not()s; the field inside the pill is bare. */
.vn-structure .st-search input,
.vn-structure .st-find-field input {
    flex: 1; min-width: 0; border: 0 !important; outline: 0; background: transparent !important; box-shadow: none !important;
    height: 100% !important; border-radius: 0 !important; padding: 0 !important; font-size: 14px !important; color: var(--vn-text);
}
.vn-structure .st-search input::placeholder,
.vn-structure .st-find-field input::placeholder { color: #8C85A0; }
.vn-structure .st-hits { font-size: 11.5px; font-weight: 600; color: var(--vn-label); white-space: nowrap; flex-shrink: 0; }
.vn-structure .st-clear {
    border: 0; background: transparent; color: var(--vn-label); cursor: pointer; padding: 4px; border-radius: 999px; display: grid; flex-shrink: 0;
}
.vn-structure .st-clear:hover { background: var(--vn-soft-hover); color: var(--vn-indigo); }

.vn-structure .st-btn-q,
.vn-structure .st-btn-s {
    height: 38px; padding: 0 14px; border-radius: 999px; border: 0; font-weight: 700; font-size: 13px; color: var(--vn-indigo);
    display: inline-flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.vn-structure .st-btn-q { background: transparent; }
.vn-structure .st-btn-q:hover { background: var(--vn-soft); }
.vn-structure .st-btn-s { background: var(--vn-soft); padding: 0 16px; }
.vn-structure .st-btn-s:hover { background: var(--vn-soft-hover); }
.vn-structure .st-btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; gap: 6px; }
.vn-structure .st-ibtn {
    width: 30px; height: 30px; border-radius: 999px; border: 0; background: transparent; color: var(--vn-head);
    display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.vn-structure .st-ibtn:hover { background: var(--vn-soft-hover); color: var(--vn-indigo); }
.vn-structure .st-ibtn.is-bad:hover { background: var(--vn-bad-soft); color: var(--vn-bad); }

/* ─── The keys, under a picking tree, only while the keyboard works it ─────────────────────────────
   Always in the markup, as the tree's description for screen readers; shown when a key was pressed in the tree
   (is-keys) and the focus is still in it. */

.vn-structure .st-keys { display: none; justify-content: flex-end; flex-wrap: wrap; gap: 4px 5px; align-items: center;
    padding: 6px 2px 0; font-size: 11.5px; color: var(--vn-label); }
.vn-structure .st-shell:focus-within .st-tree.is-keys ~ .st-keys { display: flex; }
.vn-structure .st-keys kbd,
.vn-structure .st-drop-keys kbd {
    font: 600 11px Inter, sans-serif; background: var(--vn-field); color: var(--vn-head); padding: 1px 6px; border-radius: 5px;
    box-shadow: inset 0 -1px 0 #DDD6E8; margin-left: 4px;
}

/* ─── The tree box and its rows ────────────────────────────────────────────────────────────────── */

.vn-structure .st-shell > .st-toolbar + .st-tree { margin-top: 10px; }
.vn-structure .st-tree { max-height: 430px; overflow: auto; border-radius: 12px; box-shadow: inset 0 0 0 1px #ECE7F4; padding: 6px; }
.vn-structure .st-shell.is-build .st-tree { max-height: 560px; }
/* The whole tree is framed while it has the keyboard's focus and no row is framed (has-current); then the row is. */
.vn-structure .st-tree:focus-visible { outline: 0; }
.vn-structure .st-tree:focus-visible:not(.has-current) { box-shadow: inset 0 0 0 2px var(--vn-ring); }

.vn-structure .st-row {
    position: relative; display: flex; align-items: center; gap: 9px; min-height: 38px;
    padding: 5px 10px 5px calc(8px + var(--d, 0) * 24px); border-radius: 9px;
}
.vn-structure .st-row:hover { background: #FAF8FD; }
.vn-structure .st-row.is-pickable { cursor: pointer; }
.vn-structure .st-row.is-on { background: rgba(90, 46, 142, .09); }
.vn-structure .st-row.is-on .st-nm { color: var(--vn-indigo); }
.vn-structure .st-shell:focus-within .st-tree.is-keys .st-row.is-kb { box-shadow: inset 0 0 0 2px var(--vn-ring); }

.vn-structure .st-chev {
    width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--vn-head);
    display: grid; place-items: center; cursor: pointer; flex-shrink: 0; margin-left: -2px; padding: 0;
}
.vn-structure .st-chev:hover { background: var(--vn-soft-hover); }
.vn-structure .st-chev .st-ic { transition: transform .15s; }
.vn-structure .st-chev.is-open .st-ic { transform: rotate(90deg); }
.vn-structure .st-chev-sp { width: 24px; flex-shrink: 0; margin-left: -2px; }

.vn-structure .st-label { display: flex; flex-direction: column; min-width: 0; }
.vn-structure .st-nm { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.vn-structure .st-row[data-level="Network"] .st-nm { font-weight: 800; }
.vn-structure .st-row[data-level="Group"] .st-nm { font-weight: 700; }
.vn-structure .st-path { font-size: 11.5px; color: var(--vn-label); overflow-wrap: anywhere; }
.vn-structure .st-sub { font-size: 12px; color: var(--vn-label); white-space: nowrap; }
.vn-structure .st-push { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.vn-structure .st-count {
    font-size: 11.5px; font-weight: 600; color: var(--vn-label); background: var(--vn-field); border-radius: 999px; padding: 2px 8px;
    white-space: nowrap; font-variant-numeric: tabular-nums; flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px;
}
.vn-structure .st-count.is-zero { background: transparent; color: #A69FB7; }

.vn-structure .st-radio {
    width: 18px; height: 18px; border-radius: 999px; border: 2px solid #C9C1D8; display: grid; place-items: center; flex-shrink: 0;
}
.vn-structure .st-row.is-on .st-radio { border-color: var(--vn-purple); }
.vn-structure .st-row.is-on .st-radio::after { content: ""; width: 8px; height: 8px; border-radius: 999px; background: var(--vn-purple); }

.vn-structure .st-below { margin: 2px 10px 6px calc(8px + var(--d, 0) * 24px + 34px); }

/* ─── Level marks: the network a building, a group a map pin, a franchisee a person ──────────────
   16 px in a row, 15 px in the "Wybrane miejsce" path. The franchisee is in --vn-label, not the lighter
   #A69FB7 of the old dot, so a line icon keeps 3:1 contrast on white. */

.vn-structure .st-mark { flex-shrink: 0; display: inline-grid; place-items: center; width: 16px; height: 16px; }
.vn-structure .st-mark.is-network { color: var(--vn-indigo); }
.vn-structure .st-mark.is-group { color: var(--vn-ring); }
.vn-structure .st-mark.is-franchisee { color: var(--vn-label); }
.vn-structure .st-seg .st-mark,
.vn-structure .st-seg .st-mark .st-ic { width: 15px; height: 15px; }

/* ─── Stores: leaf rows on the company page only, each a link to the store's page ─────────────────
   The mark is the store of the count pills at row size, in --vn-head (7.6:1 on white), apart from the franchisee's
   grey. The name is the link: the panel's links are purple, a store reads as a row, so it keeps the text colour and
   turns indigo with an underline under the pointer. The details and the path are quiet, as a franchisee's path. */

.vn-structure .st-mark.is-store { color: var(--vn-head); }
.vn-structure .st-row.is-store { cursor: pointer; }
.vn-structure .st-row.is-store .st-nm { font-weight: 500; }
/* The padding gives the keyboard's ring room around the text; the negative margin keeps the text where it was. */
.vn-structure .st-store { color: inherit; text-decoration: none; border-radius: 6px; padding: 2px 6px; margin: -2px -6px; }
.vn-structure .st-row.is-store:hover .st-nm { color: var(--vn-indigo); text-decoration: underline; text-underline-offset: 2px; }
.vn-structure .st-store-sub { font-size: 11.5px; color: var(--vn-label); overflow-wrap: anywhere; }

/* ─── Building: tags, row actions, a row marked for deletion, the rename field ───────────────── */

.vn-structure .st-tag { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; white-space: nowrap; flex-shrink: 0; }
.vn-structure .st-tag.is-new { background: #E3F4EC; color: var(--vn-ok); }
.vn-structure .st-tag.is-renamed { background: #FDF1DA; color: #8A5A00; }
.vn-structure .st-tag.is-deleted { background: var(--vn-bad-soft); color: var(--vn-bad); }
.vn-structure .st-tag.is-current { background: var(--vn-soft); color: var(--vn-purple); }

.vn-structure .st-row.is-deleted .st-nm,
.vn-structure .st-row.is-under-deleted .st-nm { text-decoration: line-through; color: #A69FB7; }

.vn-structure .st-actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .1s; }
.vn-structure .st-row:hover .st-actions,
.vn-structure .st-row:focus-within .st-actions,
.vn-structure .st-row.is-deleted .st-actions { opacity: 1; }
@media (hover: none) {
    .vn-structure .st-actions { opacity: 1; }
}

.vn-structure .st-input {
    height: 34px !important; border-radius: 10px !important; background: #fff !important; border: 0 !important;
    box-shadow: 0 0 0 2px var(--vn-ring) !important; padding: 0 10px; font-weight: 600; font-size: 13.5px !important;
    color: var(--vn-text); min-width: 0; width: 100%; outline: 0;
}
.vn-structure .st-input.is-bad { box-shadow: 0 0 0 2px var(--vn-bad) !important; }

/* ─── Notes: a refusal, a network switched, the structure that could not be read ─────────────── */

.vn-structure .st-note {
    display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; border-radius: 10px; padding: 8px 12px;
    color: var(--vn-bad); background: var(--vn-bad-soft);
}
.vn-structure .st-note.is-info { color: var(--vn-head); background: var(--vn-soft); }
.vn-structure .st-note .st-ic { margin-top: 1px; }

/* ─── The summary line: the footer of the picker's search field ──────────────────────────────────
   One line: what to search or click while nothing is chosen (grey), then "Wybrane", the path and the level tag. */

.vn-structure .st-summary {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-height: 42px; padding: 8px 14px; min-width: 0;
    border-radius: 12px; background: rgba(90, 46, 142, .08);
}
.vn-structure .st-summary.is-empty,
.vn-structure .st-summary.is-bad { background: var(--vn-field); color: var(--vn-label); flex-wrap: nowrap; gap: 9px; }
.vn-structure .st-summary.is-empty .st-ic { color: var(--vn-ring); }
.vn-structure .st-summary.is-bad { color: var(--vn-bad); background: var(--vn-bad-soft); font-weight: 600; }
.vn-structure .st-summary-lbl { font-size: 12px; font-weight: 600; color: var(--vn-label); }
.vn-structure .st-place { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; min-width: 0; font-size: 13.5px; }
.vn-structure .st-seg { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.vn-structure .st-seg.is-last { color: var(--vn-indigo); }
.vn-structure .st-sep { color: #B5AFC4; }
.vn-structure .st-tag.is-level { background: #fff; color: var(--vn-purple); }
.vn-structure .st-summary .st-tag.is-current { background: #fff; }

/* ─── The search field with its footer: one tinted block, the white field on top ─────────────────── */

.vn-structure .st-find-box { position: relative; border-radius: 14px; background: var(--vn-field); padding: 4px; }
.vn-structure .st-find-box .st-summary,
.vn-structure .st-find-box .st-summary.is-empty { background: transparent; min-height: 34px; padding: 6px 10px 4px; border-radius: 0; }
.vn-structure .st-find-box .st-summary.is-bad { background: var(--vn-bad-soft); border-radius: 9px; margin-top: 4px; }
.vn-structure .st-find { position: relative; min-width: 0; }
.vn-structure .st-find-field {
    height: 44px; border-radius: 11px; background: #fff; box-shadow: inset 0 0 0 1px #E4DFEE; cursor: text; min-width: 0;
    padding: 0 8px 0 14px; display: flex; align-items: center; gap: 10px; position: relative;
}
.vn-structure .st-find-field > .st-ic { color: var(--vn-purple); }
/* The short placeholder, drawn over the empty text box only in a narrow picker (below); the box's own placeholder
   and accessible name keep the full text. */
.vn-structure .st-find-short {
    display: none; position: absolute; left: 41px; right: 44px; top: 50%; transform: translateY(-50%); pointer-events: none;
    color: #8C85A0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vn-structure .st-find-field:hover { box-shadow: inset 0 0 0 1px #D3C7E6; }
.vn-structure .st-find-field:focus-within,
.vn-structure .st-find-field.is-open { box-shadow: 0 0 0 2px var(--vn-ring); }
.vn-structure .st-find-arrow {
    color: var(--vn-purple); display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0; cursor: pointer;
    transform: rotate(90deg); transition: transform .15s;
}
.vn-structure .st-find-field.is-open .st-find-arrow { transform: rotate(-90deg); }

/* ─── The list under the search field: networks while empty, results by level while typed ──────── */

.vn-structure .st-drop {
    position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); padding: 6px; background: #fff; border-radius: 12px;
    box-shadow: 0 0 0 1px #E4DFEE, 0 14px 32px rgba(33, 28, 51, .18);
}
.vn-structure .st-drop-head { font-size: 11.5px; font-weight: 600; color: var(--vn-label); padding: 4px 10px 6px; }
.vn-structure .st-options { margin: 0; padding: 0; list-style: none; max-height: 320px; overflow: auto; }
.vn-structure .st-drop.is-busy .st-options { opacity: .55; }
.vn-structure .st-option-head { font-size: 11px; font-weight: 700; color: var(--vn-head); padding: 8px 10px 3px; }
.vn-structure .st-option-head:first-child { padding-top: 2px; }
.vn-structure .st-option-more { font-size: 11.5px; color: var(--vn-label); padding: 3px 10px 6px 36px; }
.vn-structure .st-option {
    display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
}
.vn-structure .st-option:hover,
.vn-structure .st-option.is-kb { background: var(--vn-soft); }
.vn-structure .st-option-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.vn-structure .st-option-name { font-weight: 600; overflow-wrap: anywhere; }
.vn-structure .st-option.is-on .st-option-name { font-weight: 800; color: var(--vn-indigo); }
.vn-structure .st-option-sub { font-size: 11.5px; color: var(--vn-label); overflow-wrap: anywhere; }
.vn-structure .st-option.is-empty { cursor: default; color: var(--vn-label); background: transparent; }
.vn-structure .st-drop-keys {
    display: flex; justify-content: flex-end; flex-wrap: wrap; align-items: center; gap: 4px 5px; font-size: 11.5px;
    color: var(--vn-label); padding: 8px 8px 2px; margin-top: 4px; border-top: 1px solid var(--vn-divider);
}
@media (prefers-reduced-motion: reduce) {
    .vn-structure .st-find-arrow { transition: none; }
}

/* ─── Narrow ───────────────────────────────────────────────────────────────────────────────────── */

@container (max-width: 560px) {
    .vn-structure .st-sub { display: none; }
    .vn-structure .st-actions { opacity: 1; }
    .vn-structure .st-row { padding-left: calc(4px + var(--d, 0) * 14px); gap: 6px; }
    .vn-structure .st-below { margin-left: calc(4px + var(--d, 0) * 14px + 34px); }
    .vn-structure .st-shell.is-build .st-row { flex-wrap: wrap; }
    .vn-structure .st-shell.is-build .st-row .st-push { width: 100%; justify-content: flex-end; }
}

/* A picker this narrow cuts "Szukaj sieci, grupy lub franczyzobiorcy"; the short one stands in for it. */
@container (max-width: 440px) {
    .vn-structure .st-find-field input::placeholder { color: transparent; }
    .vn-structure .st-find-field input:placeholder-shown + .st-find-short { display: block; }
}
