:root {
    --primary: #d65a1f;
    --bg: #f7f7f8;
    --border: #e5e5e5;
    --text: #1f2937;
}

body {
  font-family: 'Geist Sans', system-ui, sans-serif;
}

/* Floating Button */
#chat-widget-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary) !important; /* Paksa warna agar tidak putih */
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 9999999 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: all transform 0.3s ease;
}

/* Perbaikan Container Utama */
#chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 90vh !important; /* Menggunakan vh agar adaptif dengan tinggi layar */
    max-height: 650px !important;
    background: #f9fafb;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    /* SOLUSI KETIMPA: Naikkan z-index ke angka maksimal */
    z-index: 9999999 !important;
    /* Animasi Setup */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

    /* Saat Chat Muncul */
    #chat-widget-container.show {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }

#chat-widget-button:hover {
    transform: scale(1.1) rotate(5deg);
}

/* Header */
#chat-widget-header {
  background: var(--primary);
  color: white;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.header-title {
  font-size: 15px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  font-weight: 700;
  font-size: 18px;
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
}

/* Body Chat: Tambahkan padding atas agar pesan bot tidak terpotong */
#chat-widget-body {
    flex: 1;
    padding: 20px 16px; /* 20px di atas untuk ruang napas */
    background: var(--bg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Perbaikan alignment baris pesan agar tidak terpotong samping */
.msg-row {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    align-items: flex-start; /* Sejajarkan ke atas */
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.message {
  max-width: 75%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
  border-radius: 14px;
}

.message.bot {
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  border-bottom-left-radius: 4px;
}

.message.user {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing */
.typing {
  display: inline-flex;
  gap: 6px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 14px;
}

.typing span {
  width: 6px;
  height: 6px;
  background: #bbb;
  border-radius: 50%;
  animation: blink 1.4s infinite both;
}

@keyframes blink {
  0% { opacity: .2; }
  20% { opacity: 1; }
  100% { opacity: .2; }
}

/* Quick Replies Sejajar dengan teks bot */
.quick-replies {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 5px 0 15px 42px; /* 42px = Lebar Avatar + Gap */
}

    .quick-replies button {
        background: white;
        border: 1px solid var(--primary);
        color: var(--primary);
        padding: 8px 12px;
        border-radius: 15px;
        font-size: 13px;
        cursor: pointer;
        width: fit-content;
        text-align: left;
    }

        .quick-replies button:hover {
            background: #e2e5e9;
        }

/* Footer */
#chat-widget-footer {
  display: flex;
  padding: 12px;
  border-top: 1px solid var(--border);
}

#chat-widget-input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
}

#chat-widget-send {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

#chat-powered {
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  padding-bottom: 10px;
}

@media (max-width: 480px) {
    #chat-widget-container {
        width: 100%;
        height: 100% !important;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
}
