/*
 ==============================================================================
 Project Name    : Esyasoft.AMI.Unified.Web
 File Name       : lossbalance.css
 File Purpose    : Loss and balance overviews (LbElecOverview / LbWaterOverview), from the EtihadWE Energy & Water
                   Balance sample page. Sits on top of demand.css: the container is ".dmt lbo", so the colour tokens
                   (light + dark), number tiles, cards, pills, legends and BlazorKit chart / table restyling come from
                   demand.css; this file only adds what the sample page has on top (stacked share bars, loss-mix bars,
                   attention list, tile status colours, waterfall).
 Created Date    : 2026-11-25
 ==============================================================================
*/

.dmt.lbo {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
    /* no panel of its own: cards sit straight on the tab background, like Operations / Demand */
    background: transparent;
    color: var(--fg);
    font-family: var(--font);
}

.dmt .lbo-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

    .dmt .lbo-section + .lbo-section {
        padding-top: 16px;
        border-top: 1px solid var(--line);
    }

.dmt .periodchip {
    font-size: 11.5px;
    color: var(--muted);
}

.dmt .p-mute {
    color: var(--muted);
    background: var(--surface2);
}

/* 2 : 1 grid (waterfall | billed by category); one column on narrow screens */
.dmt .dgrid.lbo-d21 {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: stretch;
}

@media (max-width: 900px) {
    .dmt .dgrid.lbo-d21 {
        grid-template-columns: minmax(0, 1fr);
    }
}

