/* Full-screen cloud desktop.
 *
 * The visitor gets the machine edge to edge: no site chrome, no scrollbars,
 * and the guest desktop scaled to the exact browser viewport. The view is
 * pinned with `position: fixed; inset: 0` so it always measures 100vw x 100vh
 * regardless of what the surrounding app shell is doing. */

body.vm-desktop-active {
  overflow: hidden !important;
}

/* Hide the site chrome so nothing competes with the desktop. */
body.vm-desktop-active #shell > .topbar,
body.vm-desktop-active .os-taskbar,
body.vm-desktop-active .whats-new {
  display: none !important;
}

#v-vm {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #05070f;
  z-index: 900;
}

#v-vm[hidden] {
  display: none !important;
}

/* Stage holds whichever surface is currently live. */
.vm-stage {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #05070f;
}

/* Remote console (platform WebSocket stream). */
.vm-frame {
  display: block;
  width: 100vw;
  height: 100vh;
  border: 0;
  margin: 0;
  padding: 0;
  background: #000;
}

.vm-frame[hidden] {
  display: none !important;
}

/* Fallback: v86 Linux scaled into the viewport. */
.vm-local {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

.vm-local[hidden] {
  display: none !important;
}

.vm-local #screen_container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.vm-local #screen_container > div {
  width: 100%;
  margin: 0;
  padding: 0;
  color: #d8d8d8;
  background: #000;
  white-space: pre;
}

/* The guest desktop draws into the canvas. v86 hides it in text mode by
   setting display: none inline, so this block is only the graphics-mode look. */
.vm-local #screen_container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  background: #000;
  cursor: default;
  touch-action: none;
  image-rendering: pixelated;
}

/* Loading / status veil. */
.vm-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: #e8eaf2;
  background: radial-gradient(circle at 50% 40%, #131a33 0%, #05070f 70%);
  z-index: 5;
}

.vm-overlay[hidden] {
  display: none !important;
}

.vm-overlay-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.vm-overlay-detail {
  font-size: 13px;
  line-height: 1.5;
  color: #9aa3bf;
  max-width: 460px;
}

.vm-overlay[data-tone="error"] .vm-overlay-title {
  color: #ff8a8a;
}

.vm-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: #6ea8ff;
  animation: vm-spin 0.9s linear infinite;
}

.vm-overlay[data-tone="error"] .vm-spinner {
  display: none;
}

@keyframes vm-spin {
  to { transform: rotate(360deg); }
}

.vm-overlay-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.vm-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #e8eaf2;
  font: inherit;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.vm-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
}

.vm-btn.primary {
  background: #3b6fe0;
  border-color: #3b6fe0;
}

.vm-btn.primary:hover {
  background: #4a7cec;
}

/* Compact control bar that fades away so the desktop stays unobstructed. */
.vm-bar {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  z-index: 10;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.vm-bar[data-idle="true"] {
  opacity: 0;
  pointer-events: none;
}

.vm-bar .vm-btn {
  padding: 7px 12px;
  font-size: 12px;
  background: rgba(10, 14, 28, 0.72);
  backdrop-filter: blur(6px);
}

.vm-status {
  font-size: 12px;
  color: #9aa3bf;
  margin: 0;
  padding: 0 12px;
  line-height: 1.4;
}

.vm-status[data-state="ready"] {
  color: #7ee2a8;
}

.vm-status[data-state="error"] {
  color: #ff8a8a;
}

@media (max-width: 720px) {
  .vm-overlay-detail { font-size: 12px; }
  .vm-bar { padding: 8px; }
}
