/* -------------------------------------------------------
 * LittleBot Chat  Core Styles
 * File: assets/css/lb-chat.css
 * ----------------------------------------------------- */

#lb-chat-root {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 99999;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px; /* slightly larger for readability */
  color: #0f172a;

  /* Variables are set from JS via inline styles */
  --lb-chat-accent: #fb263b;
  --lb-chat-header-bg: #f5f7fb;
  --lb-chat-bubble-mine: #0f172a;
  --lb-chat-bubble-other: #f3f4f6;
  --lb-chat-bubble-mine-text: #ffffff;
  --lb-chat-bubble-other-text: #111827;
}

/* Container */
#lb-chat-root .lb-chat-container {
  position: relative;
}

/* -------------------------------------------------------
 * Toggle Button
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-toggle {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: var(--lb-chat-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.32);
  color: #ffffff;
  padding: 0;
}

#lb-chat-root .lb-chat-toggle--active {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.28);
  transform: translateY(1px);
}

#lb-chat-root .lb-chat-toggle__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#lb-chat-root .lb-chat-toggle__svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Small unread badge on toggle */
#lb-chat-root .lb-chat-toggle__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  line-height: 18px;
  padding: 0 5px;
  text-align: center;
  box-shadow: 0 0 0 2px #ffffff;
}

/* -------------------------------------------------------
 * Panel
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-panel {
  position: absolute;
  bottom: 56px;
  right: 0;
  width: 720px; /* roomier layout */
  max-width: calc(100vw - 32px);
  height: 700px;
  max-height: calc(100vh - 90px);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  display: none;
}

#lb-chat-root .lb-chat-container--open .lb-chat-panel {
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------
 * Header
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--lb-chat-header-bg);
  border-bottom: 1px solid #e5e7eb;
}

#lb-chat-root .lb-chat-header__title {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

/* Right-side cluster */
#lb-chat-root .lb-chat-header__user {
  display: inline-flex;
  align-items: center;
  gap: 10px;            /* ? more breathing room */
  position: relative;
}

/* Avatar (still used in header) */
#lb-chat-root .lb-chat-header__avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background-color: #0f172a;
  background-size: cover;
  background-position: center;
}

/* Username */
#lb-chat-root .lb-chat-header__name {
  font-size: 13px;
  color: #4b5563;
  white-space: nowrap;
  margin-right: 4px;    /* ? stops chip rubbing */
}

/* Presence control (chip) */
#lb-chat-root .lb-chat-header__presence {
  margin-top: 0;        /* ? was pushing down awkwardly */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.75);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  color: #111827;
}

/* If you wrap avatar+name in a clickable button later, this will look nice */
#lb-chat-root .lb-chat-header__profile-btn {
  border: 0;
  background: transparent;
  padding: 2px 6px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#lb-chat-root .lb-chat-header__profile-btn:hover {
  background: rgba(255,255,255,0.55);
}

/* -------------------------------------------------------
 * Layout: Sidebar + Main
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

/* Sidebar */
#lb-chat-root .lb-chat-sidebar {
  flex: 0 0 260px;
  width: 260px;
  min-width: 240px;
  max-width: 360px;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #e5e7eb; /* ? one source of truth */
}

/* Tabs */
#lb-chat-root .lb-chat-sidebar__tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

#lb-chat-root .lb-chat-sidebar__tab {
  flex: 1;
  padding: 7px 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  color: #6b7280;
  text-align: center;
}

#lb-chat-root .lb-chat-sidebar__tab--active {
  color: #0f172a;
  font-weight: 600;
  border-bottom: 2px solid var(--lb-chat-accent);
}

/* Sidebar group button (New chat) */
#lb-chat-root .lb-chat-sidebar__group-action {
  padding: 8px 10px 8px;
  border-bottom: 1px solid #f3f4f6;
  background: #f8fafc;
}

