/* Dark theme tokens — copied verbatim from mobile/www/style.css so desktop
   and mobile never carry two palettes (AGENTS.md / PARITY.md rule). Any
   later panel should reuse these custom properties rather than introducing
   new colors. */
:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #2f81f7;
  --good: #3fb950;
  --bad: #f85149;
  --warn: #d29922;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
}

#shell {
  display: flex;
  height: 100vh;
}

#sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 16px;
}

#sidebar h1 {
  font-size: 18px;
  margin: 0 4px;
}

#searchBox {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#searchBox label {
  font-size: 11px;
  color: var(--text-dim);
}

#searchBox input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}

#searchBox input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-btn {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--surface-2);
}

.nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.nav-btn[aria-current="page"] {
  background: var(--surface-2);
  border-color: var(--accent);
  font-weight: 600;
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.view h2 {
  margin-top: 0;
}

.placeholder-note {
  color: var(--text-dim);
}

#infraToolbar {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#infraToolbar label {
  font-size: 12px;
  color: var(--text-dim);
}

#infraToolbar input[type="search"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  min-width: 260px;
}

#infraToolbar input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#infraRefreshBtn,
.retry-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

#infraRefreshBtn:hover,
.retry-btn:hover {
  border-color: var(--accent);
}

#infraLayout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

#infraTableContainer {
  flex: 2;
  min-width: 0;
}

#infraDetailContainer {
  flex: 1;
  min-width: 280px;
  position: sticky;
  top: 0;
}

.infra-state {
  border-radius: 8px;
  padding: 16px;
}

.infra-state--loading {
  color: var(--text-dim);
}

.infra-state--empty {
  color: var(--text-dim);
  border: 1px dashed var(--border);
}

.infra-state--error {
  background: var(--surface);
  border: 1px solid var(--bad);
}

.infra-state-title {
  margin: 0 0 6px 0;
  font-weight: 600;
}

.infra-error-detail,
.infra-refresh-error {
  color: var(--bad);
  font-size: 13px;
}

.infra-error-detail {
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.infra-asof {
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 10px;
}

.stale-badge {
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 11px;
  text-transform: uppercase;
}

.infra-empty-note {
  color: var(--text-dim);
}

.infra-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.infra-table th,
.infra-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.infra-table th {
  color: var(--text-dim);
  font-weight: 600;
  background: var(--surface-2);
  padding: 0;
}

.sort-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
}

.sort-btn:hover,
.sort-btn:focus-visible {
  color: var(--accent);
}

.guest-row {
  cursor: pointer;
}

.guest-row:hover {
  background: var(--surface-2);
}

.guest-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.guest-row--dimmed {
  opacity: 0.55;
}

.guest-row--selected {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.guest-reason {
  color: var(--text-dim);
  font-size: 11px;
}

.status--running { color: var(--good); }
.status--stopped { color: var(--bad); }
.status--paused { color: var(--warn); }
.status--unknown { color: var(--text-dim); }

.detail-empty {
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
}

.detail-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.detail-pane h3 {
  margin-top: 0;
}

.detail-idlabel {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 13px;
}

.detail-action-error {
  color: var(--bad);
  font-size: 13px;
}

.confirm-banner {
  background: var(--surface-2);
  border: 1px solid var(--bad);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
}

.confirm-banner p {
  margin: 0 0 8px 0;
  font-size: 13px;
}

.confirm-yes,
.confirm-no,
.power-btn,
.console-btn,
.snapshot-rollback-btn,
.snapshot-delete-btn,
.snapshot-create-form button,
#servicesProbeBtn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 6px;
}

.confirm-yes {
  border-color: var(--bad);
  color: var(--bad);
}

.power-controls {
  margin-bottom: 12px;
}

.resource-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin: 0 0 12px 0;
  font-size: 13px;
}

.resource-grid dt {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
}

.resource-grid dd {
  margin: 0;
}

.detail-section {
  margin-bottom: 12px;
  font-size: 13px;
}

.snapshot-list,
.service-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px 0;
}

.snapshot-list li,
.service-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.snapshot-name,
.service-name {
  font-weight: 600;
  flex-shrink: 0;
}

/* /api/services rows: the port/kind is dim metadata, and a port the server
   never observed answering is marked rather than presented as healthy. */
.service-kind {
  color: var(--text-dim);
  font-size: 0.85em;
  margin-left: 6px;
  flex-shrink: 0;
}

.service-unverified {
  color: var(--warn);
  font-size: 0.8em;
  margin-left: 6px;
  flex-shrink: 0;
}

.snapshot-desc {
  color: var(--text-dim);
  flex: 1;
}

