/* console.css — operator console for the VPS browser.
   Theme via CSS variables on :root[data-theme]; every colour comes from a token
   so the light/dark switch is one attribute change. */

:root {
  --bg: #0b1220;
  --panel: #111a2b;
  --panel-2: #16233a;
  --line: #22304a;
  --fg: #e6edf7;
  --fg-dim: #93a4bf;
  --accent: #4f8cff;
  --ok: #2fa25b;
  --warn: #c98a1b;
  --danger: #d2483f;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 12px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef2f8;
  --panel: #ffffff;
  --panel-2: #f4f7fc;
  --line: #dce3ee;
  --fg: #101828;
  --fg-dim: #5a6b85;
  --accent: #2563eb;
  --ok: #1d7f45;
  --warn: #a86910;
  --danger: #b3372f;
  --shadow: 0 10px 30px rgba(16, 24, 40, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, system-ui, "Segoe UI", sans-serif;
  font-size: 14px;
}

/* themed scrollbars, everywhere */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); background-clip: content-box; }

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  height: 100vh;
}

/* ── live browser pane ─────────────────────────────────────────────── */
.stage { display: flex; flex-direction: column; min-width: 0; background: #000; }

.stage-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.stage-title { font-weight: 600; }
.stage-title i { color: var(--accent); margin-right: 6px; }
.stage-actions { display: flex; gap: 6px; }
.dim { color: var(--fg-dim); font-weight: 400; }

#vnc { flex: 1; width: 100%; border: 0; background: #000; }

/* ── side panel ────────────────────────────────────────────────────── */
.side {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; overflow-y: auto;
  background: var(--bg); border-left: 1px solid var(--line);
}

.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.side-head h1 { font-size: 16px; margin: 0; letter-spacing: -.01em; }
.side-head .sub { margin: 2px 0 0; font-size: 12px; color: var(--fg-dim); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow);
}
.card.grow { flex: 1; min-height: 220px; }
.card-title { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--accent); }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.label { color: var(--fg-dim); font-size: 12px; }
.value { font-weight: 500; font-size: 13px; text-align: right; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg-dim);
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.pill.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }

.units { display: flex; flex-wrap: wrap; gap: 6px; }
.unit {
  font-size: 11px; padding: 3px 8px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg-dim);
  display: inline-flex; align-items: center; gap: 6px;
}
.unit .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-dim); }
.unit.up .dot { background: var(--ok); }
.unit.down .dot { background: var(--danger); }

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.span2 { grid-column: 1 / -1; }

.btn, .icon-btn {
  font: inherit; cursor: pointer; color: var(--fg);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; transition: filter .12s, border-color .12s;
}
.btn { padding: 8px 10px; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn:hover, .icon-btn:hover { filter: brightness(1.14); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #1a1206; }
.icon-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

select, input[type="search"] {
  font: inherit; font-size: 13px; color: var(--fg);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px;
}
input[type="search"] { width: 130px; }
select:focus-visible, input:focus-visible, .btn:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.hint { margin: 0; font-size: 11px; color: var(--fg-dim); }
.tools { display: inline-flex; align-items: center; gap: 6px; }

.log {
  flex: 1; margin: 0; padding: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  font-family: "JetBrains Mono", Consolas, monospace; font-size: 11.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; overflow: auto;
}
.log .l-err { color: var(--danger); }
.log .l-ok { color: var(--ok); }
.log .l-warn { color: var(--warn); }
.log .l-ts { color: var(--fg-dim); }

/* ── toasts (never alert()) ────────────────────────────────────────── */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  min-width: 220px; max-width: 340px; padding: 10px 12px;
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; box-shadow: var(--shadow); font-size: 13px;
  animation: toast-in .16s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── screenshot modal ──────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); max-width: 95vw; max-height: 92vh; overflow: hidden;
  display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal img { max-width: 92vw; max-height: 80vh; display: block; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 45vh 1fr; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
}
