/* Dommify chat widget — reuses the site's existing design tokens
   (--brand-blue, --brand-cyan, --surface-paper, --radius, --shadow-sm, --ease)
   rather than hardcoding colors, so it follows the site's dark/light theme
   automatically. */

#dommify-chat-toggle {
  position: fixed;
  right: 22px;
  bottom: 84px; /* stacked above #btt (bottom: 22px, 46px tall) so they never overlap */
  z-index: 290; /* above #btt's z-index: 280 */
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-cyan));
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

#dommify-chat-toggle:hover {
  transform: scale(1.06);
}

#dommify-chat-toggle svg {
  width: 26px;
  height: 26px;
}

.dommify-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 150px;
  z-index: 291;
  width: min(360px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 180px));
  display: flex;
  flex-direction: column;
  background: var(--surface-paper);
  color: var(--surface-paper-text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.dommify-chat-panel.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.dommify-chat-header {
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-cyan));
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.dommify-chat-header h2 {
  font-size: 1rem;
  margin: 0;
  font-weight: 700;
}

.dommify-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dommify-chat-clear,
.dommify-chat-close {
  background: none;
  border: 0;
  color: #ffffff;
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background 0.15s var(--ease);
}

.dommify-chat-clear:hover,
.dommify-chat-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

.dommify-chat-clear svg {
  width: 18px;
  height: 18px;
}

.dommify-chat-close {
  font-size: 1.3rem;
  line-height: 1;
}

.dommify-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.92rem;
}

.dommify-chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: var(--radius);
  line-height: 1.4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.dommify-chat-msg a {
  color: inherit;
  text-decoration: underline;
  word-break: break-word;
}

.dommify-chat-msg-bot {
  align-self: flex-start;
  background: var(--surface-paper-alt);
}

.dommify-chat-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-cyan));
  color: #ffffff;
}

.dommify-chat-msg-error {
  align-self: flex-start;
  background: var(--surface-paper-alt);
  color: #b3261e;
}

.dommify-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}

.dommify-chat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: dommify-chat-dot-bounce 1.2s infinite ease-in-out;
}

.dommify-chat-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.dommify-chat-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes dommify-chat-dot-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.dommify-chat-turnstile-wrap {
  padding: 10px 16px;
  border-top: 1px solid var(--surface-paper-alt);
  flex-shrink: 0;
}

.dommify-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--surface-paper-alt);
  flex-shrink: 0;
}

.dommify-chat-input-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-paper-alt);
  background: var(--surface-paper);
  color: var(--surface-paper-text);
  font-size: 0.9rem;
}

.dommify-chat-input-row button {
  padding: 8px 16px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-cyan));
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.dommify-chat-input-row button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .dommify-chat-panel {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 138px;
    max-height: min(70vh, calc(100vh - 160px));
  }

  #dommify-chat-toggle {
    right: 16px;
    bottom: 76px;
  }
}
