/* Console page - minimal layout overrides */
html:has(body.console-page),
body.console-page {
  overflow: hidden;
  background: #1a1a2e !important;
}

.console-navbar {
  min-height: 2.5rem;
  padding: 0;
  background: #1f2937;
  border-bottom: 1px solid #374151;
}

.console-navbar .logo .logo-networks {
  fill: #ffffff;
  stroke: none;
}

.console-navbar .navbar-brand {
  min-height: 2.5rem;
}

.console-navbar .navbar-item {
  padding: 0.25rem 0.75rem;
}

.console-navbar .logo {
  height: 24px;
  width: auto;
}

/* VNC console container - full width for toolbar */
.vnc-console {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 2.5rem);
}

.vnc-console:fullscreen {
  height: 100vh;
}

/* CRT monitor frame */
.vnc-crt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 0;
  padding: 1.5rem 2rem 1rem;
}

.vnc-crt-bezel {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 1200px;
  width: 100%;
  height: 720px;
  transition: width 0.3s ease, height 0.3s ease;
  background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 40%, #222 100%);
  border-radius: 18px;
  padding: 18px 18px 12px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* Inner screen bezel - dark inset frame */
.vnc-crt-screen {
  flex: 1;
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    inset 0 0 20px rgba(0, 0, 0, 0.8),
    inset 0 0 3px rgba(0, 0, 0, 0.9);
}

/* Subtle screen curvature via overlay */
.vnc-crt-screen::after {
  content: "";
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  bottom: 30px;
  border-radius: 8px;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 65%,
    rgba(0, 0, 0, 0.15) 100%
  );
  z-index: 1;
}

/* Bottom strip with brand emboss and power LED */
.vnc-crt-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 0;
}

.vnc-crt-brand {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.12);
}

.vnc-crt-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #333;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.vnc-crt-led[data-state="connected"] {
  background: #22c55e;
  box-shadow:
    0 0 4px rgba(34, 197, 94, 0.6),
    0 0 8px rgba(34, 197, 94, 0.3);
}

.vnc-crt-led[data-state="connecting"] {
  background: #eab308;
  animation: vnc-pulse 1.5s ease-in-out infinite;
}

.vnc-crt-led[data-state="error"] {
  background: #ef4444;
}

/* Screen wrapper inside the CRT */
.vnc-screen-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
}

.vnc-screen-wrapper .vnc-screen {
  width: 100%;
}

/* Fullscreen: hide CRT frame */
.vnc-console:fullscreen .vnc-crt {
  padding: 0;
}

.vnc-console:fullscreen .vnc-crt-bezel {
  max-width: none;
  border-radius: 0;
  padding: 0;
  background: none;
  box-shadow: none;
}

.vnc-console:fullscreen .vnc-crt-screen {
  border-radius: 0;
  box-shadow: none;
}

.vnc-console:fullscreen .vnc-crt-screen::after {
  display: none;
}

.vnc-console:fullscreen .vnc-crt-bottom {
  display: none;
}

.vnc-console:fullscreen .vnc-crt-bezel {
  height: auto;
  flex: 1;
}

/* Toolbar */
.vnc-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.375rem 0.75rem;
  background: #16213e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.vnc-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.75);
  font-size: var(--bulma-size-normal);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.vnc-toolbar-btn.is-active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.vnc-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

.vnc-toolbar-btn .icon {
  font-size: var(--bulma-size-normal);
}

