/* ════════════════════════════════════════════════════════════
   BYTE WIDGET — Messenger-style launcher + pop-out panel
   ════════════════════════════════════════════════════════════ */

/* ── Widget container ────────────────────────────────────── */
#byte-widget {
  position: fixed;
  z-index: 9500;
  width: 64px;
  height: 64px;
  right: 12px;
  bottom: 12px;
}
#byte-widget.byte-snapping {
  transition: left 0.3s ease, right 0.3s ease, top 0.3s ease;
}

/* When overlay is active, widget must be above it */
.guide-overlay.active ~ #byte-widget,
#byte-widget.above-overlay {
  z-index: 10001;
}

/* ── Launcher circle ─────────────────────────────────────── */
#byte-launcher {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6b21a8, #0e7490);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  position: relative;
  user-select: none;
  animation: byte-pulse 2.5s ease-in-out infinite;
  transition: transform 0.15s, box-shadow 0.15s;
}
#byte-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.5);
}
#byte-launcher:active {
  cursor: grabbing;
}

.byte-launcher-icon-bot,
.byte-launcher-icon-close {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.byte-launcher-icon-close {
  display: none;
}
#byte-widget.byte-panel-open .byte-launcher-icon-bot {
  display: none;
}
#byte-widget.byte-panel-open .byte-launcher-icon-close {
  display: flex;
}

/* Step badge */
.byte-step-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cyan, #22d3ee);
  color: #0b1627;
  font-size: 10px;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

@keyframes byte-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 0 0px rgba(34,211,238,0.15); }
  50%      { box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 0 8px rgba(34,211,238,0.06); }
}

/* ── Pop-out panel ───────────────────────────────────────── */
#byte-assistant {
  position: absolute;
  width: 440px;
  height: 420px;
  min-width: 360px;
  min-height: 280px;
  background: rgba(11,22,39,0.97);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(26,48,80,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Hidden by default */
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#byte-assistant.byte-open {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* Quadrant positioning */
#byte-assistant.pos-above { bottom: 80px; }
#byte-assistant.pos-below { top: 80px; }
#byte-assistant.pos-align-right { right: 0; }
#byte-assistant.pos-align-left { left: 0; }

/* Transform origins per quadrant */
#byte-assistant.pos-above.pos-align-right { transform-origin: bottom right; }
#byte-assistant.pos-above.pos-align-left  { transform-origin: bottom left; }
#byte-assistant.pos-below.pos-align-right { transform-origin: top right; }
#byte-assistant.pos-below.pos-align-left  { transform-origin: top left; }

/* ── Resize handles ──────────────────────────────────────── */
.byte-resize-side,
.byte-resize-corner,
.byte-resize-bottom {
  position: absolute;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.2s;
}
#byte-assistant:hover .byte-resize-side,
#byte-assistant:hover .byte-resize-corner,
#byte-assistant:hover .byte-resize-bottom {
  opacity: 1;
}

/* Side handle — vertical bar on the edge opposite the launcher */
.byte-resize-side {
  top: 20px;
  bottom: 20px;
  width: 14px;
  cursor: ew-resize;
}
.byte-resize-side::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 48px;
  border-radius: 3px;
  background: var(--border-hi);
  transition: background 0.15s, box-shadow 0.15s;
}
.byte-resize-side:hover::after {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-dim);
}

/* Position side handle based on alignment */
.pos-align-right .byte-resize-side { left: -7px; }
.pos-align-right .byte-resize-side::after { left: 4px; }
.pos-align-left .byte-resize-side  { right: -7px; }
.pos-align-left .byte-resize-side::after  { right: 4px; }

/* Bottom handle — horizontal bar for height */
.byte-resize-bottom {
  left: 20px;
  right: 20px;
  height: 14px;
  cursor: ns-resize;
}
.byte-resize-bottom::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  height: 4px;
  width: 48px;
  border-radius: 3px;
  background: var(--border-hi);
  transition: background 0.15s, box-shadow 0.15s;
}
.byte-resize-bottom:hover::after {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-dim);
}

/* Position bottom handle based on above/below */
.pos-above .byte-resize-bottom { top: -7px; }
.pos-above .byte-resize-bottom::after { top: 4px; }
.pos-below .byte-resize-bottom { bottom: -7px; }
.pos-below .byte-resize-bottom::after { bottom: 4px; }

/* Corner handle — diagonal resize */
.byte-resize-corner {
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
}
.byte-resize-corner::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--border-hi);
  transition: background 0.15s, box-shadow 0.15s;
}
.byte-resize-corner:hover::after {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-dim);
}

