
:root {
  --chat-font: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  --black: #0f0f0f;
  --white: #ffffff;
  --gray-100: #f5f5f5;
  --gray-200: #e5e5e5;
  --gray-500: #6b7280;

  --chat-shadow: 0 18px 40px rgba(0,0,0,0.25);
  --radius: 18px;
}

/* Reset */
html, body {
  margin: 0;
  padding: 0;
  background: transparent;
  font-family: var(--chat-font);
}

/* Root */
#chat-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2147483647;
}

/* Utility */
.is-hidden {
  display: none !important;
}

/* Hint */
.chat-hint {
  position: absolute;
  right: 0;
  bottom: 72px;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--black);
  color: var(--white);
  box-shadow: var(--chat-shadow);
  pointer-events: none;
}

/* Avatar */
.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  background: var(--white);
  box-shadow: var(--chat-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chat-toggle img {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
}

/* Chat Bubble */
.chat-bubble {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 32px));
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.chat-header {
  position: relative;
  background: var(--black);
  color: var(--white);
  padding: 14px;
  text-align: center;
}

.chat-title {
  font-size: 14px;
  font-weight: 600;
}

/* Header buttons (Reset + Close identisch) */
.chat-header button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--white);
  font-size: 18px;
  cursor: pointer;
  opacity: 0.85;
  padding: 4px;
  line-height: 1;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-header button:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.08);
}

.chat-header button:focus {
  outline: none;
}

.chat-reset {
  left: 12px;
}

.chat-close {
  right: 12px;
}

/* Messages */
.chat-messages {
  flex: 1;
  min-height: 0;              /* WICHTIG: verhindert Flex-Kollaps */
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message bubbles */
.message {
  max-width: 85%;
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--black);
  color: var(--white);
  border-bottom-right-radius: 6px;
}

.message.bot {
  align-self: flex-start;
  background: var(--gray-100);
  color: #111;
  border-bottom-left-radius: 6px;
}

/* Typing Indicator */
.message.typing {
  padding: 0;
  background: transparent;
  max-width: fit-content;
}

.typing-dots {
  display: inline-flex;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--gray-100);
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--gray-500);
  animation: bounce 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Input */
.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #eee;
}

.chat-text {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #ddd;
  outline: none;
}

.chat-text:focus {
  border-color: var(--black);
}

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: var(--black);
  color: var(--white);
  cursor: pointer;
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile (nur minimal, ohne iframe-desktop zu zerstören) */
@media (hover: none) and (pointer: coarse) {
  #chat-root {
    right: 12px;
    bottom: 12px;
  }

  .chat-bubble {
    width: min(360px, calc(100vw - 24px));
    height: min(520px, calc(100vh - 24px));
  }
}
