/* Peak Shaving configuration controls — multi-handle range bar + schematic.
   Global (non-isolated) because ::-webkit-slider-thumb / ::-moz-range-thumb
   pseudo-elements cannot be targeted through Blazor CSS isolation. */

.mh-range {
    width: 100%;
}

.mh-range__label {
    font-size: .8rem;
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
    margin-bottom: 4px;
}

.mh-range__track-wrap {
    position: relative;
    height: 36px;
}

/* shared baseline track */
.mh-range__track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 6px;
    transform: translateY(-50%);
    border-radius: 3px;
    background: var(--mud-palette-lines-default);
    pointer-events: none;
}

/* coloured fill between the outermost handles */
.mh-range__fill {
    position: absolute;
    top: 50%;
    height: 6px;
    transform: translateY(-50%);
    border-radius: 3px;
    background: var(--mud-palette-primary);
    opacity: .35;
    pointer-events: none;
}

/* each handle is a full-width range input stacked on the same track;
   only the thumb is interactive so neighbouring handles stay reachable */
.mh-range__input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 36px;
    margin: 0;
    background: none;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
}

.mh-range__input:focus {
    outline: none;
}

.mh-range__input::-webkit-slider-runnable-track {
    background: transparent;
    height: 36px;
}

.mh-range__input::-moz-range-track {
    background: transparent;
    height: 36px;
}

.mh-range__input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--mh-thumb, var(--mud-palette-primary));
    border: 2px solid var(--mud-palette-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
    cursor: pointer;
    margin-top: 9px;
}

.mh-range__input::-moz-range-thumb {
    pointer-events: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--mh-thumb, var(--mud-palette-primary));
    border: 2px solid var(--mud-palette-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
    cursor: pointer;
}

.mh-range__input:focus-visible::-webkit-slider-thumb {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

.mh-range__input:focus-visible::-moz-range-thumb {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* handle pinned against a neighbour limit: show the "prohibited" cursor */
.mh-range__input--blocked::-webkit-slider-thumb {
    cursor: not-allowed;
}

.mh-range__input--blocked::-moz-range-thumb {
    cursor: not-allowed;
}

.mh-range__readout {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 4px;
    font-size: .75rem;
    color: var(--mud-palette-text-secondary);
}

.mh-range__readout-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* items carrying a tooltip get a help cursor + subtle underline affordance */
.mh-range__readout-item--info {
    cursor: help;
    text-decoration: underline dotted var(--mud-palette-text-disabled);
    text-underline-offset: 2px;
}

.mh-range__readout-icon {
    font-size: .9rem !important;
    color: var(--mud-palette-text-disabled);
}

.mh-range__swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

/* Battery + grid schematic */
.ps-schematic {
    width: 100%;
}

.ps-schematic__row {
    display: flex;
    align-items: stretch;
    gap: 16px;
    height: 220px;
}

.ps-schematic__col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 96px;
}

.ps-schematic__col--grow {
    flex: 1;
    width: auto;
    min-width: 140px;
}

.ps-schematic__cap {
    font-size: .7rem;
    color: var(--mud-palette-text-secondary);
    margin-bottom: 4px;
}

/* bordered box; indicator lines are clamped to stay inside (see .ps-ind) */
.ps-box {
    position: relative;
    flex: 1;
    width: 100%;
    border: 2px solid var(--mud-palette-text-secondary);
    border-radius: 6px;
    background: var(--mud-palette-surface);
}

.ps-box--battery {
    width: 64px;
    flex: none;
    height: 100%;
}

/* battery terminal cap */
.ps-box__cap {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 6px;
    border-radius: 2px;
    background: var(--mud-palette-text-secondary);
}

/* usable-capacity highlight band */
.ps-box__band {
    position: absolute;
    left: 0;
    right: 0;
    background: var(--mud-palette-success);
    opacity: .16;
    pointer-events: none;
}

.ps-box__scale {
    font-size: .65rem;
    color: var(--mud-palette-text-secondary);
    margin-top: 4px;
    text-align: center;
}

/* a level indicator: zero-height anchor positioned at the level (clamped so the
   2px line stays fully inside the box even at 0% and 100%), with an in-flow sized
   hit area so the MudTooltip activator has real dimensions */
.ps-ind {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
    bottom: clamp(1px, var(--lvl, 0%), calc(100% - 1px));
}

.ps-ind__act {
    position: relative;
    display: block;
    width: 100%;
    height: 14px;
    margin-top: -7px;
    cursor: help;
    outline: none;
}

.ps-ind__act:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 1px;
}

.ps-ind__line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    transform: translateY(-50%);
}

/* MudTooltip wraps its child in a root span that is inline by default; make it
   fill the indicator hit area so hover & focus are detected reliably */
.ps-ind .mud-tooltip-root {
    display: block;
    width: 100%;
}
