/**
 * Copyright (c) 2014 The xterm.js authors. All rights reserved.
 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/term.js
 * @license MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * Originally forked from (with the author's permission):
 *   Fabrice Bellard's javascript vt100 for jslinux:
 *   http://bellard.org/jslinux/
 *   Copyright (c) 2011 Fabrice Bellard
 *   The original design remains. The terminal itself
 *   has been extended to include xterm CSI codes, among
 *   other features.
 */

/**
 *  Default styles for xterm.js
 */

.xterm {
    cursor: text;
    position: relative;
    user-select: none;
    -ms-user-select: none;
    -webkit-user-select: none;
}

.xterm.focus,
.xterm:focus {
    outline: none;
}

.xterm .xterm-helpers {
    position: absolute;
    top: 0;
    /**
     * The z-index of the helpers must be higher than the canvases in order for
     * IMEs to appear on top.
     */
    z-index: 5;
}

.xterm .xterm-helper-textarea {
    padding: 0;
    border: 0;
    margin: 0;
    /* Move textarea out of the screen to the far left, so that the cursor is not visible */
    position: absolute;
    opacity: 0;
    left: -9999em;
    top: 0;
    width: 0;
    height: 0;
    z-index: -5;
    /** Prevent wrapping so the IME appears against the textarea at the correct position */
    white-space: nowrap;
    overflow: hidden;
    resize: none;
}

.xterm .composition-view {
    /* TODO: Composition position got messed up somewhere */
    background: #000;
    color: #FFF;
    display: none;
    position: absolute;
    white-space: nowrap;
    z-index: 1;
}

.xterm .composition-view.active {
    display: block;
}

.xterm .xterm-viewport {
    /* On OS X this is required in order for the scroll bar to appear fully opaque */
    background-color: #000;
    overflow-y: scroll;
    cursor: default;
    position: absolute;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
}

.xterm .xterm-screen {
    position: relative;
}

.xterm .xterm-screen canvas {
    position: absolute;
    left: 0;
    top: 0;
}

.xterm-char-measure-element {
    display: inline-block;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: -9999em;
    line-height: normal;
}

.xterm.enable-mouse-events {
    /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
    cursor: default;
}

.xterm.xterm-cursor-pointer,
.xterm .xterm-cursor-pointer {
    cursor: pointer;
}

.xterm.column-select.focus {
    /* Column selection mode */
    cursor: crosshair;
}

.xterm .xterm-accessibility:not(.debug),
.xterm .xterm-message {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 10;
    color: transparent;
    pointer-events: none;
}

.xterm .xterm-accessibility-tree:not(.debug) *::selection {
  color: transparent;
}

.xterm .xterm-accessibility-tree {
  font-family: monospace;
  user-select: text;
  white-space: pre;
}

.xterm .xterm-accessibility-tree > div {
  transform-origin: left;
  width: fit-content;
}

.xterm .live-region {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.xterm-dim {
    /* Dim should not apply to background, so the opacity of the foreground color is applied
     * explicitly in the generated class and reset to 1 here */
    opacity: 1 !important;
}

.xterm-underline-1 { text-decoration: underline; }
.xterm-underline-2 { text-decoration: double underline; }
.xterm-underline-3 { text-decoration: wavy underline; }
.xterm-underline-4 { text-decoration: dotted underline; }
.xterm-underline-5 { text-decoration: dashed underline; }

.xterm-overline {
    text-decoration: overline;
}

.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }

.xterm-strikethrough {
    text-decoration: line-through;
}

.xterm-screen .xterm-decoration-container .xterm-decoration {
	z-index: 6;
	position: absolute;
}

.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
	z-index: 7;
}

.xterm-decoration-overview-ruler {
    z-index: 8;
    position: absolute;
    top: 0;
    right: 0;
    pointer-events: none;
}

.xterm-decoration-top {
    z-index: 2;
    position: relative;
}



/* Derived from vs/base/browser/ui/scrollbar/media/scrollbar.css */

/* xterm.js customization: Override xterm's cursor style */
.xterm .xterm-scrollable-element > .scrollbar {
    cursor: default;
}

/* Arrows */
.xterm .xterm-scrollable-element > .scrollbar > .scra {
	cursor: pointer;
	font-size: 11px !important;
}

.xterm .xterm-scrollable-element > .visible {
	opacity: 1;

	/* Background rule added for IE9 - to allow clicks on dom node */
	background:rgba(0,0,0,0);

	transition: opacity 100ms linear;
	/* In front of peek view */
	z-index: 11;
}
.xterm .xterm-scrollable-element > .invisible {
	opacity: 0;
	pointer-events: none;
}
.xterm .xterm-scrollable-element > .invisible.fade {
	transition: opacity 800ms linear;
}

