/* TPS Custom Chatbot Widget */
.tps-cw-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483640;
  font-family: inherit;
  color: #1f2937;
}

.tps-cw-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #1C64F2;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(28, 100, 242, 0.4);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.tps-cw-button:hover {
  transform: scale(1.05);
}

.tps-cw-button.tps-cw-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5);
}

.tps-cw-window {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 24rem;
  max-width: calc(100vw - 2rem);
  height: 40rem;
  max-height: calc(100vh - 4rem);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.tps-cw-window.tps-cw-open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.tps-cw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #1C64F2;
  color: #fff;
  gap: 8px;
}

.tps-cw-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tps-cw-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.tps-cw-logo svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.tps-cw-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tps-cw-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tps-cw-header-btn,
.tps-cw-close {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  transition: background 0.2s ease;
}

.tps-cw-header-btn:hover,
.tps-cw-close:hover {
  background: rgba(255, 255, 255, 0.32);
}

.tps-cw-header-btn svg {
  width: 15px;
  height: 15px;
}

.tps-cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tps-cw-empty {
  color: #6b7280;
  font-size: 13px;
  text-align: center;
  padding: 32px 12px;
  line-height: 1.5;
}

.tps-cw-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.tps-cw-msg-user {
  flex-direction: row;
  justify-content: flex-end;
}

.tps-cw-msg-assistant,
.tps-cw-msg-followup {
  flex-direction: row;
  justify-content: flex-start;
}

.tps-cw-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: block;
  overflow: hidden;
}

.tps-cw-avatar-user {
  border-radius: 50%;
}

.tps-cw-avatar-assistant {
  border-radius: 8px;
}

.tps-cw-avatar svg {
  display: block;
  width: 100%;
  height: 100%;
}

.tps-cw-msg-body {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  gap: 4px;
}

.tps-cw-msg-user .tps-cw-msg-body {
  align-items: flex-end;
}

.tps-cw-msg-assistant .tps-cw-msg-body,
.tps-cw-msg-followup .tps-cw-msg-body {
  align-items: flex-start;
}

.tps-cw-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.tps-cw-msg-meta {
  font-size: 11px;
  color: #6b7280;
  padding: 0 4px;
}

.tps-cw-msg-user .tps-cw-msg-bubble {
  background: #1C64F2;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.tps-cw-msg-assistant .tps-cw-msg-bubble,
.tps-cw-msg-followup .tps-cw-msg-bubble {
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

.tps-cw-msg-error {
  align-self: center;
}

.tps-cw-msg-error .tps-cw-msg-bubble {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.tps-cw-input {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  align-items: center;
}

.tps-cw-textarea {
  flex: 1;
  resize: none;
  border: none;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.4;
  font-family: inherit;
  outline: none;
  max-height: 120px;
  background: #f3f4f6;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.tps-cw-textarea:focus {
  background: #fff;
  box-shadow: 0 0 0 2px rgba(28, 100, 242, 0.22);
}

.tps-cw-textarea:disabled {
  opacity: 0.6;
}

.tps-cw-send {
  background: #1C64F2;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.2s ease, transform 0.1s ease;
}

.tps-cw-send svg {
  width: 18px;
  height: 18px;
}

.tps-cw-send:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.tps-cw-send:hover:not(:disabled) {
  background: #1850c4;
  transform: scale(1.05);
}

@media (max-width: 480px) {
  .tps-cw-window {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
    max-height: none;
  }
  .tps-cw-button {
    right: 0;
  }
}