/* ================================
   WRAPPER
================================ */
#sb-chat-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
	z-index:999;
    flex-direction: column-reverse;
    align-items: flex-end;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ================================
   TOGGLE BUTTON
================================ */
#sb-chat-toggle {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    transition: all 0.3s ease;
}

#sb-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 28px rgba(0,0,0,0.3);
}

#sb-chat-toggle.sb-hidden {
    display: none;
}

/* ================================
   CHAT BOX
================================ */
#sb-chat {
    width: 360px;
    height: 520px;
    background: #ffffff;
    border-radius: 18px 18px 10px 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    display: none; 
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 15px;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(.22, .68, 0, 1.71);
	z-index: 999999;
}

#sb-chat.sb-open {
    display: flex; /* 👈 chỉ khi mở mới chiếm chỗ */
}
#sb-chat.sb-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ================================
   HEADER
================================ */
.sb-header {
    background: var(--primary-color);
    color: #fff;
    padding: 16px 18px;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.sb-title p {
    font-size: 14px;
    opacity: 0.7;
    color: white;
    position: relative;
    line-height: 1.5;
    margin-bottom: 0px;
}
.sb-close {
    cursor: pointer;
    font-size: 20px;
    transition: 0.2s;
}

.sb-close:hover {
    transform: rotate(90deg);
}

/* ================================
   MESSAGE AREA
================================ */
#sb-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: #f5f7fb;
    scroll-behavior: smooth;
}

/* Scrollbar đẹp */
#sb-messages::-webkit-scrollbar {
    width: 6px;
}
#sb-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
}

/* ================================
   MESSAGE BUBBLE
================================ */
.sb-msg {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 20px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.5;
    animation: sbFadeIn 0.3s ease;
}

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

.sb-user {
    background: var(--primary-color);
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.sb-bot {
    background: #ffffff;
    color: #333;
    border: 1px solid #e6e6e6;
    margin-right: auto;
    border-bottom-left-radius: 5px;
}

/* ================================
   INPUT AREA
================================ */
.sb-input-area {
    display: flex;
    border-top: 1px solid #eee;
    background: #fff;
}
.sb-welcome {
    text-align: center;
    margin-top: 10%;
    color: var(--primary-color);
}
.sb-welcome i.fa.fa-comments-o {
    font-size: 80px;
    margin-bottom: 20px;
}
#sb-input {
    flex: 1;
    border: none;
    padding: 14px;
    font-size: 14px;
    outline: none;
    margin: 0px;
    height: 100%;
}

#sb-input::placeholder {
    color: #aaa;
}

.sb-input-area button {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 0 20px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.3s;
    margin: 0px;
}

.sb-input-area button:hover {
    opacity: 0.9;
}
div#sb-chat-toggle i.fa.fa-commenting-o {
    animation: rungrinh 1s infinite ease-in-out;
}
/* ================================
   MOBILE RESPONSIVE
================================ */
@media (max-width: 768px) {

    #sb-chat-wrapper {
        right: 12px;
        bottom: 12px;
    }

    #sb-chat {
        width: 95vw;
        height: 80vh;
        border-radius: 14px;
    }

    #sb-chat-toggle {
        width: 55px;
        height: 55px;
    }

    .sb-msg {
        font-size: 13px;
    }
}

/* ================================
   EXTRA AUTOMATION TOUCH
================================ */

/* Khi có tin nhắn mới có thể thêm class này bằng JS */
.sb-notify {
    animation: sbPulse 1.2s infinite;
}

@keyframes sbPulse {
    0% { box-shadow: 0 0 0 0 rgba(200,157,84,0.7); }
    70% { box-shadow: 0 0 0 12px rgba(200,157,84,0); }
    100% { box-shadow: 0 0 0 0 rgba(200,157,84,0); }
}
@keyframes rungrinh {
    0% {
        -webkit-transform: rotate(0) scale(1) skew(1deg);
    }
    10% {
        -webkit-transform: rotate(-25deg) scale(1) skew(1deg);
    }

    20% {
        -webkit-transform: rotate(25deg) scale(1) skew(1deg);
    }
    30% {
        -webkit-transform: rotate(-25deg) scale(1) skew(1deg);
    }
    40% {
        -webkit-transform: rotate(25deg) scale(1) skew(1deg);
    }
    50% {
        -webkit-transform: rotate(0) scale(1) skew(1deg);
    }
    100% {
        -webkit-transform: rotate(0) scale(1) skew(1deg);
    }
}