/* Scrollable Content Inset Shadow */
.xterm .xterm-scrollable-element > .shadow {
	position: absolute;
	display: none;
}
.xterm .xterm-scrollable-element > .shadow.top {
	display: block;
	top: 0;
	left: 3px;
	height: 3px;
	width: 100%;
	box-shadow: var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset;
}
.xterm .xterm-scrollable-element > .shadow.left {
	display: block;
	top: 3px;
	left: 0;
	height: 100%;
	width: 3px;
	box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
}
.xterm .xterm-scrollable-element > .shadow.top-left-corner {
	display: block;
	top: 0;
	left: 0;
	height: 3px;
	width: 3px;
}
.xterm .xterm-scrollable-element > .shadow.top.left {
	box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;
}

/* /linux page (Re:Vault Linux). Loaded only by linux.html, concatenated after xterm.css by build.mjs. */
.rv-lx-body { height: 100%; overflow: hidden; }
.rv-lx { display: grid; grid-template-columns: 224px minmax(0, 1fr); height: 100%; min-height: 0; color: var(--fg-2); }
.rv-lx-loading, .rv-lx-noscript { padding: 28px; color: var(--muted-2); }

/* machines sidebar */
.rv-lx-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--bg); }
.rv-lx-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 10px; }
.rv-lx-side-head h1 { font-size: 13px; font-weight: 600; color: var(--fg); letter-spacing: 0.2px; display: flex; align-items: center; gap: 8px; }
.rv-lx-side-head h1 svg { width: 18px; height: 18px; color: var(--accent); }
.rv-lx-machines { list-style: none; margin: 0; padding: 0 8px; overflow: auto; flex: 1; min-height: 0; }
.rv-lx-machine { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 2px 9px; width: 100%; text-align: left; padding: 9px 10px; margin: 0 0 2px; border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--fg-2); }
.rv-lx-machine:hover { background: var(--surface); }
.rv-lx-machine[aria-current="true"] { background: var(--surface); border-color: var(--line); color: var(--fg); }
.rv-lx-machine-dot { grid-row: span 2; align-self: center; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.rv-lx-machine[data-state="running"] .rv-lx-machine-dot { background: #27c093; box-shadow: 0 0 0 3px color-mix(in srgb, #27c093 22%, transparent); }
.rv-lx-machine[data-state="busy"] .rv-lx-machine-dot { background: var(--accent); }
.rv-lx-machine[data-state="error"] .rv-lx-machine-dot { background: var(--danger); }
.rv-lx-machine-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.rv-lx-machine-sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-lx-side-foot { padding: 10px 14px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.rv-lx-side-foot a { color: var(--muted-2); }
.rv-lx-side-foot a:hover { color: var(--fg); }

/* main column */
.rv-lx-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: clip; }
.rv-lx-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.rv-lx-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.rv-lx-title b { color: var(--fg); font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-lx-title span { color: var(--muted); font-size: 11px; }
.rv-lx-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted-2); padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--radius-pill); white-space: nowrap; }
.rv-lx-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.rv-lx-status[data-state="running"] { color: #27c093; }
.rv-lx-status[data-state="running"]::before { background: #27c093; }
.rv-lx-status[data-state="busy"]::before { background: var(--accent); animation: rvlxpulse 1.2s ease-in-out infinite; }
.rv-lx-status[data-state="error"] { color: var(--danger); }
.rv-lx-status[data-state="error"]::before { background: var(--danger); }
@keyframes rvlxpulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .rv-lx-status[data-state="busy"]::before { animation: none; } }
.rv-lx-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.rv-lx-actions .rv-btn { height: 32px; padding: 0 12px; }

.rv-lx-progress { padding: 8px 16px 0; font-size: 12px; color: var(--muted-2); }
.rv-lx-progress-track { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.rv-lx-progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }
.rv-lx-progress[data-indeterminate="1"] .rv-lx-progress-fill { width: 30%; animation: rvlxslide 1.1s ease-in-out infinite; }
@keyframes rvlxslide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .rv-lx-progress[data-indeterminate="1"] .rv-lx-progress-fill { animation: none; width: 100%; opacity: 0.4; } }

