/* Browser widget — interactive embedded web page (CDP screencast onto a canvas). */

.browser-panel { padding: 0; overflow: hidden; }
.browser-widget-mount { width: 100%; height: 100%; }

.browser-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
}

/* Tab strip — shown only when a tile holds 2+ tabs (Chrome-style). */
.browser-tabs {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 4px 6px 0;
  flex: 0 0 auto;
  overflow-x: auto;
  scrollbar-width: thin;
  background: rgba(255, 255, 255, 0.02);
}
.browser-tabs[hidden] { display: none; }
.browser-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 160px;
  min-width: 0;
  padding: 5px 6px 5px 10px;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(232, 234, 240, 0.72);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.browser-tab:hover { background: rgba(255, 255, 255, 0.1); }
.browser-tab.is-active { background: rgba(255, 255, 255, 0.14); color: var(--text, #e8eaf0); }
.browser-tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.6;
}
.browser-tab-close:hover { background: rgba(255, 255, 255, 0.2); opacity: 1; }
.browser-tab-close svg { width: 11px; height: 11px; }

/* Address/navigation bar */
.browser-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.browser-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text, #e8eaf0);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.browser-btn:hover { background: rgba(255, 255, 255, 0.14); }
.browser-btn:active { background: rgba(255, 255, 255, 0.2); }
.browser-btn svg { width: 16px; height: 16px; }

/* Clear-site-data button armed for its confirming second tap. */
.browser-btn.is-armed {
  background: rgba(240, 90, 90, 0.9);
  color: #fff;
}
.browser-btn.is-armed:hover { background: rgba(240, 90, 90, 1); }

.browser-url {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text, #e8eaf0);
  font-size: 13px;
  outline: none;
}
.browser-url:focus { border-color: rgba(var(--accent-rgb, 90 130 255), 0.7); }

/* Favorites quick-access bar — global list of label+address shortcuts. Hidden
   until there's at least one favorite (or the add-editor is open) so it never
   costs vertical space on a small tile when unused. */
.browser-favorites {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.browser-favorites[hidden] { display: none; }
.browser-fav-list {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.browser-fav-list:empty { display: none; }
.browser-fav {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  max-width: 160px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(232, 234, 240, 0.82);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.browser-fav:hover { background: rgba(255, 255, 255, 0.12); color: var(--text, #e8eaf0); }
.browser-fav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-fav-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.55;
}
.browser-fav-del:hover { background: rgba(255, 255, 255, 0.22); opacity: 1; }
.browser-fav-del svg { width: 10px; height: 10px; }
/* Star toolbar button that opens the add-editor. */
.browser-btn.browser-favbtn svg { width: 17px; height: 17px; }

/* Inline add-editor: name + address + save/cancel, revealed under the favorites row. */
.browser-fav-editor {
  display: flex;
  align-items: center;
  gap: 6px;
}
.browser-fav-editor[hidden] { display: none; }
.browser-fav-input {
  min-width: 0;
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text, #e8eaf0);
  font-size: 12px;
  outline: none;
}
.browser-fav-input:focus { border-color: rgba(var(--accent-rgb, 90 130 255), 0.7); }
.browser-fav-name { flex: 0 1 34%; }
.browser-fav-url { flex: 1 1 auto; }
.browser-fav-editor .browser-btn { width: 28px; height: 28px; }

/* Chrome hidden — a maximized-video mode: drop the tab strip, address bar and
   favorites so the page fills the whole tile. A floating button brings them back. */
.browser-wrap.is-chrome-hidden .browser-tabs,
.browser-wrap.is-chrome-hidden .browser-bar,
.browser-wrap.is-chrome-hidden .browser-favorites { display: none; }

/* Stage + canvas */
.browser-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #14161c;
}

/* Floating "show toolbar" button, top-right of the stage, only while chrome is hidden. */
.browser-reveal {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;                            /* above the tab canvases and the loading overlay */
  width: 32px;
  height: 26px;
  border-radius: 8px;
  background: rgba(20, 22, 28, 0.55);
  color: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
  opacity: 0.5;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.browser-reveal:hover { opacity: 1; background: rgba(20, 22, 28, 0.8); }
.browser-reveal[hidden] { display: none; }
.browser-canvas {
  position: absolute;          /* tab canvases stack in the stage; only the active shows */
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  /* Stretch the frame to fill the box (the page is rendered at the tile's own
     aspect ratio, so there's no distortion) — this keeps the displayed area
     equal to the canvas box so pointer coordinates map 1:1 to the page. */
  object-fit: fill;
  touch-action: none;          /* we forward gestures to the page ourselves */
  outline: none;
  cursor: default;
}
.browser-canvas[hidden] { display: none; }   /* background tabs — outrank display:block */

.browser-loading {
  position: absolute;
  inset: 0;
  z-index: 2;                            /* above the (absolute) tab canvases */
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  pointer-events: none;
  background: rgba(20, 22, 28, 0.55);   /* dim the stale/blank canvas while loading */
}
.browser-loading[hidden] { display: none; }   /* outrank the flex display above */

/* Spinner shown while a page is loading (no frame yet), so the tile never looks
   frozen during the connect/first-paint window. */
.browser-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: rgba(var(--accent-rgb, 90 130 255), 0.95);
  animation: browser-spin 0.8s linear infinite;
  will-change: transform;
}
@keyframes browser-spin { to { transform: rotate(360deg); } }
.browser-loading.is-error .browser-spinner { display: none; }   /* error = message only */

/* Error state: a readable, padded message over the tile instead of a silent black canvas. */
.browser-loading.is-error {
  padding: 16px;
  text-align: center;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(0, 0, 0, 0.35);
}

/* Was a single centred line. It now carries an action button under the text
   where Xenon can install a browser itself, so it stacks. */
.browser-unavailable {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  padding: 16px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}

.browser-unavailable p { margin: 0; max-width: 46ch; }

.browser-unavailable-install {
  padding: 7px 16px;
  border: 1px solid rgba(110, 231, 135, 0.45);
  border-radius: 8px;
  background: rgba(110, 231, 135, 0.12);
  color: #6ee787;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.browser-unavailable-install:hover:not(:disabled) { background: rgba(110, 231, 135, 0.2); }
.browser-unavailable-install:disabled { opacity: 0.6; cursor: default; }

/* Expanded: the wrap is portaled to <body> and pinned to fill the viewport. Use
   bare `inset: 0` (not 100vw/100vh) so it stays correct under the Xeneon Edge's
   root `zoom` compensation — the same pattern the lock screen overlay uses. The
   `:fullscreen` selector keeps the native OS-fullscreen element laid out too. */
.browser-wrap.browser-overlay,
.browser-wrap:fullscreen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  border-radius: 0;
  background: #14161c;
}