.service-link {
  color: var(--accent);
}

.snapshot-create-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.snapshot-create-form label {
  font-size: 11px;
  color: var(--text-dim);
}

.snapshot-create-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

.services-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.reach-badge {
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  text-transform: uppercase;
}

.reach-badge--up { color: var(--good); border: 1px solid var(--good); }
.reach-badge--down { color: var(--bad); border: 1px solid var(--bad); }
.reach-badge--unknown { color: var(--text-dim); border: 1px solid var(--border); }

/* At 1366x768 with 125-150% OS scaling the effective CSS viewport shrinks to
   roughly 900-1100px wide (sidebar 240px + 64px content padding leaves very
   little room for a 2fr/1fr side-by-side layout) — stack the detail pane
   below the table instead of letting it get crushed under its min-width. */
@media (max-width: 1080px) {
  #infraLayout {
    flex-direction: column;
  }
  #infraDetailContainer {
    position: static;
    width: 100%;
    min-width: 0;
  }
}

/* Service panels share the desktop palette and remain usable on narrow windows. */
.service-surface { margin: 1rem 0; padding: 1rem; border: 1px solid #414653; border-radius: 8px; overflow-x: auto; }
.service-surface table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.service-surface th, .service-surface td { text-align: left; padding: .5rem; border-bottom: 1px solid #414653; overflow-wrap: anywhere; }
.service-surface button, .service-confirm button { margin-right: .5rem; }
.service-confirm { color: #eee; background: #20232b; border: 1px solid #777; border-radius: 8px; max-width: 32rem; }
.service-confirm::backdrop { background: #0009; }

.config-editor fieldset { border: 0; padding: 0; margin: 0 0 12px; }
.config-editor label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.config-editor input, .config-editor textarea { max-width: 100%; }
.config-editor input[type="checkbox"] { align-self: flex-start; }
.config-editor li, .config-editor [role="alert"] { white-space: pre-wrap; overflow-wrap: anywhere; }
.config-editor button { margin: 4px 8px 4px 0; }

/* Avatar panel (issue #6). The presence banner is always visible — it's the
   thing that turns a health-check failure into a labeled, readable fallback
   instead of a blank or frozen frame. */
.avatar-presence { margin: .75rem 0; padding: .6rem .9rem; border-radius: 8px; border: 1px solid #414653; }
.avatar-presence--live { border-color: #2f9e63; }
.avatar-presence--fallback, .avatar-presence--error { border-color: #b5793a; color: #f0c98a; }
.avatar-presence--auth-required { border-color: #d97706; color: #fcd34d; }
.avatar-stage { position: relative; width: 100%; height: 420px; border: 1px solid #414653; border-radius: 8px; overflow: hidden; background: #0a0510; }
.avatar-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#avatarSpeak { margin-top: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
#avatarSpeak label { flex-basis: 100%; }
#avatarSpeakInput { flex: 1 1 320px; min-width: 0; }
#avatarSpeakLog { flex-basis: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
.avatar-speak-error { color: #f0a0a0; }
/**
 * 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 .xterm-scroll-area {
    visibility: hidden;
}

.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,
.xterm .xterm-message {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 10;
    color: transparent;
    pointer-events: none;
}

.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;
}

/* Issue/PR details in service views */
.issue-detail, .pr-detail {
  max-width: 48rem;
  width: 90vw;
}
.issue-detail pre, .pr-detail pre {
  max-height: 60vh;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: monospace;
  background: var(--surface-2);
  padding: 8px;
  border-radius: 4px;
}

.guest-actions { border: 0; padding: 0; margin: 0; min-width: 0; }
#infraToolbar select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.detail-busy, .detail-notice { color: var(--accent); }

/* Settings subnav & More drill-ins */
.settings-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.subnav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.subnav-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.subnav-btn.active {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--text);
}
.settings-drill-in-container {
  margin-top: 8px;
}

/* Nextcloud breadcrumbs */
.nc-nav-container {
  margin-bottom: 12px;
}
.nc-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.nc-crumb {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 13px;
  border-radius: 3px;
}
.nc-crumb:hover {
  text-decoration: underline;
}
.nc-crumb-sep {
  color: var(--text-dim);
  font-size: 13px;
}

/* Scripts runner */
.scripts-button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.script-action-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.script-action-btn:hover:not(:disabled) {
  border-color: var(--accent);
}
.script-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.script-result-box {
  margin-top: 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.script-output {
  margin-top: 8px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

/* Connection form */
.connection-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 480px;
  margin-top: 12px;
}
.connection-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}
.connection-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}
.connection-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.connection-status {
  font-size: 13px;
  min-height: 20px;
}
