/*
 * noVNC base CSS
 * Copyright (C) 2019 The noVNC Authors
 * noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
 * This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
 */

/*
 * Z index layers:
 *
 * 0: Main screen
 * 10: Control bar
 * 50: Transition blocker
 * 60: Connection popups
 * 100: Status bar
 * ...
 * 1000: Javascript crash
 * ...
 * 10000: Max (used for polyfills)
 */

html {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background-color: #313131;
  height: 100%;
  touch-action: none;
}

.noVNC_only_touch.noVNC_hidden {
  display: none;
}

/* ----------------------------------------
 * Spinner
 * ----------------------------------------
 */

.noVNC_spinner {
  position: relative;
}
.noVNC_spinner,
.noVNC_spinner::before,
.noVNC_spinner::after {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  box-shadow: -60px 10px 0 rgba(255, 255, 255, 0);
  animation: noVNC_spinner 1s linear infinite;
}
.noVNC_spinner::before {
  content: "";
  position: absolute;
  left: 0px;
  top: 0px;
  animation-delay: -0.1s;
}
.noVNC_spinner::after {
  content: "";
  position: absolute;
  top: 0px;
  left: 0px;
  animation-delay: 0.1s;
}
@keyframes noVNC_spinner {
  0% {
    box-shadow: -60px 10px 0 rgba(255, 255, 255, 0);
    width: 20px;
  }
  25% {
    box-shadow: 20px 10px 0 rgba(255, 255, 255, 1);
    width: 10px;
  }
  50% {
    box-shadow: 60px 10px 0 rgba(255, 255, 255, 0);
    width: 10px;
  }
}

/* ----------------------------------------
 * WebKit centering hacks
 * ----------------------------------------
 */

.noVNC_center {
  /*
   * This is a workaround because webkit misrenders transforms and
   * uses non-integer coordinates, resulting in blurry content.
   * Ideally we'd use "top: 50%; transform: translateY(-50%);" on
   * the objects instead.
   */
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.noVNC_center > * {
  pointer-events: auto;
}
.noVNC_vcenter {
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  pointer-events: none;
}
.noVNC_vcenter > * {
  pointer-events: auto;
}

/* ----------------------------------------
 * Layering
 * ----------------------------------------
 */

.noVNC_connect_layer {
  z-index: 60;
}

/* ----------------------------------------
 * Fallback error
 * ----------------------------------------
 */

#noVNC_fallback_error {
  z-index: 1000;
  visibility: hidden;
  /* Put a dark background in front of everything but the error,
     and don't let mouse events pass through */
  background: rgba(0, 0, 0, 0.8);
  pointer-events: all;
}
#noVNC_fallback_error.noVNC_open {
  visibility: visible;
}

#noVNC_fallback_error > div {
  max-width: calc(100vw - 30px - 30px);
  max-height: calc(100vh - 30px - 30px);
  overflow: auto;

  padding: 15px;

  transition: 0.5s ease-in-out;

  transform: translateY(-50px);
  opacity: 0;

  text-align: center;
  font-weight: bold;
  color: #fff;

  border-radius: 10px;
  box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.5);
  background: rgba(200, 55, 55, 0.8);
}
#noVNC_fallback_error.noVNC_open > div {
  transform: translateY(0);
  opacity: 1;
}

#noVNC_fallback_errormsg {
  font-weight: normal;
}

#noVNC_fallback_errormsg .noVNC_message {
  display: inline-block;
  text-align: left;
  font-family: monospace;
  white-space: pre-wrap;
}

#noVNC_fallback_error .noVNC_location {
  font-style: italic;
  font-size: 0.8em;
  color: rgba(255, 255, 255, 0.8);
}

#noVNC_fallback_error .noVNC_stack {
  padding: 10px;
  margin: 10px;
  font-size: 0.8em;
  text-align: left;
  font-family: monospace;
  white-space: pre;
  border: 1px solid rgba(0, 0, 0, 0.5);
  background: rgba(0, 0, 0, 0.2);
  overflow: auto;
}

/* ----------------------------------------
 * Control Bar
 * ----------------------------------------
 */

#noVNC_control_bar_anchor {
  /* The anchor is needed to get z-stacking to work */
  position: fixed;
  z-index: 10;

  transition: 0.5s ease-in-out;

  /* Edge misrenders animations without this */
  transform: translateX(0);
}
#noVNC_control_bar_anchor.noVNC_right {
  left: auto;
  right: 0;
}
:root.noVNC_connected #noVNC_control_bar_anchor.noVNC_idle {
  /* reduce opacity of the control bar when idle */
  opacity: 0.8;
}

