/* ==============================================================================
 * STYLING CHATBOT AI FLOATING WIDGET (SISABERBAGI)
 * Menyesuaikan dengan Tema Visual Project (Fraunces + Inter, Forest Green & Cream)
 * ============================================================================== */

/* Wrapper Utama Chatbot (Fixed Position di Pojok Kanan Bawah) */
.chatbot-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Inter', sans-serif;
}

/* Tombol Bubble Floating */
.chatbot-toggle-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--primary, #2D5D3F);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(45, 93, 63, 0.35);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  margin-left: auto;
}

.chatbot-toggle-btn:hover {
  background-color: var(--primary-dark, #1E432C);
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(30, 67, 44, 0.45);
}

.chatbot-toggle-btn:active {
  transform: scale(0.95);
}

.chatbot-toggle-btn .icon-chat-close {
  display: none;
}

.chatbot-toggle-btn.active .icon-chat-open {
  display: none;
}

.chatbot-toggle-btn.active .icon-chat-close {
  display: block;
}

/* Panel Chat Floating (Ukuran Standard ~350x450px) */
.chatbot-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 350px;
  height: 450px;
  max-height: calc(100vh - 110px);
  background-color: #FFFFFF;
  border-radius: 20px;
  box-shadow: 0 12px 36px rgba(35, 43, 37, 0.18);
  border: 1px solid var(--border-color, #E8E2D5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
}

.chatbot-panel.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Header Chatbot */
.chatbot-header {
  background-color: var(--primary, #2D5D3F);
  color: #FFFFFF;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  flex-shrink: 0;
}

.chatbot-title {
  font-family: 'Fraunces', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #FFFFFF;
  margin: 0;
  line-height: 1.2;
}

.chatbot-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #52C41A;
  display: inline-block;
  box-shadow: 0 0 6px #52C41A;
}

.chatbot-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chatbot-close-btn:hover {
  color: #FFFFFF;
  background-color: rgba(255, 255, 255, 0.15);
}

/* Area Pesan Chat (Scrollable) */
.chatbot-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background-color: var(--bg-body, #FAF6EE);
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Gelembung Pesan (Chat Bubbles) */
.chat-msg {
  max-width: 85%;
  font-size: 0.88rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeInMsg 0.25s ease-out forwards;
}

@keyframes fadeInMsg {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pesan dari Asisten AI */
.chat-msg-bot {
  align-self: flex-start;
  background-color: #FFFFFF;
  color: var(--text-main, #232B25);
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-color, #E8E2D5);
}

/* Pesan dari User */
.chat-msg-user {
  align-self: flex-end;
  background-color: var(--primary, #2D5D3F);
  color: #FFFFFF;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 6px rgba(45, 93, 63, 0.2);
}

/* Indikator "Mengetik..." (Typing Indicator) */
.chat-typing {
  align-self: flex-start;
  background-color: #FFFFFF;
  padding: 10px 16px;
  border-radius: 16px 16px 16px 4px;
  border: 1px solid var(--border-color, #E8E2D5);
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-muted, #68776C);
  border-radius: 50%;
  animation: typingBlink 1.4s infinite ease-in-out both;
}

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

@keyframes typingBlink {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Form Input Chatbot */
.chatbot-input-form {
  padding: 12px 14px;
  background-color: #FFFFFF;
  border-top: 1px solid var(--border-color, #E8E2D5);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chatbot-input {
  flex: 1;
  border: 1px solid var(--border-color, #E8E2D5);
  border-radius: 24px;
  padding: 9px 14px;
  font-size: 0.86rem;
  outline: none;
  background-color: var(--bg-body, #FAF6EE);
  color: var(--text-main, #232B25);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.chatbot-input:focus {
  border-color: var(--primary, #2D5D3F);
  background-color: #FFFFFF;
}

.chatbot-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--primary, #2D5D3F);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.chatbot-send-btn:hover {
  background-color: var(--primary-dark, #1E432C);
  transform: scale(1.05);
}

.chatbot-send-btn:disabled {
  background-color: var(--border-color, #E8E2D5);
  cursor: not-allowed;
  transform: none;
}

/* Responsif untuk Layar Mobile (Ukuran Kecil) */
@media (max-width: 480px) {
  .chatbot-wrapper {
    bottom: 16px;
    right: 16px;
  }
  
  .chatbot-panel {
    width: calc(100vw - 32px);
    max-width: 350px;
    bottom: 68px;
    right: 0;
    height: 420px;
  }
}
