/* e.emach.pl — canonical B45 device-card renderer
   ------------------------------------------------
   Specialised geometry for class_code 2.73 only.
   Pipeline: source parameters -> B45 virtual profile -> independent parameter
   renderers -> this layout. This file must not suppress Developer inspector
   frames; diagnostic styling is owned by developer-parameter-inspector.css.
*/

.device-card .device-card-live-values.has-b45-card-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 30fr) minmax(0, 40fr) minmax(0, 30fr) !important;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) !important;
    column-gap: 7px !important;
    row-gap: 3px !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 132px !important;
    height: auto !important;
    padding: 8px 9px 7px !important;
    margin: 0 !important;
    align-items: stretch !important;
    overflow: visible !important;
    background: transparent !important;
    --b45-main-value-size: 1.08rem;
    --b45-main-value-weight: 500;
}

.device-card .has-b45-card-layout > .card-virtual-parameter {
    box-sizing: border-box;
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
}

.device-card .has-b45-card-layout > [data-virtual-slot="left-top"] {
    grid-column: 1 !important;
    grid-row: 1 !important;
}
.device-card .has-b45-card-layout > [data-virtual-slot="left-bottom"] {
    grid-column: 1 !important;
    grid-row: 2 !important;
}
.device-card .has-b45-card-layout > [data-virtual-slot="center"] {
    grid-column: 2 !important;
    grid-row: 1 / 3 !important;
}
.device-card .has-b45-card-layout > [data-virtual-slot="right-top"] {
    grid-column: 3 !important;
    grid-row: 1 !important;
}
.device-card .has-b45-card-layout > [data-virtual-slot="right-bottom"] {
    grid-column: 3 !important;
    grid-row: 2 !important;
}

/* Left: parameter icon is deliberately placed left of the value. */
.device-card .has-b45-card-layout .b45-card-metric,
.device-card .has-b45-card-layout .b45-card-timer {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    min-width: 0 !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    padding: 3px 0 !important;
    text-align: left !important;
}

.device-card .has-b45-card-layout .b45-card-metric-icon,
.device-card .has-b45-card-layout .b45-card-timer-icon {
    display: inline-flex !important;
    width: 22px !important;
    height: 22px !important;
    flex: 0 0 22px !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--icon-neutral);
    background: transparent !important;
    border: 0 !important;
}

.device-card .has-b45-card-layout .b45-card-metric-icon svg,
.device-card .has-b45-card-layout .b45-card-timer-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.device-card .has-b45-card-layout .b45-card-metric-copy,
.device-card .has-b45-card-layout .b45-card-timer-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
    align-content: center;
}

.device-card .has-b45-card-layout .b45-card-main-value {
    display: block;
    min-width: 0;
    max-width: 100%;
    color: var(--iot-card-text);
    font-size: var(--b45-main-value-size);
    line-height: 1.03;
    font-weight: var(--b45-main-value-weight);
    letter-spacing: -.012em;
    white-space: nowrap;
}

.device-card .has-b45-card-layout .b45-card-main-value small {
    font-size: .68em;
    font-weight: var(--b45-main-value-weight);
}

.device-card .has-b45-card-layout .b45-card-secondary-value {
    display: block;
    color: var(--iot-card-muted);
    font-size: .65rem;
    line-height: 1.05;
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
}

/* Centre: the observed battery is the primary object, exactly as on B38.
   The device type is identified by the topbar; the B45 body therefore does not
   repeat the charger icon. SOC remains encoded only by the battery fill. */
.device-card .has-b45-card-layout .b45-card-center {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    justify-items: center !important;
    align-content: center !important;
    gap: 5px !important;
    padding: 1px 2px !important;
    text-align: center !important;
}

/* Keep the B45 battery geometry identical to the canonical B38 card battery. */
.device-card .has-b45-card-layout .b45-card-battery {
    position: relative;
    display: flex;
    width: 58px;
    height: 108px;
    align-items: center;
    justify-content: center;
    color: var(--iot-card-text);
}

.device-card .has-b45-card-layout .b45-card-battery-base {
    display: block;
    width: 58px;
    height: 108px;
    max-width: none;
}

