/* ============================================================
   CHATBOT.CSS — Tampilan Modern (gaya WhatsApp/ChatGPT)
   Diselaraskan dengan tema warung: cream, oranye, coklat tua
   ============================================================ */

:root {
    --cb-cream: #FCEFD2;
    --cb-cream-soft: #FFF8EA;
    --cb-brown-dark: #4A2E12;
    --cb-brown: #6B4423;
    --cb-orange: #F2A73B;
    --cb-orange-dark: #E0921F;
    --cb-green-accent: #6FA96F;
    --cb-white: #FFFFFF;
    --cb-gray-text: #8A7A63;
    --cb-shadow: 0 10px 40px rgba(74, 46, 18, 0.18);
    --cb-radius-lg: 22px;
    --cb-radius-md: 16px;
    --cb-radius-sm: 10px;
    --cb-font: 'Poppins', 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

#cb-wrapper * {
    box-sizing: border-box;
    font-family: var(--cb-font);
}

/* ---------------- TOGGLE BUTTON ---------------- */
#cb-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--cb-brown), var(--cb-brown-dark));
    color: var(--cb-cream);
    border: none;
    cursor: pointer;
    box-shadow: var(--cb-shadow);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

#cb-toggle-btn:hover {
    transform: scale(1.07);
    box-shadow: 0 12px 34px rgba(74, 46, 18, 0.3);
}

#cb-toggle-btn:active {
    transform: scale(0.95);
}

.cb-toggle-icon-close { display: none; }
#cb-toggle-btn.cb-open .cb-toggle-icon-chat { display: none; }
#cb-toggle-btn.cb-open .cb-toggle-icon-close { display: inline; }

/* Kelas .cb-open ditambahkan lewat JS ke tombol manapun yang jadi trigger
   (baik tombol bawaan #cb-toggle-btn maupun tombol popup milikmu sendiri),
   supaya efek "aktif" tetap konsisten. Sesuaikan style ini kalau perlu. */
.cb-open {
    box-shadow: 0 0 0 3px rgba(242, 167, 59, 0.55) !important;
}

/* pulse halus supaya tombol terasa "hidup" */
#cb-toggle-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(242, 167, 59, 0.55);
    animation: cb-pulse 2.6s infinite;
    pointer-events: none;
}

@keyframes cb-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(242, 167, 59, 0.55); }
    70%  { box-shadow: 0 0 0 14px rgba(242, 167, 59, 0); }
    100% { box-shadow: 0 0 0 0 rgba(242, 167, 59, 0); }
}

/* ---------------- CHAT WINDOW ---------------- */
#cb-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: var(--cb-cream-soft);
    border-radius: var(--cb-radius-lg);
    box-shadow: var(--cb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    transform-origin: bottom right;
    transition: transform 0.28s cubic-bezier(.2,.9,.3,1.2), opacity 0.22s ease;
}

#cb-window.cb-hidden {
    opacity: 0;
    transform: scale(0.85) translateY(16px);
    pointer-events: none;
}

/* ---------------- HEADER ---------------- */
#cb-header {
    background: linear-gradient(120deg, var(--cb-brown-dark), var(--cb-brown));
    color: var(--cb-cream-soft);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.cb-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--cb-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 2px solid rgba(255,255,255,0.35);
    flex-shrink: 0;
}

.cb-header-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.cb-header-status {
    font-size: 11.5px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cb-dot-online {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6FE07A;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(111, 224, 122, 0.25);
}

.cb-header-actions {
    display: flex;
    gap: 4px;
}

.cb-header-actions button {
    background: rgba(255,255,255,0.12);
    border: none;
    color: var(--cb-cream-soft);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.cb-header-actions button:hover {
    background: rgba(255,255,255,0.24);
}

/* ---------------- MESSAGES AREA ---------------- */
#cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background:
        radial-gradient(circle at 20% 10%, rgba(242,167,59,0.08) 0, transparent 40%),
        var(--cb-cream);
}

#cb-messages::-webkit-scrollbar { width: 6px; }
#cb-messages::-webkit-scrollbar-track { background: transparent; }
#cb-messages::-webkit-scrollbar-thumb {
    background: rgba(107, 68, 35, 0.28);
    border-radius: 10px;
}