#lb-chat-root .lb-chat-sidebar__group-btn {
  width: 100%;
  border-radius: 999px;
  border: 1px dashed #d1d5db;
  background: #ffffff;
  font-size: 12px;
  padding: 7px 10px;
  cursor: pointer;
  color: #4b5563;
  text-align: center;
}

#lb-chat-root .lb-chat-sidebar__group-btn:hover {
  border-color: var(--lb-chat-accent);
  color: #111827;
}

/* Sidebar lists */
#lb-chat-root .lb-chat-sidebar__list-wrapper {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

#lb-chat-root .lb-chat-sidebar__list {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 6px 10px;
}

/* -------------------------------------------------------
 * Conversation rows (Option B)
 * - Remove big letter avatar circles
 * - Use presence dot as leading indicator
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-convo-row {
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border-radius: 12px;
  text-align: left;
  gap: 10px;
  margin: 4px 4px; /* subtle spacing */
}

#lb-chat-root .lb-chat-convo-row:hover {
  background: rgba(255,255,255,0.55);
}

#lb-chat-root .lb-chat-convo-row--active {
  background: #e5f2ff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

#lb-chat-root .lb-chat-convo-row--pulse {
  animation: lbChatConvoPulse 1.8s ease-out 1;
  background: rgba(14, 165, 233, 0.10);
}

@keyframes lbChatConvoPulse {
  0% { box-shadow: 0 0 0 0 rgba(14,165,233,0.35); }
  60% { box-shadow: 0 0 0 8px rgba(14,165,233,0); }
  100% { box-shadow: 0 0 0 0 rgba(14,165,233,0); }
}

@media (prefers-reduced-motion: reduce) {
  #lb-chat-root .lb-chat-convo-row--pulse {
    animation: none;
  }
}


/* Hide the letter bubble, but keep the element as a container for the dot */
#lb-chat-root .lb-chat-convo-row__avatar {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: transparent;
  font-size: 0;          /* ? hides S/L letter */
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Presence dot  larger, cleaner */
#lb-chat-root .lb-chat-presence-dot {
  position: static;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid #f8fafc;
  background: #9ca3af; /* default/offline */
}

#lb-chat-root .lb-chat-presence-dot--online {
  background: #22c55e;
}

#lb-chat-root .lb-chat-presence-dot--away {
  background: #f59e0b;
}

#lb-chat-root .lb-chat-presence-dot--invisible {
  background: #9ca3af;
}

#lb-chat-root .lb-chat-presence-dot--auto {
  background: #60a5fa;
}

#lb-chat-root .lb-chat-convo-row__meta {
  flex: 1 1 auto;
  min-width: 0;
}

#lb-chat-root .lb-chat-convo-row__title {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#lb-chat-root .lb-chat-convo-row__snippet {
  display: none;
}

#lb-chat-root .lb-chat-convo-row__side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 18px;
}

#lb-chat-root .lb-chat-convo-row__badge {
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--lb-chat-accent);
  color: #ffffff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  padding: 0 5px;
}

/* -------------------------------------------------------
 * Contact rows (kept for group creator list)
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-contact-row {
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 8px 8px;
  border-radius: 10px;
  text-align: left;
  gap: 8px;
  margin: 3px 2px;
}

#lb-chat-root .lb-chat-contact-row:hover {
  background: #f3f4f6;
}

#lb-chat-root .lb-chat-contact-row__avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background-color: #e5e7eb;
  background-size: cover;
  background-position: center;
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#lb-chat-root .lb-chat-contact-row__meta {
  flex: 1 1 auto;
  min-width: 0;
}

#lb-chat-root .lb-chat-contact-row__name {
  font-size: 12px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#lb-chat-root .lb-chat-contact-row__email {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#lb-chat-root .lb-chat-contact-row__action {
  font-size: 11px;
  color: var(--lb-chat-accent);
  white-space: nowrap;
  margin-left: 4px;
}

/* -------------------------------------------------------
 * Group creator
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-group-creator {
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 8px;
  margin-bottom: 6px;
  background: #f9fafb;
}

#lb-chat-root .lb-chat-group-creator__field {
  margin-bottom: 6px;
}

#lb-chat-root .lb-chat-group-creator__label {
  font-size: 11px;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: 2px;
}

#lb-chat-root .lb-chat-group-creator__input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 6px 8px;
  font-size: 12px;
  outline: none;
  background: #ffffff;
}

#lb-chat-root .lb-chat-group-creator__input:focus {
  border-color: var(--lb-chat-accent);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.1);
}

/* Participant list */
#lb-chat-root .lb-chat-group-creator__list {
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 6px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  padding: 4px;
}

