/* Toi Taplink help chat widget */

.toitap-help-chat {
  --toitap-chat-accent: #7c3aed;
  --toitap-chat-accent-hover: #6d28d9;
  --toitap-chat-surface: rgba(255, 255, 255, 0.92);
  --toitap-chat-border: rgba(124, 58, 237, 0.18);
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  font-family: inherit;
}

.toitap-help-chat__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 9999px;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: #fff;
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.toitap-help-chat__toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(124, 58, 237, 0.42);
}

.toitap-help-chat__toggle:focus-visible {
  outline: 2px solid #c4b5fd;
  outline-offset: 3px;
}

.toitap-help-chat__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  display: flex;
  flex-direction: column;
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(32rem, calc(100vh - 6rem));
  overflow: hidden;
  border: 1px solid var(--toitap-chat-border);
  border-radius: 1.25rem;
  background: var(--toitap-chat-surface);
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.toitap-help-chat.is-open .toitap-help-chat__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.toitap-help-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.toitap-help-chat__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e1b4b;
}

.toitap-help-chat__subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: #64748b;
}

.toitap-help-chat__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}

.toitap-help-chat__close:hover {
  background: rgba(124, 58, 237, 0.08);
  color: #7c3aed;
}

.toitap-help-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  overflow-y: auto;
  min-height: 12rem;
  max-height: 18rem;
}

.toitap-help-chat__bubble {
  max-width: 92%;
  padding: 0.65rem 0.8rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.toitap-help-chat__bubble--bot {
  align-self: flex-start;
  background: #f5f3ff;
  color: #312e81;
  border-bottom-left-radius: 0.25rem;
}

.toitap-help-chat__bubble--user {
  align-self: flex-end;
  background: var(--toitap-chat-accent);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.toitap-help-chat__text {
  white-space: pre-wrap;
  word-break: break-word;
}

.toitap-help-chat__bubble--streaming .toitap-help-chat__text::after {
  content: "";
  display: inline-block;
  width: 0.42em;
  height: 1.05em;
  margin-left: 0.08em;
  vertical-align: text-bottom;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.75;
  animation: toitap-help-chat-cursor 0.85s step-end infinite;
}

@keyframes toitap-help-chat-cursor {
  0%,
  45% {
    opacity: 0.75;
  }

  50%,
  100% {
    opacity: 0;
  }
}

.toitap-help-chat__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.toitap-help-chat__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  border-radius: 9999px;
  background: #25d366;
  color: #fff !important;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.toitap-help-chat__link:hover {
  background: #1ebe57;
  color: #fff !important;
}

.toitap-help-chat__bubble--typing {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  min-height: 2rem;
}

.toitap-help-chat__dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 9999px;
  background: #a78bfa;
  animation: toitap-help-chat-bounce 1.2s infinite ease-in-out;
}

.toitap-help-chat__dot:nth-child(2) {
  animation-delay: 0.15s;
}

.toitap-help-chat__dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes toitap-help-chat-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.toitap-help-chat__form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.toitap-help-chat__input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.9rem;
  background: #fff;
  font-size: 16px;
  color: #0f172a;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.toitap-help-chat__input:focus {
  outline: none;
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);
}

.toitap-help-chat__send {
  flex-shrink: 0;
  padding: 0.65rem 0.9rem;
  border: 0;
  border-radius: 0.9rem;
  background: var(--toitap-chat-accent);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.toitap-help-chat__send:hover:not(:disabled) {
  background: var(--toitap-chat-accent-hover);
}

.toitap-help-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .toitap-help-chat {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .toitap-help-chat__panel {
    width: min(22rem, calc(100vw - 1.5rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  .toitap-help-chat__panel,
  .toitap-help-chat__toggle,
  .toitap-help-chat__dot {
    transition: none;
    animation: none;
  }

  .toitap-help-chat__bubble--streaming .toitap-help-chat__text::after {
    animation: none;
    opacity: 0.75;
  }
}
