/* Chatbot Styles */
.dxc-chatbot-wrapper {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
}

/* Robot Bot To (Mặc định hiện) */
.bot-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: bottom center;
}

/* Nút Chat Đơn Giản (Mặc định ẩn) */
.dxc-simple-chat-btn {
    position: absolute;
    bottom: 60px; /* Nhấc cao hơn nút scroll-to-top một khoảng */
    right: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--mc-primary-color, #17c0eb);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(23, 192, 235, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 9999;
}

.dxc-simple-chat-btn svg {
    width: 20px;
    height: 20px;
}

/* KHI CUỘN (Thêm class is-scrolled vào wrapper) */
.dxc-chatbot-wrapper.is-scrolled .bot-container {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
}

.dxc-chatbot-wrapper.is-scrolled .dxc-simple-chat-btn {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Phải đặt hiệu ứng HOVER ở đây (sau is-scrolled) để nó không bị CSS của is-scrolled ghi đè translateY */
.dxc-chatbot-wrapper.is-scrolled .dxc-simple-chat-btn:hover {
    background: #0ea5e9;
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.5);
    transform: translateY(-3px);
}

.dxc-chatbot-wrapper.is-scrolled .dxc-simple-chat-btn:active {
    transform: translateY(0);
}

/* Bong bóng thoại */
/* Tắt animation nếu không ở trang chủ */
.bot-container.not-home,
.bot-container.not-home * {
    animation: none !important;
}

/* Bong bóng thoại (Dời sang bên trái hoàn toàn) */
.bot-container .speech-bubble {
    background: #ffffff;
    padding: 12px 18px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    color: #1e293b;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 600;
    width: max-content;
    max-width: calc(100vw - 160px); /* Đảm bảo không bị tràn mép trái màn hình */
    text-align: center;
    position: absolute;
    bottom: 70px; /* Căn ngang với thân bot */
    right: 100%; /* Dời hoàn toàn sang mép trái của bot */
    margin-right: 15px; /* Cách bot 15px */
    border: 2px solid #0284c7;
    animation: floatBubble 2.5s ease-in-out infinite;
}

.bot-container .speech-bubble::after {
    content: '';
    position: absolute;
    bottom: 25px; /* Điều chỉnh đuôi chĩa đúng vào đầu bot */
    right: -10px; /* Nằm ở mép phải bong bóng */
    border-width: 8px 0 8px 10px; /* Đuôi chĩa sang phải */
    border-style: solid;
    border-color: transparent transparent transparent #0284c7;
    display: block;
    width: 0;
}

/* Giao diện Robot mới */
.bot-container .robot {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bot-container .head {
    width: 80px;
    height: 60px;
    background: linear-gradient(145deg, #38bdf8, #0284c7);
    border-radius: 20px 20px 14px 14px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
    z-index: 2;
    transform-origin: bottom center;
    animation: headWobble 2s ease-in-out infinite;
}

.bot-container .antenna {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 12px;
    background: #0284c7;
}

.bot-container .antenna::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -4px;
    width: 12px;
    height: 12px;
    background: #f59e0b;
    border-radius: 50%;
    box-shadow: 0 0 8px #f59e0b;
}

.bot-container .face {
    display: flex;
    gap: 16px;
}

.bot-container .eye {
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-radius: 50%;
    animation: blink 3.5s infinite;
}

.bot-container .body {
    width: 90px;
    height: 70px;
    background: linear-gradient(145deg, #0284c7, #0369a1);
    border-radius: 12px 12px 24px 24px;
    margin-top: 4px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    animation: bodyBob 2s ease-in-out infinite;
}

.bot-container .badge {
    font-size: 11px;
    font-weight: 800;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 1px;
}

.bot-container .arm {
    position: absolute;
    top: 15px;
    width: 14px;
    height: 35px;
    background: #38bdf8;
    border-radius: 8px;
}
.bot-container .arm.left { left: -16px; }
.bot-container .arm.right { right: -16px; }

/* KEYFRAMES MỚI */
@keyframes headWobble {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-7deg) translateX(-2px); }
    75% { transform: rotate(7deg) translateX(2px); }
}
@keyframes bodyBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px) scaleY(0.97); }
}
@keyframes floatBubble {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
@keyframes blink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}

/* =========================================
   WIDGET CHATBOT (Khung chat góc màn hình)
========================================= */
.dxc-chatbot-widget {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 140px; /* Đẩy sang bên trái của bot (30px + ~110px bot) */
    width: 380px;
    max-width: calc(100vw - 160px); /* Đảm bảo không tràn màn hình trái */
    height: 600px;
    max-height: calc(100vh - 60px); /* Tối đa chiều cao không vượt màn hình */
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 10000;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.dxc-chatbot-widget.is-active {
    display: flex;
    animation: widgetPop 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* KHI PHÓNG TO TOÀN MÀN HÌNH */
.dxc-chatbot-widget.is-fullscreen {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    z-index: 100000;
}

/* HEADER CỦA WIDGET */
.dxc-widget-header {
    background: linear-gradient(135deg, #0369a1, #0284c7);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 2;
}

.dxc-widget-title {
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dxc-status-dot {
    width: 10px;
    height: 10px;
    background: #10b981; /* Xanh lá - Đang online */
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
    animation: pulseDot 2s infinite;
}

.dxc-widget-actions {
    display: flex;
    gap: 14px;
}

.dxc-action-btn {
    background: none;
    border: none;
    color: white;
    opacity: 0.7;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.dxc-action-btn:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* Đổi icon phóng to thành thu nhỏ khi đang ở fullscreen */
.dxc-chatbot-widget.is-fullscreen .dxc-expand-btn {
    transform: rotate(180deg);
}
.dxc-chatbot-widget.is-fullscreen .dxc-action-btn:hover {
    transform: rotate(180deg) scale(1.15);
}

/* BODY CỦA WIDGET */
.dxc-widget-body {
    flex: 1;
    padding: 24px 20px;
    background: #f8fafc;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dxc-message {
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 14.5px;
    line-height: 1.5;
    max-width: 85%;
}

.dxc-message.bot-msg {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

/* FOOTER CỦA WIDGET */
.dxc-widget-footer {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    align-items: center;
    z-index: 2;
}

.dxc-chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.dxc-chat-input:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.dxc-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #0284c7;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.dxc-send-btn:hover {
    background: #0369a1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

@keyframes widgetPop {
    0% { opacity: 0; transform: scale(0.9) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes pulseDot {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* =========================================
   RESPONSIVE CHO MOBILE
========================================= */
@media (max-width: 768px) {
    .dxc-chatbot-widget {
        right: 20px;
        bottom: 90px; /* Nhấc lên trên nút chat ở màn nhỏ */
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 120px);
    }
}

/* KEYFRAMES */
@keyframes badgerHeadWobble { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(-8deg) translateX(-2px); } 75% { transform: rotate(8deg) translateX(2px); } }
@keyframes badgerEarTwitchLeft { 0%, 100% { transform: rotate(-25deg); } 25% { transform: rotate(-32deg); } 75% { transform: rotate(-18deg); } }
@keyframes badgerEarTwitchRight { 0%, 100% { transform: rotate(25deg); } 25% { transform: rotate(18deg); } 75% { transform: rotate(32deg); } }
@keyframes badgerBodyBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(2px) scaleY(0.98); } }
@keyframes badgerTailWag { 0%, 100% { transform: rotate(-22deg); } 50% { transform: rotate(-6deg) scale(1.05); } }
@keyframes badgerFloatBubble { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes badgerBlink { 0%, 90%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