#lb-chat-root .lb-chat-group-creator__row {
  display: flex;
  align-items: flex-start;
  padding: 5px;
  border-radius: 8px;
  cursor: pointer;
  gap: 8px;
}

#lb-chat-root .lb-chat-group-creator__row:hover {
  background: #f3f4f6;
}

#lb-chat-root .lb-chat-group-creator__checkbox {
  margin-top: 2px;
}

#lb-chat-root .lb-chat-group-creator__row-text {
  flex: 1 1 auto;
  min-width: 0;
}

#lb-chat-root .lb-chat-group-creator__row-name {
  font-size: 12px;
  font-weight: 500;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#lb-chat-root .lb-chat-group-creator__row-email {
  font-size: 10px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Actions */
#lb-chat-root .lb-chat-group-creator__actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

#lb-chat-root .lb-chat-group-creator__btn {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  border: 1px solid transparent;
  cursor: pointer;
}

#lb-chat-root .lb-chat-group-creator__btn--secondary {
  background: #ffffff;
  border-color: #d1d5db;
  color: #4b5563;
}

#lb-chat-root .lb-chat-group-creator__btn--secondary:hover {
  background: #f9fafb;
}

#lb-chat-root .lb-chat-group-creator__btn--primary {
  background: var(--lb-chat-accent);
  color: #ffffff;
}

#lb-chat-root .lb-chat-group-creator__btn--primary:hover {
  filter: brightness(0.95);
}

/* -------------------------------------------------------
 * Main column
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #f9fafb;
}

/* Main top bar */
#lb-chat-root .lb-chat-main__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  font-size: 12px;
  font-weight: 600;
  color: #111827;
}

#lb-chat-root .lb-chat-main__top-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* If you use the title/subtitle wrap */
#lb-chat-root .lb-chat-main__top-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#lb-chat-root .lb-chat-main__top-title {
  font-weight: 600;
}

#lb-chat-root .lb-chat-main__top-subtitle {
  font-size: 11px;
  opacity: 0.7;
  word-break: break-all;
}

/* Action chips */
#lb-chat-root .lb-chat-main__rename,
#lb-chat-root .lb-chat-main__leave,
#lb-chat-root .lb-chat-main__delete {
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #4b5563;
  font-size: 10px;
  padding: 3px 8px;
  cursor: pointer;
}

#lb-chat-root .lb-chat-main__leave {
  color: #b45309;
  border-color: #fed7aa;
  background: #fef3c7;
}

#lb-chat-root .lb-chat-main__delete {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

#lb-chat-root .lb-chat-main__rename:hover,
#lb-chat-root .lb-chat-main__leave:hover,
#lb-chat-root .lb-chat-main__delete:hover {
  filter: brightness(0.97);
}

/* Empty state */
#lb-chat-root .lb-chat-main__empty {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: #6b7280;
}

/* -------------------------------------------------------
 * Thread + messages
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 10px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Typing indicator */
#lb-chat-root .lb-chat-typing {
  padding: 6px 12px;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px; /* keeps layout stable */
  background: #ffffff;
  border-top: 1px solid #eef2f7;
}

#lb-chat-root .lb-chat-typing.lb-chat-typing--hidden {
  opacity: 0;
  pointer-events: none;
}

#lb-chat-root .lb-chat-typing__dots {
  display: inline-flex;
  gap: 3px;
}

