:root {
  --primary-color: #8b5cf6; /* Warna ungu premium */
  --secondary-color: #5b21b6; /* Ungu gelap untuk kontras */
  --accent-color: #a78bfa; /* Ungu cerah untuk aksen */
  --light-color: #f5f5ff; /* Putih lembut untuk teks */
  --dark-color: #1e1e2f; /* Latar gelap elegan */
  --user-msg-color: #ff3b3b; /* Merah premium untuk pesan pengguna */
  --bot-msg-color: #3b82f6; /* Biru modern untuk pesan bot */
  --user-glow: rgba(255, 59, 59, 0.5); /* Glow merah lembut */
  --bot-glow: rgba(59, 130, 246, 0.5); /* Glow biru lembut */
  --premium-glow: rgba(139, 92, 246, 0.6); /* Glow premium untuk elemen utama */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1e1e2f, #2a2a4a);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  color: var(--light-color);
  overflow-y: auto;
}

canvas#stars {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5; /* Sedikit lebih transparan untuk kesan premium */
}

.chat-container {
  width: 100%;
  max-width: 950px; /* Sedikit lebih lebar untuk tampilan premium */
  height: 92vh; /* Memberi ruang lebih */
  background: rgba(30, 30, 47, 0.85); /* Latar gelap transparan premium */
  border-radius: 16px; /* Radius lebih halus */
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 20px var(--premium-glow); /* Glow premium */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(139, 92, 246, 0.4); /* Border premium */
}

.chat-header {
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  color: var(--light-color);
  padding: 16px;
  text-align: center;
  font-size: 22px; /* Ukuran font lebih besar */
  font-weight: 700; /* Lebih tebal untuk kesan premium */
  letter-spacing: 0.8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* Shadow lebih dalam */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-messages {
  flex: 1;
  padding: 20px; /* Padding lebih besar */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px; /* Jarak antar pesan lebih rapat */
}

.message-container {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.message {
  padding: 12px 22px; /* Padding lebih nyaman */
  border-radius: 20px; /* Radius lebih halus */
  max-width: 80%; /* Lebar pesan sedikit lebih kecil */
  line-height: 1.6;
  word-wrap: break-word;
  will-change: transform, opacity;
  animation: fadeIn 0.4s ease; /* Animasi lebih halus */
  position: relative; /* Untuk efek glow tambahan */
}

.message:hover {
  transform: translateY(-2px); /* Hover lebih halus */
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 12px var(--premium-glow); /* Glow premium saat hover */
}

.user-message {
  background: linear-gradient(90deg, var(--user-msg-color), #ff6b6b);
  color: var(--light-color);
  align-self: flex-end;
  border-bottom-right-radius: 6px; /* Radius lebih kecil untuk detail */
  white-space: pre-wrap;
  box-shadow: 0 0 10px var(--user-glow), 0 0 20px var(--user-glow); /* Double glow effect */
}

.user-message::before,
.user-message::after {
  content: '';
  width: 5px;
  height: 5px;
  background: var(--user-glow);
  border-radius: 50%;
  position: absolute;
  left: -8px;
  animation: typing 2s infinite ease-in-out; /* Animasi lebih lambat untuk elegan */
}

.user-message::before {
  top: 10px;
}

.user-message::after {
  top: 20px;
  animation-delay: 0.5s;
}

.bot-message {
  background: linear-gradient(90deg, var(--bot-msg-color), #60a5fa);
  color: var(--light-color);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  box-shadow: 0 0 10px var(--bot-glow), 0 0 20px var(--bot-glow);
}

.bot-message::before,
.bot-message::after {
  content: '';
  width: 5px;
  height: 5px;
  background: var(--bot-glow);
  border-radius: 50%;
  position: absolute;
  right: -8px;
  animation: typing 2s infinite ease-in-out;
}

.bot-message::before {
  top: 10px;
}

.bot-message::after {
  top: 20px;
  animation-delay: 0.5s;
}

.bot-message p {
  margin: 0 0 0.8em 0;
}

.bot-message p:last-child {
  margin-bottom: 0;
}

.message-time {
  font-size: 10px; /* Ukuran lebih kecil untuk kesan minimalis */
  margin-top: 6px;
  opacity: 0.6; /* Sedikit lebih transparan */
  color: var(--light-color);
}

.user-message + .message-time {
  align-self: flex-end;
}

.bot-message + .message-time {
  align-self: flex-start;
}

.chat-input-container {
  padding: 16px;
  display: flex;
  background: rgba(30, 30, 47, 0.85); /* Latar input premium */
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

#user-input {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 30px; /* Radius lebih besar untuk kesan modern */
  font-size: 15px;
  outline: none;
  background: rgba(255, 59, 59, 0.25); /* Latar merah transparan */
  color: var(--light-color);
  box-shadow: 0 0 10px var(--user-glow), 0 0 20px var(--user-glow);
  transition: box-shadow 0.3s ease;
}

#user-input:focus {
  box-shadow: 0 0 15px var(--user-glow), 0 0 25px var(--user-glow); /* Glow lebih kuat */
}

#send-button {
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  color: var(--light-color);
  border: none;
  padding: 0 28px;
  margin-left: 12px;
  border-radius: 30px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 0 10px var(--premium-glow), 0 0 20px var(--premium-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#send-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 15px var(--premium-glow), 0 0 25px var(--premium-glow);
}

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 10px 16px;
  background: linear-gradient(90deg, var(--bot-msg-color), #60a5fa);
  border-radius: 20px;
  align-self: flex-start;
  box-shadow: 0 0 10px var(--bot-glow), 0 0 20px var(--bot-glow);
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--light-color);
  border-radius: 50%;
  animation: typing 2s infinite ease-in-out;
}

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

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

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

/* Media query untuk HP */
@media (max-width: 768px) {
  .chat-container {
    height: 96vh;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* Shadow lebih ringan di HP */
  }
  .chat-header {
    font-size: 20px;
    padding: 12px;
  }
  .chat-messages {
    padding: 12px;
    gap: 8px;
  }
  .message {
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 16px;
  }
  #user-input {
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 25px;
  }
  #send-button {
    padding: 0 22px;
    border-radius: 25px;
  }
  .user-message, .bot-message, #user-input, #send-button, .typing-indicator {
    box-shadow: 0 0 6px var(--premium-glow); /* Glow minimal di HP untuk performa */
  }
}