.dmt .lbo-card {
    height: 100%;
}

    .dmt .lbo-card .uuc-card-body {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

/* energy balance waterfall: the sample page's own SVG and palette (light / dark) */
.dmt .lbo-wf {
    --wf-s1: #257de0;
    --wf-s2: #f47230;
    --wf-s3: #00b894;
    --wf-s4: #6a4ce2;
    --wf-tl: #9aa3b2;
    --wf-text: #1b1f26;
    --wf-text2: #5b6474;
    --wf-text3: #8a93a2;
    --wf-line: #e2e5ea;
    --wf-card: #ffffff;
    --wf-shadow: 0 10px 30px rgba(30, 40, 60, .10);
    padding: 0 10px;
}

html[data-theme="dark"] .dmt .lbo-wf {
    --wf-s1: #338ced;
    --wf-s2: #e76624;
    --wf-s3: #00a888;
    --wf-s4: #9887ef;
    --wf-tl: #7d8798;
    --wf-text: #e8ebf0;
    --wf-text2: #a3abb9;
    --wf-text3: #6f7888;
    --wf-line: #2a303a;
    --wf-card: #1a1e25;
    --wf-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

    .dmt .lbo-wf svg {
        display: block;
        overflow: visible;
    }

    .dmt .lbo-wf text {
        font-family: var(--mono);
        font-size: 11px;
    }

    .dmt .lbo-wf .lbo-wf-val {
        fill: var(--wf-text);
        font-weight: 600;
    }

    .dmt .lbo-wf .lbo-wf-name {
        fill: var(--wf-text2);
        font-family: var(--font);
        font-size: 11.5px;
    }

    .dmt .lbo-wf .lbo-wf-pct {
        fill: var(--wf-text3);
    }

    .dmt .lbo-wf .lbo-wf-link {
        stroke: var(--wf-text3);
        stroke-dasharray: 2 3;
    }

    .dmt .lbo-wf .lbo-wf-base {
        stroke: var(--wf-line);
    }

    .dmt .lbo-wf .lbo-wf-in {
        position: relative;
    }

    /* hover area over a bar; its tooltip is the sample page's #tip card */
    .dmt .lbo-wf .lbo-wf-hit {
        position: absolute;
        cursor: default;
    }

    .dmt .lbo-wf .lbo-wf-tip {
        display: none;
        position: absolute;
        left: calc(100% + 14px);
        top: 50%;
        z-index: 100;
        pointer-events: none;
        min-width: 200px;
        max-width: 320px;
        padding: 8px 10px;
        border: 1px solid var(--wf-line);
        border-radius: 10px;
        background: var(--wf-card);
        color: var(--wf-text);
        font-size: 12px;
        box-shadow: var(--wf-shadow);
        white-space: nowrap;
    }

    .dmt .lbo-wf .lbo-wf-hit--left .lbo-wf-tip {
        left: auto;
        right: calc(100% + 14px);
    }

    .dmt .lbo-wf .lbo-wf-hit:hover .lbo-wf-tip {
        display: block;
    }

    .dmt .lbo-wf .lbo-wf-tip .tt {
        font-weight: 600;
        margin-bottom: 4px;
    }

    .dmt .lbo-wf .lbo-wf-tip .tr {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        font-family: var(--mono);
    }

        .dmt .lbo-wf .lbo-wf-tip .tr span:first-child {
            font-family: var(--font);
            color: var(--wf-text2);
        }

/* six number tiles in one row (demand.css .statgrid uses 5 for the Demand page) */
.dmt .lbo-section .statgrid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1100px) {
    .dmt .lbo-section .statgrid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .dmt .lbo-section .statgrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* number tile status: value colour (the dot before the title comes from demand.css .tile-warn) */
.dmt .statgrid .tile-bad .uuc-kpi-value {
    color: var(--bad);
}

.dmt .statgrid .tile-bad .uuc-kpi-title::before {
    background: var(--bad);
}

.dmt .statgrid .tile-warn:not(.tile-bad) .uuc-kpi-value {
    color: var(--warn);
}

.dmt .statgrid .tile-ok .uuc-kpi-value {
    color: var(--ok);
}

.dmt .statgrid .tile-ok .uuc-kpi-title::before {
    background: var(--ok);
    opacity: 1;
}

/* value colour by status (tables) */
.dmt .lbo-v--good {
    color: var(--ok);
}

.dmt .lbo-v--warn {
    color: var(--warn);
}

.dmt .lbo-v--bad {
    color: var(--bad);
}

.dmt .lbo-v--info {
    color: var(--info);
}

/* one bar split into coloured shares */
.dmt .lbo-stack {
    display: flex;
    width: 100%;
    overflow: hidden;
    border-radius: 4px;
    background: var(--surface2);
    gap: 1px;
}

    .dmt .lbo-stack > span {
        min-width: 2px;
    }

.dmt .lbo-sq {
    display: inline-block;
    width: 10px !important;
    height: 10px !important;
    border-radius: 3px !important;
    vertical-align: -1px;
}

/* IWA components under the stacked bar: six columns, 3 + 3 / 2 per row on narrow screens */
.dmt .lbo-parts {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

@media (max-width: 1100px) {
    .dmt .lbo-parts {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .dmt .lbo-parts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* child rows: name + small sub-line, loss mix bar */
.dmt .lbo-nm {
    display: flex;
    flex-direction: column;
    font-weight: 600;
}

    .dmt .lbo-nm small {
        font-weight: 400;
        font-size: 11px;
        color: var(--muted);
    }

.dmt .lbo-mix {
    display: flex;
    gap: 2px;
    height: 10px;
}

    .dmt .lbo-mix > span {
        display: block;
        height: 100%;
        border-radius: 3px;
    }

.dmt .lbo-table .uuc-table-tbody tr.row-click {
    cursor: pointer;
}

/* needs attention */
.dmt .lbo-attn {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

    .dmt .lbo-attn li {
        display: flex;
        gap: 10px;
        padding: 8px 0;
        border-top: 1px solid var(--line2);
    }

        .dmt .lbo-attn li:first-child {
            border-top: 0;
            padding-top: 0;
        }

    .dmt .lbo-attn .t {
        font-weight: 600;
        font-size: 12.5px;
    }

    .dmt .lbo-attn .d {
        font-size: 11.5px;
        color: var(--muted);
    }

.dmt .lbo-dot {
    flex: none;
    width: 8px;
    height: 8px;
    margin-top: 5px;
    border-radius: 50%;
    background: var(--muted);
}

.dmt .lbo-dot--bad {
    background: var(--bad);
}

.dmt .lbo-dot--warn {
    background: var(--warn);
}

.dmt .lbo-dot--info {
    background: var(--info);
}

.dmt .lbo-note {
    margin: 0;
    font-size: 11.5px;
    color: var(--muted);
}

/* chart colours that demand.css does not map yet (SVG attributes hold the light palette) */
.dmt [fill="#0F766E"] {
    fill: var(--ok);
}

.dmt [fill="#0369A1"] {
    fill: var(--water);
}

.dmt [fill="#B42318"] {
    fill: var(--bad);
}

.dmt [stroke="#0F766E"] {
    stroke: var(--ok);
}
