@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-2px);
  }
  60% {
    transform: translateY(0);
  }
  80% {
    transform: translateY(2px);
  }
}

/* KONTENER GŁÓWNY */
#chat-widget-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  z-index: 999999;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#chat-widget-container .hidden {
  display: none !important;
}

/* OKRĄGŁY DYMEK / BĄBELEK OTWIERAJĄCY (Brak napisu - czysta ikonka) */
#chat-bubble {
  position: relative;
  width: 64px;
  height: 64px;
  background-color: #1f2937; /* bg-gray-800 */
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 0;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

#chat-bubble:hover {
  transform: scale(1.05);
  background-color: #111827;
}

#chat-bubble .notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background-color: #2f6b57;
  color: #ffffff;
  font-size: 12px;
  font-weight: bold;
  border-radius: 9999px;
  width: 20px;
  height: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  user-select: none;
  border: 0;
}

/* POP-UP CZATU */
#chat-popup {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 40vw;
  min-width: 340px;
  max-width: 450px;
  height: 70vh;
  max-height: 600px;
  background-color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
  border: 0;
}

/* NAGŁÓWEK CZATU */
#chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background-color: #2f6b57; /* bg-red-700 */
  color: #ffffff;
}

#chat-header .header-title {
  display: flex;
  align-items: center;
}

#chat-header img {
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  margin-right: 10px;
  object-fit: cover;
}

#chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
}

#chat-header #close-popup {
  background: transparent;
  border: none;
  color: #ffffff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#chat-header #close-popup svg {
  width: 24px;
  height: 24px;
}

/* OBSZAR WIADOMOŚCI */
#chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: #ffffff;
}

.msg-row {
  display: flex;
  margin-bottom: 8px;
}

.msg-row.user-message {
  justify-content: flex-end;
}

.bubble {
  max-width: 80%;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-line;
}

.bubble.assistant {
  background-color: #e5e7eb; /* bg-gray-200 */
  color: #000000;
}

.msg-row.user-message .bubble {
  background-color: #1f2937; /* bg-gray-800 */
  color: #ffffff;
}

/* LOADER / ANIMACJA KROPEK */
.typing {
  padding: 0 16px 8px 16px;
}

.typing .bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background-color: #eaeaea;
}

.typing .ellipsis {
  width: 5px;
  height: 5px;
  display: inline-block;
  background: #b7b7b7;
  border-radius: 50%;
  animation: bounce 1.3s linear infinite;
}

.typing .ellipsis.one { animation-delay: 0.6s; }
.typing .ellipsis.two { animation-delay: 0.5s; }
.typing .ellipsis.three { animation-delay: 0.8s; }

/* KONTENER INPUTA I PRZYCISKU */
#chat-input-container {
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  background-color: #ffffff;
}

#chat-input-container .input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

#chat-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 9999px;
  padding: 8px 16px;
  outline: none;
  font-size: 14px;
  background-color: #ffffff;
}

#chat-input:focus {
  border-color: #2f6b57;
}

#chat-submit {
  background-color: #2f6b57; /* bg-red-700 */
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 9999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.2s ease;
}

.chat-privacy-info {
  margin-top: 6px;
  font-size: 12px;
}

.chat-privacy-info a {
  color: #2f6b57;
}

#chat-submit:hover {
  background-color: #2f6b57; /* bg-red-500 */
}

/* WERSJA MOBILNA */
@media (max-width: 768px) {
  #chat-popup {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
  }
}