/* TradePlane chat widget */

#tp-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #3B7DD8;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  transition: transform .15s ease, background .15s ease;
}
#tp-chat-bubble:hover {
  transform: scale(1.06);
  background: #2B63AD;
}
#tp-chat-bubble svg {
  width: 24px;
  height: 24px;
  fill: #fff;
}

#tp-chat-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  z-index: 9001;
  width: min(380px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 120px));
  background: #1C2733;
  border: 1px solid rgba(240,237,230,.09);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(.97);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#tp-chat-panel.tp-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.tp-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(240,237,230,.09);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.tp-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tp-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #253040;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tp-avatar svg {
  width: 16px;
  height: 16px;
  fill: #3B7DD8;
}
.tp-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #F0EDE6;
  line-height: 1.2;
}
.tp-subtitle {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: #7A8FA6;
  line-height: 1.2;
}
.tp-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #7A8FA6;
  display: flex;
  align-items: center;
  border-radius: 4px;
  transition: color .15s;
}
.tp-close:hover { color: #F0EDE6; }
.tp-close svg { width: 16px; height: 16px; fill: currentColor; }

.tp-persona-bar {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(240,237,230,.09);
  flex-shrink: 0;
}
.tp-persona-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  color: #7A8FA6;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.tp-persona-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tp-pbtn {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #7A8FA6;
  background: #253040;
  border: 1px solid rgba(240,237,230,.09);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.tp-pbtn:hover {
  color: #F0EDE6;
  background: rgba(59,125,216,.15);
  border-color: rgba(59,125,216,.4);
}
.tp-pbtn.tp-active {
  color: #F0EDE6;
  background: rgba(59,125,216,.2);
  border-color: #3B7DD8;
}

.tp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(122,143,166,.3) transparent;
}
.tp-messages::-webkit-scrollbar { width: 4px; }
.tp-messages::-webkit-scrollbar-thumb { background: rgba(122,143,166,.3); border-radius: 2px; }

.tp-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 90%;
}
.tp-msg.tp-user { align-self: flex-end; align-items: flex-end; }
.tp-msg.tp-bot  { align-self: flex-start; align-items: flex-start; }

.tp-bubble {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 10px;
  word-break: break-word;
}
.tp-msg.tp-user .tp-bubble {
  background: #3B7DD8;
  color: #fff;
  border-bottom-right-radius: 3px;
}
.tp-msg.tp-bot .tp-bubble {
  background: #253040;
  color: #F0EDE6;
  border-bottom-left-radius: 3px;
}

.tp-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #253040;
  border-radius: 10px;
  border-bottom-left-radius: 3px;
}
.tp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7A8FA6;
  animation: tp-bounce .9s infinite;
}
.tp-dot:nth-child(2) { animation-delay: .15s; }
.tp-dot:nth-child(3) { animation-delay: .3s; }
@keyframes tp-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

.tp-input-row {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(240,237,230,.09);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
#tp-input {
  flex: 1;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: #F0EDE6;
  background: #253040;
  border: 1px solid rgba(240,237,230,.09);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
  resize: none;
  line-height: 1.4;
  max-height: 100px;
  transition: border-color .15s;
}
#tp-input::placeholder { color: #7A8FA6; }
#tp-input:focus { border-color: rgba(59,125,216,.5); }

#tp-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #3B7DD8;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background .15s, opacity .15s;
}
#tp-send:hover { background: #2B63AD; }
#tp-send:disabled { opacity: .4; cursor: default; }
#tp-send svg { width: 16px; height: 16px; fill: #fff; }

.tp-error {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: #e07070;
  padding: 4px 4px 0;
}
