/* Cloud Browser dashboard - GOLLE dark visual system.
   Mirrors golle-it-mcp-canvas/src/app/globals.css (navy card #1b2742, border
   #2a3444, muted #9aa6bd, accent #dc70cb, brand gradient). Plain static CSS,
   no build step. */

:root {
  --bg: #0f1729;
  --bg2: #162035;
  --card: #1b2742;
  --card2: #16203a;
  --border: #2a3444;
  --border2: #3a465c;
  --text: #e6e8ec;
  --muted: #9aa6bd;
  --accent: #dc70cb;
  --grad: linear-gradient(135deg, #f5c494 0%, #dc70cb 31%, #b975de 66%, #828bf6 100%);
  --ok: #4ec98b;
  --warn: #f5c494;
  --bad: #f16c8b;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

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

code, pre, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

a { color: inherit; }

button { font-family: inherit; }

/* ---- Form controls: >=16px so iOS Safari never auto-zooms on focus ---- */
input, textarea, select {
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: #6b7690; }
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; color: var(--text); font-size: 14px; margin: 0; }
.check input { width: auto; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  border: none;
  background: var(--grad);
  color: #101728;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(220, 112, 203, 0.3);
}
.btn.danger { color: var(--bad); border-color: rgba(241, 108, 139, 0.4); }
.btn.danger:hover { background: rgba(241, 108, 139, 0.1); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }

/* ---- App shell ---- */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.signet {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  background: var(--grad);
  box-shadow: 0 2px 10px rgba(220, 112, 203, 0.35);
}
/* When the signet slot holds the real emblem <img>, keep its aspect ratio and
   drop the placeholder gradient/rounded box so the artwork shows unclipped. */
img.signet { width: auto; height: 30px; border-radius: 0; background: none; box-shadow: none; object-fit: contain; }
.brand b { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.gx { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--card2); color: var(--text); }
.nav-item.active { background: var(--card); color: var(--text); border-color: var(--border); }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { padding: 6px 8px; font-size: 12px; color: var(--muted); }
.sidebar .foot a { color: var(--accent); text-decoration: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.page { padding: 26px 30px; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 700; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

/* ---- Cards / tables ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 20px; }
.grid { display: grid; gap: 14px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(255,255,255,0.015); }
.tbl .actions { display: flex; gap: 8px; justify-content: flex-end; }
.tbl-wrap { overflow-x: auto; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); color: var(--muted); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.active { color: var(--ok); border-color: rgba(78,201,139,.35); } .badge.active .dot { background: var(--ok); }
.badge.idle { color: var(--warn); border-color: rgba(245,196,148,.35); } .badge.idle .dot { background: var(--warn); }
.badge.starting { color: #8aa2ff; border-color: rgba(130,139,246,.4); } .badge.starting .dot { background: #8aa2ff; animation: pulse 1s infinite; }
.badge.stopped { color: var(--muted); } .badge.stopped .dot { background: #566; }
.badge.error { color: var(--bad); border-color: rgba(241,108,139,.4); } .badge.error .dot { background: var(--bad); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.muted { color: var(--muted); }
.mono-sm { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 34px; margin-bottom: 10px; opacity: .5; }
.url-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Compact per-session RAM readout in the Sessions table. */
.ram { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.ram .txt { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--text); white-space: nowrap; }
.ram .bar { width: 112px; height: 5px; border-radius: 4px; background: var(--border); overflow: hidden; }
.ram .bar i { display: block; height: 100%; background: var(--grad); }

/* ---- Modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(6,10,20,.72); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; animation: fadeIn .15s ease; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; animation: popIn .18s cubic-bezier(.22,1,.36,1); }
.modal.wide { max-width: 660px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--border); }
.x { cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; background: none; border: none; }
.x:hover { color: var(--text); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---- Login gate ---- */
.gate { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.gate .box { text-align: center; max-width: 380px; }
.gate .signet { width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 22px; }
.gate h1 { font-size: 24px; margin: 0 0 8px; }
.gate p { color: var(--muted); margin: 0 0 26px; }

/* ---- Toasts ---- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: 12px 16px; font-size: 14px; box-shadow: var(--shadow); max-width: 360px; animation: toastIn .2s ease; }
.toast.err { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Live view ---- */
.live { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }
.live-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg2); flex-wrap: wrap; }
.live-bar .grow { flex: 1; min-width: 40px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { background: transparent; border: none; color: var(--muted); padding: 7px 13px; font-size: 13px; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: none; }
.seg button.on { color: #101728; font-weight: 600; }
.seg button.on[data-mode="human"] { background: var(--grad); }
.seg button.on[data-mode="hybrid"] { background: linear-gradient(135deg,#b975de,#828bf6); color: #fff; }
.seg button.on[data-mode="agent"] { background: #2a3444; color: var(--text); }
.seg.vp button.on { background: var(--accent); color: #101728; font-weight: 600; }

.tabs-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--card2); overflow-x: auto; }
.tab-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg2); color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap; max-width: 240px; flex: 0 0 auto; }
.tab-chip.active { color: var(--text); border-color: var(--accent); }
.tab-chip .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.tab-chip .cx { color: var(--muted); font-size: 15px; line-height: 1; }
.tab-chip .cx:hover { color: var(--bad); }

.addr-bar { display: flex; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--card2); }
.addr-bar input { font-family: "JetBrains Mono", monospace; font-size: 13px; padding: 8px 12px; }
@media (max-width: 640px) { .addr-bar input { font-size: 16px; } }

.stage-wrap { flex: 1; position: relative; background: #0a0f1c; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
.stage { position: relative; width: 100%; height: 100%; }
.stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.stage.interactive { cursor: crosshair; }
.stage:focus { outline: none; }

.stage-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; text-align: center; color: var(--muted); background: rgba(8,12,22,.55); padding: 20px; }
.stage-overlay.transparent { background: transparent; pointer-events: none; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.usage { display: inline-flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); font-family: "JetBrains Mono", monospace; }
.usage .meter { width: 60px; height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; }
.usage .meter i { display: block; height: 100%; background: var(--grad); }

/* Hard-cap countdown badge in the live bar. Neutral, then amber < 15min, red < 5min. */
.live-timer { font-size: 12px; font-family: "JetBrains Mono", monospace; color: var(--muted); padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
.live-timer:empty { display: none; }
.live-timer.soon { color: var(--warn); border-color: rgba(245,196,148,.35); }
.live-timer.warn { color: var(--bad); border-color: rgba(241,108,139,.4); }

/* Terminal "session ended" overlay (replaces the endless Reconnecting loop). */
.stage-overlay.ended { gap: 10px; color: var(--text); }
.stage-overlay.ended .muted { color: var(--muted); font-size: 13px; max-width: 340px; }
.stage-overlay.ended .ended-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Native dialog modal (over the stage) */
.dlg-back { position: absolute; inset: 0; background: rgba(6,10,20,.7); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 20px; }
.dlg { background: var(--card); border: 1px solid var(--accent); border-radius: 14px; max-width: 460px; width: 100%; box-shadow: var(--shadow); }
.dlg .h { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dlg .b { padding: 18px; }
.dlg .b .msg { white-space: pre-wrap; word-break: break-word; margin-bottom: 12px; }
.dlg .f { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
kbd { background: var(--card2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: 12px; font-family: "JetBrains Mono", monospace; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---- Connect + Guide (MCP setup + docs) ---- */
.stack { display: flex; flex-direction: column; gap: 18px; }
.doc-card { padding: 22px 24px; }
.doc-card h2 { margin: 0 0 8px; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-card > p { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.doc-card > label { margin-top: 4px; }

.tag { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: rgba(78,201,139,.14); color: var(--ok); border: 1px solid rgba(78,201,139,.35); text-transform: uppercase; letter-spacing: .4px; }

.copyfield { display: flex; gap: 10px; align-items: stretch; margin-bottom: 14px; flex-wrap: wrap; }
.copyfield .val { flex: 1 1 220px; min-width: 0; display: flex; align-items: center; padding: 10px 14px; background: var(--card2); border: 1px solid var(--border); border-radius: 10px; font-family: "JetBrains Mono", monospace; font-size: 13px; color: var(--text); overflow-x: auto; white-space: nowrap; }
.copyfield .val.mask { color: var(--muted); letter-spacing: 1px; }
.copyfield > .btn { flex: 0 0 auto; }

ol.steps { margin: 0 0 16px; padding-left: 22px; color: var(--text); font-size: 13.5px; line-height: 1.7; }
ol.steps li { margin-bottom: 7px; }
ol.steps li::marker { color: var(--accent); font-weight: 700; }

.codebox { background: #0c1220; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.codebox .cb-head { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px 7px 14px; border-bottom: 1px solid var(--border); background: var(--bg2); }
.codebox .cb-head span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.codebox pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-family: "JetBrains Mono", monospace; font-size: 12.5px; line-height: 1.6; color: #cbd3e6; }

.callout { display: flex; gap: 11px; padding: 13px 15px; border-radius: 10px; font-size: 13px; line-height: 1.6; border: 1px solid var(--border); background: var(--card2); color: var(--muted); }
.callout .ic { flex: 0 0 auto; font-size: 15px; line-height: 1.5; }
.callout strong { color: var(--text); }
.callout.warn { border-color: rgba(245,196,148,.4); background: rgba(245,196,148,.08); color: #e9d3b4; }
.callout.warn .ic { color: var(--warn); }

.prose { color: var(--muted); font-size: 13.5px; line-height: 1.7; margin: 0 0 12px; }
.prose:last-child { margin-bottom: 0; }
.prose-list { margin: 0; padding-left: 20px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.prose-list li { margin-bottom: 8px; }
.prose strong, .prose-list strong, .prose b, .prose-list b { color: var(--text); font-weight: 600; }
.prose code, .prose-list code { background: var(--card2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-size: 12px; color: var(--text); }

.tool-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tool-group { border: 1px solid var(--border); border-radius: 10px; padding: 13px 15px; background: var(--card2); }
.tool-group h3 { margin: 0 0 9px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); font-weight: 700; }
.tool-group code { display: block; font-size: 12px; color: var(--text); padding: 3px 0; }

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 10px; }
  .sidebar .brand { padding: 4px 8px; }
  .sidebar .brand small { display: none; }
  .sidebar .spacer { flex: 0; }
  .sidebar .foot { display: none; }
  .nav-item span.lbl { display: none; }
  .page { padding: 18px 16px; }
}
/* iOS zoom guard: force >=16px on every focusable control at mobile widths. */
@media (max-width: 640px) {
  input, textarea, select { font-size: 16px; }
}
