/* === Chatbox Container === */
#chatbox-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 390px;
  max-height: 80vh;
  border: 1px solid #ccc;
  border-radius: 10px;
  font-family: Arial, sans-serif;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  background-color: #fff;
  color: #000;
}

/* === Header === */
#chatbox-header {
  background-color: #0c4b8e;
  color: white;
  padding: 10px;
  display: flex;
  align-items: center;
  font-weight: bold;
  font-size: 14px;
}

.chat-logo {
  width: 24px;
  height: 24px;
  margin-right: 10px;
}

/* === Chat Body === */
#chatbox-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* === Chat Entries (User & Bot) === */
.chat-entry {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 90%;
  animation: fadeIn 0.3s ease;
}

.chat-entry.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-entry.bot {
  align-self: flex-start;
}

/* === Avatar === */
.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
}

/* === Chat Bubble === */
.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
}

.user .bubble {
  background-color: #DCF8C6;
  border-bottom-right-radius: 0;
  color: #000;
}

.bot .bubble {
  background-color: #f1f0f0;
  border-bottom-left-radius: 0;
  color: #000;
}

/* === Timestamp === */
.timestamp {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
  text-align: right;
}

/* === Input Area === */
#chatbox-input {
  display: flex;
  padding: 10px;
  border-top: 1px solid #eee;
}

#chat-message {
  flex: 1;
  padding: 8px;
  font-size: 14px;
}

button {
  padding: 8px 12px;
  background: #0c4b8e;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

/* === Typing Animation === */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 14px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: #888;
  border-radius: 50%;
  animation: typingBounce 1s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.7);
    opacity: 0.3;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* === Fade In === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === DARK MODE === */
html.dark #chatbox-container {
  background-color: #1f2937; /* tailwind gray-800 */
  color: #f3f4f6;
  border-color: #374151;
}

html.dark .user .bubble {
  background-color: #4b5563; /* gray-600 */
  color: #f3f4f6;
}

html.dark .bot .bubble {
  background-color: #374151; /* gray-700 */
  color: #f3f4f6;
}

html.dark .timestamp {
  color: #9ca3af; /* gray-400 */
}

/* === Chatbox Container mobile === */

@media (max-width: 768px) {
  #chatbox-container {
    width: 90vw;        /* 90% dari lebar layar */
    right: 5vw;         /* beri jarak dari sisi kanan */
    bottom: 20px;
    max-height: 85vh;
  }
}

@media (max-width: 480px) {
  #chatbox-container {
    font-size: 13px;
  }

  #chat-message {
    font-size: 13px;
  }

  .bubble {
    font-size: 13px;
    padding: 8px 10px;
  }
}
