/* ========================================================================
   SoftAIBox — Floating chat widget
   Matches the design tokens of the existing landing page
   (green-deep #1f7a3f, ink #14181a, line #e6e2d6, Plus Jakarta Sans)
   ======================================================================== */

.sb-chat {
  --sb-ink:        #14181a;
  --sb-ink-2:      #2b3236;
  --sb-muted:      #6b7177;
  --sb-line:       #e6e2d6;
  --sb-bg:         #faf8f3;
  --sb-bg-2:       #f5f2e9;
  --sb-card:       #ffffff;
  --sb-green:      #10b981;
  --sb-green-2:    #65d063;
  --sb-green-3:    #a3e635;
  --sb-green-soft: #e8f5dc;
  --sb-green-deep: #1f7a3f;
  --sb-rose-soft:  #ffe1de;
  --sb-rose-ink:   #c0392a;

  position: fixed;
  bottom: 24px;
  right:  24px;
  z-index: 2147483600;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: var(--sb-ink);
}

/* --- Launcher button (floating bubble) ---------------------------------- */
.sb-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--sb-ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  box-shadow:
    0 6px 14px rgba(20, 24, 26, 0.28),
    0 0 0 4px rgba(163, 230, 53, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.sb-launcher:hover { transform: translateY(-2px); }
.sb-launcher:active { transform: translateY(1px); }
.sb-launcher svg { width: 26px; height: 26px; }
.sb-launcher .sb-badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--sb-green-3);
  border: 2px solid var(--sb-ink);
  display: none;
}
.sb-launcher.sb-has-new .sb-badge { display: block; }

/* --- Panel -------------------------------------------------------------- */
.sb-panel {
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--sb-card);
  border: 1px solid var(--sb-line);
  border-radius: 22px;
  box-shadow: 0 30px 60px -20px rgba(20, 40, 30, 0.30);
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.sb-chat.sb-open .sb-panel {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* --- Header ------------------------------------------------------------- */
.sb-head {
  padding: 14px 16px;
  background: var(--sb-ink);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sb-head .sb-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--sb-green), var(--sb-green-3), var(--sb-green));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #14281a;
  font-weight: 700;
  font-size: 14px;
}
.sb-head .sb-title  { font-weight: 700; font-size: 15px; line-height: 1.2; }
.sb-head .sb-sub    {
  color: #c9cdcf;
  font-size: 11px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.10em;
  margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.sb-head .sb-sub .sb-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--sb-green-2);
  box-shadow: 0 0 0 3px rgba(101, 208, 99, 0.18);
}
.sb-head .sb-uuid {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: rgba(255,255,255,0.12);
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.sb-head .sb-uuid:hover { background: rgba(255,255,255,0.20); }
.sb-head .sb-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.sb-head .sb-close:hover { background: rgba(255,255,255,0.12); }

/* --- UUID prompt (shown once on first open) ----------------------------- */
.sb-restore {
  padding: 14px 16px;
  background: var(--sb-bg-2);
  border-bottom: 1px solid var(--sb-line);
  font-size: 13px;
}
.sb-restore label {
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sb-muted);
  margin-bottom: 6px;
}
.sb-restore-row { display: flex; gap: 8px; }
.sb-restore input {
  flex: 1;
  border: 1px solid var(--sb-line);
  background: #fff;
  border-radius: 10px;
  padding: 9px 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  outline: none;
}
.sb-restore input:focus {
  border-color: var(--sb-green-2);
  box-shadow: 0 0 0 3px rgba(101,208,99,0.18);
}
.sb-restore button {
  border: none;
  background: var(--sb-ink);
  color: #fff;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.sb-restore .sb-restore-skip {
  display: block;
  margin-top: 8px;
  color: var(--sb-muted);
  font-size: 12px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

/* --- Messages ----------------------------------------------------------- */
.sb-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sb-body::-webkit-scrollbar { width: 8px; }
.sb-body::-webkit-scrollbar-thumb {
  background: var(--sb-line);
  border-radius: 4px;
}

.sb-msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.sb-msg.sb-user {
  align-self: flex-end;
  background: var(--sb-ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sb-msg.sb-assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--sb-line);
  border-bottom-left-radius: 4px;
}
.sb-msg.sb-admin {
  align-self: flex-start;
  background: var(--sb-green-soft);
  border: 1px solid #c8e3a7;
  border-bottom-left-radius: 4px;
}
.sb-msg.sb-admin::before {
  content: "Team member";
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--sb-green-deep);
  margin-bottom: 4px;
}
.sb-msg.sb-system {
  align-self: center;
  background: transparent;
  color: var(--sb-muted);
  font-size: 12px;
  font-style: italic;
  border: none;
  padding: 4px 0;
  max-width: 100%;
  text-align: center;
}

/* Typing indicator */
.sb-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--sb-line);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: none;
}
.sb-typing.sb-show { display: flex; gap: 4px; }
.sb-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--sb-muted);
  animation: sbBounce 1.2s infinite;
}
.sb-typing span:nth-child(2) { animation-delay: 0.15s; }
.sb-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes sbBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1;  }
}

/* Escalation banner */
.sb-escalated {
  margin: 4px 0 0;
  padding: 10px 12px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12px;
  border-radius: 10px;
  display: none;
}
.sb-escalated.sb-show { display: block; }

/* --- Composer ----------------------------------------------------------- */
.sb-foot {
  border-top: 1px solid var(--sb-line);
  background: #fff;
  padding: 10px 12px;
}
.sb-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.sb-input {
  flex: 1;
  border: 1px solid var(--sb-line);
  border-radius: 14px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 40px;
  line-height: 1.4;
  background: var(--sb-bg);
  color: var(--sb-ink);
}
.sb-input:focus {
  background: #fff;
  border-color: var(--sb-green-2);
  box-shadow: 0 0 0 3px rgba(101, 208, 99, 0.15);
}
.sb-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--sb-green-3);
  color: #14281a;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 0 #6ea523;
  transition: transform 0.1s ease;
}
.sb-send:hover  { transform: translateY(-1px); }
.sb-send:active { transform: translateY(1px); }
.sb-send:disabled {
  background: var(--sb-line);
  color: var(--sb-muted);
  cursor: not-allowed;
  box-shadow: none;
}
.sb-send svg { width: 18px; height: 18px; }

.sb-foot-hint {
  text-align: center;
  color: var(--sb-muted);
  font-size: 11px;
  margin-top: 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.08em;
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 480px) {
  .sb-chat { bottom: 16px; right: 16px; left: 16px; }
  .sb-panel {
    width: auto;
    height: calc(100vh - 100px);
    right: 0;
    left: auto;
  }
  .sb-launcher { margin-left: auto; }
}

/* Tooltip / copied toast */
.sb-toast {
  position: absolute;
  top: 56px;
  right: 12px;
  background: var(--sb-ink);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  transform: translateY(-4px);
  z-index: 10;
}
.sb-toast.sb-show { opacity: 1; transform: translateY(0); }