#lb-chat-root .lb-chat-typing__dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #9ca3af;
  display: inline-block;
  animation: lbChatTyping 1.2s infinite;
}

#lb-chat-root .lb-chat-typing__dots span:nth-child(2) {
  animation-delay: 0.15s;
}

#lb-chat-root .lb-chat-typing__dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes lbChatTyping {
  0%,
  60%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* Date separators */
#lb-chat-root .lb-chat-date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
}

#lb-chat-root .lb-chat-date-separator::before,
#lb-chat-root .lb-chat-date-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

#lb-chat-root .lb-chat-date-separator__label {
  font-size: 10px;
  color: #6b7280;
  background: #f9fafb;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  margin: 0 6px;
}

/* Message container */
#lb-chat-root .lb-chat-message {
  max-width: 82%;
  align-self: flex-start;
  padding: 0;
}

#lb-chat-root .lb-chat-message--mine {
  align-self: flex-end;
}

/* Sender label */
#lb-chat-root .lb-chat-message__sender {
  font-size: 12px;
  font-weight: 600;
  margin: 0 6px 2px;
  color: #6b7280;
}

#lb-chat-root .lb-chat-message--mine .lb-chat-message__sender {
  text-align: right;
}

/* Bubble */
#lb-chat-root .lb-chat-message__inner {
  padding: 8px 11px;
  background: var(--lb-chat-bubble-other);
  color: var(--lb-chat-bubble-other-text);
  font-size: 14px;
  line-height: 1.35;
  word-break: break-word;

  border-radius: 14px 14px 14px 6px; /* ? default "theirs" */
}

/* Mine bubble style */
#lb-chat-root .lb-chat-message--mine .lb-chat-message__inner {
  background: var(--lb-chat-bubble-mine);
  color: var(--lb-chat-bubble-mine-text);
  border-radius: 14px 14px 6px 14px;
}

/* Emoji-only messages: make small emoji replies readable */
#lb-chat-root .lb-chat-message--emoji-only .lb-chat-message__inner {
  font-size: 28px;
  line-height: 1.15;
  padding: 10px 12px;
}

/* Paragraph support inside messages */
#lb-chat-root .lb-chat-message__inner p {
  margin: 0 0 8px;
}

#lb-chat-root .lb-chat-message__inner p:last-child {
  margin-bottom: 0;
}

/* Links in messages */
#lb-chat-root .lb-chat-message__inner a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Meta row */
#lb-chat-root .lb-chat-message__meta {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 3px;
  margin-left: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#lb-chat-root .lb-chat-message__meta-time,
#lb-chat-root .lb-chat-message__meta-receipt {
  white-space: nowrap;
}

#lb-chat-root .lb-chat-message__meta-edited {
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
  margin-left: 6px;
}

/* System messages */
#lb-chat-root .lb-chat-message--system .lb-chat-message__inner {
  background: transparent;
  border-radius: 0;
  padding: 0;
  color: #6b7280;
  font-size: 11px;
}

/* Pasted image display */
#lb-chat-root .lb-chat-img {
  max-width: 260px;
  height: auto;
  border-radius: 12px;
  display: block;
}

/* -------------------------------------------------------
 * Composer
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-composer {
  border-top: 1px solid #e5e7eb;
  padding: 10px 12px;
  background: #ffffff;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

#lb-chat-root .lb-chat-composer__input {
  flex: 1 1 320px;
  min-width: 0;
  min-height: 78px;
  max-height: 180px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
}

#lb-chat-root .lb-chat-composer__input:focus {
  border-color: var(--lb-chat-accent);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.12);
}

/* Emoji button - support multiple possible classnames */
#lb-chat-root .lb-chat-composer__emoji,
#lb-chat-root .lb-chat-emoji-btn,
#lb-chat-root .lb-chat-emoji-toggle {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-size: 18px;
  line-height: 36px;
  cursor: pointer;
  color: #374151;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#lb-chat-root .lb-chat-composer__emoji:hover,