#noVNC_control_bar {
  position: relative;
  left: -100%; /* was: calc(-100% + 15px) */
  right: auto;

  transition: 0.5s ease-in-out;
}
/* Programmatic focus only (tabIndex=-1); do not show a focus ring on the panel. */
#noVNC_control_bar:focus {
  outline: none;
}
#noVNC_control_bar.noVNC_open {
  left: 0;
  right: auto;
}

.noVNC_right #noVNC_control_bar {
  left: auto;
  right: -100%; /* was: calc(-100% + 15px) */
}

.noVNC_right #noVNC_control_bar.noVNC_open {
  left: auto;
  right: 0;
}

#noVNC_control_bar .noVNC_scroll {
  max-height: 90vh;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Control bar content */

/* noVNC Touch Device only buttons */
:root:not(.noVNC_touch) #noVNC_keyboard_button {
  display: none;
}

/* Control bar hint */
#noVNC_control_bar_hint {
  position: fixed;
  left: calc(100vw - 50px);
  right: auto;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 100px;
  height: 50%;
  max-height: 600px;

  visibility: hidden;
  opacity: 0;
  transition: 0.2s ease-in-out;
  background: transparent;
  box-shadow:
    0 0 10px black,
    inset 0 0 10px 10px rgba(110, 132, 163, 0.8);
  border-radius: 10px;
  transition-delay: 0s;
}
#noVNC_control_bar_anchor.noVNC_right #noVNC_control_bar_hint {
  left: auto;
  right: calc(100vw - 50px);
}
#noVNC_control_bar_hint.noVNC_active {
  visibility: visible;
  opacity: 1;
  transition-delay: 0.2s;
  transform: translateY(-50%) scale(1);
}

/* ----------------------------------------
 * Status Dialog
 * ----------------------------------------
 */

#noVNC_status {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 100;
  transform: translateY(-100%);

  cursor: pointer;

  transition: 0.5s ease-in-out;

  visibility: hidden;
  opacity: 0;

  padding: 5px;

  display: flex;
  flex-direction: row;
  justify-content: center;
  align-content: center;

  line-height: 1.6;
  word-wrap: break-word;
  color: #fff;

  border-bottom: 1px solid rgba(0, 0, 0, 0.9);
}
#noVNC_status.noVNC_open {
  transform: translateY(0);
  visibility: visible;
  opacity: 1;
}

#noVNC_status::before {
  content: "";
  display: inline-block;
  width: 25px;
  height: 25px;
  margin-right: 5px;
}

#noVNC_status.noVNC_status_normal {
  background: rgba(128, 128, 128, 0.9);
}
#noVNC_status.noVNC_status_normal::before {
  content: url("../images/info.svg") " ";
}
#noVNC_status.noVNC_status_error {
  background: rgba(200, 55, 55, 0.9);
}
#noVNC_status.noVNC_status_error::before {
  content: url("../images/error.svg") " ";
}
#noVNC_status.noVNC_status_warn {
  /*background: rgba(180,180,30,0.9);*/
  background: rgba(255, 193, 7, 0.9);
}
#noVNC_status.noVNC_status_warn::before {
  content: url("../images/warning.svg") " ";
}

/* ----------------------------------------
 * Password Dialog
 * ----------------------------------------
 */

#noVNC_credentials_dlg {
  position: relative;

  transform: translateY(-50px);

  visibility: hidden;
  opacity: 0;

  transition: 0.5s ease-in-out;
}
#noVNC_credentials_dlg.noVNC_open {
  transform: translateY(0);
  visibility: visible;
  opacity: 1;
}
.noVNC_hidden {
  display: none;
}

/*
.toolbar {
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
*/
.fmgr-dialog .toolbar .btn {
  width: 50px;
  height: 50px;
  font-size: 1.2rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  margin-right: 8px;
}

.fmgr-dialog .toolbar .btn:last-child {
  margin-right: 0;
}

.fmgr-dialog .toolbar .btn-clicked {
  transform: scale(0.9); /* Shrink the button slightly */
}

/* ----------------------------------------
 * Main Area
 * ----------------------------------------
 */

/* Transition screen */
#noVNC_transition {
  transition: 0.5s ease-in-out;

  display: flex;
  opacity: 0;
  visibility: hidden;

  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;

  color: white;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;

  /*display: flex;*/
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
:root.noVNC_loading #noVNC_transition,
:root.noVNC_connecting #noVNC_transition,
:root.noVNC_disconnecting #noVNC_transition,
:root.noVNC_reconnecting #noVNC_transition {
  opacity: 1;
  visibility: visible;
}
:root:not(.noVNC_reconnecting) #noVNC_cancel_reconnect_button {
  display: none;
}
#noVNC_transition_text {
  font-size: 1.5em;
}

/* Main container */
#noVNC_container {
  width: 100%;
  height: 100%;
}

