/* Floating console window (partials/console_modal.php + console-window.js): non-blocking, movable
   by its title bar, resizable from the bottom-right corner, minimizable to a small bar. Sits under
   real modals (1050) so confirm dialogs still show above it. */
.nx-console-win {
  position: fixed;
  z-index: 1045;
  display: flex;
  flex-direction: column;
  min-width: 360px;
  min-height: 240px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  resize: both;
  overflow: hidden;
  background: var(--tblr-bg-surface);
  border: 1px solid var(--tblr-border-color);
  border-radius: var(--tblr-border-radius-lg);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, .25);
}
.nx-console-win[hidden] { display: none !important; }
.nx-console-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem .5rem .375rem .875rem;
  border-bottom: 1px solid var(--tblr-border-color);
  cursor: move;
  user-select: none;
  touch-action: none;
}
.nx-console-title { font-weight: 600; min-width: 0; }
.nx-console-tools { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.nx-console-dragging .console-screen { pointer-events: none; }
.nx-console-win .console-screen { flex: 1 1 auto; height: auto; min-height: 0; border-radius: 0; }
.nx-console-paste { padding: .5rem .75rem; border-bottom: 1px solid var(--tblr-border-color); }
.nx-console-foot {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .25rem .75rem;
  font-size: .75rem;
  border-top: 1px solid var(--tblr-border-color);
}
/* Kind-specific controls (data-kind is set when a session starts). */
.nx-console-win:not([data-kind="term"]) .nx-term-only { display: none !important; }
.nx-console-win:not([data-kind="vnc"]) .nx-vnc-only { display: none !important; }
/* Minimized: just the title bar, docked bottom-right; click the bar (or the button) to restore. */
.nx-console-win.nx-console-min {
  left: auto !important;
  top: auto !important;
  right: 1rem;
  bottom: 1rem;
  width: 340px !important;
  height: auto !important;
  min-height: 0;
  resize: none;
}
.nx-console-min .nx-console-bar { cursor: pointer; border-bottom: 0; }
.nx-console-min .console-screen,
.nx-console-min .nx-console-paste,
.nx-console-min .nx-console-foot,
.nx-console-min .nx-console-tools > :not(.js-console-min):not(.js-console-close) { display: none !important; }
@media (max-width: 575.98px) {
  .nx-console-win:not(.nx-console-min) { left: 8px !important; top: 8px !important; width: calc(100vw - 16px) !important; height: calc(100vh - 16px) !important; resize: none; }
}

/* Guest console screen, shared by the noVNC (vnc) and xterm.js (term) renderers. */
.console-screen {
  width: 100%;
  height: min(55vh, 420px);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* It's the bottom-most, full-bleed element of the modal/card: round its bottom corners so the
     black doesn't poke past the rounded container (overflow:hidden clips the content to match). */
  border-bottom-left-radius: var(--tblr-border-radius);
  border-bottom-right-radius: var(--tblr-border-radius);
}

/* noVNC: center its framebuffer canvas + clamp it to the box. */
.console-screen canvas {
  max-width: 100%;
  max-height: 100%;
}

/* xterm.js: fill the whole box (not centered/clamped), and DO NOT clamp xterm's own render
   canvases; the noVNC rule above would otherwise squash the terminal. */
/* xterm mount wrapper: full box; the terminal itself is pinned to 80 cols (matching the serial
   console), so center it horizontally and let it fill the height. */
/* The terminal fills the whole console area (absolute, so it never depends on a percentage
   height of a flex child); xterm-fit then sizes columns/rows (or the font, for QEMU serial). */
.console-screen { position: relative; }
.console-screen .console-term { position: absolute; inset: 0; }
.console-screen .xterm {
  height: 100%;
  padding: 4px 6px;
  box-sizing: border-box;
}
/* QEMU serial: the font follows the window width, so the size buttons do nothing there. */
.nx-console-win[data-fixed-cols] .js-console-font { display: none !important; }
.console-screen .xterm canvas {
  max-width: none;
  max-height: none;
}
