/* custom_chatbox.css */
/* Reset dasar atau gaya global jika diperlukan untuk chatbox saja */
.chatbox-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.chatbox-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px; /* Lebar chatbox */
    max-height: 80vh; /* Tinggi maksimum chatbox */
    height: 500px; /* Tinggi default chatbox */
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px; /* Sudut yang lebih melengkung */
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    font-family: 'Arial', sans-serif; /* Pilih font yang Anda suka */
    overflow: hidden; /* Penting untuk border-radius pada child */
    z-index: 9999; /* Pastikan di atas elemen lain */
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    transform: translateY(20px) scale(0.95); /* Efek awal tersembunyi */
    opacity: 0;
    visibility: hidden; /* Awalnya tersembunyi */
}

.chatbox-container.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.chatbox-header {
    background-color: #007bff; /* Warna utama tema Anda */
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1em;
    font-weight: bold;
}

.chatbox-close-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    line-height: 1;
}
.chatbox-close-button:hover {
    opacity: 0.8;
}

.chatbox-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f9f9f9; /* Warna latar area pesan */
    display: flex;
    flex-direction: column;
    gap: 10px; /* Jarak antar pesan */
}

.message {
    padding: 10px 15px;
    border-radius: 18px; /* Bentuk gelembung chat */
    max-width: 80%;
    line-height: 1.45;
    word-wrap: break-word; /* Agar teks panjang tidak keluar batas */
    white-space: pre-line;
}

.visitor-message {
    background-color: #e9ecef; /* Warna gelembung pesan pengunjung */
    color: #333;
    align-self: flex-start; /* Pesan pengunjung di kiri */
    border-bottom-left-radius: 6px; /* Variasi bentuk */
}

.ai-reply-message {
    background-color: #007bff; /* Warna gelembung pesan AI (sesuaikan dengan header) */
    color: white;
    align-self: flex-end; /* Pesan AI di kanan */
    border-bottom-right-radius: 6px; /* Variasi bentuk */
}

.system-message { /* Untuk pesan error atau info dari sistem */
    font-style: italic;
    color: #777;
    font-size: 0.9em;
    text-align: center;
    background-color: transparent;
    padding: 5px;
    align-self: center;
    width: 100%;
}

.chatbox-input-area {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-top: 1px solid #e0e0e0;
    background-color: #ffffff;
}

#visitorMessageInput {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 20px; /* Input field lebih bulat */
    margin-right: 10px;
    font-size: 0.95em;
    outline: none; /* Hilangkan outline saat fokus jika diinginkan */
}
#visitorMessageInput:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

#sendMessageButton {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%; /* Tombol bulat */
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
#sendMessageButton:hover {
    background-color: #0056b3;
}
#sendMessageButton svg {
    width: 18px;
    height: 18px;
}

.chatbox-footer {
    padding: 8px;
    text-align: center;
    font-size: 0.75em;
    color: #aaa;
    background-color: #f1f1f1;
    border-top: 1px solid #e0e0e0;
}
.chatbox-footer a {
    color: #007bff;
    text-decoration: none;
}
.chatbox-footer a:hover {
    text-decoration: underline;
}

/* Tombol Toggle Chatbox */
.chatbox-toggle-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9998; /* Di bawah chatbox tapi di atas konten lain */
    transition: transform 0.3s ease, background-color 0.3s ease;
}
.chatbox-toggle-button:hover {
    background-color: #0056b3;
    transform: scale(1.1);
}
.chatbox-toggle-button svg {
    width: 28px;
    height: 28px;
}

/* Sembunyikan tombol toggle jika chatbox terbuka */
.chatbox-container.open + .chatbox-toggle-button {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5);
}

/* Gaya untuk Typing Indicator */
.typing-indicator .typing-dots {
    display: flex;
    align-items: center;
}
.typing-indicator .typing-dots span {
    height: 8px;
    width: 8px;
    background-color: currentColor; /* Mengambil warna dari .ai-reply-message (putih) */
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px; /* Jarak antar titik */
    animation: typing-blink 1.4s infinite both;
}
.typing-indicator .typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-indicator .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-blink {
    0% { opacity: 0.2; transform: scale(0.8); }
    20% { opacity: 1; transform: scale(1); }
    100% { opacity: 0.2; transform: scale(0.8); }
}

/* Pastikan pesan ai-reply-message punya cukup padding jika hanya berisi typing indicator */
.message.ai-reply-message.typing-indicator {
    background-color: #007bff; /* Sama dengan .ai-reply-message */
    color: white; /* Agar titik-titik berwarna putih */
}

/* ============================= */
/* TAMBAHAN: RENDER GAMBAR & ZOOM */
/* ============================= */

/* Blok gambar dalam balasan AI */
.ai-reply-message .chat-image-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 6px 0 10px;
}
.ai-reply-message .chat-image-caption {
    font-size: 12px;
    opacity: 0.9;
}
.ai-reply-message .chat-image {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    cursor: zoom-in;
    transition: transform 0.2s ease;
    border: 1px solid rgba(0,0,0,0.08);
}
.ai-reply-message .chat-image:hover {
    transform: scale(1.02);
}

/* Modal zoom gambar */
#chatImageModal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000; /* Di atas chatbox (chatbox z-index: 9999) */
}
#chatImageModal.active { display: flex; }
.chat-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8);
}
.chat-modal-img {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    box-shadow: 0 0 28px rgba(0,0,0,0.5);
    animation: fadeIn .18s ease;
    background: #0b0e14;
}
@keyframes fadeIn {
    from { opacity: 0; transform: scale(.96); }
    to   { opacity: 1; transform: scale(1); }
}
