.dashboard-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: 8px 0;
}

.dashboard-grid {
    position: relative;
}

/* Shown only while a widget is being dragged/resized, so the operator can see the
   grid it will snap to. --grid-cell-w/--grid-cell-h are set by dashboardGrid.js from
   GridStack's own cellWidth()/getCellHeight() (real pixel size, margin/gutter already
   accounted for) right before this class is toggled on - a plain 100%/12 CSS guess
   drifts from the actual column boundaries because it ignores that gutter. */
.dashboard-grid.grid-stack-dragging {
    --grid-cell-w: 100px;
    --grid-cell-h: 78px;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.10) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.10) 1px, transparent 1px);
    background-size: var(--grid-cell-w) var(--grid-cell-h);
    background-position: 0 0;
}

.grid-stack-item-content {
    background: var(--mud-palette-surface, #242424);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.widget-card {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.widget-card-toolbar {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--mud-palette-surface, #242424);
    border-radius: 8px;
    padding: 2px;
}

.widget-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    cursor: grab;
    color: var(--mud-palette-text-secondary, #9e9e9e);
}

.widget-drag-handle:active {
    cursor: grabbing;
}

.widget-toggle-switch {
    margin: 0;
}

.widget-card-disabled {
    opacity: 0.55;
    filter: grayscale(1);
    outline: 1px dashed var(--mud-palette-text-secondary, #9e9e9e);
    outline-offset: -1px;
}

.widget-card-disabled .widget-card-body {
    pointer-events: none;
}

.widget-card-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

/* Renders the widget's content at its natural (default-size) layout, then visually
   scales the whole thing down to fit the current grid cell - so text, charts and
   icons all shrink together instead of getting clipped or scrolling. --wscale is
   set by dashboardGrid.js from the ratio of current grid units to the widget's
   default w/h (never scales up past 1). */
.widget-scale-inner {
    --wscale: 1;
    width: calc(100% / var(--wscale));
    height: calc(100% / var(--wscale));
    transform: scale(var(--wscale));
    transform-origin: top left;
}

.grid-stack-item.ui-draggable-dragging .widget-card-body,
.grid-stack-item.ui-resizable-resizing .widget-card-body {
    pointer-events: none;
}

/* GridStack's own drop-target indicator - the cell(s) the widget will land in once
   released. Overrides the library's default (barely visible on our dark theme) with
   a clearly highlighted, accent-colored box. */
.grid-stack-placeholder > .placeholder-content {
    background: rgba(89, 74, 226, 0.28);
    border: 2px dashed var(--mud-palette-primary, #594AE2);
    border-radius: 8px;
    height: 100%;
}
