/* TERP - Anagrafica e distinte, Distinte (A4): the BOM explorer tree and its surrounding chrome.
   Loaded only by boms.jsp. Reuses tp-card/tp-tabs/tp-kpis/tp-badge from app.css; nothing here
   assumes a maximum depth (no "level 7" selector anywhere - see components/bomtree.js). */

.tp-bomtree
{
    font-size: .86rem;
    max-height: 70vh;
    overflow: auto;
    border: 1px solid var(--tp-line);
    border-radius: var(--tp-radius-sm);
}

.tp-bomrow
{
    display: flex;
    align-items: center;
    gap: .5rem;
    padding-top: .4rem;
    padding-bottom: .4rem;
    padding-right: .6rem;
    border-bottom: 1px solid var(--tp-line-2);
    cursor: pointer;
}

.tp-bomrow:last-child { border-bottom: 0; }
.tp-bomrow:hover { background: var(--tp-accent-l); }
.tp-bomrow:focus-visible { outline: 2px solid var(--tp-accent); outline-offset: -2px; }
.tp-bomrow.tp-bomrow-dim { opacity: .5; }

.tp-bomrow-caret
{
    flex: 0 0 28px;
    height: 28px;
    width: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    border-radius: 999px;
    color: var(--tp-ink-3);
    cursor: pointer;
}

.tp-bomrow-caret:hover { background: rgba(var(--tp-accent-rgb), .15); color: var(--tp-accent-d); }
.tp-bomrow-caret-leaf { cursor: default; }
.tp-bomrow-caret-leaf:hover { background: none; }

.tp-bomrow-badge
{
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .1rem .4rem;
    border-radius: 999px;
    border: 1px solid;
    font-size: .68rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tp-bomrow-main
{
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tp-bomrow-main a { font-weight: 600; cursor: pointer; }
.tp-bomrow-qty
{
    flex: 0 0 auto;
    font-size: .76rem;
    font-variant-numeric: tabular-nums;
    color: var(--tp-ink-3);
    white-space: nowrap;
}

.tp-bomrow-badges { flex: 0 0 auto; display: flex; gap: .25rem; flex-wrap: nowrap; }
.tp-bomrow-badges .tp-badge { cursor: help; }

@media (max-width: 767.98px)
{
    .tp-bomtree { font-size: .78rem; max-height: 65vh; }
    .tp-bomrow-main { flex-basis: 100%; order: 1; white-space: normal; }
    .tp-bomrow-qty { order: 2; font-size: .7rem; }
    .tp-bomrow-badges { order: 3; flex-wrap: wrap; }
    .tp-bomrow { flex-wrap: wrap; row-gap: .15rem; min-height: 44px; }
}

/* Explorer toolbar: model/serial pickers, expand-to-level control, search. Wraps freely at 390px
   instead of scrolling the page sideways (C12). */
.tp-bom-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.tp-bom-toolbar > * { flex: 0 0 auto; }
.tp-bom-toolbar .form-select, .tp-bom-toolbar .tp-search { min-width: 150px; }
.tp-bom-levels { display: inline-flex; flex-wrap: wrap; gap: .2rem; }
.tp-bom-levels button
{
    min-width: 36px;
    min-height: 36px;
    border: 1px solid var(--tp-line);
    background: var(--tp-card);
    border-radius: var(--tp-radius-sm);
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
}

.tp-bom-levels button.active { background: var(--tp-accent); color: #fff; border-color: var(--tp-accent); }
.tp-bom-levels button:hover:not(.active) { border-color: var(--tp-accent-line); background: var(--tp-accent-l); }

.tp-bom-crumbpath { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; font-size: .8rem; color: var(--tp-ink-3); margin-bottom: .5rem; }
.tp-bom-crumbpath b { color: var(--tp-ink); }
.tp-bom-crumbpath i { font-size: .6rem; }

.tp-bom-searchresults { position: absolute; z-index: 20; background: var(--tp-card); border: 1px solid var(--tp-line); border-radius: var(--tp-radius-sm); box-shadow: var(--tp-shadow); max-height: 50vh; overflow: auto; min-width: 280px; }
.tp-bom-searchresults .list-group-item { cursor: pointer; }
.tp-bom-searchresults .list-group-item:hover { background: var(--tp-accent-l); }

@media (prefers-reduced-motion: no-preference)
{
    .tp-bomrow { animation: tp-fadeup .2s ease both; }
}

@media (max-width: 575.98px)
{
    .tp-bom-toolbar .form-select, .tp-bom-toolbar .tp-search { flex: 1 1 140px; }
}
