/* The directory tree, shared by the handbook (/handbook) and the protocols (/protocols).

   Global rather than scoped, and for the reason login.css is: more than one component renders these
   rows. DirectoryTreeView draws the folders, the page draws its own entry rows and hands them in as a
   template — and a .razor.css reaches only the elements its own component renders, so neither side's
   scoped sheet would reach the other's rows. Every class carries the dir-tree prefix, so nothing here
   leaks into the rest of the application. What one page adds to its own rows — the protocols' date
   columns — stays in that page's scoped sheet, which reaches them because the page renders them.

   Order matters in one place: .dir-tree .btn-icon-sm comes before the kebab and move-button rules, so a
   disabled move button is not lit back up by the generic hover. */

/* ── Toolbar: the view switch and "Alles auf-/zuklappen" ── */

.dir-tree-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin: 0.6rem 0 0.4rem;
    flex-wrap: wrap;
}

.dir-tree-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* ── The tree ──────────────────────────────────────── */

.dir-tree {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 2rem;
}

.dir-tree-node {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* Directory rows are floating cards, as everything else in the language is —
   the tree reads as a stack of surfaces rather than as a ruled list. */
.dir-tree-row-wrapper {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: calc(var(--depth, 0) * 1.4rem);
    padding: 0.3rem 0.6rem 0.3rem 0.55rem;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.dir-tree-row-wrapper:hover {
    box-shadow: var(--shadow-md);
}

.dir-tree-row {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.6rem;
    border-radius: var(--radius-md);
    color: var(--clr-slate-700);
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 0.15s ease;
    min-width: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.dir-tree-row-wrapper:hover .dir-tree-row {
    color: var(--clr-slate-900);
}

.dir-tree-chevron {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--clr-slate-400);
    transition: color 0.15s;
}

.dir-tree-row-wrapper:hover .dir-tree-chevron {
    color: var(--clr-slate-600);
}

.dir-tree-chevron-spacer {
    display: inline-flex;
    width: 14px;
    flex-shrink: 0;
}

.dir-tree-row-leaf {
    cursor: default;
}

.dir-tree-children {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    animation: dirTreeExpand 0.18s ease-out;
}

@keyframes dirTreeExpand {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Article rows are cards too, indented under their directory. */
.dir-tree-article {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: calc(var(--depth, 1) * 1.4rem + 1.6rem);
    padding: 0.25rem 0.6rem 0.25rem 0.55rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.2s ease;
}

.dir-tree-article:hover {
    box-shadow: var(--shadow-md);
}

.dir-tree-article-row {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-md);
    color: var(--clr-slate-600);
    font-size: 0.88rem;
    font-weight: 400;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.dir-tree-article:hover .dir-tree-article-row {
    color: var(--clr-slate-900);
}

.dir-tree-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dir-tree-name-empty {
    color: var(--clr-slate-400);
    font-style: italic;
}

/* Marks a directory whose access is restricted – the rules reach everything below it. */
.dir-tree-lock {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--clr-slate-400);
}

.dir-tree-count {
    background: var(--surface-track);
    color: var(--clr-slate-500);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-pill);
}

.dir-tree .btn-icon-sm {
    padding: 0.3rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--clr-slate-500);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dir-tree .btn-icon-sm:hover {
    background: var(--surface-hover);
    color: var(--clr-slate-700);
}

.dir-tree-kebab,
.dir-tree-row-action {
    flex-shrink: 0;
    color: var(--clr-slate-400);
    opacity: 0.55;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.dir-tree-row-wrapper:hover .dir-tree-kebab,
.dir-tree-row-wrapper:focus-within .dir-tree-kebab,
.dir-tree-article:hover .dir-tree-kebab,
.dir-tree-article:focus-within .dir-tree-kebab,
.dir-tree-row-wrapper:hover .dir-tree-row-action,
.dir-tree-row-wrapper:focus-within .dir-tree-row-action,
.dir-tree-article:hover .dir-tree-row-action,
.dir-tree-article:focus-within .dir-tree-row-action {
    opacity: 1;
}

.dir-tree-kebab:hover,
.dir-tree-row-action:hover:not(:disabled) {
    color: var(--clr-slate-700);
    background: var(--surface-hover);
    opacity: 1;
}

/* Reordering, out of the menu and into the row — but only where the row can spare the width.
   Below the breakpoint the same two entries stay available in the kebab. */
.dir-tree-row-move {
    display: inline-flex;
}

/* The :hover twin keeps the row-hover and .btn-icon-sm rules from lighting a dead button back up. */
.dir-tree-row-move:disabled,
.dir-tree-row-move:disabled:hover {
    opacity: 0.25;
    cursor: default;
    background: transparent;
    color: var(--clr-slate-400);
}

@media (max-width: 720px) {
    .dir-tree-row-move {
        display: none;
    }
}

@media (hover: none) {
    .dir-tree-kebab,
    .dir-tree-row-action {
        opacity: 1;
    }
}

/* ── Drag & Drop ────────────────────────────────────── */

/* The grip says "this row moves". Faint until the row is hovered, so a tree at rest stays quiet. */
.dir-tree-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.1rem;
    align-self: stretch;
    color: var(--clr-slate-300);
    opacity: 0.5;
    cursor: grab;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.dir-tree-row-wrapper:hover .dir-tree-drag-handle,
.dir-tree-row-wrapper:focus-within .dir-tree-drag-handle,
.dir-tree-article:hover .dir-tree-drag-handle,
.dir-tree-article:focus-within .dir-tree-drag-handle {
    opacity: 1;
    color: var(--clr-slate-400);
}

.dir-tree-drag-handle:active {
    cursor: grabbing;
}

/* Keeps rows that cannot be moved aligned with the ones that can. */
.dir-tree-drag-handle-spacer {
    display: inline-flex;
    flex-shrink: 0;
    width: 1.1rem;
}

@media (hover: none) {
    .dir-tree-drag-handle {
        opacity: 1;
    }
}

.dir-tree-row-wrapper[draggable="true"]:active,
.dir-tree-article[draggable="true"]:active {
    cursor: grabbing;
}

.dir-tree-node-dragging {
    opacity: 0.45;
}

/* While a drag is running only the drop targets themselves see the pointer. Without this every icon and
   button inside a row fires its own dragenter/dragleave pair as the pointer crosses it, and the highlight
   blinks all the way across the row. */
.dir-tree.is-dragging .dir-tree-row-wrapper > *,
.dir-tree.is-dragging .dir-tree-article > *,
.dir-tree.is-dragging .dir-tree-root-drop * {
    pointer-events: none;
}

.dir-tree-drag-over-dir {
    background: var(--clr-blue-50) !important;
    outline: 2px dashed var(--clr-blue-400);
    outline-offset: -2px;
}

/* The gap between two cards is the drop zone for "sort in here". It reaches a little into both
   neighbours so it is easy to hit, and takes up no layout height of its own. */
.dir-tree-drop-indicator {
    height: 12px;
    margin: -6px 0;
    position: relative;
    z-index: 2;
}

/* The line is drawn on top of the layout, never inside it: showing it must not move a single row,
   otherwise the row slides out from under the pointer and the drag starts fighting itself. */
.dir-tree-drop-indicator::after {
    content: '';
    position: absolute;
    left: calc(var(--depth, 0) * 1.4rem + 0.6rem);
    right: 0.4rem;
    top: 50%;
    height: 3px;
    margin-top: -1.5px;
    border-radius: 2px;
    background: var(--clr-blue-500);
    box-shadow: 0 0 0 2px rgba(42, 86, 214, 0.18);
    opacity: 0;
    transition: opacity 0.1s ease;
}

/* Dot on the leading edge — the same "insert here" mark editors use. */
.dir-tree-drop-indicator::before {
    content: '';
    position: absolute;
    left: calc(var(--depth, 0) * 1.4rem + 0.35rem);
    top: 50%;
    width: 9px;
    height: 9px;
    margin-top: -4.5px;
    border-radius: 50%;
    border: 2.5px solid var(--clr-blue-500);
    background: var(--surface);
    opacity: 0;
    transition: opacity 0.1s ease;
    z-index: 1;
}

.dir-tree-drop-indicator-active::after,
.dir-tree-drop-indicator-active::before {
    opacity: 1;
}

/* Article rows sit one step further in than their directory — their indicator follows. */
.dir-tree-article-wrapper > .dir-tree-drop-indicator::after {
    left: calc(var(--depth, 0) * 1.4rem + 1.6rem + 0.6rem);
}

.dir-tree-article-wrapper > .dir-tree-drop-indicator::before {
    left: calc(var(--depth, 0) * 1.4rem + 1.6rem + 0.35rem);
}

.dir-tree-article-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.dir-tree-root-drop {
    margin-top: 0.6rem;
    padding: 0.65rem 0.85rem;
    border: 1.5px dashed var(--clr-slate-200);
    border-radius: var(--radius-md);
    color: var(--clr-slate-400);
    font-size: 0.82rem;
    display: none;
    align-items: center;
    gap: 0.4rem;
    text-align: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.dir-tree.is-dragging .dir-tree-root-drop {
    display: flex;
}

.dir-tree-drag-over-root {
    border-color: var(--clr-blue-400);
    background: var(--clr-blue-50);
    color: var(--clr-blue-700);
}

