/* ============================
   CHATBOT KÍNH PHỦ NANO
   ============================ */

/* Ẩn hoàn toàn trên điện thoại (màn hình < 768px) */
@media (max-width: 767px) {
    #cb-btn, #cb-win { display: none !important; }
}

#cb-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #0068FF;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    box-shadow: 0 4px 14px rgba(0, 104, 255, 0.4);
    transition: transform 0.2s;
}
#cb-btn:hover { transform: scale(1.07); }
#cb-btn img {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    object-fit: cover;
}

/* Nút mở lại khi đã tắt */
#cb-reopen {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0068FF;
    color: white;
    border: none;
    border-radius: 24px;
    padding: 10px 18px 10px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    z-index: 99999;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(0,104,255,0.35);
    transition: background 0.15s;
}
#cb-reopen:hover { background: #0056d6; }
#cb-reopen.show { display: flex; }

/* Cửa sổ chat */
#cb-win {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 330px;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e0e0e0;
    display: none;
    flex-direction: column;
    max-height: 460px;
    z-index: 99999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.13);
    overflow: hidden;
}
#cb-win.open { display: flex; }

/* Header */
#cb-head {
    background: #0068FF;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
#cb-head .av {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.4);
}
#cb-head .av img { width: 100%; height: 100%; object-fit: cover; }
#cb-head .nm { color: white; font-size: 14px; font-weight: 600; margin: 0 0 2px; }
#cb-head .st { color: rgba(255,255,255,0.8); font-size: 11px; margin: 0; }
#cb-head .info { flex: 1; }

/* Nút header: thu nhỏ và đóng hẳn */
#cb-head .head-btns {
    display: flex;
    gap: 6px;
    align-items: center;
}
#cb-head .cl, #cb-head .dismiss {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 5px;
    opacity: 0.8;
    border-radius: 4px;
    transition: opacity 0.15s, background 0.15s;
}
#cb-head .cl:hover, #cb-head .dismiss:hover { opacity: 1; background: rgba(255,255,255,0.15); }
#cb-head .dismiss { font-size: 14px; }

/* Khu vực tin nhắn */
#cb-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 160px;
    max-height: 260px;
    background: #f7f8fc;
}
#cb-msgs::-webkit-scrollbar { width: 4px; }
#cb-msgs::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.cb-bot, .cb-usr { display: flex; gap: 7px; align-items: flex-end; }
.cb-usr { flex-direction: row-reverse; }

.cb-av { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.cb-av img { width: 100%; height: 100%; object-fit: cover; }

.cb-bub {
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    max-width: 215px;
}
.cb-bot .cb-bub {
    background: #fff;
    color: #202124;
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.cb-usr .cb-bub {
    background: #0068FF;
    color: white;
    border-bottom-right-radius: 3px;
}
.cb-bub a { color: #0068FF; font-size: 12px; display: block; margin-top: 5px; font-weight: 500; text-decoration: none; }
.cb-bub a:hover { text-decoration: underline; }
.cb-usr .cb-bub a { color: #cce0ff; }

/* Nút lựa chọn */
#cb-opts {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.cb-opt {
    background: #fff;
    border: 1.5px solid #0068FF;
    color: #0068FF;
    padding: 7px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12.5px;
    text-align: left;
    transition: background 0.15s;
    font-family: inherit;
}
.cb-opt:hover { background: #e8f0fe; }

/* Thanh nhập SĐT */
#cb-sdt-bar {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    display: none;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
#cb-sdt-bar input {
    flex: 1;
    border: 1.5px solid #dadce0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}
#cb-sdt-bar input:focus { border-color: #0068FF; }
#cb-sdt-bar button {
    background: #0068FF;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
#cb-sdt-bar button:hover { background: #0056d6; }

/* Hiệu ứng đang gõ */
.cb-typing { display: flex; gap: 4px; padding: 8px 12px; align-items: center; }
.cb-typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #b0b5be;
    animation: cb-bounce 1s infinite;
}
.cb-typing span:nth-child(2) { animation-delay: .15s; }
.cb-typing span:nth-child(3) { animation-delay: .30s; }

@keyframes cb-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* Ô chat tự do */
#cb-free-bar {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    box-sizing: border-box;
    width: 100%;
}
#cb-free-bar input {
    flex: 1;
    min-width: 0;
    border: 1.5px solid #dadce0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
#cb-free-bar input:focus { border-color: #0068FF; }
#cb-free-btn {
    background: #0068FF;
    color: white;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    min-width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
#cb-free-btn:hover { background: #0056d6; }