.vnc-toolbar-title {
  color: #fff;
  font-weight: 600;
  font-size: var(--bulma-size-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.vnc-toolbar-status {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: rgba(255, 255, 255, 0.6);
  font-size: var(--bulma-size-normal);
  margin-left: auto;
}

.vnc-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Status dot */
.vnc-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  flex-shrink: 0;
}

.vnc-status-dot[data-state="connecting"] {
  background: #fbbf24;
  animation: vnc-pulse 1.5s ease-in-out infinite;
}

.vnc-status-dot[data-state="connected"] {
  background: #34d399;
  animation: vnc-pulse 2s ease-in-out infinite;
}

.vnc-status-dot[data-state="error"] {
  background: #f87171;
}

.vnc-status-dot[data-state="disconnected"] {
  background: #6b7280;
}

@keyframes vnc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* VNC screen area */
.vnc-screen {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Hint below viewer */
.vnc-hint {
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: var(--bulma-size-normal);
  padding: 0.5rem;
  margin: 0;
}

.vnc-hint .icon {
  vertical-align: middle;
  margin-right: 0.25rem;
}

/* Keyboard button: only useful on touch devices without a physical keyboard */
@media (hover: hover) {
  .vnc-toolbar-kb {
    display: none;
  }
}

/* Hidden textarea for mobile keyboard input */
.vnc-kb-input {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Special keys bar */
.vnc-keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0 0;
  max-width: 1200px;
  width: 100%;
}

.vnc-keys-group {
  display: flex;
  gap: 3px;
  padding-right: 0.5rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.vnc-keys-group:last-child {
  padding-right: 0;
  border-right: none;
}

.vnc-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2rem;
  padding: 0 0.5rem;
  background: #2a2a3e;
  border: 1px solid #3d3d56;
  border-bottom: 2px solid #22222f;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.7);
  font-family: inherit;
  font-size: var(--bulma-size-small);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, border-color 0.1s, transform 0.05s, box-shadow 0.1s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.vnc-key:hover {
  background: #363650;
  color: rgba(255, 255, 255, 0.9);
  border-color: #4d4d6a;
}

.vnc-key:active {
  transform: translateY(1px);
  border-bottom-width: 1px;
  box-shadow: none;
}

.vnc-key-mod.is-active {
  background: #3b3082;
  border-color: #7c6bdb;
  color: #c4b8ff;
  box-shadow: 0 0 6px rgba(124, 107, 219, 0.4);
}

/* Fullscreen: keys bar stays visible */
.vnc-console:fullscreen .vnc-keys {
  padding: 0.5rem 0 0;
}

/* Responsive: shrink F-keys on small screens */
@media (max-width: 1024px) {
  .vnc-keys-fkeys .vnc-key:nth-child(n+5):nth-child(-n+8) {
    display: none;
  }
}

@media (max-width: 768px) {
  .vnc-keys-fkeys .vnc-key:nth-child(n+5) {
    display: none;
  }

  .vnc-key {
    min-width: 2rem;
    height: 1.75rem;
    padding: 0 0.375rem;
  }

  .vnc-keys {
    gap: 0.375rem;
    padding: 0.5rem 0.5rem 0;
  }

  .vnc-keys-group {
    padding-right: 0.375rem;
  }
}

/* ======== Theme: Silver (konami code easter egg) ======== */
.vnc-theme-silver .vnc-crt-bezel {
  background:
    linear-gradient(170deg,
      #9a9a9f 0%, #7a7a80 15%, #8e8e94 30%,
      #6e6e74 50%, #82828a 70%, #6a6a70 100%),
    linear-gradient(90deg,
      rgba(255, 255, 255, 0.04) 0%,
      rgba(255, 255, 255, 0.1) 50%,
      rgba(255, 255, 255, 0.04) 100%);
  background-blend-mode: overlay;
  border-radius: 12px;
  padding: 14px;
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    inset 1px 0 0 rgba(255, 255, 255, 0.1),
    inset -1px 0 0 rgba(0, 0, 0, 0.15);
}

.vnc-theme-silver .vnc-crt-screen {
  border-radius: 4px;
  box-shadow:
    inset 0 0 2px rgba(0, 0, 0, 0.8);
}

.vnc-theme-silver .vnc-crt-screen::after {
  display: none;
}

.vnc-theme-silver .vnc-crt-bottom {
  display: none;
}

/* Scanline flash on theme switch */
@keyframes vnc-scanlines {
  0%   { opacity: 0.9; background-position: 0 0; }
  10%  { opacity: 0.3; }
  20%  { opacity: 0.8; background-position: 0 20%; }
  30%  { opacity: 0.2; }
  40%  { opacity: 0.7; background-position: 0 45%; }
  55%  { opacity: 0.5; background-position: 0 60%; }
  70%  { opacity: 0.3; background-position: 0 80%; }
  85%  { opacity: 0.15; background-position: 0 90%; }
  100% { opacity: 0; background-position: 0 100%; }
}

.vnc-crt-screen.vnc-glitch::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 255, 0, 0.06) 0px,
      transparent 2px,
      transparent 4px
    ),
    linear-gradient(
      180deg,
      transparent 30%,
      rgba(0, 255, 65, 0.15) 50%,
      transparent 70%
    );
  animation: vnc-scanlines 1.5s ease-out forwards;
}

/* Boot screen overlay */
.vnc-boot {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: #000;
  display: flex;
  align-items: flex-start;
  padding: 2rem;
  transition: opacity 0.4s ease-out;
}

.vnc-boot.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.vnc-boot-text {
  font-family: "Courier New", Courier, monospace;
  font-size: var(--bulma-size-normal);
  color: #33ff33;
  line-height: 1.6;
  text-shadow: 0 0 4px rgba(51, 255, 51, 0.4);
  opacity: 0;
  animation: vnc-boot-reveal 0.3s ease-out 2s forwards;
}

@keyframes vnc-boot-reveal {
  to { opacity: 1; }
}

.vnc-boot-dots::after {
  content: "";
  animation: vnc-dots 1.5s steps(3) infinite;
}

@keyframes vnc-dots {
  0%   { content: ""; }
  33%  { content: "."; }
  66%  { content: ".."; }
  100% { content: "..."; }
}

.vnc-boot-cursor {
  animation: vnc-blink 0.8s step-end infinite;
}

.vnc-boot-text .vnc-boot-error {
  color: #ff4444;
  text-shadow: 0 0 4px rgba(255, 68, 68, 0.4);
}

@keyframes vnc-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Responsive: hide button labels on small screens */
@media (max-width: 768px) {
  .vnc-toolbar-btn span:not(.icon) {
    display: none;
  }

  .vnc-toolbar-title {
    max-width: 120px;
  }
}
