/* CSS untuk Asisten Chat - Versi Final dengan Perbaikan Tampilan */

/* Style untuk Chat Window Saat Terbuka (Desktop) */
#chat-assistant {
  position: fixed;
  bottom: 20px; right: 60px; left: auto;
  width: 380px; max-width: calc(100% - 40px);
  height: 500px; max-height: calc(100% - 100px);
  border-radius: 15px; background: #ffffff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  z-index: 2147483647;
  /* [UPDATE] Diubah agar tooltip terlihat, tapi diimbangi dengan perbaikan di bawah */
  overflow: visible; 
  display: flex; flex-direction: column;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  /* [BARU] Sembunyikan asisten untuk sementara */
  display: none !important;
}

#chat-assistant.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

/* Style Utama untuk Tombol Bulat Saat Tertutup (Desktop) */
#chat-assistant.closed {
  background: linear-gradient(120deg, #4f00bc, #ff1493, #ff7e5f, #00c6ff);
  background-size: 300% 300%;
  animation: gamerGradient 8s ease infinite;
  width: 60px; height: 60px;
  border-radius: 50%;
  bottom: 150px; right: 60px;
  max-height: 60px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  border: 2px solid #ffffff;
  box-sizing: border-box;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), bottom 0.3s ease-in-out;
}

/* --- PENYESUAIAN POSISI AMAN UNTUK MOBILE --- */
@media (max-width: 768px) {
  #chat-assistant.closed {
    width: 48px; height: 48px;
    right: 20px;
    bottom: 100px;
  }
  #chat-assistant.closed #voxy-icon {
    width: 24px; height: 24px;
  }
  #chat-assistant:not(.closed) {
    left: 0; right: 0; bottom: 0;
    width: 100%; max-width: 100%;
    height: 85vh; max-height: 100%;
    border-radius: 20px 20px 0 0;
  }
}
@media (max-width: 576px) {
  #chat-assistant.closed {
      bottom: 120px;
  }
}

/* [FIX] Aturan yang hilang untuk menghindari tabrakan */
#chat-assistant.closed.is-avoiding {
  /* Posisi baru saat harus menghindar, nilainya diatur oleh JavaScript */
  bottom: var(--avoid-offset, 250px); /* 250px adalah fallback jika JS gagal */
}


/* --- Sisa CSS dari kode yang Anda setujui --- */
#chat-header {
  color: white; padding: 12px 18px; font-weight: 600; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important; flex-shrink: 0;
  background: linear-gradient(120deg, #4f00bc, #ff1493, #ff7e5f, #00c6ff);
  background-size: 300% 300%; animation: gamerGradient 8s ease infinite;
  /* [FIX] Menambahkan border-radius agar sudut atas tidak tajam saat terbuka */
  border-radius: 15px 15px 0 0;
}
#chat-assistant.closed #chat-header {
  padding: 0; background: transparent; box-shadow: none;
  width: 100%; height: 100%; display: flex;
  align-items: center; justify-content: center;
  /* [FIX] Menambahkan border-radius agar header ikut membulat saat tertutup */
  border-radius: 50%;
}
#voxy-icon { width: 25px; height: 25px; margin-right: 8px; vertical-align: middle; fill: currentColor; }
#chat-assistant.closed #chat-header span { display: none; }
#chat-assistant.closed #voxy-icon { margin: 0; fill: #ffffff; }
#chat-body { display: flex; flex-direction: column; flex-grow: 1; opacity: 1; overflow: hidden; transition: opacity 0.2s ease-in-out; }
#chat-assistant.closed #chat-body { opacity: 0; height: 0; }
#chat-messages-container { flex-grow: 1; padding: 20px; overflow-y: auto; }
#chat-input-form { display: flex; padding: 15px; border-top: 1px solid #e9e9eb; background-color: #fff; flex-shrink: 0; }
#chat-input-form input { flex-grow: 1; border: 1px solid #ddd; border-radius: 20px; padding: 10px 15px; font-size: 16px; margin-right: 10px; transition: all 0.3s ease; }
#chat-input-form input:focus { outline: none; border-color: #a400a4; box-shadow: 0 0 10px rgba(164, 0, 164, 0.5); }
#chat-input-form button { border: none; background-color: #007bff; color: white; border-radius: 50%; width: 44px; height: 44px; cursor: pointer; font-size: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
#chat-input-form button:hover { background-color: #0099ff; transform: scale(1.1); }
.message { display: flex; align-items: flex-end; margin-bottom: 15px; max-width: 90%;}
.message.user { margin-left: auto; flex-direction: row-reverse; }
.message.assistant { margin-right: auto; }
.message-bubble { padding: 10px 15px; border-radius: 20px; line-height: 1.5; }
.message.user .message-bubble { background-color: #007bff; color: white; border-bottom-right-radius: 5px; }
.message.assistant .message-bubble { background-color: #f1f0f0; color: #333; border-bottom-left-radius: 5px; }
.typing-indicator span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background-color: #999; margin: 0 1px; animation: typing 1.4s infinite both; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
#chat-input-form input:disabled { background-color: #f5f5f5; }
#chat-input-form button:disabled { background-color: #a0a0a0; cursor: not-allowed; transform: scale(1); }
@keyframes gamerGradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

/* Style untuk Tooltip "Tanya Voxy" */
#voxy-tooltip {
  position: absolute;
  top: 50%; right: 115%;
  transform: translateY(-50%);
  background-color: #1a1a1a; color: #ffffff;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}
#voxy-tooltip::after {
  content: ''; position: absolute;
  top: 50%; left: 100%;
  transform: translateY(-50%);
  border-width: 6px; border-style: solid;
  border-color: transparent transparent transparent #1a1a1a;
}
#voxy-tooltip.visible { opacity: 1; visibility: visible; }
#chat-assistant:not(.closed) #voxy-tooltip { display: none; }