#lb-chat-root .lb-chat-emoji-btn:hover,
#lb-chat-root .lb-chat-emoji-toggle:hover {
  background: #f9fafb;
}

#lb-chat-root .lb-chat-composer__send {
  flex: 0 0 auto;
  border-radius: 999px;
  border: none;
  background: var(--lb-chat-accent);
  color: #ffffff;
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}

#lb-chat-root .lb-chat-composer__send:hover {
  filter: brightness(0.96);
}

#lb-chat-root .lb-chat-editbar,
#lb-chat-root .lb-chat-replybar {
  flex: 1 1 100%;
  order: 1;
}

#lb-chat-root .lb-chat-composer__input {
  order: 2;
}

#lb-chat-root .lb-chat-composer__send {
  order: 3;
  align-self: flex-end;
}

/* Generic empty block */
#lb-chat-root .lb-chat-empty {
  font-size: 11px;
  color: #9ca3af;
  padding: 6px;
  text-align: center;
}

/* -------------------------------------------------------
 * Presence menu (opened by clicking avatar/name later)
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-presence-menu {
  position: absolute;
  right: 8px;
  top: 44px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 160px;
  z-index: 9999;
}

#lb-chat-root .lb-chat-presence-menu__item {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}

#lb-chat-root .lb-chat-presence-menu__item:hover {
  background: #f3f4f6;
}

#lb-chat-root .lb-chat-presence-menu__item.is-active {
  background: #e5f2ff;
  font-weight: 600;
}

/* -------------------------------------------------------
 * Scrollbars (WebKit)
 * ----------------------------------------------------- */

#lb-chat-root .lb-chat-sidebar__list::-webkit-scrollbar,
#lb-chat-root .lb-chat-group-creator__list::-webkit-scrollbar,
#lb-chat-root .lb-chat-thread::-webkit-scrollbar {
  width: 6px;
}

#lb-chat-root .lb-chat-sidebar__list::-webkit-scrollbar-track,
#lb-chat-root .lb-chat-group-creator__list::-webkit-scrollbar-track,
#lb-chat-root .lb-chat-thread::-webkit-scrollbar-track {
  background: transparent;
}

#lb-chat-root .lb-chat-sidebar__list::-webkit-scrollbar-thumb,
#lb-chat-root .lb-chat-group-creator__list::-webkit-scrollbar-thumb,
#lb-chat-root .lb-chat-thread::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 999px;
}

/* Small-screen tweak */
@media (max-width: 480px) {
  #lb-chat-root .lb-chat-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 90px);
  }
}

/* Ensure clickable UI stays clickable even if parent overlays exist */
#lb-chat-root .lb-chat-sidebar,
#lb-chat-root .lb-chat-header {
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

/* =====================================================
 * Enhancements: actions, search, drafts, drag-drop
 * ===================================================== */

/* Message actions (hover) */
#lb-chat-root .lb-chat-message {
  position: relative;
}

#lb-chat-root .lb-chat-message__actions {
  position: absolute;
  top: 2px;
  left: 6px;
  right: auto;
  display: inline-flex;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 8px 18px rgba(0,0,0,0.10);
  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 3;
}

#lb-chat-root .lb-chat-message:hover .lb-chat-message__actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#lb-chat-root .lb-chat-message--mine .lb-chat-message__actions {
  right: 6px;
  left: auto;
}

#lb-chat-root .lb-chat-action {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  color: #111827;
  padding: 2px 6px;
  border-radius: 999px;
}

#lb-chat-root .lb-chat-action:hover {
  background: rgba(0,0,0,0.06);
}

#lb-chat-root .lb-chat-action--danger {
  color: #b91c1c;
}

/* Reaction picker */
#lb-chat-root .lb-chat-reaction-picker {
  position: absolute;
  top: 30px;
  left: 6px;
  right: auto;
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
  z-index: 4;
}

#lb-chat-root .lb-chat-message--mine .lb-chat-reaction-picker {
  right: 6px;
  left: auto;
}