/* Corner position adapts to quadrant */
.pos-above.pos-align-right .byte-resize-corner { top: -8px; left: -8px; cursor: nwse-resize; }
.pos-above.pos-align-right .byte-resize-corner::after { top: 4px; left: 4px; }
.pos-above.pos-align-left  .byte-resize-corner { top: -8px; right: -8px; cursor: nesw-resize; }
.pos-above.pos-align-left  .byte-resize-corner::after { top: 4px; right: 4px; }
.pos-below.pos-align-right .byte-resize-corner { bottom: -8px; left: -8px; cursor: nesw-resize; }
.pos-below.pos-align-right .byte-resize-corner::after { bottom: 4px; left: 4px; }
.pos-below.pos-align-left  .byte-resize-corner { bottom: -8px; right: -8px; cursor: nwse-resize; }
.pos-below.pos-align-left  .byte-resize-corner::after { bottom: 4px; right: 4px; }

/* ── Panel header ────────────────────────────────────────── */
#byte-header {
  padding: 10px 12px 8px;
  background: rgba(15,28,48,0.95);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: grab;
  user-select: none;
}
#byte-header:active {
  cursor: grabbing;
}
.byte-header-meta {
  flex: 1;
  min-width: 0;
}
.byte-ctrl-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  margin-top: 2px;
}
.byte-ctrl-btn:hover {
  background: rgba(244,63,94,0.12);
  border-color: var(--red);
  color: var(--red);
}

/* ── Panel footer ────────────────────────────────────────── */
#byte-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(15,28,48,0.95);
  border-top: 1px solid var(--border);
}
/* Ergonomic swap when panel is on left side */
.pos-align-left #byte-footer {
  flex-direction: row-reverse;
}

/* ════════════════════════════════════════════════════════════
   GUIDE CONTENT STYLES (preserved for scenario.js compatibility)
   ════════════════════════════════════════════════════════════ */

.guide-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(34,211,238,0.15), rgba(168,85,247,0.1));
  border: 2px solid var(--cyan-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.guide-name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
}
.guide-step {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--cyan);
  font-family: 'JetBrains Mono', monospace;
}

.guide-progress-track {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}
.guide-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Body ────────────────────────────────────────────────── */
.guide-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-2);
}
.guide-body h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 8px;
}
.guide-body h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  margin: 12px 0 6px;
}
.guide-body p {
  margin-bottom: 8px;
}
.guide-body ul, .guide-body ol {
  margin: 6px 0 10px;
  padding-left: 18px;
}
.guide-body li { margin-bottom: 4px; }
.guide-body code {
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--cyan);
}
.guide-body strong { color: var(--text-1); }

/* Guide content blocks */
.guide-tip {
  padding: 10px 12px;
  border-radius: 6px;
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.6;
}
.guide-tip.action {
  background: rgba(34,211,238,0.06);
  border: 1px solid rgba(34,211,238,0.15);
  border-left: 3px solid var(--cyan);
  color: var(--text-2);
}
.guide-tip.warning {
  background: rgba(244,63,94,0.06);
  border: 1px solid rgba(244,63,94,0.15);
  border-left: 3px solid var(--red);
  color: var(--text-2);
}
.guide-tip.success {
  background: rgba(34,197,94,0.06);
  border: 1px solid rgba(34,197,94,0.15);
  border-left: 3px solid var(--green);
  color: var(--text-2);
}
.guide-tip.info {
  background: rgba(168,85,247,0.06);
  border: 1px solid rgba(168,85,247,0.15);
  border-left: 3px solid var(--purple);
  color: var(--text-2);
}

.guide-cmd {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--green);
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

.guide-payload {
  background: var(--bg-base);
  border: 1px solid rgba(244,63,94,0.2);
  border-left: 3px solid var(--red);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--red);
  margin: 8px 0;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.guide-payload:hover {
  background: rgba(244,63,94,0.04);
}
.guide-payload::after {
  content: 'click to copy';
  position: absolute;
  right: 8px;
  top: 8px;
  font-size: 9px;
  color: var(--text-3);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  transition: color 0.15s;
}
.guide-payload.copied {
  background: rgba(34,197,94,0.08);
  border-color: rgba(34,197,94,0.3);
}
.guide-payload.copied::after {
  content: 'copied!';
  color: var(--green);
}

/* ── Lock Banner ─────────────────────────────────────────── */
.guide-lock {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(244,63,94,0.06);
  border-top: 1px solid rgba(244,63,94,0.15);
  font-size: 11px;
  font-weight: 600;
  color: var(--red);
}
.guide-lock.visible { display: flex; }
.guide-lock.unlocked {
  background: rgba(34,197,94,0.06);
  border-top-color: rgba(34,197,94,0.15);
  color: var(--green);
}

/* ── Nav buttons ─────────────────────────────────────────── */
.guide-nav { display: flex; gap: 6px; }
.guide-btn {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.guide-btn:hover:not(:disabled) { border-color: var(--cyan); color: var(--text-1); }
.guide-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.guide-btn-next {
  background: linear-gradient(135deg, var(--purple-dim), var(--cyan-dim)) !important;
  border-color: var(--cyan-dim) !important;
  color: #fff !important;
}
.guide-btn-next:hover:not(:disabled) { box-shadow: 0 2px 8px rgba(34,211,238,0.3); }
