/* ---------- Dashboard grid (Components/DashboardGrid.razor) ---------- */

/* 12 column grid (6 on a medium, 1 on a narrow screen); tiles span --w columns and --h rows, the order is the
   saved order and dense auto-placement fills the gaps (see js/dashboard.js for the drag / resize gestures). */
.dash-grid {
    --dash-cols: 12;
    --dash-row: 32px;
    display: grid;
    grid-template-columns: repeat(var(--dash-cols), minmax(0, 1fr));
    grid-auto-rows: var(--dash-row);
    grid-auto-flow: row dense;
    gap: 12px;
}

.dash-tile {
    position: relative;
    grid-column: span var(--w, 4);
    grid-row: span var(--h, 6);
    padding: 10px 12px 12px;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dash-tile-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

/* Fixed height: the body takes the rest of the tile and scrolls; views that follow --kofa-view-height fill it. */
.dash-tile.fixed .dash-tile-inner {
    flex: 1 1 auto;
    min-height: 0;
}

.dash-tile.fixed .dash-tile-body {
    --kofa-view-height: 100%;
    flex: 1 1 0;
    min-height: 0;
    overflow: auto;
}

/* Auto height: the inner box keeps its natural height, dashboard.js measures it into rows. */
.dash-tile.auto .dash-tile-inner {
    flex: none;
}

@media (max-width: 1100px) {
    .dash-grid { --dash-cols: 6; }
    .dash-tile { grid-column: span var(--wm, 2); }
}

@media (max-width: 700px) {
    .dash-grid { --dash-cols: 1; }
    .dash-tile { grid-column: 1 / -1; }
}

.dash-grid.editing .dash-tile {
    outline: 1px dashed var(--accent-fill-rest, #0f6cbd);
    outline-offset: -1px;
}

.dash-grid.editing .dash-tile-head {
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.dash-tile.dragging {
    opacity: 0.75;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 2;
}

.dash-tile.dragging.move .dash-tile-head {
    cursor: grabbing;
}

.dash-grid.editing .dash-tile-body {
    pointer-events: none;
}

.dash-resize {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 26px;
    height: 26px;
    cursor: nwse-resize;
    touch-action: none;
    z-index: 3;
    background: linear-gradient(135deg, transparent 0 50%, var(--accent-fill-rest, #0f6cbd) 50% 58%, transparent 58% 68%,
        var(--accent-fill-rest, #0f6cbd) 68% 76%, transparent 76%);
}

.dash-tile-size {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    margin-right: 4px;
    white-space: nowrap;
    align-self: center;
}

.dash-tile-open {
    flex: none;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
}

.dash-tile-open:hover {
    opacity: 1;
    background: var(--neutral-fill-stealth-hover, rgba(127, 127, 127, 0.15));
}

.dash-tile-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.dash-tile-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
    text-decoration: none;
}

a.dash-tile-title:hover {
    text-decoration: underline;
}

.dash-tile-komod {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-tile-tools {
    display: flex;
    gap: 2px;
    flex: none;
}

.dash-tile-tools button:disabled {
    opacity: 0.35;
    cursor: default;
}

.dash-tile-tools button {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--neutral-stroke-rest, #ccc);
    border-radius: 4px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.dash-tile-status {
    font-size: 0.85rem;
}

.dash-tile-body {
    min-width: 0;
}

.state-dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9e9e9e;
}

.state-dot.state-running { background: #2e9e44; }
.state-dot.state-faulted { background: #c42b1c; }
.state-dot.state-starting,
.state-dot.state-stopping { background: #d4a000; }