#lb-chat-root .lb-chat-reaction-picker__btn {
  border: 0;
  background: #f3f4f6;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 10px;
}

#lb-chat-root .lb-chat-reaction-picker__btn:hover {
  filter: brightness(0.97);
}

/* Meta grouping: hide meta row when grouped */
#lb-chat-root .lb-chat-message__meta--hidden {
  display: none;
}

/* Reply bar */
#lb-chat-root .lb-chat-replybar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(0,0,0,0.08);
  background: #f9fafb;
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #374151;
}

/* Edit bar */
#lb-chat-root .lb-chat-editbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(0,0,0,0.08);
  background: #fff7ed;
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #7c2d12;
}

#lb-chat-root .lb-chat-editbar__close {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #7c2d12;
}

#lb-chat-root .lb-chat-replybar__close {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  color: #6b7280;
}

#lb-chat-root .lb-chat-replybar__close:hover {
  color: #111827;
}

/* Search */
#lb-chat-root .lb-chat-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.9);
}

#lb-chat-root .lb-chat-search--hidden {
  display: none;
}

#lb-chat-root .lb-chat-search__input {
  width: 180px;
  max-width: 26vw;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 12px;
}

#lb-chat-root .lb-chat-search__close {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  color: #6b7280;
}

#lb-chat-root .lb-chat-main__searchbtn {
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #4b5563;
  font-size: 10px;
  padding: 2px 6px;
  cursor: pointer;
}

#lb-chat-root .lb-chat-main__searchbtn:hover {
  filter: brightness(0.97);
}

/* Drag over highlight */
#lb-chat-root .lb-chat-thread--dragover {
  outline: 2px dashed rgba(0,0,0,0.18);
  outline-offset: -6px;
}

/* Reactions summary chips */
#lb-chat-root .lb-chat-reactions {
  display: inline-flex;
  gap: 6px;
  margin: 4px 0 0;
  padding-left: 4px;
}

#lb-chat-root .lb-chat-reactions__chip {
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.9);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
}

#lb-chat-root .lb-chat-reactions__chip:hover {
  filter: brightness(0.98);
}

/* Hide meta when grouped */
#lb-chat-root .lb-chat-message__meta--hidden {
  display: none;
}


/* Infinite scroll + drag state */
#lb-chat-root .lb-chat-thread__loading{
  font-size: 11px;
  color:#6b7280;
  text-align:center;
  padding:6px 8px;
}
#lb-chat-root .lb-chat-composer__input--dragover{
  border-color: var(--lb-chat-accent);
  box-shadow: 0 0 0 2px rgba(248,113,113,0.12);
}


/* Image lightbox */
.lb-chat-lightbox{position:fixed;inset:0;display:none;z-index:999999;}
.lb-chat-lightbox.is-open{display:block;}
.lb-chat-lightbox__backdrop{position:absolute;inset:0;background:rgba(0,0,0,0.65);}
.lb-chat-lightbox__img{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);max-width:92vw;max-height:88vh;border-radius:12px;box-shadow:0 10px 40px rgba(0,0,0,0.5);background:#fff;}
.lb-chat-lightbox__close{position:absolute;right:16px;top:16px;width:40px;height:40px;border-radius:999px;border:none;background:rgba(255,255,255,0.9);cursor:pointer;font-size:22px;line-height:1;}


/* -------------------------------------------------------
 * Guest Widget Styles
 * ----------------------------------------------------- */