.cb-msg-row {
    display: flex;
    width: 100%;
}

.cb-msg-row.cb-user { justify-content: flex-end; }
.cb-msg-row.cb-bot { justify-content: flex-start; }

.cb-bubble {
    position: relative;
    max-width: 78%;
    padding: 9px 13px 16px 13px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
    box-shadow: 0 2px 6px rgba(74,46,18,0.08);
}

.cb-user-bubble {
    background: linear-gradient(135deg, var(--cb-orange), var(--cb-orange-dark));
    color: #3A2408;
    border-radius: var(--cb-radius-md) var(--cb-radius-md) 4px var(--cb-radius-md);
}

.cb-bot-bubble {
    background: var(--cb-white);
    color: var(--cb-brown-dark);
    border-radius: var(--cb-radius-md) var(--cb-radius-md) var(--cb-radius-md) 4px;
    border: 1px solid rgba(107,68,35,0.08);
}

.cb-bubble strong {
    color: var(--cb-brown-dark);
}

.cb-meta {
    position: absolute;
    bottom: 4px;
    right: 10px;
    font-size: 10px;
    opacity: 0.55;
}

.cb-user-bubble .cb-meta { color: #3A2408; }
.cb-bot-bubble .cb-meta { color: var(--cb-gray-text); }

/* animasi bubble muncul */
@keyframes cb-pop-in {
    0% { opacity: 0; transform: translateY(8px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
.cb-pop-in {
    animation: cb-pop-in 0.25s ease-out;
}

/* ---------------- TYPING INDICATOR ---------------- */
.cb-typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 13px 16px;
}

.cb-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cb-brown);
    opacity: 0.5;
    animation: cb-typing-bounce 1.2s infinite ease-in-out;
}

.cb-typing-dot:nth-child(1) { animation-delay: 0s; }
.cb-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes cb-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------------- QUICK REPLIES ---------------- */
#cb-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 8px 12px;
    flex-shrink: 0;
    background: var(--cb-cream);
}

.cb-quick-btn {
    background: var(--cb-white);
    border: 1.5px solid var(--cb-orange);
    color: var(--cb-brown-dark);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.cb-quick-btn:hover {
    background: var(--cb-orange);
    color: #3A2408;
    transform: translateY(-1px);
}

/* ---------------- INPUT AREA ---------------- */
#cb-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--cb-white);
    border-top: 1px solid rgba(107,68,35,0.08);
    flex-shrink: 0;
}

#cb-input {
    flex: 1;
    border: 1.5px solid rgba(107,68,35,0.15);
    background: var(--cb-cream-soft);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--cb-brown-dark);
    outline: none;
    transition: border-color 0.2s ease;
}

#cb-input:focus {
    border-color: var(--cb-orange);
}

#cb-input::placeholder {
    color: var(--cb-gray-text);
}

#cb-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-orange), var(--cb-orange-dark));
    color: #3A2408;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 3px 8px rgba(224,146,31,0.4);
}

#cb-send-btn:hover { transform: scale(1.08); }
#cb-send-btn:active { transform: scale(0.92); }

/* ---------------- RESPONSIVE (MOBILE) ---------------- */
@media (max-width: 480px) {
    #cb-window {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 90px;
        height: calc(100vh - 130px);
    }
    #cb-toggle-btn {
        right: 16px;
        bottom: 16px;
    }
}

/* ---------------- ACCESSIBILITY ---------------- */
#cb-toggle-btn:focus-visible,
#cb-send-btn:focus-visible,
.cb-quick-btn:focus-visible,
.cb-header-actions button:focus-visible,
#cb-input:focus-visible {
    outline: 2px solid var(--cb-green-accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    #cb-toggle-btn::after,
    .cb-typing-dot,
    .cb-pop-in {
        animation: none !important;
    }
    #cb-window {
        transition: none !important;
    }
}