/* Dashboard widget windows — Windows-style floating, resizable panels.
   Geometry (left/top/width/height) is applied inline by js/widget-window.js. */

.widget-canvas {
    position: relative;
    width: 100%;
}

.widget-window {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
    overflow: hidden;
}

/* Stacked fallback below the floating breakpoint (mobile/tablet). */
.widget-window:not(.is-floating) {
    margin-bottom: 16px;
}

.widget-window.is-floating {
    position: absolute;
    transition: box-shadow .12s ease;
}

.widget-window.is-dragging {
    box-shadow: 0 14px 34px rgba(0, 0, 0, .24);
    user-select: none;
    z-index: 30;
}

.widget-window:focus-within {
    z-index: 20;
}

.widget-window__titlebar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 6px 4px 14px;
    background: var(--mud-palette-background-gray);
    border-bottom: 1px solid var(--mud-palette-lines-default);
    user-select: none;
}

.widget-window.is-floating .widget-window__titlebar {
    cursor: move;
}

.widget-window__title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-weight: 600;
    font-size: .9rem;
    color: var(--mud-palette-text-primary);
}

.widget-window__title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.widget-window__actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.widget-window__body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 16px;
}

/* ── Resize handles: only live while floating (hidden when stacked / maximized) ── */
.widget-window__handle {
    position: absolute;
    z-index: 5;
    touch-action: none;
}

.widget-window:not(.is-floating) .widget-window__handle,
.widget-window.is-maximized .widget-window__handle {
    display: none;
}

.widget-window__handle--n { top: -3px; left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.widget-window__handle--s { bottom: -3px; left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.widget-window__handle--e { top: 10px; bottom: 10px; right: -3px; width: 8px; cursor: ew-resize; }
.widget-window__handle--w { top: 10px; bottom: 10px; left: -3px; width: 8px; cursor: ew-resize; }
.widget-window__handle--ne { top: -3px; right: -3px; width: 16px; height: 16px; cursor: nesw-resize; }
.widget-window__handle--nw { top: -3px; left: -3px; width: 16px; height: 16px; cursor: nwse-resize; }
.widget-window__handle--se { bottom: -3px; right: -3px; width: 16px; height: 16px; cursor: nwse-resize; }
.widget-window__handle--sw { bottom: -3px; left: -3px; width: 16px; height: 16px; cursor: nesw-resize; }

/* While dragging/resizing, keep the whole page from selecting text. */
body.widget-window-busy,
body.widget-window-busy * {
    user-select: none !important;
}