.device-card .has-b45-card-layout .b45-card-battery > .battery-status-overlay-svg {
    position: absolute;
    left: 50%;
    top: 53.90625%;
    width: 58%;
    height: 58%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.device-card .has-b45-card-layout .b45-card-center.is-alarm .b45-card-battery-base {
    --battery-base-outline: var(--battery-status-alarm);
    --battery-base-segment: var(--battery-status-alarm);
}

/* Disconnected is neutral absence, not an error: no X, only a quiet shadow. */
.device-card .has-b45-card-layout .b45-card-center.is-disconnected-shadow .b45-card-battery-base {
    opacity: .26;
    --battery-base-segment: transparent;
}

/* Existing B45 operator-state semantics are preserved; only presentation moves
   directly below the battery. */
.device-card .has-b45-card-layout .b45-card-process-label {
    display: block;
    max-width: 100%;
    color: var(--iot-card-muted);
    font-size: .60rem;
    line-height: 1.05;
    font-weight: var(--font-weight-semibold);
    letter-spacing: .055em;
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right: both counters remain visible. Process identity is carried by the
   glyph itself — no generic clock icon. Long durations are fitted in JS by
   lowering time resolution only when the full value actually overflows. */
.device-card .has-b45-card-layout .b45-card-timer-label {
    color: var(--iot-card-muted);
    font-size: .57rem;
    line-height: 1.03;
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
}

.device-card .has-b45-card-layout .b45-card-timer-value {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    color: var(--iot-card-text);
    font-size: var(--b45-main-value-size);
    line-height: 1.03;
    font-weight: var(--b45-main-value-weight);
    white-space: nowrap;
}

.device-card .has-b45-card-layout .b45-process-glyph-svg {
    color: var(--icon-neutral);
}

/* Cooling uses the canonical parameter/cooling.svg snowflake. */
.device-card .has-b45-card-layout .b45-process-glyph-svg.is-cooling {
    stroke-width: 1.55;
}


/* Narrow cards keep the same semantic geometry; only scale and gaps shrink. */
@container device-card (max-width: 360px) {
    .device-card .device-card-live-values.has-b45-card-layout {
        grid-template-columns: minmax(0, 31fr) minmax(0, 38fr) minmax(0, 31fr) !important;
        column-gap: 4px !important;
        min-height: 122px !important;
        padding: 7px 6px 6px !important;
        --b45-main-value-size: 1rem;
    }

    .device-card .has-b45-card-layout .b45-card-battery,
    .device-card .has-b45-card-layout .b45-card-battery-base {
        width: 52px;
        height: 97px;
    }

    .device-card .has-b45-card-layout .b45-card-process-label { font-size: .53rem; }

    .device-card .has-b45-card-layout .b45-card-secondary-value { font-size: .56rem; }
    .device-card .has-b45-card-layout .b45-card-timer-label { font-size: .50rem; }
    .device-card .has-b45-card-layout .b45-card-metric-icon,
    .device-card .has-b45-card-layout .b45-card-timer-icon {
        width: 19px !important;
        height: 19px !important;
        flex-basis: 19px !important;
    }
}

/* Match historical generic value-cell specificity for geometry only.
   Developer diagnostics are intentionally not reset here. */
.device-card .device-card-live-values.has-b45-card-layout > .device-card-live-value.card-virtual-parameter {
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
}

/* ========================================================================== */
/* v9.8.332 — reusable compact B45 row, stable geometric centre               */
/* ========================================================================== */
.bqs-group-card-controllers {
    border-top: 1px solid var(--iot-card-panel-border, var(--device-card-panel-border));
}

.b45-compact-row {
    display: grid;
    box-sizing: border-box;
    min-width: 0;
    min-height: 54px;
    /* Equal flexible side zones keep the battery exactly on the row axis. */
    grid-template-columns: minmax(0, 1fr) 142px minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
    padding: 6px 10px;
    color: var(--device-card-text);
    background: transparent;
}

.b45-compact-row + .b45-compact-row {
    border-top: 1px solid color-mix(in srgb, var(--iot-card-panel-border, var(--device-card-panel-border)) 72%, transparent);
}

.b45-compact-row.is-offline {
    opacity: var(--offline-card-opacity, .40);
}

.b45-compact-row-left {
    display: grid;
    min-width: 0;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
}

.b45-compact-row-device-icon {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    color: var(--icon-neutral);
}

.b45-compact-row-device-icon-svg {
    display: block;
    width: 29px;
    height: 29px;
}

.b45-compact-row-name {
    min-width: 0;
    overflow: hidden;
    color: var(--device-card-text);
    font-size: .78rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.b45-compact-row-state {
    display: grid;
    min-width: 0;
    grid-template-rows: 26px auto;
    justify-items: center;
    align-items: center;
    row-gap: 2px;
}

.b45-compact-row-battery {
    position: relative;
    display: flex;
    width: 48px;
    height: 26px;
    align-items: center;
    justify-content: center;
    color: var(--device-card-text);
}

.b45-compact-row-battery-base {
    display: block;
    width: 48px;
    height: 26px;
}

.b45-compact-row-battery > .battery-status-overlay-svg {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.b45-compact-row-state-label {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    color: var(--device-card-muted);
    font-size: .52rem;
    font-weight: var(--font-weight-semibold);
    letter-spacing: .025em;
    line-height: 1.05;
    text-align: center;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Fixed icon/value columns make all process icons and durations line up. */
.b45-compact-row-time {
    display: grid;
    min-width: 0;
    grid-template-columns: 18px 78px;
    align-items: center;
    justify-content: end;
    column-gap: 5px;
    color: var(--device-card-text);
    font-size: .82rem;
    line-height: 1;
    white-space: nowrap;
}

.b45-compact-row-time-value {
    display: block;
    min-width: 0;
    overflow: hidden;
    font-size: inherit;
    font-weight: 500;
    line-height: inherit;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.b45-compact-row-time-icon {
    display: grid;
    width: 18px;
    height: 18px;
    place-items: center;
    color: var(--icon-neutral);
}

.b45-compact-row-time-icon:empty {
    visibility: hidden;
}

.b45-compact-row-time-icon-svg,
.b45-compact-row-time-icon > svg {
    display: block;
    width: 17px;
    height: 17px;
}

.bqs-group-card-controllers-more {
    min-height: 28px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding: 4px 10px 5px 48px;
    border-top: 1px solid color-mix(in srgb, var(--iot-card-panel-border, var(--device-card-panel-border)) 62%, transparent);
    color: var(--device-card-muted);
    font-size: .68rem;
    font-weight: 500;
    line-height: 1.1;
}

@media (max-width: 700px) {
    .b45-compact-row {
        min-height: 52px;
        grid-template-columns: minmax(0, 1fr) 126px minmax(0, 1fr);
        column-gap: 6px;
        padding: 5px 8px;
    }

    .b45-compact-row-left {
        grid-template-columns: 28px minmax(0, 1fr);
        column-gap: 6px;
    }

    .b45-compact-row-device-icon {
        width: 28px;
        height: 28px;
    }

    .b45-compact-row-device-icon-svg {
        width: 27px;
        height: 27px;
    }

    .b45-compact-row-state {
        grid-template-rows: 24px auto;
    }

    .b45-compact-row-battery,
    .b45-compact-row-battery-base {
        width: 44px;
        height: 24px;
    }

    .b45-compact-row-battery > .battery-status-overlay-svg {
        width: 17px;
        height: 17px;
    }

    .b45-compact-row-name { font-size: .73rem; }
    .b45-compact-row-state-label { font-size: .47rem; }
    .b45-compact-row-time {
        grid-template-columns: 16px 68px;
        column-gap: 4px;
        font-size: .76rem;
    }
    .b45-compact-row-time-icon,
    .b45-compact-row-time-icon-svg,
    .b45-compact-row-time-icon > svg {
        width: 16px;
        height: 16px;
    }
    .bqs-group-card-controllers-more {
        min-height: 26px;
        padding-left: 42px;
        font-size: .64rem;
    }
}
