/*  Copyright (C) Solar MD (Pty) ltd - All Rights Reserved
 *  Proprietary and confidential.
 *
 *  Styling for customJsComp/modbusDebugDialog_1.0.0.js.
 *  Every selector is scoped under .mbusDbg to keep this isolated —
 *  nothing here can leak into other dialogs or device pages.
 */

.mbusDbg {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    color: #333;
    display: flex;
    flex-direction: column;
}

/* ─── Toolbar (Refresh / Auto / Reset etc.) ─────────────────────────── */
.mbusDbg .mbusDbg-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 6px 12px;
    border-bottom: 1px solid #eee;
}
.mbusDbg .mbusDbg-bar button,
.mbusDbg .mbusDbg-setting button {
    padding: 5px 14px;
    border: 1px solid #b0b0b0;
    background: #ffffff;
    color: #333 !important;        /* dialog body sets a near-white default;
                                      override so the labels are readable */
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.4;
    font-family: inherit;
}
.mbusDbg .mbusDbg-bar button:hover,
.mbusDbg .mbusDbg-setting button:hover {
    background: #f0f0f0;
    border-color: #888;
}
.mbusDbg .mbusDbg-hint {
    color: #888;
    font-size: 11px;
    margin-left: 8px;
}

/* ─── Overview tiles ────────────────────────────────────────────────── */
.mbusDbg .mbusDbg-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 12px;
}
.mbusDbg .mbusDbg-tile {
    background: #fafafa;
    border: 1px solid #e7e7e7;
    border-radius: 4px;
    padding: 12px 14px;
    min-height: 86px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.mbusDbg .mbusDbg-tile-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.mbusDbg .mbusDbg-tile-value {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    margin: 4px 0;
    /* prevent very long error labels from blowing the tile */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mbusDbg .mbusDbg-tile-value.ok   { color: #2ca02c; }
.mbusDbg .mbusDbg-tile-value.warn { color: #f0a020; }
.mbusDbg .mbusDbg-tile-value.bad  { color: #d62728; }
.mbusDbg .mbusDbg-tile-sub {
    font-size: 11px;
    color: #666;
}

/* ─── Errors tab ────────────────────────────────────────────────────── */
.mbusDbg .mbusDbg-err-wrap {
    display: flex;
    /* Tab content is scrollable now; let this flex pair take its natural
       size and have a sensible minimum so the donut has room to render. */
    min-height: 360px;
    gap: 12px;
    padding: 12px;
}
.mbusDbg .mbusDbg-donut {
    flex: 1 1 60%;
    border: 1px solid #e7e7e7;
    border-radius: 4px;
    background: #fff;
    min-height: 300px;
    position: relative;
}
.mbusDbg .mbusDbg-err-table {
    flex: 1 1 40%;
    border: 1px solid #e7e7e7;
    border-radius: 4px;
    background: #fff;
    padding: 8px 10px;
    overflow-y: auto;
    font-size: 12px;
}
.mbusDbg .mbusDbg-err-head {
    font-weight: 600;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
    color: #555;
}
.mbusDbg .mbusDbg-err-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "name count"
        "class count";
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed #f0f0f0;
}
.mbusDbg .mbusDbg-err-name  { grid-area: name;  font-weight: 500; }
.mbusDbg .mbusDbg-err-class { grid-area: class; font-size: 10px; color: #999; font-family: monospace; }
.mbusDbg .mbusDbg-err-count { grid-area: count; font-weight: 600; color: #d62728; padding-left: 8px; }
.mbusDbg .mbusDbg-err-empty {
    padding: 40px 8px;
    text-align: center;
    color: #888;
    font-style: italic;
}
.mbusDbg .mbusDbg-empty {
    padding: 80px 16px;
    text-align: center;
    color: #aaa;
    font-style: italic;
}

/* ─── Settings tab ──────────────────────────────────────────────────── */
.mbusDbg .mbusDbg-note {
    margin: 12px;
    padding: 8px 12px;
    background: #fff7e0;
    border: 1px solid #f0d678;
    border-radius: 3px;
    font-size: 12px;
    color: #6a4f00;
}
.mbusDbg .mbusDbg-settings {
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.mbusDbg .mbusDbg-setting {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px;
    background: #fafafa;
    border: 1px solid #e7e7e7;
    border-radius: 4px;
}
.mbusDbg .mbusDbg-setting-left {
    flex: 1 1 auto;
}
.mbusDbg .mbusDbg-setting-label {
    font-weight: 600;
    margin-bottom: 4px;
}
.mbusDbg .mbusDbg-setting-info {
    font-size: 11px;
    color: #666;
    line-height: 1.4;
}
.mbusDbg .mbusDbg-setting-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
.mbusDbg .mbusDbg-setting-input {
    width: 90px;
    padding: 4px 6px;
    border: 1px solid #d0d0d0;
    border-radius: 3px;
    font-size: 13px;
    text-align: right;
}
.mbusDbg .mbusDbg-setting-unit {
    font-size: 11px;
    color: #888;
    min-width: 22px;
}

/* ─── Live-update pip in the dialog title bar ──────────────────────── */
/* Small "LIVE" pill with a pulsing red dot — visible at a glance so the
   operator knows the data is refreshing without studying the buttons. */
.mbusDbg-live-pip {
    display: inline-block;
    margin-left: 10px;
    padding: 1px 8px 1px 22px;     /* room for the ::before dot */
    background: rgba(214, 39, 40, 0.18);
    border: 1px solid rgba(214, 39, 40, 0.4);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffd9d9;
    position: relative;
    vertical-align: middle;
    animation: mbusDbgLivePulse 2s ease-in-out infinite;
}
.mbusDbg-live-pip::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff4040;
    box-shadow: 0 0 6px #ff4040;
    animation: mbusDbgLiveDot 1s ease-in-out infinite;
}
/* Pip envelope softly breathes — communicates that something is live
   but without being noisy. */
@keyframes mbusDbgLivePulse {
    0%, 100% { background: rgba(214, 39, 40, 0.18); }
    50%      { background: rgba(214, 39, 40, 0.35); }
}
/* Dot itself blinks more sharply to draw the eye. */
@keyframes mbusDbgLiveDot {
    0%, 100% { opacity: 1.0; box-shadow: 0 0 6px #ff4040; }
    50%      { opacity: 0.4; box-shadow: 0 0 2px #ff4040; }
}

/* ─── Stale-data banner ─────────────────────────────────────────────── */
.mbusDbg .mbusDbg-stale-banner {
    margin: 8px 12px 0 12px;
    padding: 6px 10px;
    background: #fff3e6;
    border: 1px solid #f0c060;
    border-radius: 3px;
    font-size: 11px;
    color: #714a00;
    font-style: italic;
}

/* ─── Findings strip (anomaly-detection chips) ──────────────────────── */
.mbusDbg .mbusDbg-findings {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px 0 12px;
}
.mbusDbg .mbusDbg-finding {
    border-left: 4px solid #b0b0b0;
    background: #fafafa;
    padding: 6px 10px;
    border-radius: 3px;
    font-size: 12px;
}
.mbusDbg .mbusDbg-finding-head {
    display: flex;
    align-items: center;
    gap: 8px;
}
.mbusDbg .mbusDbg-finding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #b0b0b0;
    flex-shrink: 0;
}
.mbusDbg .mbusDbg-finding-title {
    font-weight: 600;
    color: #333;
}
.mbusDbg .mbusDbg-finding-detail {
    margin-top: 3px;
    color: #555;
    line-height: 1.35;
}
.mbusDbg .mbusDbg-finding-hint {
    margin-top: 3px;
    color: #2a6dad;
    font-style: italic;
}
.mbusDbg .mbusDbg-sev-info {
    border-left-color: #2a6dad;
    background: #f3f8fc;
}
.mbusDbg .mbusDbg-sev-info .mbusDbg-finding-dot {
    background: #2a6dad;
}
.mbusDbg .mbusDbg-sev-warn {
    border-left-color: #f0a020;
    background: #fff8ec;
}
.mbusDbg .mbusDbg-sev-warn .mbusDbg-finding-dot {
    background: #f0a020;
}
.mbusDbg .mbusDbg-sev-critical {
    border-left-color: #d62728;
    background: #fcf0f0;
}
.mbusDbg .mbusDbg-sev-critical .mbusDbg-finding-dot {
    background: #d62728;
}

/* ─── Timeline tab ──────────────────────────────────────────────────── */
.mbusDbg .mbusDbg-tl-label {
    font-size: 12px;
    color: #555;
    margin-right: 4px;
}
.mbusDbg .mbusDbg-tl-select {
    padding: 4px 6px;
    border: 1px solid #b0b0b0;
    border-radius: 3px;
    font-size: 12px;
    background: #fff;
    color: #333;
}
.mbusDbg .mbusDbg-tl-filter {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;          /* push toggle to the right edge */
}
.mbusDbg .mbusDbg-tl-filter-label {
    font-size: 12px;
    color: #555;
    cursor: pointer;
}
.mbusDbg .mbusDbg-tl-status {
    padding: 6px 12px;
    font-size: 11px;
    color: #555;
    border-bottom: 1px solid #eee;
    font-style: italic;
}
.mbusDbg .mbusDbg-gantt {
    margin: 4px 12px 12px 12px;
    /* Height is set ADAPTIVELY in JS based on the number of rows in the
       current view: ~60 px per row, clamped to [200, 540]. The 200 px
       floor keeps 2-row recordings from being awkward; the 540 px
       ceiling prevents "Show whole bus" with 20+ units from pushing
       the dialog body unreadably tall. The fallback below applies
       only before the first render. */
    min-height: 200px;
    height: 220px;
    border: 1px solid #e7e7e7;
    border-radius: 4px;
    background: #fff;
}

/* ─── Per-unit breakdown table (iface mode only) ─────────────────────
   A compact "every slave on the bus" table that lives below the KPI
   tiles in the Overview tab. Sorted worst-first so the bad actors
   surface immediately. */
.mbusDbg .mbusDbg-unit-breakdown {
    margin: 4px 12px 12px 12px;
    border: 1px solid #ececec;
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
    font-size: 12px;
}
.mbusDbg .mbusDbg-unit-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 2fr;
    gap: 0;
    padding: 6px 10px;
    border-bottom: 1px solid #f3f3f3;
}
.mbusDbg .mbusDbg-unit-row:last-child {
    border-bottom: none;
}
.mbusDbg .mbusDbg-unit-head {
    background: #fafafa;
    font-weight: 600;
    color: #555;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.mbusDbg .mbusDbg-unit-cell {
    padding: 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mbusDbg .mbusDbg-unit-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #1f77b4;
}
.mbusDbg .mbusDbg-unit-cell.ok   { color: #2ca02c; font-weight: 600; }
.mbusDbg .mbusDbg-unit-cell.warn { color: #b8860b; font-weight: 600; }
.mbusDbg .mbusDbg-unit-cell.bad  { color: #d62728; font-weight: 600; }
.mbusDbg .mbusDbg-unit-err {
    color: #555;
    font-size: 11px;
}

/* Legend strip above the Gantt — replaces the verbose y-axis labels
   that used to eat ~180px of horizontal space. Compact row of swatches
   with hover-tooltip explanations. */
.mbusDbg .mbusDbg-gantt-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    margin: 4px 12px 0 12px;
    padding: 4px 8px;
    font-size: 11px;
    color: #555;
    background: #fafafa;
    border: 1px solid #ececec;
    border-radius: 4px;
    min-height: 22px;
}
.mbusDbg .mbusDbg-gantt-legend-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: default;
}
.mbusDbg .mbusDbg-gantt-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.mbusDbg .mbusDbg-gantt-legend-label {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: #333;
}

/* ─── Gateway tab (Phase B) ─────────────────────────────────────────── */
.mbusDbg .mbusDbg-gw-cmp,
.mbusDbg .mbusDbg-gw-cfg {
    margin: 8px 12px;
    background: #fff;
    border: 1px solid #e7e7e7;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 12px;
}
.mbusDbg .mbusDbg-gw-cmp-row {
    display: grid;
    grid-template-columns: 200px 1fr 1fr;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px dashed #f0f0f0;
}
.mbusDbg .mbusDbg-gw-cmp-head {
    font-weight: 600;
    color: #555;
    border-bottom: 1px solid #ddd;
}
.mbusDbg .mbusDbg-gw-cmp-label {
    color: #666;
}
.mbusDbg .mbusDbg-gw-cmp-val {
    text-align: right;
    font-family: monospace;
    color: #333;
    padding-right: 12px;
}
.mbusDbg .mbusDbg-gw-cmp-note {
    font-size: 11px;
    color: #888;
    font-style: italic;
    padding: 2px 0 4px 200px;     /* aligned with the value columns */
}
.mbusDbg .mbusDbg-gw-cfg-body {
    margin-top: 4px;
}
.mbusDbg .mbusDbg-gw-cfg-row {
    display: grid;
    grid-template-columns: 1fr auto;
    padding: 4px 0;
    border-bottom: 1px dashed #f0f0f0;
}
.mbusDbg .mbusDbg-gw-cfg-k {
    color: #555;
}
.mbusDbg .mbusDbg-gw-cfg-v {
    font-family: monospace;
    font-weight: 600;
    color: #333;
}

/* ─── Raw tab ───────────────────────────────────────────────────────── */
.mbusDbg .mbusDbg-raw {
    /* Outer tab content scrolls — no inner max-height/overflow here, or
       we'd end up with nested scrollbars. */
    padding: 0 12px 12px 12px;
    font-size: 12px;
}
.mbusDbg .mbusDbg-raw-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    padding: 4px 0;
    border-bottom: 1px dashed #f0f0f0;
}
.mbusDbg .mbusDbg-raw-key {
    color: #666;
}
.mbusDbg .mbusDbg-raw-val {
    font-family: monospace;
    text-align: right;
    word-break: break-all;
}

/* ─── Adaptive tab (ADR-001 Phase 1 telemetry) ──────────────────────── */
/* Container for the whole tab body. Padding matches the other tabs so
   the toolbar/hint above lines up. Tile grid reuses .mbusDbg-tiles
   for column layout. */
.mbusDbg .mbusDbg-adaptive {
    padding: 0 0 12px 0;
    font-size: 12px;
}
/* Smaller unit suffix inside a tile value ("ms" after a number). */
.mbusDbg .mbusDbg-tile-unit {
    font-size: 13px;
    font-weight: 400;
    color: #888;
    margin-left: 4px;
}
/* Formula breakdown block — three-column key / value / note grid so
   the operator can see how the suggested timeout was computed. */
.mbusDbg .mbusDbg-adaptive-formula {
    margin: 12px;
    border: 1px solid #e7e7e7;
    border-radius: 4px;
    background: #fafafa;
}
.mbusDbg .mbusDbg-adaptive-formula-head {
    padding: 8px 12px;
    border-bottom: 1px solid #e7e7e7;
    font-weight: 600;
    color: #444;
}
.mbusDbg .mbusDbg-adaptive-formula-row {
    display: grid;
    grid-template-columns: 200px 120px 1fr;
    padding: 6px 12px;
    border-bottom: 1px dashed #f0f0f0;
}
.mbusDbg .mbusDbg-adaptive-formula-row:last-child {
    border-bottom: none;
}
.mbusDbg .mbusDbg-adaptive-formula-k {
    color: #444;
    font-family: monospace;
}
.mbusDbg .mbusDbg-adaptive-formula-v {
    text-align: right;
    font-family: monospace;
    font-weight: 600;
    color: #333;
}
.mbusDbg .mbusDbg-adaptive-formula-note {
    padding-left: 16px;
    color: #777;
    font-style: italic;
}
/* Live-toggle panel at the top of the Adaptive tab. */
.mbusDbg .mbusDbg-adaptive-toggles {
    margin: 12px;
    border: 1px solid #d0d8e0;
    border-radius: 4px;
    background: #f5f8fb;
}
.mbusDbg .mbusDbg-adaptive-toggles-head {
    padding: 8px 12px;
    border-bottom: 1px solid #d0d8e0;
    font-weight: 600;
    color: #2a5a8a;
    font-size: 12px;
}
.mbusDbg .mbusDbg-adaptive-toggles-body {
    padding: 4px 12px 8px 12px;
}
.mbusDbg .mbusDbg-toggle-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #e0e6ec;
}
.mbusDbg .mbusDbg-toggle-row:last-child {
    border-bottom: none;
}
.mbusDbg .mbusDbg-toggle-left {
    flex: 1;
    padding-right: 12px;
}
.mbusDbg .mbusDbg-toggle-label {
    font-weight: 500;
    color: #333;
    font-size: 12px;
}
.mbusDbg .mbusDbg-toggle-hint {
    color: #666;
    font-size: 11px;
    margin-top: 2px;
    line-height: 1.4;
}
.mbusDbg .mbusDbg-toggle-right {
    flex: 0 0 auto;
}
.mbusDbg .mbusDbg-toggle-checkbox {
    transform: scale(1.4);
    cursor: pointer;
}
.mbusDbg .mbusDbg-toggle-checkbox:disabled {
    cursor: not-allowed;
}

/* Footer block with operator guidance + doc references. */
.mbusDbg .mbusDbg-adaptive-footer {
    margin: 12px;
    padding: 12px;
    border-left: 3px solid #c0c0c0;
    background: #fcfcfc;
    color: #555;
    line-height: 1.5;
}
.mbusDbg .mbusDbg-adaptive-footer code {
    background: #efefef;
    padding: 0 4px;
    border-radius: 2px;
    font-size: 11px;
}
