/*
 * Site-knowledge chat panel (extends lawtheme-avatar widget).
 */

.lawtheme-avatar-widget--chat .lawtheme-avatar-bubble--chat {
  width: 100%;
  max-width: min(360px, calc(100vw - 10px));
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  max-height: min(52vh, 480px);
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.lawtheme-avatar-bubble-head {
  flex: 0 0 auto;
}

.lawtheme-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 100px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 8px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.lawtheme-chat-thread::-webkit-scrollbar {
  width: 6px;
}

.lawtheme-chat-thread::-webkit-scrollbar-thumb {
  background: rgba(154, 133, 158, 0.35);
  border-radius: 999px;
}

.lawtheme-chat-composer {
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 4px;
  border-top: 1px solid rgba(150, 130, 95, 0.12);
}

.lawtheme-chat-composer.is-compact .lawtheme-chat-quick {
  display: none;
}

.lawtheme-chat-msg {
  margin: 0;
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.lawtheme-chat-msg--bot,
.lawtheme-avatar-msg.lawtheme-chat-msg--bot {
  align-self: flex-start;
  background: rgba(197, 173, 197, 0.16);
  border: 1px solid rgba(150, 130, 95, 0.12);
  border-radius: 14px 14px 14px 4px;
  color: #4a4048;
}

.lawtheme-chat-msg--user {
  align-self: flex-end;
  background: linear-gradient(160deg, #9a859e 0%, #7f6c84 100%);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 8px 18px rgba(74, 61, 82, 0.18);
}

.lawtheme-chat-msg-text {
  margin: 0;
}

.lawtheme-chat-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.lawtheme-chat-sources-label {
  width: 100%;
  color: #6b5a70;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lawtheme-chat-sources a {
  display: inline-flex;
  align-items: center;
  padding: 0.45em 0.75em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(150, 130, 95, 0.18);
  color: #5a4863 !important;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.lawtheme-chat-sources a:hover {
  background: #fff;
  color: #6b5a70 !important;
}

.lawtheme-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.lawtheme-chat-quick-btn {
  padding: 0.45em 0.7em;
  border: 1px solid rgba(150, 130, 95, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: #5a4863;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.lawtheme-chat-quick-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}

.lawtheme-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.lawtheme-chat-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid rgba(150, 130, 95, 0.24);
  border-radius: 12px;
  background: #fff;
  color: #2e2830;
  font-size: 14px;
  line-height: 1.3;
}

.lawtheme-chat-input:focus {
  outline: none;
  border-color: rgba(154, 133, 158, 0.65);
  box-shadow: 0 0 0 3px rgba(197, 173, 197, 0.22);
}

.lawtheme-chat-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: var(--lawyer-btn-bg, #9a859e);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(154, 133, 158, 0.35);
  transition: transform 0.2s ease, background 0.2s ease;
}

.lawtheme-chat-send:hover {
  background: var(--lawyer-btn-hover, #8b7790);
  transform: translateY(-1px);
}

.lawtheme-chat-send:disabled,
.lawtheme-chat-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.lawtheme-chat-human-link-wrap {
  margin: 0;
  text-align: center;
}

.lawtheme-chat-human-link {
  padding: 0;
  border: 0;
  background: none;
  color: #6b5a70 !important;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.lawtheme-chat-human-link:hover {
  color: #5a4863 !important;
}

/* 3D mode (v2.4.0): chat bubble stacked directly above avatar stage */
.lawtheme-avatar-widget.is-3d .lawtheme-avatar-bubble--chat {
  width: min(340px, calc(100vw - 28px));
  max-height: min(58vh, 520px);
}

.lawtheme-avatar-widget.is-3d .lawtheme-chat-thread {
  max-height: min(28vh, 220px);
}

@media (max-width: 767px) {
  .lawtheme-avatar-widget--chat .lawtheme-avatar-bubble--chat {
    width: min(340px, calc(100vw - 24px));
    max-height: min(50vh, 440px);
  }

  .lawtheme-avatar-widget.is-3d .lawtheme-avatar-bubble--chat {
    max-height: min(48vh, 420px);
  }

  .lawtheme-avatar-widget.is-3d .lawtheme-chat-thread {
    max-height: min(22vh, 180px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lawtheme-chat-quick-btn,
  .lawtheme-chat-send {
    transition: none !important;
  }
}