#noVNC_keyboardinput {
  width: 1px;
  height: 1px;
  background-color: #fff;
  color: #fff;
  border: 0;
  position: absolute;
  left: -40px;
  z-index: -1;
  ime-mode: disabled;
}

/* ----------------------------------------
 * Action Button
 * ----------------------------------------
 */

.btn.noVNC_selected {
  background: #e9ecef;
  border: 1px solid;
  border-color: #ced4da;
}

html[data-bs-theme="dark"] .btn.noVNC_selected {
  background: #3b3b3b;
  border: 1px solid;
  border-color: #525151;
}

/* ----------------------------------------
 * Accordion Button
 * ----------------------------------------
 */

.custom-accordion-button {
  display: flex;
  cursor: pointer;
}
.custom-accordion-button::after {
  content: "\276F";
  margin-left: 0.5rem;
  transition: transform 0.2s ease-in-out;
}
.custom-accordion-button:not(.collapsed)::after {
  content: "\276F";
  transform: rotate(90deg);
}

/* ----------------------------------------
 * Control Bar Handle
 * ----------------------------------------
 *
 * The element is kept as-is because app/ui.js binds its click/drag handlers
 * to it, but it is re-styled as a faint chevron pinned to the top-left corner
 * of the noVNC container. It points right while the panel is closed, and
 * follows the right edge of the panel (pointing left) while it is open.
 */

:root {
  --control-bar-panel-width: 21rem; /* must match the card's inline width */
  --control-bar-handle-size: 22px;
  --control-bar-handle-offset: 2px; /* the "very little padding" */
  --control-bar-handle-color: rgba(255, 255, 255, 0.35);
  --control-bar-handle-color-hover: rgba(255, 255, 255, 0.9);
  --control-bar-handle-bg-hover: rgba(0, 0, 0, 0.25);
}

.handle {
  position: fixed;
  top: var(--control-bar-handle-offset);
  left: var(--control-bar-handle-offset);

  width: var(--control-bar-handle-size);
  height: var(--control-bar-handle-size);

  display: flex;
  align-items: center;
  justify-content: center;

  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;

  color: var(--control-bar-handle-color);
  cursor: pointer;

  /* ui.js writes an inline transform on resize/drag; keep the button pinned. */
  transform: none !important;

  transition:
    left 0.5s ease-in-out,
    right 0.5s ease-in-out,
    color 0.2s ease,
    background-color 0.2s ease;

  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.handle:hover,
.handle:active {
  color: var(--control-bar-handle-color-hover);
  background-color: var(--control-bar-handle-bg-hover);
}

/* The original three dots (which morph into an "X") are no longer used. */
.handle .dots {
  display: none;
}

.handle-chevron {
  width: 16px;
  height: 16px;
  pointer-events: none;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.6));
  transition: transform 0.3s ease-in-out;
}

/* Open: sit just outside the panel and point back towards it. */
#noVNC_control_bar.noVNC_open .handle {
  left: calc(
    var(--control-bar-panel-width) + var(--control-bar-handle-offset) + 2px
  );
}
#noVNC_control_bar.noVNC_open .handle-chevron {
  transform: rotate(180deg);
}

/* Mirrored variant for a right-anchored control bar. */
.noVNC_right .handle {
  left: auto;
  right: var(--control-bar-handle-offset);
}
.noVNC_right .handle-chevron {
  transform: rotate(180deg);
}
.noVNC_right #noVNC_control_bar.noVNC_open .handle {
  left: auto;
  right: calc(
    var(--control-bar-panel-width) + var(--control-bar-handle-offset) + 2px
  );
}
.noVNC_right #noVNC_control_bar.noVNC_open .handle-chevron {
  transform: rotate(0deg);
}

/* A native <select> uses min-width: auto, so a long device name would widen the panel. */
#noVNC_microphone_device {
  min-width: 0;
  width: 0;
}

/* ----------------------------------------
 * Control Bar: full-height panel
 * ----------------------------------------
 */

/* Panel spans the whole viewport instead of the default 90vh centered box. */
#noVNC_control_bar {
  height: 100%;
}

#noVNC_control_bar > .card.noVNC_scroll {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: none; /* was 90vh */
  border-radius: 0; /* flush with the screen edges */
}

/* The section list takes the leftover height and distributes its items. */
#noVNC_control_bar > .card.noVNC_scroll > .list-group {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Don't let sections squash when the window is short; let the card scroll. */
#noVNC_control_bar > .card.noVNC_scroll > .list-group > .list-group-item {
  flex-shrink: 0;
}

/* BeamWatch's control panel owns audio: hide noVNC's built-in audio section
   (volume slider + mute button). The controls stay in the DOM so the bridge
   script can drive them. */
#noVNC_audio_section {
  display: none !important;
}
