/* GridStack Custom Styles for TEDMatrix */

/* Grid container styling */
.grid-stack {
    background: transparent;
    min-height: 400px;
    position: relative;
}

/* Fit-to-screen editor canvas: gridstack sets the grid height from the computed cell height
   (rows × cell), so drop the default min-height floor that would otherwise force a scroll on a
   short canvas. The grid then fills exactly the area its flex parent provides. */
.grid-stack-fit {
    min-height: 0 !important;
}


/* Grid item styling */
.grid-stack-item {
    overflow: visible;
}

/* Grid item content - ensure it fills the entire item */
/* GridStack applies margin via inline top/right/bottom/left on this element */
.grid-stack-item-content {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* MudPaper card inside the content area - fills available space */
.grid-stack-item-content > .widget-card {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Hover effect for draggable items */
.grid-stack:not(.grid-stack-static) .grid-stack-item:hover {
    z-index: 100;
}

/* Placeholder styling while dragging */
.grid-stack-placeholder {
    background: rgba(var(--mud-palette-primary-rgb), 0.2) !important;
    border: 2px dashed var(--mud-palette-primary);
    border-radius: 4px;
}

/* Resize handle styling */
.grid-stack-item > .ui-resizable-handle {
    opacity: 0.7;
}

.grid-stack-item:hover > .ui-resizable-handle {
    opacity: 1;
}

/* Ensure MudCard fills the widget card area */
.widget-card .mud-card {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Make card content scrollable if it overflows */
.widget-card .mud-card .mud-card-content {
    overflow: auto;
    flex: 1;
}

/* Prevent text selection while dragging */
.grid-stack.grid-stack-dragging {
    user-select: none;
}

/* Animation for adding/removing items */
.grid-stack-item {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Static grid (non-draggable) cursor */
.grid-stack-static .grid-stack-item {
    cursor: default;
}

/* Draggable grid cursor */
.grid-stack:not(.grid-stack-static) .grid-stack-item .mud-card-header {
    cursor: move;
    cursor: grab;
}

.grid-stack:not(.grid-stack-static) .grid-stack-item .mud-card-header:active {
    cursor: grabbing;
}

/* ── Composite palette: drag preconfigured widgets (dsconfig.composite) onto the grid ── */

/* Palette chip. position:relative contains the globally abs-positioned .grid-stack-item-content
   (the chip's card / setupDragIn's drag handle) inside the fixed-size chip. */
.composite-palette-item {
    position: relative;
    width: 180px;
    height: 64px;
    flex: 0 0 auto;
    cursor: grab;
}

.composite-palette-item:active {
    cursor: grabbing;
}

.composite-palette-card {
    display: flex;
    flex-direction: row !important; /* global .grid-stack-item-content sets column */
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
    background: var(--mud-palette-surface);
    font-size: .8rem;
}

.composite-palette-item:hover .composite-palette-card {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}

.composite-palette-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The dropped clone holding its grid cells while Blazor builds the real tile: render it as a
   dashed translucent ghost (doubles as the loading placeholder until makeWidget swaps it out). */
.grid-stack > .composite-palette-item .composite-palette-card {
    opacity: .55;
    border-style: dashed;
    height: 100%;
    justify-content: center;
}
