.tp-chatbot-host {
  position: fixed;
  bottom: 24px;
  z-index: 9999;
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
  pointer-events: none;
}

/* ─── Bubble ─────────────────────────────────────────────────────────────── */

.tp-chatbot-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7b1fa2, #9c27b0);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(123, 31, 162, 0.4);
  transition: transform 0.2s;
  margin-left: auto;
  pointer-events: auto;
}

.tp-chatbot-bubble:hover {
  transform: scale(1.08);
}

/* ─── Window ─────────────────────────────────────────────────────────────── */

.tp-chatbot-window {
  position: absolute;
  bottom: 70px;
  width: 380px;
  height: 580px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.25s ease;
}

.tp-chatbot-window.open { opacity: 1; visibility: visible; transform: scale(1) translateY(0); pointer-events: all; }

/* ─── Header ─────────────────────────────────────────────────────────────── */

.tp-chatbot-header {
  background: linear-gradient(135deg, #7b1fa2, #9c27b0);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tp-chatbot-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #7b1fa2;
  font-size: 15px;
  margin-right: 8px;
  flex-shrink: 0;
}

.tp-chatbot-title {
  color: white;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tp-chatbot-subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  margin-top: 1px;
  display: flex;
  align-items: center;
}

/* Header icon buttons */
.tp-header-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition:
    opacity 0.15s,
    background 0.15s;
  flex-shrink: 0;
}

.tp-header-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* ─── Messages area ──────────────────────────────────────────────────────── */

.tp-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f5f5f7;
  scroll-behavior: smooth;
}

.tp-chatbot-messages::-webkit-scrollbar {
  width: 4px;
}
.tp-chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}
.tp-chatbot-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

/* ─── Message bubbles ────────────────────────────────────────────────────── */

.tp-chatbot-message {
  display: flex;
}

.tp-chatbot-message.user {
  justify-content: flex-end;
}

.tp-chatbot-message.assistant,
.tp-chatbot-message.agent,
.tp-chatbot-message.system {
  justify-content: flex-start;
}

.tp-chatbot-bubble-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tp-chatbot-message.user .tp-chatbot-bubble-msg {
  background: linear-gradient(135deg, #7b1fa2, #9c27b0);
  color: white;
  border-radius: 16px 16px 4px 16px;
}

.tp-chatbot-message.assistant .tp-chatbot-bubble-msg {
  background: white;
  color: #1a1a2e;
  border: 1px solid #ede8f5;
  border-radius: 16px 16px 16px 4px;
}

.tp-chatbot-message.agent .tp-chatbot-bubble-msg {
  background: #fff8e1;
  color: #1a1a2e;
  border: 1px solid #ffe082;
  border-radius: 16px 16px 16px 4px;
}

.tp-chatbot-message.system .tp-chatbot-bubble-msg {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
  border-radius: 10px;
  font-size: 12px;
  max-width: 90%;
}

.tp-chatbot-role {
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #7b1fa2;
  display: flex;
  align-items: center;
}

.tp-chatbot-message.user .tp-chatbot-role {
  color: rgba(255, 255, 255, 0.85);
  justify-content: flex-end;
}

/* ─── Typing indicator ───────────────────────────────────────────────────── */

.tp-chatbot-typing {
  display: flex;
  gap: 4px;
  padding: 4px 2px;
}

.tp-chatbot-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7b1fa2;
  animation: tp-typing 1.2s infinite;
}

.tp-chatbot-typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.tp-chatbot-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes tp-typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ─── Agent bar ──────────────────────────────────────────────────────────── */

.tp-chatbot-agent-bar {
  padding: 8px 14px;
  border-top: 1px solid #f0ecf8;
  background: white;
  flex-shrink: 0;
}

.tp-chatbot-agent-btn {
  width: 100%;
  padding: 9px;
  background: none;
  border: 1.5px solid #7b1fa2;
  border-radius: 8px;
  color: #7b1fa2;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tp-chatbot-agent-btn:hover {
  background: #7b1fa2;
  color: white;
}

/* ─── Input bar ──────────────────────────────────────────────────────────── */

.tp-chatbot-input-bar {
  padding: 10px 12px;
  border-top: 1px solid #f0ecf8;
  background: white;
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}

.tp-attach-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7b1fa2;
  transition: background 0.15s;
  flex-shrink: 0;
}

.tp-attach-btn:hover {
  background: #f0ecf8;
}

.tp-chatbot-input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid #ede8f5;
  font-size: 13px;
  resize: none;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafafa;
  transition: border 0.2s;
  min-height: 36px;
  max-height: 100px;
  overflow-y: auto;
}

.tp-chatbot-input:focus {
  outline: none;
  border-color: #7b1fa2;
}

.tp-chatbot-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7b1fa2, #9c27b0);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.tp-chatbot-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tp-chatbot-send:hover:not(:disabled) {
  opacity: 0.85;
}

/* ─── Close bar ──────────────────────────────────────────────────────────── */

.tp-close-btn {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 18px;
  font-size: 12px;
  color: #9ca3af;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  transition:
    border-color 0.15s,
    color 0.15s;
  display: inline-flex;
  align-items: center;
}

.tp-close-btn:hover {
  border-color: #d1d5db;
  color: #6b7280;
}

/* ─── Conversation list ──────────────────────────────────────────────────── */

.tp-conv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid #f5f5f5;
  cursor: pointer;
  transition: background 0.15s;
}

.tp-conv-item:hover {
  background: #f9f5ff;
}

.tp-conv-new-btn {
  width: 100%;
  padding: 12px;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  transition: opacity 0.2s;
}

.tp-conv-new-btn:hover {
  opacity: 0.9;
}

/* ─── Feedback buttons ───────────────────────────────────────────────────── */

.tp-feedback-bar {
  display: flex;
  gap: 4px;
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid #f0ecf8;
  justify-content: flex-end;
}

.tp-feedback-btn {
  background: none;
  border: 1px solid #e8e0f0;
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: #aaa;
  transition:
    color 0.15s,
    border-color 0.15s,
    transform 0.1s;
}

.tp-feedback-btn[data-rating='positive']:hover {
  color: #22c55e;
  border-color: #22c55e;
  transform: scale(1.1);
}

.tp-feedback-btn[data-rating='negative']:hover {
  color: #ef4444;
  border-color: #ef4444;
  transform: scale(1.1);
}

/* ─── CSAT buttons ───────────────────────────────────────────────────────── */

.tp-csat-btn {
  padding: 10px 22px;
  border-radius: 8px;
  background: white;
  font-size: 13px;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.tp-csat-btn:hover {
  transform: scale(1.05);
}

/* ─── Markdown content ───────────────────────────────────────────────────── */

.tp-md h1,
.tp-md h2,
.tp-md h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 8px 0 3px;
  color: #1a1a2e;
}

.tp-md p {
  margin: 3px 0;
}

.tp-md ul,
.tp-md ol {
  margin: 4px 0 4px 16px;
  padding: 0;
}

.tp-md li {
  margin: 2px 0;
}

.tp-md strong {
  font-weight: 700;
}

.tp-md em {
  font-style: italic;
}

.tp-md a {
  color: #7b1fa2;
  text-decoration: underline;
}

.tp-md code {
  background: #f0ecf8;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}
