/* support-assistant.css — floating help widget (Guide for users, Nexus for admins) */

#sa-widget {
  position: fixed;
  right: 18px;
  bottom: 88px; /* clear the sticky bottom nav */
  z-index: 1090;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

#sa-widget * { box-sizing: border-box; }

/* Launcher button */
#sa-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #828282, #919191);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#sa-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16); }
#sa-launcher:active { transform: scale(0.97); }

/* Panel */
#sa-panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 70vh;
  max-height: 560px;
  background: var(--surface-sunken);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.16);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
#sa-widget.sa-open #sa-panel { display: flex; }
#sa-widget.sa-open #sa-launcher { display: none; }

/* Header */
#sa-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(130, 130, 130, 0.25), rgba(145, 145, 145, 0.18));
  border-bottom: 1px solid var(--line);
}
#sa-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  object-fit: cover; background: var(--fill-mid-soft); flex: 0 0 auto;
}
#sa-title { font-weight: 700; font-size: 15px; line-height: 1.1; }
#sa-subtitle { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
#sa-header .sa-spacer { flex: 1; }
#sa-close {
  background: transparent; border: none; color: var(--ink-soft);
  font-size: 22px; cursor: pointer; line-height: 1; padding: 4px;
}
#sa-close:hover { color: var(--ink); }

/* Admin mode toggle */
#sa-toggle {
  display: flex; gap: 6px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface-raised);
}
#sa-toggle button {
  flex: 1; padding: 6px 8px; font-size: 12px; font-weight: 600;
  border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--ink-muted); cursor: pointer;
}
#sa-toggle button.sa-active { background: var(--fill-mid); border-color: var(--line); color: var(--ink); }

/* Messages */
#sa-messages {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.sa-msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.sa-msg.sa-user { align-self: flex-end; background: var(--fill-mid); color: var(--ink); border-bottom-right-radius: 4px; }
.sa-msg.sa-bot { align-self: flex-start; background: var(--surface-sunken); color: var(--ink); border-bottom-left-radius: 4px; }
.sa-msg.sa-error { align-self: center; background: transparent; color: #f40000; font-size: 12px; }

/* Rendered markdown inside a bot bubble */
.sa-msg.sa-md p { margin: 0 0 8px; }
.sa-msg.sa-md p:last-child { margin-bottom: 0; }
.sa-msg.sa-md ul, .sa-msg.sa-md ol { margin: 4px 0; padding-left: 20px; }
.sa-msg.sa-md li { margin: 2px 0; }
.sa-msg.sa-md a { color: var(--ink-soft); text-decoration: underline; }
.sa-msg.sa-md strong { font-weight: 700; }
.sa-msg.sa-md code { background: var(--glass-strong); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.sa-msg.sa-md h1, .sa-msg.sa-md h2, .sa-msg.sa-md h3 { font-size: 14px; margin: 6px 0 4px; }

/* Typing indicator */
.sa-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px; }
.sa-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--fill-mid); animation: sa-bounce 1.2s infinite ease-in-out; }
.sa-typing span:nth-child(2) { animation-delay: 0.2s; }
.sa-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sa-bounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* Composer */
#sa-composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface-raised); }
#sa-input {
  flex: 1; resize: none; max-height: 96px;
  background: var(--surface-sunken); border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); padding: 9px 12px; font-size: 14px; font-family: inherit;
}
#sa-input:focus { outline: none; border-color: var(--line); }
#sa-send {
  flex: 0 0 auto; width: 40px; border: none; border-radius: 12px; cursor: pointer;
  background: var(--fill-mid); color: var(--ink); font-size: 18px;
}
#sa-send:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 480px) {
  #sa-widget { right: 12px; bottom: 78px; }
  #sa-panel { height: 72vh; }
}
