#chatbox.hidden {
  display: none;
}

.chat-toggle-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: #2563eb;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 20px 45px rgba(37, 99, 235, 0.28);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.chat-toggle-button:hover {
  background: #1d4ed8;
  transform: scale(1.04);
}

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 40;
  width: 380px;
  height: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);
}

.chat-header {
  padding: 13px 16px;
  color: #ffffff;
  background: #2563eb;
  font-weight: 700;
}

.chat-header-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
}

.chat-subtitle {
  margin-top: 2px;
  color: #dbeafe;
  font-size: 12px;
  font-weight: 400;
}

#messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.user {
  align-self: flex-end;
  background: #3b82f6;
  color: white;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  max-width: 75%;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.assistant {
  align-self: flex-start;
  background: #f1f5f9;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  max-width: 72%;
  font-size: 14px;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
}

.typing {
  display: flex;
  gap: 4px;
  align-self: flex-start;
  background: #f1f5f9;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
}

.dot {
  width: 6px;
  height: 6px;
  background: #6b7280;
  border-radius: 50%;
  animation: blink 1.4s infinite both;
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0% {
    opacity: 0.2;
  }

  20% {
    opacity: 1;
  }

  100% {
    opacity: 0.2;
  }
}

.fade {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  max-width: 85%;
  align-self: flex-start;
}

.quick-reply-btn {
  border: 1px solid #bfdbfe;
  background: white;
  color: #2563eb;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.quick-reply-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.quick-reply-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-input-row {
  display: flex;
  overflow: hidden;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  border-radius: 0 0 16px 16px;
  min-height: 52px;
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 13px 16px;
  border: 0;
  outline: 0;
  font-size: 14px;
}

.chat-send {
  padding: 0 20px;
  color: #ffffff;
  background: #2563eb;
  border: 0;
  font-weight: 700;
  cursor: pointer;
}

.chat-send:hover {
  background: #1d4ed8;
}

.chat-send:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

@media (max-width: 640px) {
  #chatbox {
    left: 12px;
    right: 12px;
    bottom: 84px;
    width: auto;
    height: min(560px, calc(100dvh - 132px));
  }

  .chat-toggle-button {
    right: 24px;
    bottom: 24px;
  }

  #userInput {
    font-size: 16px;
  }
}
