/* =============================
   CHAT BUTTON
============================= */
#chat-button {
    position: fixed;     /* Kunci utama agar posisinya diam menempel di layar */
    bottom: 30px;        /* Jarak aman dari bagian bawah layar */
    right: 20px;         /* Jarak dari bagian kanan layar */
    background: transparent;
    color: #fff;
    width: 150px; 
    height: 150px;
    cursor: pointer;
    z-index: 2147483647; /* Memastikan posisinya selalu di lapisan paling atas */
    transition: 0.3s;
    overflow: hidden; 
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: none;

    /* EFEK MELAYANG */
    animation: floatMascot 3s ease-in-out infinite;
}


/* Mengatur ukuran gambar maskot di dalam tombol */
#chat-button img {
    width: 100%;
    height: 100%;
    object-fit: contain; 
}

/* Efek saat kursor diarahkan ke maskot (berhenti mengambang & membesar) */
#chat-button:hover {
    animation-play-state: paused; /* Berhenti melayang sebentar saat disentuh kursor */
    transform: scale(1.1);
    box-shadow: none;
}

/* RUMUS ANIMASI MENGAMBANG (FLOATING) */
@keyframes floatMascot {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-12px); /* Maskot naik ke atas sejauh 12 piksel */
    }
    100% {
        transform: translateY(0px);
    }
}



/* Notifikasi merah */
#chat-button.notif {
    background: #dc2626;
    animation: pulseChat 1s infinite;
}

/* Titik notif */
#chat-button::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: #dc2626;
    border: 2px solid white;
    border-radius: 50%;
    display: none;
    z-index: 2;
}

#chat-button.notif::after {
    display: block;
}

@keyframes pulseChat {
    0% { box-shadow: 0 0 0 0 rgba(220,38,38,0.7); }
    70% { box-shadow: 0 0 0 12px rgba(220,38,38,0); }
    100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}


/* Animasi menyapa (bergoyang / melambai) saat diklik */
@keyframes mascotWave {
    0% { transform: rotate(0deg) scale(1); }
    20% { transform: rotate(-15deg) scale(1.1); }
    40% { transform: rotate(15deg) scale(1.1); }
    60% { transform: rotate(-10deg) scale(1.05); }
    80% { transform: rotate(10deg) scale(1.05); }
    100% { transform: rotate(0deg) scale(1); }
}

/* Kelas untuk memicu animasi saat tombol diklik */
#chat-button.animate-wave {
    animation: mascotWave 0.6s ease;
    transform-origin: bottom center; /* Titik tumpu goyangan dari bawah */
}

/* =============================
   CHAT WIDGET
============================= */
/* Posisi Utama Widget di Pojok Kanan Bawah */
#chat-widget {
    position: fixed;
    bottom: 160px;
    right: 150px;
    width: 350px;
    height: 450px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: none; /* Awalnya tersembunyi */
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    font-family: Arial, sans-serif;
}

/* Header Chat */
.chat-header {
    background: #0f4c81;
    color: white;
    padding: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Kotak Pesan / Area Chat */
.chat-box {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f4f7f6;
}

/* Desain Dasar Bubble Teks */
.message {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 80%;
    line-height: 1.4;
    word-wrap: break-word;
    font-size: 14px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Bubble Pesan Bot (Kiri dengan bentuk sudut khas) */
.bot-message {
    background: #ffffff;
    color: #333333;
    align-self: flex-start;
    border-top-left-radius: 2px;
    border: 1px solid #e1e8ed;
}

/* Bubble Pesan Pengguna (Kanan dengan warna tema) */
.user-message {
    background: #0f4c81;
    color: white;
    align-self: flex-end;
    border-top-right-radius: 2px;
}

/* Area Input Pesan */
.chat-input {
    display: flex;
    border-top: 1px solid #ddd;
    padding: 10px;
    background: #fff;
}

.chat-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
}

.chat-input button {
    background: #0f4c81;
    color: white;
    border: none;
    padding: 10px 15px;
    margin-left: 8px;
    border-radius: 6px;
    cursor: pointer;
}

.chat-input button:hover {
    background: #0d3d6b;
}






/* =============================
   CHAT BUBBLE SYSTEM
============================= */
.chat {
    display: flex;
    margin: 8px 0;
}

/* Posisi kiri/kanan */
.chat.pengunjung {
    justify-content: flex-end;
}

.chat.admin {
    justify-content: flex-start;
}

.chat.sistem {
    justify-content: center;
}

/* Bubble */
.bubble {
    position: relative;
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 75%;
    word-wrap: break-word;
    font-size: 14px;
}

/* Warna bubble */
.chat.pengunjung .bubble {
    background: #2563eb;
    color: #fff;
}

.chat.admin .bubble {
    background: #16a34a;
    color: #fff;
}

.chat.sistem .bubble {
    background: #eee;
    color: #333;
    font-size: 13px;
}

/* Waktu */
.chat-time {
    font-size: 11px;
    opacity: 0.8;
    text-align: right;
    margin-top: 4px;
}


/* =============================
   IMAGE CHAT
============================= */
.chat-image {
    max-width: 180px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 5px;
}


/* =============================
   IMAGE PREVIEW MODAL
============================= */
#imagePreviewModal {
    display: none;
    position: fixed;
    z-index: 2147483647;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
}

#imagePreviewModal img {
    max-width: 90%;
    max-height: 85%;
    border-radius: 10px;
}

#closePreview {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 30px;
    color: #fff;
    cursor: pointer;
}

.chat.sistem {
    justify-content: center;
}

.chat.sistem .bubble {
    background: #e5e7eb;
    color: #444;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 8px;
}