.rv-lx-notice { margin: 10px 16px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 12.5px; line-height: 1.5; color: var(--fg-2); display: flex; gap: 10px; align-items: flex-start; }
.rv-lx-notice[data-kind="error"] { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.rv-lx-notice[data-kind="ok"] { border-color: color-mix(in srgb, #27c093 40%, var(--line)); }
.rv-lx-notice p { flex: 1; margin: 0; }
.rv-lx-notice button { background: none; border: 0; color: var(--muted); padding: 0 2px; font-size: 16px; line-height: 1; }

.rv-lx-tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
.rv-lx-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px 9px; color: var(--muted-2); font-size: 13px; margin-bottom: -1px; }
.rv-lx-tab:hover { color: var(--fg); }
.rv-lx-tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
/* clip, not hidden: focusing xterm's textarea must never scroll the page (hidden still allows it) */
.rv-lx-panel { flex: 1; min-height: 0; position: relative; overflow: clip; }
.rv-lx-panel[hidden] { display: none; }

/* console */
.rv-lx-console { position: absolute; inset: 0; background: var(--surface); padding: 8px 6px 4px 10px; overflow: clip; }
.rv-lx-term { width: 100%; height: 100%; }
.rv-lx-term .xterm { height: 100%; }
.rv-lx-term .xterm-viewport { background: transparent !important; }

/* screen */
.rv-lx-screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #000; overflow: hidden; outline: none; }
.rv-lx-screen:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-2); }
.rv-lx-v86-screen { position: relative; line-height: 0; }
.rv-lx-v86-screen > div { white-space: pre; font: 14px/1 ui-monospace, Menlo, Consolas, monospace; color: #ddd; line-height: normal; }
.rv-lx-v86-screen > canvas { display: none; image-rendering: pixelated; }
.rv-lx-kms { max-width: 100%; max-height: 100%; background: #000; outline: none; }
.rv-lx-kms:focus-visible { box-shadow: 0 0 0 2px var(--accent-2); }
.rv-lx-capture { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); padding: 7px 14px; border-radius: var(--radius-pill); background: rgba(0, 0, 0, 0.72); border: 1px solid var(--line); color: var(--fg); font-size: 12px; pointer-events: none; white-space: nowrap; }
.rv-lx-capture kbd, .rv-lx-help kbd { font: 11px ui-monospace, Menlo, monospace; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); }
.rv-lx-screen-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 24px; line-height: 1.6; }

/* files + machine forms */
.rv-lx-scroll { position: absolute; inset: 0; overflow: auto; padding: 16px; }
.rv-lx-section { max-width: 760px; margin: 0 0 22px; }
.rv-lx-section h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.rv-lx-help { font-size: 12.5px; color: var(--muted-2); line-height: 1.6; margin: 0 0 10px; }
.rv-lx-code { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.rv-lx-code code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 12px ui-monospace, Menlo, Consolas, monospace; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--fg); }
.rv-lx-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 22px; border: 1px dashed var(--line); border-radius: var(--radius-lg); background: var(--surface); text-align: center; color: var(--muted-2); font-size: 13px; }
.rv-lx-drop[data-over="1"] { border-color: var(--accent); color: var(--fg); }
.rv-lx-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.rv-lx-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.rv-lx-row:last-child { border-bottom: 0; }
.rv-lx-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); }
.rv-lx-row .rv-btn { height: 28px; padding: 0 10px; font-size: 12px; }
.rv-lx-empty { padding: 12px; font-size: 12.5px; color: var(--muted); }
.rv-lx-form { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 10px 14px; align-items: center; }
.rv-lx-form label { font-size: 13px; color: var(--fg-2); }
.rv-lx-form small { grid-column: 2; margin-top: -6px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.rv-lx-input, .rv-lx-select { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--fg); font: inherit; min-width: 0; width: 100%; max-width: 420px; }
.rv-lx-input:focus, .rv-lx-select:focus { outline: none; border-color: var(--accent-2); }
.rv-lx-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.rv-lx-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* modal (licence notice, confirmations) */
.rv-lx-modal { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(0, 0, 0, 0.66); }
.rv-lx-dialog { width: 100%; max-width: 560px; max-height: 100%; overflow: auto; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg); color: var(--fg-2); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.rv-lx-dialog h2 { color: var(--fg); font-size: 17px; margin: 0 0 10px; }
.rv-lx-dialog p { font-size: 13px; line-height: 1.6; margin: 0 0 12px; }
.rv-lx-dialog ul { margin: 0 0 12px 18px; font-size: 12.5px; line-height: 1.8; }
.rv-lx-dialog a { color: var(--accent); }

/* narrow: the machine list becomes a strip above the main column */
@media (max-width: 760px) {
	.rv-lx { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
	.rv-lx-side { border-right: 0; border-bottom: 1px solid var(--line); }
	.rv-lx-machines { display: flex; gap: 4px; overflow-x: auto; padding: 0 8px 8px; }
	.rv-lx-machine { width: auto; min-width: 150px; }
	.rv-lx-side-foot { display: none; }
	.rv-lx-form { grid-template-columns: minmax(0, 1fr); }
	.rv-lx-form small { grid-column: 1; }
}

/* disabled buttons must look disabled (the licence notice's Continue, Start while another machine runs) */
.rv-lx .rv-btn[disabled], .rv-lx-dialog .rv-btn[disabled] { opacity: 0.45; cursor: default; filter: saturate(0.4); }
.rv-lx .rv-btn[disabled]:hover, .rv-lx-dialog .rv-btn[disabled]:hover { border-color: var(--line); background: inherit; }