#lb-chat-root.lb-chat-root--guest-widget {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 99999;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#lb-chat-root.lb-chat-root--guest-widget .lb-chat-sr-only { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:-1px!important; overflow:hidden!important; clip:rect(0,0,0,0)!important; white-space:nowrap!important; border:0!important; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-toggle--guest-icon:focus-visible,
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-button:focus-visible,
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-input:focus-visible { outline: 2px solid #0f172a; outline-offset: 2px; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-toggle--guest-icon {
  background: var(--lb-chat-accent, #fb263b);
  color: #fff; border: 0; border-radius: 999px; width: 50px; height: 50px; bottom: 50px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 8px 22px rgba(15,23,42,.32);
}
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-panel--guest {
  position: absolute; right: 0; bottom: 115px; width: 650px; max-width: calc(100vw - 24px);
  height: 680px; max-height: calc(100vh - 90px); background: #fff; border-radius: 18px;
  box-shadow: 0 20px 45px rgba(15,23,42,.35); display: flex; flex-direction: column; overflow: hidden;
}
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-panel__header { display:flex; justify-content:space-between; align-items:center; padding:14px 16px; border-bottom:1px solid #e5e7eb; background:#f8fafc; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-panel__title { font-size: 22px; font-weight: 700; color: #0f172a; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-panel__status { font-size: 15px; color: #475569; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-panel__body { flex:1; overflow-y:auto; padding:18px; background:#f3f4f6; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-messages { display:flex; flex-direction:column; gap:12px; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-message { max-width: 78%; padding: 10px 12px; border-radius: 12px; line-height: 1.45; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-message--guest { align-self:flex-end; background:#0f172a; color:#fff; border-bottom-right-radius: 3px; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-message--agent { align-self:flex-start; background:#ffffff; color:#0f172a; border:1px solid #e5e7eb; border-bottom-left-radius: 3px; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-message__meta { font-size: 12px; margin-bottom: 4px; opacity: .9; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-message--guest .lb-chat-message__meta { color: rgba(255,255,255,.88); }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-message--agent .lb-chat-message__meta { color: #64748b; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-message__agent-name { font-weight: 600; color: inherit; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-message__body { font-size: 17px; word-break: break-word; white-space: pre-wrap; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-offline-notice { padding: 10px 14px; font-size: 14px; color:#7c2d12; background:#ffedd5; border-top:1px solid #fdba74; border-bottom:1px solid #fdba74; display:none; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-profile { display:flex; flex-direction:column; gap:8px; padding:12px 14px; border-top:1px solid #e5e7eb; background:#f8fafc; cursor: default; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-profile.lb-chat-profile--collapsed { gap:0; cursor: pointer; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-profile.lb-chat-profile--collapsed .lb-chat-input--name,
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-profile.lb-chat-profile--collapsed .lb-chat-input--email { display:none; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-profile.lb-chat-profile--collapsed::before { content: "Contact details saved (click to edit)"; font-size: 13px; color:#475569; margin-bottom: 8px; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-input { font-size: 16px; border:1px solid #cbd5e1; border-radius:8px; padding:10px 12px; width:100%; box-sizing:border-box; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-input:focus { outline: none; border-color:#0f172a; box-shadow:0 0 0 2px rgba(15,23,42,.08); }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-button { background:#0f172a; color:#fff; border:none; border-radius:999px; padding:8px 14px; font-size:14px; font-weight:600; cursor:pointer; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-button--profile-save { align-self:flex-end; }

#lb-chat-root.lb-chat-root--guest-widget .lb-chat-privacy-notice { padding: 8px 14px; font-size: 12px; line-height: 1.4; color:#475569; background:#f8fafc; border-top:1px solid #e5e7eb; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-composer { display:flex; flex-wrap:wrap; align-items:flex-end; gap:8px; padding:12px 14px; background:#fff; border-top:1px solid #e5e7eb; }
#lb-chat-root.lb-chat-root--guest-widget .lb-chat-input--message { resize:none; min-height:44px; max-height:120px; font-size:16px; }
@media (max-width: 768px) {
  #lb-chat-root.lb-chat-root--guest-widget { right: 10px; bottom: 10px; }
  #lb-chat-root.lb-chat-root--guest-widget .lb-chat-panel--guest { width: calc(100vw - 20px); height: min(72vh, 620px); }
  #lb-chat-root.lb-chat-root--guest-widget .lb-chat-panel__title { font-size: 18px; }
  #lb-chat-root.lb-chat-root--guest-widget .lb-chat-message__body { font-size: 16px; }
}
